KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > jasperreports > engine > design > JRDesignFrame


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.design;
29
30 import java.awt.Color JavaDoc;
31 import java.io.IOException JavaDoc;
32 import java.util.ArrayList JavaDoc;
33 import java.util.List JavaDoc;
34
35 import net.sf.jasperreports.engine.JRAbstractObjectFactory;
36 import net.sf.jasperreports.engine.JRBox;
37 import net.sf.jasperreports.engine.JRChild;
38 import net.sf.jasperreports.engine.JRConstants;
39 import net.sf.jasperreports.engine.JRDefaultStyleProvider;
40 import net.sf.jasperreports.engine.JRElement;
41 import net.sf.jasperreports.engine.JRElementGroup;
42 import net.sf.jasperreports.engine.JRExpressionCollector;
43 import net.sf.jasperreports.engine.JRFrame;
44 import net.sf.jasperreports.engine.base.JRBaseElementGroup;
45 import net.sf.jasperreports.engine.util.JRStyleResolver;
46 import net.sf.jasperreports.engine.xml.JRXmlWriter;
47
48 /**
49  * Implementation of {@link net.sf.jasperreports.engine.JRFrame JRFrame} to be used at design time.
50  *
51  * @author Lucian Chirita (lucianc@users.sourceforge.net)
52  * @version $Id: JRDesignFrame.java 1229 2006-04-19 13:27:35 +0300 (Wed, 19 Apr 2006) teodord $
53  */

