001: /*
002: * Copyright (C) 2005 - 2008 JasperSoft Corporation. All rights reserved.
003: * http://www.jaspersoft.com.
004: *
005: * Unless you have purchased a commercial license agreement from JasperSoft,
006: * the following license terms apply:
007: *
008: * This program is free software; you can redistribute it and/or modify
009: * it under the terms of the GNU General Public License version 2 as published by
010: * the Free Software Foundation.
011: *
012: * This program is distributed WITHOUT ANY WARRANTY; and without the
013: * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
014: * See the GNU General Public License for more details.
015: *
016: * You should have received a copy of the GNU General Public License
017: * along with this program; if not, see http://www.gnu.org/licenses/gpl.txt
018: * or write to:
019: *
020: * Free Software Foundation, Inc.,
021: * 59 Temple Place - Suite 330,
022: * Boston, MA USA 02111-1307
023: *
024: *
025: *
026: *
027: * GraphicReportElement.java
028: *
029: * Created on 28 febbraio 2003, 19.22
030: *
031: */
032:
033: package it.businesslogic.ireport;
034:
035: import it.businesslogic.ireport.gui.*;
036: import it.businesslogic.ireport.util.*;
037: import java.awt.*;
038: import java.awt.image.*;
039: import java.awt.geom.*;
040:
041: public abstract class GraphicReportElement extends ReportElement {
042:
043: /**
044: * Key for element properties handled using the IReportHashMapBean
045: */
046: public static final String FILL = "FILL";
047: public static final String PEN = "PEN";
048:
049: /**
050: * Default values. If a value can change for different elements,
051: * it is not listed here (i.e. MODE).
052: */
053: public static final String DEFAULT_FILL = "Solid";
054: public static final String DEFAULT_PEN = "Thin";
055:
056: private Pen pen = null;
057:
058: //public String graphicElementPen;
059: //public String fill;
060:
061: public GraphicReportElement(int x, int y, int width, int height) {
062: super (x, y, Math.abs(width), Math.abs(height));
063: //setGraphicElementPen("Thin");
064: //fill="Solid";
065: //stretchType="NoStretch";
066: // Name the elements differently
067: setKey("graphic");
068: }
069:
070: public void drawObject(Graphics2D g, double zoom_factor,
071: int x_shift_origin, int y_shift_origin) {
072: super .drawGraphicsElement(g, getGraphicElementPen(),
073: zoom_factor, x_shift_origin, y_shift_origin);
074: }
075:
076: /** Getter for property fill.
077: * @return Value of property fill.
078: *
079: */
080: public java.lang.String getFill() {
081: if (getPropertyValue(FILL) == null) {
082: // Look for a fgcolor in the stylesheet...
083: if (getStyle() != null) {
084: return getStyle().getAttributeString(
085: getStyle().ATTRIBUTE_fill, DEFAULT_FILL, true);
086: }
087: }
088: return getStringValue(FILL, DEFAULT_FILL);
089: }
090:
091: /** Setter for property fill.
092: * @param fill New value of property fill.
093: *
094: */
095: public void setFill(java.lang.String fill) {
096: setPropertyValue(FILL, fill);
097: }
098:
099: /** Getter for property graphicElementPen.
100: * @return Value of property graphicElementPen.
101: *
102: */
103: public java.lang.String getGraphicElementPen() {
104: if (getPropertyValue(PEN) == null) {
105: // Look for a fgcolor in the stylesheet...
106: if (getStyle() != null) {
107: return getStyle().getAttributeString(
108: getStyle().ATTRIBUTE_pen, DEFAULT_PEN, true);
109: }
110: }
111: return getStringValue(PEN, DEFAULT_PEN);
112: }
113:
114: /** Setter for property graphicElementPen.
115: * @param graphicElementPen New value of property graphicElementPen.
116: *
117: */
118: public void setGraphicElementPen(java.lang.String graphicElementPen) {
119: setPropertyValue(PEN, graphicElementPen);
120: }
121:
122: public void copyBaseReportElement(ReportElement destination,
123: ReportElement source) {
124: super .copyBaseReportElement(destination, source);
125:
126: if (destination instanceof GraphicReportElement
127: && source instanceof GraphicReportElement) {
128:
129: destination.setPropertyValue(PEN, getPropertyValue(PEN));
130: destination.setPropertyValue(FILL, getPropertyValue(FILL));
131: //((GraphicReportElement)destination).setFill( new String( ((GraphicReportElement)source).getFill() ));
132: //((GraphicReportElement)destination).setGraphicElementPen( new String( ((GraphicReportElement)source).getGraphicElementPen() ));
133: //((GraphicReportElement)destination).setStretchType( new String( ((GraphicReportElement)source).getStretchType()) );
134: }
135: }
136:
137: public void setStyle(Style style) {
138: super .setStyle(style);
139: if (style != null) {
140: //this.setFill( style.getAttributeString( style.ATTRIBUTE_fill, getFill(), true) );
141: //this.setGraphicElementPen( style.getAttributeString( style.ATTRIBUTE_pen,getGraphicElementPen(), true) );
142: }
143: }
144:
145: public Pen getPen() {
146: return pen;
147: }
148:
149: public void setPen(Pen pen) {
150: this.pen = pen;
151: }
152: }
|