KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > jasperreports > engine > base > JRBaseFrame


1 /*
2  * ============================================================================
3  * GNU Lesser General Public License
4  * ============================================================================
5  *
6  * JasperReports - Free Java report-generating library.
7  * Copyright (C) 2001-2006 JasperSoft Corporation http://www.jaspersoft.com
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
22  *
23  * JasperSoft Corporation
24  * 303 Second Street, Suite 450 North
25  * San Francisco, CA 94107
26  * http://www.jaspersoft.com
27  */

28 package net.sf.jasperreports.engine.base;
29
30 import java.awt.Color JavaDoc;
31 import java.io.IOException JavaDoc;
32 import java.util.ArrayList JavaDoc;
33 import java.util.Iterator JavaDoc;
34 import java.util.List JavaDoc;
35
36 import net.sf.jasperreports.engine.JRAbstractObjectFactory;
37 import net.sf.jasperreports.engine.JRChild;
38 import net.sf.jasperreports.engine.JRConstants;
39 import net.sf.jasperreports.engine.JRElement;
40 import net.sf.jasperreports.engine.JRExpressionCollector;
41 import net.sf.jasperreports.engine.JRFrame;
42 import net.sf.jasperreports.engine.util.JRStyleResolver;
43 import net.sf.jasperreports.engine.xml.JRXmlWriter;
44
45 /**
46  * Base read-only implementation of {@link net.sf.jasperreports.engine.JRFrame JRFrame}.
47  *
48  * @author Lucian Chirita (lucianc@users.sourceforge.net)
49  * @version $Id: JRBaseFrame.java 1229 2006-04-19 13:27:35 +0300 (Wed, 19 Apr 2006) teodord $
50  */

