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: * FrameReportElement.java
028: *
029: * Created on 28 febbraio 2003, 19.20
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: import java.awt.font.*;
041: import java.util.*;
042: import java.util.List;
043: import java.text.AttributedCharacterIterator;
044: import java.text.AttributedString;
045:
046: public class FrameReportElement extends ReportElement implements
047: BoxElement {
048:
049: private Box box = null;
050:
051: public FrameReportElement(int x, int y, int width, int height) {
052: super (x, y, width, height);
053: //see net.sf.jasperreports.engine.base.JRBaseFont
054: //setGraphicElementPen("Thin");
055: //this.bgcolor = Color.WHITE;
056: //this.fgcolor = Color.BLACK;
057: setBox(new Box());
058: setKey("frame");
059: //set font
060: transparentDefault = "Transparent";
061: }
062:
063: public void drawObject(Graphics2D g, double zoom_factor,
064: int x_shift_origin, int y_shift_origin) {
065: position.x -= 10;
066: position.y -= 10;
067: x_shift_origin -= 10;
068: y_shift_origin -= 10;
069:
070: this .zoom_factor = zoom_factor;
071:
072: g.setColor(getBgcolor());
073: if (!getTransparent().equalsIgnoreCase("Transparent"))
074: g.fillRoundRect(getZoomedDim(position.x) - x_shift_origin,
075: getZoomedDim(position.y) - y_shift_origin,
076: getZoomedDim(width), getZoomedDim(height), 0, 0);
077: g.setColor(getFgcolor());
078:
079: position.x += 10;
080: position.y += 10;
081: x_shift_origin += 10;
082: y_shift_origin += 10;
083:
084: drawBorder(g, zoom_factor, x_shift_origin, y_shift_origin);
085: drawBorder(g, zoom_factor, x_shift_origin, y_shift_origin,
086: getBox());
087: //drawGraphicsElement(g,this.getGraphicElementPen(), zoom_factor, x_shift_origin,y_shift_origin, 0);
088: }
089:
090: public ReportElement cloneMe() {
091: FrameReportElement newReportElement = new FrameReportElement(
092: position.x, position.y, width, height);
093: copyBaseReportElement(newReportElement, this );
094: return newReportElement;
095: }
096:
097: public void copyBaseReportElement(ReportElement destination,
098: ReportElement source) {
099: super .copyBaseReportElement(destination, source);
100:
101: if (destination instanceof BoxElement
102: && source instanceof BoxElement) {
103: ((BoxElement) destination).setBox(((BoxElement) source)
104: .getBox().cloneMe());
105: }
106: }
107:
108: public Box getBox() {
109: return box;
110: }
111:
112: public void setBox(Box box) {
113: this .box = box;
114: }
115:
116: public void setStyle(Style style) {
117:
118: super .setStyle(style);
119:
120: if (style != null) {
121: // BOX
122: if (style.getAttributeString(style.ATTRIBUTE_border, null,
123: true) != null)
124: this .getBox().setBorder(
125: style.getAttributeString(
126: style.ATTRIBUTE_border, null, true));
127: if (style.getAttributeColor(style.ATTRIBUTE_borderColor,
128: null, true) != null)
129: this .getBox().setBorderColor(
130: style
131: .getAttributeColor(
132: style.ATTRIBUTE_borderColor,
133: null, true));
134: if (style.getAttributeString(style.ATTRIBUTE_padding, null,
135: true) != null)
136: this .getBox().setPadding(
137: Integer.parseInt(style.getAttributeString(
138: style.ATTRIBUTE_padding, null, true)));
139:
140: if (style.getAttributeString(style.ATTRIBUTE_topBorder,
141: null, true) != null)
142: this .getBox().setTopBorder(
143: style.getAttributeString(
144: style.ATTRIBUTE_topBorder, null, true));
145: if (style.getAttributeColor(style.ATTRIBUTE_topBorderColor,
146: null, true) != null)
147: this .getBox().setTopBorderColor(
148: style.getAttributeColor(
149: style.ATTRIBUTE_topBorderColor, null,
150: true));
151: if (style.getAttributeString(style.ATTRIBUTE_topPadding,
152: null, true) != null)
153: this .getBox().setTopPadding(
154: Integer
155: .parseInt(style.getAttributeString(
156: style.ATTRIBUTE_topPadding,
157: null, true)));
158:
159: if (style.getAttributeString(style.ATTRIBUTE_leftBorder,
160: null, true) != null)
161: this .getBox()
162: .setLeftBorder(
163: style.getAttributeString(
164: style.ATTRIBUTE_leftBorder,
165: null, true));
166: if (style.getAttributeColor(
167: style.ATTRIBUTE_leftBorderColor, null, true) != null)
168: this .getBox().setLeftBorderColor(
169: style.getAttributeColor(
170: style.ATTRIBUTE_leftBorderColor, null,
171: true));
172: if (style.getAttributeString(style.ATTRIBUTE_leftPadding,
173: null, true) != null)
174: this .getBox().setLeftPadding(
175: Integer.parseInt(style
176: .getAttributeString(
177: style.ATTRIBUTE_leftPadding,
178: null, true)));
179:
180: if (style.getAttributeString(style.ATTRIBUTE_rightBorder,
181: null, true) != null)
182: this .getBox().setRightBorder(
183: style
184: .getAttributeString(
185: style.ATTRIBUTE_rightBorder,
186: null, true));
187: if (style.getAttributeColor(
188: style.ATTRIBUTE_rightBorderColor, null, true) != null)
189: this .getBox().setRightBorderColor(
190: style.getAttributeColor(
191: style.ATTRIBUTE_rightBorderColor, null,
192: true));
193: if (style.getAttributeString(style.ATTRIBUTE_rightPadding,
194: null, true) != null)
195: this .getBox().setRightPadding(
196: Integer.parseInt(style.getAttributeString(
197: style.ATTRIBUTE_rightPadding, null,
198: true)));
199:
200: if (style.getAttributeString(style.ATTRIBUTE_bottomBorder,
201: null, true) != null)
202: this .getBox().setBottomBorder(
203: style.getAttributeString(
204: style.ATTRIBUTE_bottomBorder, null,
205: true));
206: if (style.getAttributeColor(
207: style.ATTRIBUTE_bottomBorderColor, null, true) != null)
208: this .getBox().setBottomBorderColor(
209: style.getAttributeColor(
210: style.ATTRIBUTE_bottomBorderColor,
211: null, true));
212: if (style.getAttributeString(style.ATTRIBUTE_bottomPadding,
213: null, true) != null)
214: this .getBox().setBottomPadding(
215: Integer.parseInt(style.getAttributeString(
216: style.ATTRIBUTE_bottomPadding, null,
217: true)));
218:
219: }
220: }
221:
222: }
|