001: /**
002: * ===========================================
003: * JFreeReport : a free Java reporting library
004: * ===========================================
005: *
006: * Project Info: http://reporting.pentaho.org/
007: *
008: * (C) Copyright 2001-2007, by Object Refinery Ltd, Pentaho Corporation and Contributors.
009: *
010: * This library is free software; you can redistribute it and/or modify it under the terms
011: * of the GNU Lesser General Public License as published by the Free Software Foundation;
012: * either version 2.1 of the License, or (at your option) any later version.
013: *
014: * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
015: * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
016: * See the GNU Lesser General Public License for more details.
017: *
018: * You should have received a copy of the GNU Lesser General Public License along with this
019: * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
020: * Boston, MA 02111-1307, USA.
021: *
022: * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
023: * in the United States and other countries.]
024: *
025: * ------------
026: * LogicalPageKey.java
027: * ------------
028: * (C) Copyright 2001-2007, by Object Refinery Ltd, Pentaho Corporation and Contributors.
029: */package org.jfree.report.layout.output;
030:
031: import java.io.Serializable;
032:
033: /**
034: * Creation-Date: 10.11.2006, 13:04:36
035: *
036: * @author Thomas Morgner
037: */
038: public final class LogicalPageKey implements Serializable {
039: private int position;
040: private int width;
041: private int height;
042: private PhysicalPageKey[] physicalPageKeys;
043:
044: public LogicalPageKey(final int position, final int width,
045: final int height) {
046: this .position = position;
047: this .width = width;
048: this .height = height;
049: this .physicalPageKeys = new PhysicalPageKey[width * height];
050:
051: final int pageKeyCount = physicalPageKeys.length;
052: for (int i = 0; i < pageKeyCount; i++) {
053: physicalPageKeys[i] = new PhysicalPageKey(this , i % width,
054: i / width);
055: }
056: }
057:
058: public int getWidth() {
059: return width;
060: }
061:
062: public int getHeight() {
063: return height;
064: }
065:
066: public int getPosition() {
067: return position;
068: }
069:
070: public PhysicalPageKey getPage(final int x, final int y) {
071: return physicalPageKeys[x + y * width];
072: }
073:
074: public boolean equals(final Object o) {
075: if (this == o) {
076: return true;
077: }
078: if (o == null || getClass() != o.getClass()) {
079: return false;
080: }
081:
082: final LogicalPageKey that = (LogicalPageKey) o;
083:
084: if (height != that.height) {
085: return false;
086: }
087: if (position != that.position) {
088: return false;
089: }
090: if (width != that.width) {
091: return false;
092: }
093:
094: return true;
095: }
096:
097: public int hashCode() {
098: int result = position;
099: result = 29 * result + width;
100: result = 29 * result + height;
101: return result;
102: }
103: }
|