KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > it > businesslogic > ireport > FrameReportElement


1 /*
2  * Copyright (C) 2005 - 2006 JasperSoft Corporation. All rights reserved.
3  * http://www.jaspersoft.com.
4  *
5  * Unless you have purchased a commercial license agreement from JasperSoft,
6  * the following license terms apply:
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License version 2 as published by
10  * the Free Software Foundation.
11  *
12  * This program is distributed WITHOUT ANY WARRANTY; and without the
13  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14  * See the GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, see http://www.gnu.org/licenses/gpl.txt
18  * or write to:
19  *
20  * Free Software Foundation, Inc.,
21  * 59 Temple Place - Suite 330,
22  * Boston, MA USA 02111-1307
23  *
24  *
25  *
26  *
27  * FrameReportElement.java
28  *
29  * Created on 28 febbraio 2003, 19.20
30  *
31  */

32
33 package it.businesslogic.ireport;
34 import it.businesslogic.ireport.gui.*;
35 import it.businesslogic.ireport.util.*;
36 import java.awt.*;
37 import java.awt.image.*;
38 import java.awt.geom.*;
39 import java.awt.font.*;
40 import java.util.*;
41 import java.util.List JavaDoc;
42 import java.text.AttributedCharacterIterator JavaDoc;
43 import java.text.AttributedString JavaDoc;
44
45 public class FrameReportElement extends ReportElement implements BoxElement {
46
47    private Box box = null;
48    
49    public FrameReportElement(int x, int y, int width, int height)
50    {
51       super(x,y,width,height);
52       //see net.sf.jasperreports.engine.base.JRBaseFont
53
//setGraphicElementPen("Thin");
54
//this.bgcolor = Color.WHITE;
55
//this.fgcolor = Color.BLACK;
56
setBox(new Box());
57           setKey("frame");
58       //set font
59
transparentDefault = "Transparent";
60    }
61    
62    public void drawObject(Graphics2D g,double zoom_factor, int x_shift_origin, int y_shift_origin)
63    {
64         position.x -= 10;
65         position.y -= 10;
66         x_shift_origin -= 10;
67         y_shift_origin -= 10;
68
69         this.zoom_factor = zoom_factor;
70
71         g.setColor ( getBgcolor() );
72         if (!getTransparent().equalsIgnoreCase ("Transparent"))
73             g.fillRoundRect ( getZoomedDim (position.x)-x_shift_origin,
74             getZoomedDim (position.y)-y_shift_origin,
75             getZoomedDim (width),
76             getZoomedDim (height),
77             0,
78             0);
79         g.setColor ( getFgcolor() );
80
81         position.x += 10;
82         position.y += 10;
83         x_shift_origin += 10;
84         y_shift_origin += 10;
85         
86      drawBorder( g, zoom_factor, x_shift_origin,y_shift_origin);
87      drawBorder( g, zoom_factor, x_shift_origin,y_shift_origin,getBox());
88      //drawGraphicsElement(g,this.getGraphicElementPen(), zoom_factor, x_shift_origin,y_shift_origin, 0);
89
}
90    
91    public ReportElement cloneMe () {
92         FrameReportElement newReportElement = new FrameReportElement (position.x, position.y, width, height);
93         copyBaseReportElement (newReportElement, this);
94         return newReportElement;
95    }
96      
97    public void copyBaseReportElement(ReportElement destination, ReportElement source)
98    {
99       super.copyBaseReportElement(destination, source);
100       
101       if (destination instanceof BoxElement && source instanceof BoxElement )
102       {
103          ((BoxElement)destination).setBox( ((BoxElement)source).getBox().cloneMe() );
104       }
105    }
106
107     public Box getBox() {
108         return box;
109     }
110
111     public void setBox(Box box) {
112         this.box = box;
113     }
114     
115     public void setStyle(Style style) {
116      
117         super.setStyle(style);
118         
119         if (style != null)
120         {
121             // BOX
122
if (style.getAttributeString(style.ATTRIBUTE_border, null, true) != null)
123                 this.getBox().setBorder( style.getAttributeString(style.ATTRIBUTE_border, null, true) );
124             if (style.getAttributeColor(style.ATTRIBUTE_borderColor, null, true) != null)
125                 this.getBox().setBorderColor( style.getAttributeColor(style.ATTRIBUTE_borderColor, null, true));
126             if (style.getAttributeString(style.ATTRIBUTE_padding, null, true) != null)
127                 this.getBox().setPadding( Integer.parseInt( style.getAttributeString(style.ATTRIBUTE_padding, null, true) ));
128             
129             if (style.getAttributeString(style.ATTRIBUTE_topBorder, null, true) != null)
130                 this.getBox().setTopBorder( style.getAttributeString(style.ATTRIBUTE_topBorder, null, true) );
131             if (style.getAttributeColor(style.ATTRIBUTE_topBorderColor, null, true) != null)
132                 this.getBox().setTopBorderColor( style.getAttributeColor(style.ATTRIBUTE_topBorderColor, null, true));
133             if (style.getAttributeString(style.ATTRIBUTE_topPadding, null, true) != null)
134                 this.getBox().setTopPadding( Integer.parseInt( style.getAttributeString(style.ATTRIBUTE_topPadding, null, true) ));
135             
136             if (style.getAttributeString(style.ATTRIBUTE_leftBorder, null, true) != null)
137                 this.getBox().setLeftBorder( style.getAttributeString(style.ATTRIBUTE_leftBorder, null, true) );
138             if (style.getAttributeColor(style.ATTRIBUTE_leftBorderColor, null, true) != null)
139                 this.getBox().setLeftBorderColor( style.getAttributeColor(style.ATTRIBUTE_leftBorderColor, null, true));
140             if (style.getAttributeString(style.ATTRIBUTE_leftPadding, null, true) != null)
141                 this.getBox().setLeftPadding( Integer.parseInt( style.getAttributeString(style.ATTRIBUTE_leftPadding, null, true) ));
142             
143             if (style.getAttributeString(style.ATTRIBUTE_rightBorder, null, true) != null)
144                 this.getBox().setRightBorder( style.getAttributeString(style.ATTRIBUTE_rightBorder, null, true) );
145             if (style.getAttributeColor(style.ATTRIBUTE_rightBorderColor, null, true) != null)
146                 this.getBox().setRightBorderColor( style.getAttributeColor(style.ATTRIBUTE_rightBorderColor, null, true));
147             if (style.getAttributeString(style.ATTRIBUTE_rightPadding, null, true) != null)
148                 this.getBox().setRightPadding( Integer.parseInt( style.getAttributeString(style.ATTRIBUTE_rightPadding, null, true) ));
149             
150             if (style.getAttributeString(style.ATTRIBUTE_bottomBorder, null, true) != null)
151                 this.getBox().setBottomBorder( style.getAttributeString(style.ATTRIBUTE_bottomBorder, null, true) );
152             if (style.getAttributeColor(style.ATTRIBUTE_bottomBorderColor, null, true) != null)
153                 this.getBox().setBottomBorderColor( style.getAttributeColor(style.ATTRIBUTE_bottomBorderColor, null, true));
154             if (style.getAttributeString(style.ATTRIBUTE_bottomPadding, null, true) != null)
155                 this.getBox().setBottomPadding( Integer.parseInt( style.getAttributeString(style.ATTRIBUTE_bottomPadding, null, true) ));
156             
157         }
158      }
159
160 }
161
Popular Tags