KickJava   Java API By Example, From Geeks To Geeks.

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


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  * GraphicReportElement.java
28  *
29  * Created on 28 febbraio 2003, 19.22
30  *
31  */

32
33 package it.businesslogic.ireport;
34
35 import it.businesslogic.ireport.gui.*;
36 import it.businesslogic.ireport.util.*;
37 import java.awt.*;
38 import java.awt.image.*;
39 import java.awt.geom.*;
40
41 public abstract class GraphicReportElement extends ReportElement
42 {
43
44         /**
45          * Key for element properties handled using the IReportHashMapBean
46          */

47         public static final String JavaDoc FILL = "FILL";
48         public static final String JavaDoc PEN = "PEN";
49         
50         /**
51          * Default values. If a value can change for different elements,
52          * it is not listed here (i.e. MODE).
53          */

54         public static final String JavaDoc DEFAULT_FILL = "Solid";
55         public static final String JavaDoc DEFAULT_PEN = "Thin";
56     
57     //public String graphicElementPen;
58
//public String fill;
59

60     public GraphicReportElement(int x, int y, int width, int height)
61     {
62         super(x,y, Math.abs(width), Math.abs(height));
63         //setGraphicElementPen("Thin");
64
//fill="Solid";
65
//stretchType="NoStretch";
66
// Name the elements differently
67
setKey("graphic");
68     }
69     
70     public void drawObject(Graphics2D g,double zoom_factor, int x_shift_origin, int y_shift_origin)
71     {
72         super.drawGraphicsElement(g, getGraphicElementPen(), zoom_factor, x_shift_origin, y_shift_origin );
73     }
74         
75         /** Getter for property fill.
76          * @return Value of property fill.
77          *
78          */

79         public java.lang.String JavaDoc getFill() {
80             if (getPropertyValue(FILL) == null)
81             {
82                 // Look for a fgcolor in the stylesheet...
83
if (getStyle() != null)
84                 {
85                    return getStyle().getAttributeString( getStyle().ATTRIBUTE_fill, DEFAULT_FILL, true);
86                 }
87             }
88             return getStringValue(FILL, DEFAULT_FILL );
89         }
90         
91         /** Setter for property fill.
92          * @param fill New value of property fill.
93          *
94          */

95         public void setFill(java.lang.String JavaDoc fill) {
96             setPropertyValue(FILL, fill);
97         }
98         
99         /** Getter for property graphicElementPen.
100          * @return Value of property graphicElementPen.
101          *
102          */

103         public java.lang.String JavaDoc getGraphicElementPen() {
104            if (getPropertyValue(PEN) == null)
105             {
106                 // Look for a fgcolor in the stylesheet...
107
if (getStyle() != null)
108                 {
109                    return getStyle().getAttributeString( getStyle().ATTRIBUTE_pen, DEFAULT_PEN, true);
110                 }
111             }
112             return getStringValue(PEN, DEFAULT_PEN );
113         }
114         
115         /** Setter for property graphicElementPen.
116          * @param graphicElementPen New value of property graphicElementPen.
117          *
118          */

119         public void setGraphicElementPen(java.lang.String JavaDoc graphicElementPen) {
120             setPropertyValue(PEN, graphicElementPen);
121         }
122         
123         public void copyBaseReportElement(ReportElement destination, ReportElement source)
124         {
125                 super.copyBaseReportElement(destination, source);
126                 
127                 if (destination instanceof GraphicReportElement &&
128                     source instanceof GraphicReportElement )
129                 {
130                     
131                     destination.setPropertyValue(PEN, getPropertyValue(PEN));
132                     destination.setPropertyValue(FILL, getPropertyValue(FILL));
133                     //((GraphicReportElement)destination).setFill( new String( ((GraphicReportElement)source).getFill() ));
134
//((GraphicReportElement)destination).setGraphicElementPen( new String( ((GraphicReportElement)source).getGraphicElementPen() ));
135
//((GraphicReportElement)destination).setStretchType( new String( ((GraphicReportElement)source).getStretchType()) );
136
}
137         }
138         
139          public void setStyle(Style style) {
140                 super.setStyle(style);
141                 if (style != null)
142                 {
143                     //this.setFill( style.getAttributeString( style.ATTRIBUTE_fill, getFill(), true) );
144
//this.setGraphicElementPen( style.getAttributeString( style.ATTRIBUTE_pen,getGraphicElementPen(), true) );
145
}
146          }
147 }
148
149
Popular Tags