54 public class JRDesignFrame extends JRDesignElement implements JRFrame
55 {
56     private static final long serialVersionUID = JRConstants.SERIAL_VERSION_UID;
57     
58     private List JavaDoc children;
59
60     /**
61      * Creates a new frame object.
62      *
63      * @param defaultStyleProvider default style provider instance
64      */

65     public JRDesignFrame(JRDefaultStyleProvider defaultStyleProvider)
66     {
67         super(defaultStyleProvider);
68         
69         children = new ArrayList JavaDoc();
70     }
71
72     
73     /**
74      * Creates a new frame object.
75      */

76     public JRDesignFrame()
77     {
78         this(null);
79     }
80
81     
82     public void collectExpressions(JRExpressionCollector collector)
83     {
84         collector.collect(this);
85     }
86
87     public JRChild getCopy(JRAbstractObjectFactory factory)
88     {
89         return factory.getFrame(this);
90     }
91
92     public void writeXml(JRXmlWriter writer) throws IOException JavaDoc
93     {
94         writer.writeFrame(this);
95     }
96
97     public JRElement[] getElements()
98     {
99         return JRBaseElementGroup.getElements(children);
100     }
101
102     
103     /**
104      * Adds a sub element to the frame.
105      *
106      * @param element the element to add
107      */

108     public void addElement(JRElement element)
109     {
110         children.add(element);
111     }
112     
113     
114     /**
115      * Removes a sub element from the frame.
116      *
117      * @param element the element to remove
118      * @return <tt>true</tt> if this frame contained the specified element
119      */

120     public boolean removeElement(JRElement element)
121     {
122         return children.remove(element);
123     }
124
125     
126     /**
127      * Adds an element group to the frame.
128      *
129      * @param group the element group to add
130      */

131     public void addElementGroup(JRElementGroup group)
132     {
133         children.add(group);
134     }
135     
136     
137     /**
138      * Removes a group element from the frame.
139      *
140      * @param group the group to remove
141      * @return <tt>true</tt> if this frame contained the specified group
142      */

143     public boolean removeElementGroup(JRElementGroup group)
144     {
145         return children.remove(group);
146     }
147
148     
149     public List JavaDoc getChildren()
150     {
151         return children;
152     }
153
154     public JRElement getElementByKey(String JavaDoc elementKey)
155     {
156         return JRBaseElementGroup.getElementByKey(getElements(), elementKey);
157     }
158     
159     
160     public byte getMode()
161     {
162         return JRStyleResolver.getMode(this, MODE_TRANSPARENT);
163     }
164     
165     
166     // box
167
protected Byte JavaDoc border;
168     protected Byte JavaDoc topBorder = null;
169     protected Byte JavaDoc leftBorder = null;
170     protected Byte JavaDoc bottomBorder = null;
171     protected Byte JavaDoc rightBorder = null;
172     protected Color JavaDoc borderColor = null;
173     protected Color JavaDoc topBorderColor = null;
174     protected Color JavaDoc leftBorderColor = null;
175     protected Color JavaDoc bottomBorderColor = null;
176     protected Color JavaDoc rightBorderColor = null;
177     protected Integer JavaDoc padding;
178     protected Integer JavaDoc topPadding = null;
179     protected Integer JavaDoc leftPadding = null;
180     protected Integer JavaDoc bottomPadding = null;
181     protected Integer JavaDoc rightPadding = null;
182
183
184     public byte getBorder()
185     {
186         return JRStyleResolver.getBorder(this);
187     }
188
189     public Byte JavaDoc getOwnBorder()
190     {
191         return border;
192     }
193
194     public void setBorder(byte border)
195     {
196         this.border = new Byte JavaDoc(border);
197     }
198
199     public void setBorder(Byte JavaDoc border)
200     {
201         this.border = border;
202     }
203
204     public Color JavaDoc getBorderColor()
205     {
206         return JRStyleResolver.getBorderColor(this, getForecolor());
207     }
208
209     public Color JavaDoc getOwnBorderColor()
210     {
211         return borderColor;
212     }
213
214     public void setBorderColor(Color JavaDoc borderColor)
215     {
216         this.borderColor = borderColor;
217     }
218
219     public int getPadding()
220     {
221         return JRStyleResolver.getPadding(this);
222     }
223
224     public Integer JavaDoc getOwnPadding()
225     {
226         return padding;
227     }
228
229     public void setPadding(int padding)
230     {
231         this.padding = new Integer JavaDoc(padding);
232     }
233
234     public void setPadding(Integer JavaDoc padding)
235     {
236         this.padding = padding;
237     }
238
239     public byte getTopBorder()
240     {
241         return JRStyleResolver.getTopBorder(this);
242     }
243
244     public Byte JavaDoc getOwnTopBorder()
245     {
246         return topBorder;
247     }
248
249     public void setTopBorder(byte topBorder)
250     {
251         this.topBorder = new Byte JavaDoc(topBorder);
252     }
253
254     public void setTopBorder(Byte JavaDoc topBorder)
255     {
256         this.topBorder = topBorder;
257     }
258
259     public Color JavaDoc getTopBorderColor()
260     {
261         return JRStyleResolver.getTopBorderColor(this, getForecolor());
262     }
263
264     public Color JavaDoc getOwnTopBorderColor()
265     {
266         return topBorderColor;
267     }
268
269     public void setTopBorderColor(Color JavaDoc topBorderColor)
270     {
271         this.topBorderColor = topBorderColor;
272     }
273
274     public int getTopPadding()
275     {
276         return JRStyleResolver.getTopPadding(this);
277     }
278
279     public Integer JavaDoc getOwnTopPadding()
280     {
281         return topPadding;
282     }
283
284     public void setTopPadding(int topPadding)
285     {
286         this.topPadding = new Integer JavaDoc(topPadding);
287     }
288
289     public void setTopPadding(Integer JavaDoc topPadding)
290     {
291         this.topPadding = topPadding;
292     }
293
294     public byte getLeftBorder()
295     {
296         return JRStyleResolver.getLeftBorder(this);
297     }
298
299     public Byte JavaDoc getOwnLeftBorder()
300     {
301         return leftBorder;
302     }
303
304     public void setLeftBorder(byte leftBorder)
305     {
306         this.leftBorder = new Byte JavaDoc(leftBorder);
307     }
308
309     public void setLeftBorder(Byte JavaDoc leftBorder)
310     {
311         this.leftBorder = leftBorder;
312     }
313
314     public Color JavaDoc getLeftBorderColor()
315     {
316         return JRStyleResolver.getLeftBorderColor(this, getForecolor());
317     }
318
319     public Color JavaDoc getOwnLeftBorderColor()
320     {
321         return leftBorderColor;
322     }
323
324     public void setLeftBorderColor(Color JavaDoc leftBorderColor)
325     {
326         this.leftBorderColor = leftBorderColor;
327     }
328
329     public int getLeftPadding()
330     {
331         return JRStyleResolver.getLeftPadding(this);
332     }
333
334     public Integer JavaDoc getOwnLeftPadding()
335     {
336         return leftPadding;
337     }
338
339     public void setLeftPadding(int leftPadding)
340     {
341         this.leftPadding = new Integer JavaDoc(leftPadding);
342     }
343
344     public void setLeftPadding(Integer JavaDoc leftPadding)
345     {
346         this.leftPadding = leftPadding;
347     }
348
349     public byte getBottomBorder()
350     {
351         return JRStyleResolver.getBottomBorder(this);
352     }
353
354     public Byte JavaDoc getOwnBottomBorder()
355     {
356         return bottomBorder;
357     }
358
359     public void setBottomBorder(byte bottomBorder)
360     {
361         this.bottomBorder = new Byte JavaDoc(bottomBorder);
362     }
363
364     public void setBottomBorder(Byte JavaDoc bottomBorder)
365     {
366         this.bottomBorder = bottomBorder;
367     }
368
369     public Color JavaDoc getBottomBorderColor()
370     {
371         return JRStyleResolver.getBottomBorderColor(this, getForecolor());
372     }
373
374     public Color JavaDoc getOwnBottomBorderColor()
375     {
376         return bottomBorderColor;
377     }
378
379     public void setBottomBorderColor(Color JavaDoc bottomBorderColor)
380     {
381         this.bottomBorderColor = bottomBorderColor;
382     }
383
384     public int getBottomPadding()
385     {
386         return JRStyleResolver.getBottomPadding(this);
387     }
388
389     public Integer JavaDoc getOwnBottomPadding()
390     {
391         return bottomPadding;
392     }
393
394     public void setBottomPadding(int bottomPadding)
395     {
396         this.bottomPadding = new Integer JavaDoc(bottomPadding);
397     }
398
399     public void setBottomPadding(Integer JavaDoc bottomPadding)
400     {
401         this.bottomPadding = bottomPadding;
402     }
403
404     public byte getRightBorder()
405     {
406         return JRStyleResolver.getRightBorder(this);
407     }
408
409     public Byte JavaDoc getOwnRightBorder()
410     {
411         return rightBorder;
412     }
413
414     public void setRightBorder(byte rightBorder)
415     {
416         this.rightBorder = new Byte JavaDoc(rightBorder);
417     }
418
419     public void setRightBorder(Byte JavaDoc rightBorder)
420     {
421         this.rightBorder = rightBorder;
422     }
423
424     public Color JavaDoc getRightBorderColor()
425     {
426         return JRStyleResolver.getRightBorderColor(this, getForecolor());
427     }
428
429     public Color JavaDoc getOwnRightBorderColor()
430     {
431         return rightBorderColor;
432     }
433
434     public void setRightBorderColor(Color JavaDoc rightBorderColor)
435     {
436         this.rightBorderColor = rightBorderColor;
437     }
438
439     public int getRightPadding()
440     {
441         return JRStyleResolver.getRightPadding(this);
442     }
443
444     public Integer JavaDoc getOwnRightPadding()
445     {
446         return rightPadding;
447     }
448
449     public void setRightPadding(int rightPadding)
450     {
451         this.rightPadding = new Integer JavaDoc(rightPadding);
452     }
453
454     public void setRightPadding(Integer JavaDoc rightPadding)
455     {
456         this.rightPadding = rightPadding;
457     }
458     
459     
460     /**
461      * Sets all the box attributes.
462      *
463      * @param box a box object to get the box attributes from
464      */

465     public void setBox(JRBox box)
466     {
467         if (box != null)
468         {
469             border = box.getOwnBorder();
470             topBorder = box.getOwnTopBorder();
471             leftBorder = box.getOwnLeftBorder();
472             bottomBorder = box.getOwnBottomBorder();
473             rightBorder = box.getOwnRightBorder();
474             borderColor = box.getOwnBorderColor();
475             topBorderColor = box.getOwnTopBorderColor();
476             leftBorderColor = box.getOwnLeftBorderColor();
477             bottomBorderColor = box.getOwnBottomBorderColor();
478             rightBorderColor = box.getOwnRightBorderColor();
479             padding = box.getOwnPadding();
480             topPadding = box.getOwnTopPadding();
481             leftPadding = box.getOwnLeftPadding();
482             bottomPadding = box.getOwnBottomPadding();
483             rightPadding = box.getOwnRightPadding();
484         }
485     }
486 }
487
Popular Tags