001: /*
002: * ============================================================================
003: * GNU Lesser General Public License
004: * ============================================================================
005: *
006: * JasperReports - Free Java report-generating library.
007: * Copyright (C) 2001-2006 JasperSoft Corporation http://www.jaspersoft.com
008: *
009: * This library is free software; you can redistribute it and/or
010: * modify it under the terms of the GNU Lesser General Public
011: * License as published by the Free Software Foundation; either
012: * 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,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
017: * Lesser General Public License for more details.
018: *
019: * You should have received a copy of the GNU Lesser General Public
020: * License along with this library; if not, write to the Free Software
021: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
022: *
023: * JasperSoft Corporation
024: * 303 Second Street, Suite 450 North
025: * San Francisco, CA 94107
026: * http://www.jaspersoft.com
027: */
028: package net.sf.jasperreports.engine.base;
029:
030: import java.awt.Color;
031: import java.io.IOException;
032: import java.util.ArrayList;
033: import java.util.Iterator;
034: import java.util.List;
035:
036: import net.sf.jasperreports.engine.JRAbstractObjectFactory;
037: import net.sf.jasperreports.engine.JRChild;
038: import net.sf.jasperreports.engine.JRConstants;
039: import net.sf.jasperreports.engine.JRElement;
040: import net.sf.jasperreports.engine.JRExpressionCollector;
041: import net.sf.jasperreports.engine.JRFrame;
042: import net.sf.jasperreports.engine.util.JRStyleResolver;
043: import net.sf.jasperreports.engine.xml.JRXmlWriter;
044:
045: /**
046: * Base read-only implementation of {@link net.sf.jasperreports.engine.JRFrame JRFrame}.
047: *
048: * @author Lucian Chirita (lucianc@users.sourceforge.net)
049: * @version $Id: JRBaseFrame.java 1229 2006-04-19 10:27:35Z teodord $
050: */
051: public class JRBaseFrame extends JRBaseElement implements JRFrame {
052: private static final long serialVersionUID = JRConstants.SERIAL_VERSION_UID;
053:
054: protected List children;
055:
056: public JRBaseFrame(JRFrame frame, JRBaseObjectFactory factory) {
057: super (frame, factory);
058:
059: List frameChildren = frame.getChildren();
060: if (frameChildren != null) {
061: children = new ArrayList(frameChildren.size());
062: for (Iterator it = frameChildren.iterator(); it.hasNext();) {
063: JRChild child = (JRChild) it.next();
064: children.add(child.getCopy(factory));
065: }
066: }
067:
068: copyBox(frame);
069: }
070:
071: private void copyBox(JRFrame frame) {
072: border = frame.getOwnBorder();
073: topBorder = frame.getOwnTopBorder();
074: leftBorder = frame.getOwnLeftBorder();
075: bottomBorder = frame.getOwnBottomBorder();
076: rightBorder = frame.getOwnRightBorder();
077: borderColor = frame.getOwnBorderColor();
078: topBorderColor = frame.getOwnTopBorderColor();
079: leftBorderColor = frame.getOwnLeftBorderColor();
080: bottomBorderColor = frame.getOwnBottomBorderColor();
081: rightBorderColor = frame.getOwnRightBorderColor();
082: padding = frame.getOwnPadding();
083: topPadding = frame.getOwnTopPadding();
084: leftPadding = frame.getOwnLeftPadding();
085: bottomPadding = frame.getOwnBottomPadding();
086: rightPadding = frame.getOwnRightPadding();
087: }
088:
089: public JRElement[] getElements() {
090: return JRBaseElementGroup.getElements(children);
091: }
092:
093: public void collectExpressions(JRExpressionCollector collector) {
094: collector.collect(this );
095: }
096:
097: public JRChild getCopy(JRAbstractObjectFactory factory) {
098: return factory.getFrame(this );
099: }
100:
101: public void writeXml(JRXmlWriter writer) throws IOException {
102: writer.writeFrame(this );
103: }
104:
105: public List getChildren() {
106: return children;
107: }
108:
109: public JRElement getElementByKey(String elementKey) {
110: return JRBaseElementGroup.getElementByKey(getElements(),
111: elementKey);
112: }
113:
114: // box
115: protected Byte border;
116: protected Byte topBorder = null;
117: protected Byte leftBorder = null;
118: protected Byte bottomBorder = null;
119: protected Byte rightBorder = null;
120: protected Color borderColor = null;
121: protected Color topBorderColor = null;
122: protected Color leftBorderColor = null;
123: protected Color bottomBorderColor = null;
124: protected Color rightBorderColor = null;
125: protected Integer padding;
126: protected Integer topPadding = null;
127: protected Integer leftPadding = null;
128: protected Integer bottomPadding = null;
129: protected Integer rightPadding = null;
130:
131: public byte getBorder() {
132: return JRStyleResolver.getBorder(this );
133: }
134:
135: public Byte getOwnBorder() {
136: return border;
137: }
138:
139: public void setBorder(byte border) {
140: this .border = new Byte(border);
141: }
142:
143: public void setBorder(Byte border) {
144: this .border = border;
145: }
146:
147: public Color getBorderColor() {
148: return JRStyleResolver.getBorderColor(this , getForecolor());
149: }
150:
151: public Color getOwnBorderColor() {
152: return borderColor;
153: }
154:
155: public void setBorderColor(Color borderColor) {
156: this .borderColor = borderColor;
157: }
158:
159: public int getPadding() {
160: return JRStyleResolver.getPadding(this );
161: }
162:
163: public Integer getOwnPadding() {
164: return padding;
165: }
166:
167: public void setPadding(int padding) {
168: this .padding = new Integer(padding);
169: }
170:
171: public void setPadding(Integer padding) {
172: this .padding = padding;
173: }
174:
175: public byte getTopBorder() {
176: return JRStyleResolver.getTopBorder(this );
177: }
178:
179: public Byte getOwnTopBorder() {
180: return topBorder;
181: }
182:
183: public void setTopBorder(byte topBorder) {
184: this .topBorder = new Byte(topBorder);
185: }
186:
187: public void setTopBorder(Byte topBorder) {
188: this .topBorder = topBorder;
189: }
190:
191: public Color getTopBorderColor() {
192: return JRStyleResolver.getTopBorderColor(this , getForecolor());
193: }
194:
195: public Color getOwnTopBorderColor() {
196: return topBorderColor;
197: }
198:
199: public void setTopBorderColor(Color topBorderColor) {
200: this .topBorderColor = topBorderColor;
201: }
202:
203: public int getTopPadding() {
204: return JRStyleResolver.getTopPadding(this );
205: }
206:
207: public Integer getOwnTopPadding() {
208: return topPadding;
209: }
210:
211: public void setTopPadding(int topPadding) {
212: this .topPadding = new Integer(topPadding);
213: }
214:
215: public void setTopPadding(Integer topPadding) {
216: this .topPadding = topPadding;
217: }
218:
219: public byte getLeftBorder() {
220: return JRStyleResolver.getLeftBorder(this );
221: }
222:
223: public Byte getOwnLeftBorder() {
224: return leftBorder;
225: }
226:
227: public void setLeftBorder(byte leftBorder) {
228: this .leftBorder = new Byte(leftBorder);
229: }
230:
231: public void setLeftBorder(Byte leftBorder) {
232: this .leftBorder = leftBorder;
233: }
234:
235: public Color getLeftBorderColor() {
236: return JRStyleResolver.getLeftBorderColor(this , getForecolor());
237: }
238:
239: public Color getOwnLeftBorderColor() {
240: return leftBorderColor;
241: }
242:
243: public void setLeftBorderColor(Color leftBorderColor) {
244: this .leftBorderColor = leftBorderColor;
245: }
246:
247: public int getLeftPadding() {
248: return JRStyleResolver.getLeftPadding(this );
249: }
250:
251: public Integer getOwnLeftPadding() {
252: return leftPadding;
253: }
254:
255: public void setLeftPadding(int leftPadding) {
256: this .leftPadding = new Integer(leftPadding);
257: }
258:
259: public void setLeftPadding(Integer leftPadding) {
260: this .leftPadding = leftPadding;
261: }
262:
263: public byte getBottomBorder() {
264: return JRStyleResolver.getBottomBorder(this );
265: }
266:
267: public Byte getOwnBottomBorder() {
268: return bottomBorder;
269: }
270:
271: public void setBottomBorder(byte bottomBorder) {
272: this .bottomBorder = new Byte(bottomBorder);
273: }
274:
275: public void setBottomBorder(Byte bottomBorder) {
276: this .bottomBorder = bottomBorder;
277: }
278:
279: public Color getBottomBorderColor() {
280: return JRStyleResolver.getBottomBorderColor(this ,
281: getForecolor());
282: }
283:
284: public Color getOwnBottomBorderColor() {
285: return bottomBorderColor;
286: }
287:
288: public void setBottomBorderColor(Color bottomBorderColor) {
289: this .bottomBorderColor = bottomBorderColor;
290: }
291:
292: public int getBottomPadding() {
293: return JRStyleResolver.getBottomPadding(this );
294: }
295:
296: public Integer getOwnBottomPadding() {
297: return bottomPadding;
298: }
299:
300: public void setBottomPadding(int bottomPadding) {
301: this .bottomPadding = new Integer(bottomPadding);
302: }
303:
304: public void setBottomPadding(Integer bottomPadding) {
305: this .bottomPadding = bottomPadding;
306: }
307:
308: public byte getRightBorder() {
309: return JRStyleResolver.getRightBorder(this );
310: }
311:
312: public Byte getOwnRightBorder() {
313: return rightBorder;
314: }
315:
316: public void setRightBorder(byte rightBorder) {
317: this .rightBorder = new Byte(rightBorder);
318: }
319:
320: public void setRightBorder(Byte rightBorder) {
321: this .rightBorder = rightBorder;
322: }
323:
324: public Color getRightBorderColor() {
325: return JRStyleResolver
326: .getRightBorderColor(this , getForecolor());
327: }
328:
329: public Color getOwnRightBorderColor() {
330: return rightBorderColor;
331: }
332:
333: public void setRightBorderColor(Color rightBorderColor) {
334: this .rightBorderColor = rightBorderColor;
335: }
336:
337: public int getRightPadding() {
338: return JRStyleResolver.getRightPadding(this );
339: }
340:
341: public Integer getOwnRightPadding() {
342: return rightPadding;
343: }
344:
345: public void setRightPadding(int rightPadding) {
346: this .rightPadding = new Integer(rightPadding);
347: }
348:
349: public void setRightPadding(Integer rightPadding) {
350: this .rightPadding = rightPadding;
351: }
352:
353: public byte getMode() {
354: return JRStyleResolver.getMode(this, MODE_TRANSPARENT);
355: }
356: }
|