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: * ChartReportElement2.java
028: *
029: * Created on 8 luglio 2005, 17.06
030: *
031: */
032:
033: package it.businesslogic.ireport;
034:
035: import it.businesslogic.ireport.chart.Chart;
036: import java.awt.*;
037: import java.util.Vector;
038:
039: /**
040: *
041: * @author Administrator
042: */
043: public class ChartReportElement2 extends ReportElement implements
044: BoxElement, java.awt.image.ImageObserver,
045: HyperLinkableReportElement {
046:
047: private Box box = null;
048: private Chart chart = null;
049: private String evaluationTime = "Now";
050: private String evaluationGroup = "";
051: private String tooltipExpression = "";
052:
053: private String renderType = null;
054:
055: /** Creates a new instance of JRChartReportElement */
056: public ChartReportElement2(int x, int y, int width, int height) {
057: super (x, y, width, height);
058: setBox(new Box());
059:
060: }
061:
062: public Box getBox() {
063: return box;
064: }
065:
066: public void setBox(Box box) {
067: this .box = box;
068: }
069:
070: public Chart getChart() {
071: return chart;
072: }
073:
074: public void setChart(Chart chart) {
075: this .chart = chart;
076: }
077:
078: public void drawObject(Graphics2D g, double zoom_factor,
079: int x_shift_origin, int y_shift_origin) {
080: position.x += -10 + box.getLeftPadding();
081: position.y += -10 + box.getTopPadding();
082: width = width - box.getLeftPadding() - box.getRightPadding();
083: height = height - box.getTopPadding() - box.getBottomPadding();
084:
085: x_shift_origin -= 10;
086: y_shift_origin -= 10;
087:
088: this .zoom_factor = zoom_factor;
089: Image imgx = getChart().getChartImage();
090:
091: g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
092: RenderingHints.VALUE_ANTIALIAS_ON);
093: g.setRenderingHint(RenderingHints.KEY_DITHERING,
094: RenderingHints.VALUE_DITHER_ENABLE);
095:
096: if (imgx != null) {
097: int imageWidth = imgx.getWidth(this );
098: int imageHeight = imgx.getHeight(this );
099: /*
100: if (imgx instanceof Image)
101: {
102: ((Image)imgx).setTransparent(true);
103: }
104: */
105:
106: //
107:
108: g.drawImage(imgx,
109: getZoomedDim(position.x) - x_shift_origin,
110: getZoomedDim(position.y) - y_shift_origin,
111: getZoomedDim(position.x + width) - x_shift_origin,
112: getZoomedDim(position.y + height) - y_shift_origin,
113: 0, 0, imageWidth, imageHeight, null, this );
114:
115: //-x_shift_origin+ getZoomedDim( position.x-10)+10 ,-y_shift_origin+getZoomedDim(position.y)+10, getZoomedDim( this.width), getZoomedDim( this.height),
116:
117: }
118:
119: if (it.businesslogic.ireport.gui.MainFrame.getMainInstance()
120: .getProperties().getProperty("Antialias", "true")
121: .equals("false")) {
122: g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
123: RenderingHints.VALUE_ANTIALIAS_OFF);
124: g.setRenderingHint(RenderingHints.KEY_DITHERING,
125: RenderingHints.VALUE_DITHER_DISABLE);
126: }
127: //position.x += 10;
128: //position.y += 10;
129:
130: position.x += 10 - box.getLeftPadding();
131: position.y += 10 - box.getTopPadding();
132: width = width + box.getLeftPadding() + box.getRightPadding();
133: height = height + box.getTopPadding() + box.getBottomPadding();
134:
135: x_shift_origin += 10;
136: y_shift_origin += 10;
137:
138: super .drawBorder((Graphics2D) g, zoom_factor, x_shift_origin,
139: y_shift_origin);
140: drawBorder(g, zoom_factor, x_shift_origin, y_shift_origin,
141: getBox());
142: }
143:
144: public String getEvaluationTime() {
145: return evaluationTime;
146: }
147:
148: public void setEvaluationTime(String evaluationTime) {
149: this .evaluationTime = evaluationTime;
150: }
151:
152: public String getEvaluationGroup() {
153: return evaluationGroup;
154: }
155:
156: public void setEvaluationGroup(String evaluationGroup) {
157: this .evaluationGroup = evaluationGroup;
158: }
159:
160: public boolean imageUpdate(Image img, int infoflags, int x, int y,
161: int width, int height) {
162: return true;
163: }
164:
165: public ReportElement cloneMe() {
166: ChartReportElement2 newReportElement = new ChartReportElement2(
167: position.x, position.y, width, height);
168: copyBaseReportElement(newReportElement, this );
169: return newReportElement;
170: }
171:
172: public void copyBaseReportElement(ReportElement destination,
173: ReportElement source) {
174: super .copyBaseReportElement(destination, source);
175:
176: if (destination instanceof ChartReportElement2
177: && source instanceof ChartReportElement2) {
178: ((ChartReportElement2) destination)
179: .setBox(((ChartReportElement2) source).getBox()
180: .cloneMe());
181: ((ChartReportElement2) destination)
182: .setChart(((ChartReportElement2) source).getChart()
183: .cloneMe());
184: ((ChartReportElement2) destination)
185: .setEvaluationGroup(((ChartReportElement2) source)
186: .getEvaluationGroup());
187: ((ChartReportElement2) destination)
188: .setEvaluationTime(((ChartReportElement2) source)
189: .getEvaluationTime());
190: }
191: }
192:
193: public String getAnchorNameExpression() {
194: return getChart().getAnchorNameExpression();
195: }
196:
197: public String getHyperlinkAnchorExpression() {
198: return getChart().getHyperlinkAnchorExpression();
199: }
200:
201: public String getHyperlinkPageExpression() {
202: return getChart().getHyperlinkPageExpression();
203: }
204:
205: public String getHyperlinkReferenceExpression() {
206: return getChart().getHyperlinkReferenceExpression();
207: }
208:
209: public String getHyperlinkTarget() {
210: return getChart().getHyperlinkTarget();
211: }
212:
213: public String getHyperlinkType() {
214: return getChart().getHyperlinkType();
215: }
216:
217: public void setAnchorNameExpression(String anchorNameExpression) {
218: getChart().setAnchorNameExpression(anchorNameExpression);
219: }
220:
221: public void setHyperlinkAnchorExpression(
222: String hyperlinkAnchorExpression) {
223: getChart().setHyperlinkAnchorExpression(
224: hyperlinkAnchorExpression);
225: }
226:
227: public void setHyperlinkPageExpression(
228: String hyperlinkPageExpression) {
229: getChart().setHyperlinkPageExpression(hyperlinkPageExpression);
230: }
231:
232: public void setHyperlinkReferenceExpression(
233: String hyperlinkReferenceExpression) {
234: getChart().setHyperlinkReferenceExpression(
235: hyperlinkReferenceExpression);
236: }
237:
238: public void setHyperlinkTarget(String hyperlinkTarget) {
239: getChart().setHyperlinkTarget(hyperlinkTarget);
240: }
241:
242: public void setHyperlinkType(String hyperlinkType) {
243: getChart().setHyperlinkType(hyperlinkType);
244: }
245:
246: public int getBookmarkLevel() {
247: return getChart().getBookmarkLevel();
248: }
249:
250: public void setBookmarkLevel(int bookmarkLevel) {
251: getChart().setBookmarkLevel(bookmarkLevel);
252: }
253:
254: public void setStyle(Style style) {
255:
256: super .setStyle(style);
257:
258: if (style != null) {
259: // BOX
260: if (style.getAttributeString(style.ATTRIBUTE_border, null,
261: true) != null)
262: this .getBox().setBorder(
263: style.getAttributeString(
264: style.ATTRIBUTE_border, null, true));
265: if (style.getAttributeColor(style.ATTRIBUTE_borderColor,
266: null, true) != null)
267: this .getBox().setBorderColor(
268: style
269: .getAttributeColor(
270: style.ATTRIBUTE_borderColor,
271: null, true));
272: if (style.getAttributeString(style.ATTRIBUTE_padding, null,
273: true) != null)
274: this .getBox().setPadding(
275: Integer.parseInt(style.getAttributeString(
276: style.ATTRIBUTE_padding, null, true)));
277:
278: if (style.getAttributeString(style.ATTRIBUTE_topBorder,
279: null, true) != null)
280: this .getBox().setTopBorder(
281: style.getAttributeString(
282: style.ATTRIBUTE_topBorder, null, true));
283: if (style.getAttributeColor(style.ATTRIBUTE_topBorderColor,
284: null, true) != null)
285: this .getBox().setTopBorderColor(
286: style.getAttributeColor(
287: style.ATTRIBUTE_topBorderColor, null,
288: true));
289: if (style.getAttributeString(style.ATTRIBUTE_topPadding,
290: null, true) != null)
291: this .getBox().setTopPadding(
292: Integer
293: .parseInt(style.getAttributeString(
294: style.ATTRIBUTE_topPadding,
295: null, true)));
296:
297: if (style.getAttributeString(style.ATTRIBUTE_leftBorder,
298: null, true) != null)
299: this .getBox()
300: .setLeftBorder(
301: style.getAttributeString(
302: style.ATTRIBUTE_leftBorder,
303: null, true));
304: if (style.getAttributeColor(
305: style.ATTRIBUTE_leftBorderColor, null, true) != null)
306: this .getBox().setLeftBorderColor(
307: style.getAttributeColor(
308: style.ATTRIBUTE_leftBorderColor, null,
309: true));
310: if (style.getAttributeString(style.ATTRIBUTE_leftPadding,
311: null, true) != null)
312: this .getBox().setLeftPadding(
313: Integer.parseInt(style
314: .getAttributeString(
315: style.ATTRIBUTE_leftPadding,
316: null, true)));
317:
318: if (style.getAttributeString(style.ATTRIBUTE_rightBorder,
319: null, true) != null)
320: this .getBox().setRightBorder(
321: style
322: .getAttributeString(
323: style.ATTRIBUTE_rightBorder,
324: null, true));
325: if (style.getAttributeColor(
326: style.ATTRIBUTE_rightBorderColor, null, true) != null)
327: this .getBox().setRightBorderColor(
328: style.getAttributeColor(
329: style.ATTRIBUTE_rightBorderColor, null,
330: true));
331: if (style.getAttributeString(style.ATTRIBUTE_rightPadding,
332: null, true) != null)
333: this .getBox().setRightPadding(
334: Integer.parseInt(style.getAttributeString(
335: style.ATTRIBUTE_rightPadding, null,
336: true)));
337:
338: if (style.getAttributeString(style.ATTRIBUTE_bottomBorder,
339: null, true) != null)
340: this .getBox().setBottomBorder(
341: style.getAttributeString(
342: style.ATTRIBUTE_bottomBorder, null,
343: true));
344: if (style.getAttributeColor(
345: style.ATTRIBUTE_bottomBorderColor, null, true) != null)
346: this .getBox().setBottomBorderColor(
347: style.getAttributeColor(
348: style.ATTRIBUTE_bottomBorderColor,
349: null, true));
350: if (style.getAttributeString(style.ATTRIBUTE_bottomPadding,
351: null, true) != null)
352: this .getBox().setBottomPadding(
353: Integer.parseInt(style.getAttributeString(
354: style.ATTRIBUTE_bottomPadding, null,
355: true)));
356:
357: }
358: }
359:
360: public java.util.List getLinkParameters() {
361: return getChart().getLinkParameters();
362: }
363:
364: public void setLinkParameters(java.util.List linkParameters) {
365: getChart().setLinkParameters(linkParameters);
366: }
367:
368: public String getTooltipExpression() {
369: return tooltipExpression;
370: }
371:
372: public void setTooltipExpression(String tooltipExpression) {
373: this .tooltipExpression = tooltipExpression;
374: }
375:
376: public String getRenderType() {
377: return renderType;
378: }
379:
380: public void setRenderType(String renderType) {
381: this.renderType = renderType;
382: }
383:
384: }
|