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: * TableRectangle.java
027: * ------------
028: * (C) Copyright 2001-2007, by Object Refinery Ltd, Pentaho Corporation and Contributors.
029: */package org.jfree.report.modules.output.table.base;
030:
031: /**
032: * The TableRectangle contains GridCoordinates for the tables. The rectangle contains x- and y-cuts, so as long as the
033: * cell is not empty (width==0, height==0), x1 and x2 will not have the same value.
034: */
035: public class TableRectangle {
036: private int x1;
037: private int y1;
038: private int x2;
039: private int y2;
040:
041: public TableRectangle() {
042: }
043:
044: public TableRectangle(final int x1, final int x2, final int y1,
045: final int y2) {
046: setRect(x1, y1, x2, y2);
047: }
048:
049: public int getX1() {
050: return x1;
051: }
052:
053: public int getX2() {
054: return x2;
055: }
056:
057: public int getY1() {
058: return y1;
059: }
060:
061: public int getY2() {
062: return y2;
063: }
064:
065: public void setRect(final int x1, final int y1, final int x2,
066: final int y2) {
067: if (x1 > x2) {
068: throw new IllegalArgumentException(
069: "x1 is greater than x2 - the rectangle would have negative content.");
070: }
071: if (y1 > y2) {
072: throw new IllegalArgumentException(
073: "y1 is greater than y2 - the rectangle would have negative content.");
074: }
075: this .x1 = x1;
076: this .x2 = x2;
077: this .y1 = y1;
078: this .y2 = y2;
079: }
080:
081: public boolean isOrigin(final int x, final int y) {
082: return (x == x1 && y == y1);
083: }
084:
085: public int getRowSpan() {
086: return y2 - y1;
087: }
088:
089: public int getColumnSpan() {
090: return x2 - x1;
091: }
092:
093: public String toString() {
094: return "org.jfree.report.modules.output.table.base.TableRectangle{"
095: + "x1="
096: + x1
097: + ", y1="
098: + y1
099: + ", x2="
100: + x2
101: + ", y2="
102: + y2 + '}';
103: }
104: }
|