001: /*
002: * Copyright (C) 2005 - 2008 JasperSoft Corporation. All rights reserved.
003: * http://www.jaspersoft.com.
004: *
005: * Unless you have purchased a commercial license agreement from JasperSoft,
006: * the following license terms apply:
007: *
008: * This program is free software; you can redistribute it and/or modify
009: * it under the terms of the GNU General Public License version 2 as published by
010: * the Free Software Foundation.
011: *
012: * This program is distributed WITHOUT ANY WARRANTY; and without the
013: * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
014: * See the GNU General Public License for more details.
015: *
016: * You should have received a copy of the GNU General Public License
017: * along with this program; if not, see http://www.gnu.org/licenses/gpl.txt
018: * or write to:
019: *
020: * Free Software Foundation, Inc.,
021: * 59 Temple Place - Suite 330,
022: * Boston, MA USA 02111-1307
023: *
024: *
025: *
026: *
027: * Box.java
028: *
029: * Created on 29 novembre 2004, 17.09
030: *
031: */
032:
033: package it.businesslogic.ireport;
034:
035: import java.awt.Color;
036:
037: /**
038: *
039: * @author Administrator
040: */
041: public class Box {
042:
043: /** Creates a new instance of Box */
044: public Box() {
045: in = instanceNum++;
046: }
047:
048: int in = 0;
049: static int instanceNum = 0;
050:
051: private Pen pen = null;
052: private Pen topPen = null;
053: private Pen bottomPen = null;
054: private Pen leftPen = null;
055: private Pen rightPen = null;
056:
057: private String border = "None";
058: private Color borderColor = java.awt.Color.BLACK;
059: private int padding = 0;
060:
061: private String topBorder = "None";
062: private Color topBorderColor = java.awt.Color.BLACK;
063: private int topPadding = 0;
064:
065: private String bottomBorder = "None";
066: private Color bottomBorderColor = java.awt.Color.BLACK;
067: private int bottomPadding = 0;
068:
069: private String leftBorder = "None";
070: private Color leftBorderColor = java.awt.Color.BLACK;
071: private int leftPadding = 0;
072:
073: private String rightBorder = "None";
074: private Color rightBorderColor = java.awt.Color.BLACK;
075: private int rightPadding = 0;
076:
077: public String getBorder() {
078: return border;
079: }
080:
081: public void setBorder(String border) {
082: this .border = border;
083: }
084:
085: public Color getBorderColor() {
086: return borderColor;
087: }
088:
089: public void setBorderColor(Color borderColor) {
090: this .borderColor = borderColor;
091: }
092:
093: public int getPadding() {
094: return padding;
095: }
096:
097: public void setPadding(int padding) {
098: this .padding = padding;
099: }
100:
101: public String getTopBorder() {
102: return topBorder;
103: }
104:
105: public void setTopBorder(String topBorder) {
106: this .topBorder = topBorder;
107: }
108:
109: public Color getTopBorderColor() {
110: return topBorderColor;
111: }
112:
113: public void setTopBorderColor(Color topBorderColor) {
114: this .topBorderColor = topBorderColor;
115: }
116:
117: public int getTopPadding() {
118: return topPadding;
119: }
120:
121: public void setTopPadding(int topPadding) {
122: this .topPadding = topPadding;
123: }
124:
125: public String getBottomBorder() {
126: return bottomBorder;
127: }
128:
129: public void setBottomBorder(String bottomBorder) {
130: this .bottomBorder = bottomBorder;
131: }
132:
133: public Color getBottomBorderColor() {
134: return bottomBorderColor;
135: }
136:
137: public void setBottomBorderColor(Color bottomBorderColor) {
138: this .bottomBorderColor = bottomBorderColor;
139: }
140:
141: public int getBottomPadding() {
142: return bottomPadding;
143: }
144:
145: public void setBottomPadding(int bottomPadding) {
146: this .bottomPadding = bottomPadding;
147: }
148:
149: public String getLeftBorder() {
150: return leftBorder;
151: }
152:
153: public void setLeftBorder(String leftBorder) {
154: this .leftBorder = leftBorder;
155: }
156:
157: public Color getLeftBorderColor() {
158: return leftBorderColor;
159: }
160:
161: public void setLeftBorderColor(Color leftBorderColor) {
162: this .leftBorderColor = leftBorderColor;
163: }
164:
165: public int getLeftPadding() {
166: return leftPadding;
167: }
168:
169: public void setLeftPadding(int leftPadding) {
170: this .leftPadding = leftPadding;
171: }
172:
173: public String getRightBorder() {
174: return rightBorder;
175: }
176:
177: public void setRightBorder(String rightBorder) {
178: this .rightBorder = rightBorder;
179: }
180:
181: public Color getRightBorderColor() {
182: return rightBorderColor;
183: }
184:
185: public void setRightBorderColor(Color rightBorderColor) {
186: this .rightBorderColor = rightBorderColor;
187: }
188:
189: public int getRightPadding() {
190: return rightPadding;
191: }
192:
193: public void setRightPadding(int rightPadding) {
194: this .rightPadding = rightPadding;
195: }
196:
197: public Box cloneMe() {
198: Box bb = new Box();
199: bb.setRightBorderColor(this .getRightBorderColor());
200: bb.setRightBorder(this .getRightBorder());
201: bb.setRightPadding(this .getRightPadding());
202:
203: bb.setLeftBorderColor(this .getLeftBorderColor());
204: bb.setLeftBorder(this .getLeftBorder());
205: bb.setLeftPadding(this .getLeftPadding());
206:
207: bb.setTopBorderColor(this .getTopBorderColor());
208: bb.setTopBorder(this .getTopBorder());
209: bb.setTopPadding(this .getTopPadding());
210:
211: bb.setBottomBorderColor(this .getBottomBorderColor());
212: bb.setBottomBorder(this .getBottomBorder());
213: bb.setBottomPadding(this .getBottomPadding());
214:
215: bb.setBorderColor(this .getBorderColor());
216: bb.setBorder(this .getBorder());
217: bb.setPadding(this .getPadding());
218:
219: bb.setPen(pen == null ? null : pen.cloneMe());
220: bb.setTopPen(topPen == null ? null : topPen.cloneMe());
221: bb.setBottomPen(bottomPen == null ? null : bottomPen.cloneMe());
222: bb.setLeftPen(leftPen == null ? null : leftPen.cloneMe());
223: bb.setRightPen(rightPen == null ? null : rightPen.cloneMe());
224:
225: return bb;
226: }
227:
228: public Pen getPen() {
229: return pen;
230: }
231:
232: public void setPen(Pen pen) {
233: this .pen = pen;
234: }
235:
236: public Pen getTopPen() {
237: return topPen;
238: }
239:
240: public void setTopPen(Pen topPen) {
241: this .topPen = topPen;
242: }
243:
244: public Pen getBottomPen() {
245: return bottomPen;
246: }
247:
248: public void setBottomPen(Pen bottomPen) {
249: this .bottomPen = bottomPen;
250: }
251:
252: public Pen getLeftPen() {
253: return leftPen;
254: }
255:
256: public void setLeftPen(Pen leftPen) {
257: this .leftPen = leftPen;
258: }
259:
260: public Pen getRightPen() {
261: return rightPen;
262: }
263:
264: public void setRightPen(Pen rightPen) {
265: this .rightPen = rightPen;
266: }
267:
268: /**
269: * This method fills the missing definitions with supplied box...
270: *
271: *
272: * @param newBox
273: */
274: public Box derive(Box newBox) {
275: Box box = this .cloneMe();
276: if (newBox == null)
277: return box;
278:
279: box.setPen(copyNullAttributes(box.getPen(), newBox.getPen()));
280: box.setTopPen(copyNullAttributes(box.getTopPen(), newBox
281: .getTopPen()));
282: box.setLeftPen(copyNullAttributes(box.getLeftPen(), newBox
283: .getLeftPen()));
284: box.setRightPen(copyNullAttributes(box.getRightPen(), newBox
285: .getRightPen()));
286: box.setBottomPen(copyNullAttributes(box.getBottomPen(), newBox
287: .getBottomPen()));
288:
289: return box;
290:
291: }
292:
293: private Pen copyNullAttributes(Pen to, Pen from) {
294: if (to == null) {
295: to = new Pen();
296: if (from != null) {
297: to.setLineWidth(from.getLineWidth());
298: }
299: }
300: if (to.getLineColor() == null && from != null)
301: to.setLineColor(from.getLineColor());
302: if (to.getLineStyle() == null && from != null)
303: to.setLineStyle(from.getLineStyle());
304:
305: return to;
306: }
307:
308: public String toString() {
309: return "Box (" + in + ") [ Pen: " + getPen() + ", TopPen: "
310: + getTopPen() + ", LeftPen: " + getLeftPen()
311: + ", RightPen: " + getRightPen() + ", BottomPen: "
312: + getBottomPen() + "]";
313:
314: }
315:
316: }
|