51 public class JRBaseFrame extends JRBaseElement implements JRFrame
52 {
53     private static final long serialVersionUID = JRConstants.SERIAL_VERSION_UID;
54     
55     protected List JavaDoc children;
56
57     public JRBaseFrame(JRFrame frame, JRBaseObjectFactory factory)
58     {
59         super(frame, factory);
60
61         List JavaDoc frameChildren = frame.getChildren();
62         if (frameChildren != null)
63         {
64             children = new ArrayList JavaDoc(frameChildren.size());
65             for (Iterator JavaDoc it = frameChildren.iterator(); it.hasNext();)
66             {
67                 JRChild child = (JRChild) it.next();
68                 children.add(child.getCopy(factory));
69             }
70         }
71         
72         copyBox(frame);
73     }
74
75     private void copyBox(JRFrame frame)
76     {
77         border = frame.getOwnBorder();
78         topBorder = frame.getOwnTopBorder();
79         leftBorder = frame.getOwnLeftBorder();
80         bottomBorder = frame.getOwnBottomBorder();
81         rightBorder = frame.getOwnRightBorder();
82         borderColor = frame.getOwnBorderColor();
83         topBorderColor = frame.getOwnTopBorderColor();
84         leftBorderColor = frame.getOwnLeftBorderColor();
85         bottomBorderColor = frame.getOwnBottomBorderColor();
86         rightBorderColor = frame.getOwnRightBorderColor();
87         padding = frame.getOwnPadding();
88         topPadding = frame.getOwnTopPadding();
89         leftPadding = frame.getOwnLeftPadding();
90         bottomPadding = frame.getOwnBottomPadding();
91         rightPadding = frame.getOwnRightPadding();
92     }
93
94     public JRElement[] getElements()
95     {
96         return JRBaseElementGroup.getElements(children);
97     }
98
99     public void collectExpressions(JRExpressionCollector collector)
100     {
101         collector.collect(this);
102     }
103
104     public JRChild getCopy(JRAbstractObjectFactory factory)
105     {
106         return factory.getFrame(this);
107     }
108
109     public void writeXml(JRXmlWriter writer) throws IOException JavaDoc
110     {
111         writer.writeFrame(this);
112     }
113
114     public List JavaDoc getChildren()
115     {
116         return children;
117     }
118
119     public JRElement getElementByKey(String JavaDoc elementKey)
120     {
121         return JRBaseElementGroup.getElementByKey(getElements(), elementKey);
122     }
123
124
125     // box
126
protected Byte JavaDoc border;
127     protected Byte JavaDoc topBorder = null;
128     protected Byte JavaDoc leftBorder = null;
129     protected Byte JavaDoc bottomBorder = null;
130     protected Byte JavaDoc rightBorder = null;
131     protected Color JavaDoc borderColor = null;
132     protected Color JavaDoc topBorderColor = null;
133     protected Color JavaDoc leftBorderColor = null;
134     protected Color JavaDoc bottomBorderColor = null;
135     protected Color JavaDoc rightBorderColor = null;
136     protected Integer JavaDoc padding;
137     protected Integer JavaDoc topPadding = null;
138     protected Integer JavaDoc leftPadding = null;
139     protected Integer JavaDoc bottomPadding = null;
140     protected Integer JavaDoc rightPadding = null;
141
142
143     public byte getBorder()
144     {
145         return JRStyleResolver.getBorder(this);
146     }
147
148     public Byte JavaDoc getOwnBorder()
149     {
150         return border;
151     }
152
153     public void setBorder(byte border)
154     {
155         this.border = new Byte JavaDoc(border);
156     }
157
158     public void setBorder(Byte JavaDoc border)
159     {
160         this.border = border;
161     }
162
163     public Color JavaDoc getBorderColor()
164     {
165         return JRStyleResolver.getBorderColor(this, getForecolor());
166     }
167
168     public Color JavaDoc getOwnBorderColor()
169     {
170         return borderColor;
171     }
172
173     public void setBorderColor(Color JavaDoc borderColor)
174     {
175         this.borderColor = borderColor;
176     }
177
178     public int getPadding()
179     {
180         return JRStyleResolver.getPadding(this);
181     }
182
183     public Integer JavaDoc getOwnPadding()
184     {
185         return padding;
186     }
187
188     public void setPadding(int padding)
189     {
190         this.padding = new Integer JavaDoc(padding);
191     }
192
193     public void setPadding(Integer JavaDoc padding)
194     {
195         this.padding = padding;
196     }
197
198     public byte getTopBorder()
199     {
200         return JRStyleResolver.getTopBorder(this);
201     }
202
203     public Byte JavaDoc getOwnTopBorder()
204     {
205         return topBorder;
206     }
207
208     public void setTopBorder(byte topBorder)
209     {
210         this.topBorder = new Byte JavaDoc(topBorder);
211     }
212
213     public void setTopBorder(Byte JavaDoc topBorder)
214     {
215         this.topBorder = topBorder;
216     }
217
218     public Color JavaDoc getTopBorderColor()
219     {
220         return JRStyleResolver.getTopBorderColor(this, getForecolor());
221     }
222
223     public Color JavaDoc getOwnTopBorderColor()
224     {
225         return topBorderColor;
226     }
227
228     public void setTopBorderColor(Color JavaDoc topBorderColor)
229     {
230         this.topBorderColor = topBorderColor;
231     }
232
233     public int getTopPadding()
234     {
235         return JRStyleResolver.getTopPadding(this);
236     }
237
238     public Integer JavaDoc getOwnTopPadding()
239     {
240         return topPadding;
241     }
242
243     public void setTopPadding(int topPadding)
244     {
245         this.topPadding = new Integer JavaDoc(topPadding);
246     }
247
248     public void setTopPadding(Integer JavaDoc topPadding)
249     {
250         this.topPadding = topPadding;
251     }
252
253     public byte getLeftBorder()
254     {
255         return JRStyleResolver.getLeftBorder(this);
256     }
257
258     public Byte JavaDoc getOwnLeftBorder()
259     {
260         return leftBorder;
261     }
262
263     public void setLeftBorder(byte leftBorder)
264     {
265         this.leftBorder = new Byte JavaDoc(leftBorder);
266     }
267
268     public void setLeftBorder(Byte JavaDoc leftBorder)
269     {
270         this.leftBorder = leftBorder;
271     }
272
273     public Color JavaDoc getLeftBorderColor()
274     {
275         return JRStyleResolver.getLeftBorderColor(this, getForecolor());
276     }
277
278     public Color JavaDoc getOwnLeftBorderColor()
279     {
280         return leftBorderColor;
281     }
282
283     public void setLeftBorderColor(Color JavaDoc leftBorderColor)
284     {
285         this.leftBorderColor = leftBorderColor;
286     }
287
288     public int getLeftPadding()
289     {
290         return JRStyleResolver.getLeftPadding(this);
291     }
292
293     public Integer JavaDoc getOwnLeftPadding()
294     {
295         return leftPadding;
296     }
297
298     public void setLeftPadding(int leftPadding)
299     {
300         this.leftPadding = new Integer JavaDoc(leftPadding);
301     }
302
303     public void setLeftPadding(Integer JavaDoc leftPadding)
304     {
305         this.leftPadding = leftPadding;
306     }
307
308     public byte getBottomBorder()
309     {
310         return JRStyleResolver.getBottomBorder(this);
311     }
312
313     public Byte JavaDoc getOwnBottomBorder()
314     {
315         return bottomBorder;
316     }
317
318     public void setBottomBorder(byte bottomBorder)
319     {
320         this.bottomBorder = new Byte JavaDoc(bottomBorder);
321     }
322
323     public void setBottomBorder(Byte JavaDoc bottomBorder)
324     {
325         this.bottomBorder = bottomBorder;
326     }
327
328     public Color JavaDoc getBottomBorderColor()
329     {
330         return JRStyleResolver.getBottomBorderColor(this, getForecolor());
331     }
332
333     public Color JavaDoc getOwnBottomBorderColor()
334     {
335         return bottomBorderColor;
336     }
337
338     public void setBottomBorderColor(Color JavaDoc bottomBorderColor)
339     {
340         this.bottomBorderColor = bottomBorderColor;
341     }
342
343     public int getBottomPadding()
344     {
345         return JRStyleResolver.getBottomPadding(this);
346     }
347
348     public Integer JavaDoc getOwnBottomPadding()
349     {
350         return bottomPadding;
351     }
352
353     public void setBottomPadding(int bottomPadding)
354     {
355         this.bottomPadding = new Integer JavaDoc(bottomPadding);
356     }
357
358     public void setBottomPadding(Integer JavaDoc bottomPadding)
359     {
360         this.bottomPadding = bottomPadding;
361     }
362
363     public byte getRightBorder()
364     {
365         return JRStyleResolver.getRightBorder(this);
366     }
367
368     public Byte JavaDoc getOwnRightBorder()
369     {
370         return rightBorder;
371     }
372
373     public void setRightBorder(byte rightBorder)
374     {
375         this.rightBorder = new Byte JavaDoc(rightBorder);
376     }
377
378     public void setRightBorder(Byte JavaDoc rightBorder)
379     {
380         this.rightBorder = rightBorder;
381     }
382
383     public Color JavaDoc getRightBorderColor()
384     {
385         return JRStyleResolver.getRightBorderColor(this, getForecolor());
386     }
387
388     public Color JavaDoc getOwnRightBorderColor()
389     {
390         return rightBorderColor;
391     }
392
393     public void setRightBorderColor(Color JavaDoc rightBorderColor)
394     {
395         this.rightBorderColor = rightBorderColor;
396     }
397
398     public int getRightPadding()
399     {
400         return JRStyleResolver.getRightPadding(this);
401     }
402
403     public Integer JavaDoc getOwnRightPadding()
404     {
405         return rightPadding;
406     }
407
408     public void setRightPadding(int rightPadding)
409     {
410         this.rightPadding = new Integer JavaDoc(rightPadding);
411     }
412
413     public void setRightPadding(Integer JavaDoc rightPadding)
414     {
415         this.rightPadding = rightPadding;
416     }
417     
418     public byte getMode()
419     {
420         return JRStyleResolver.getMode(this, MODE_TRANSPARENT);
421     }
422 }
423
Popular Tags