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: * AvailableCharts.java
028: *
029: * Created on 2 ottobre 2004, 10.29
030: *
031: */
032:
033: package it.businesslogic.ireport.chart;
034:
035: import java.util.*;
036: import it.businesslogic.ireport.gui.sheet.SheetProperty;
037:
038: /**
039: * @author Administrator
040: */
041: public class AvailableCharts {
042:
043: static private java.util.Vector charts;
044: static private javax.swing.ImageIcon genericChart = null;
045: static {
046:
047: charts = new Vector();
048:
049: ChartDefinition cd = new ChartDefinition();
050: cd.setNeededSeries(new String[] { "Labels", "Serie1" });
051: cd.setChartName("Pie");
052: cd
053: .setIcon(new javax.swing.ImageIcon(
054: AvailableCharts.class
055: .getClass()
056: .getResource(
057: "/it/businesslogic/ireport/icons/charts/pie.png")));
058: cd.setType("Pie charts");
059: cd.setFactory("JFreeChart-0.21");
060: addChartSheetProperties(cd);
061:
062: charts.add(cd);
063:
064: ChartDefinition cd2 = new ChartDefinition();
065:
066: cd2.setNeededSeries(new String[] { "Labels", "Serie1" });
067: cd2.setChartName("Pie3D");
068: cd2
069: .setIcon(new javax.swing.ImageIcon(
070: AvailableCharts.class
071: .getClass()
072: .getResource(
073: "/it/businesslogic/ireport/icons/charts/pie3d.png")));
074: cd2.setType("Pie charts");
075: cd2.setFactory("JFreeChart-0.21");
076: addChartSheetProperties(cd2);
077: cd2.getSheetProperties().add(
078: new SheetProperty("depthFactor", "Depth factor",
079: SheetProperty.NUMBER, "0.2"));
080: cd2.getSheetProperties().add(
081: new SheetProperty("foregroundAlpha",
082: "Foreground Alpha", SheetProperty.NUMBER,
083: "0.33"));
084:
085: charts.add(cd2);
086:
087: ChartDefinition cd3 = new ChartDefinition();
088: cd3.setNeededSeries(new String[] { "Values", "Categories",
089: "Series" });
090: cd3.setChartName("Bar");
091: cd3
092: .setIcon(new javax.swing.ImageIcon(
093: AvailableCharts.class
094: .getClass()
095: .getResource(
096: "/it/businesslogic/ireport/icons/charts/bar.png")));
097: cd3.setType("Bar charts");
098: cd3.setFactory("JFreeChart-0.21");
099: addChartSheetProperties(cd3);
100: SheetProperty nsp = new SheetProperty("plotOrientation",
101: "Plot orientation", SheetProperty.COMBOBOX_NK, "2");
102: nsp.getTags().add(
103: new it.businesslogic.ireport.gui.sheet.Tag(1,
104: "Horizontal"));
105: nsp.getTags().add(
106: new it.businesslogic.ireport.gui.sheet.Tag(2,
107: "Vertical"));
108: cd3.getSheetProperties().add(nsp);
109: cd3.getSheetProperties().add(
110: new SheetProperty("foregroundAlpha",
111: "Foreground Alpha", SheetProperty.NUMBER,
112: "0.33"));
113: cd3.getSheetProperties().add(
114: new SheetProperty("valueLabel", "Value label",
115: SheetProperty.STRING, ""));
116: cd3.getSheetProperties().add(
117: new SheetProperty("categoryLabel", "Category label",
118: SheetProperty.STRING, ""));
119: charts.add(cd3);
120:
121: ChartDefinition cd4 = new ChartDefinition();
122: cd4.setNeededSeries(new String[] { "Values", "Categories",
123: "Series" });
124: cd4.setChartName("Bar3D");
125: cd4
126: .setIcon(new javax.swing.ImageIcon(
127: AvailableCharts.class
128: .getClass()
129: .getResource(
130: "/it/businesslogic/ireport/icons/charts/bar3d.png")));
131: cd4.setType("Bar charts");
132: cd4.setFactory("JFreeChart-0.21");
133: addChartSheetProperties(cd4);
134: nsp = new SheetProperty("plotOrientation", "Plot orientation",
135: SheetProperty.COMBOBOX_NK, "2");
136: nsp.getTags().add(
137: new it.businesslogic.ireport.gui.sheet.Tag(1,
138: "Horizontal"));
139: nsp.getTags().add(
140: new it.businesslogic.ireport.gui.sheet.Tag(2,
141: "Vertical"));
142: cd4.getSheetProperties().add(nsp);
143: cd4.getSheetProperties().add(
144: new SheetProperty("foregroundAlpha",
145: "Foreground Alpha", SheetProperty.NUMBER,
146: "0.33"));
147: cd4.getSheetProperties().add(
148: new SheetProperty("valueLabel", "Value label",
149: SheetProperty.STRING, ""));
150: cd4.getSheetProperties().add(
151: new SheetProperty("categoryLabel", "Category label",
152: SheetProperty.STRING, ""));
153: charts.add(cd4);
154:
155: ChartDefinition cd5 = new ChartDefinition();
156: cd5.setNeededSeries(new String[] { "Values", "Categories",
157: "Series" });
158: cd5.setChartName("Line");
159: cd5
160: .setIcon(new javax.swing.ImageIcon(
161: AvailableCharts.class
162: .getClass()
163: .getResource(
164: "/it/businesslogic/ireport/icons/charts/line.png")));
165: cd5.setType("Bar charts");
166: cd5.setFactory("JFreeChart-0.21");
167: addChartSheetProperties(cd5);
168: nsp = new SheetProperty("plotOrientation", "Plot orientation",
169: SheetProperty.COMBOBOX_NK, "2");
170: nsp.getTags().add(
171: new it.businesslogic.ireport.gui.sheet.Tag(1,
172: "Horizontal"));
173: nsp.getTags().add(
174: new it.businesslogic.ireport.gui.sheet.Tag(2,
175: "Vertical"));
176: cd5.getSheetProperties().add(nsp);
177: cd5.getSheetProperties().add(
178: new SheetProperty("foregroundAlpha",
179: "Foreground Alpha", SheetProperty.NUMBER,
180: "0.33"));
181: cd5.getSheetProperties().add(
182: new SheetProperty("valueLabel", "Y Label label",
183: SheetProperty.STRING, ""));
184: cd5.getSheetProperties().add(
185: new SheetProperty("categoryLabel", "X Label",
186: SheetProperty.STRING, ""));
187: charts.add(cd5);
188:
189: ChartDefinition cd6 = new ChartDefinition();
190: cd6.setNeededSeries(new String[] { "Values", "Categories",
191: "Series" });
192: cd6.setChartName("Area");
193: cd6
194: .setIcon(new javax.swing.ImageIcon(
195: AvailableCharts.class
196: .getClass()
197: .getResource(
198: "/it/businesslogic/ireport/icons/charts/area.png")));
199: cd6.setType("Bar charts");
200: cd6.setFactory("JFreeChart-0.21");
201: addChartSheetProperties(cd6);
202: nsp = new SheetProperty("plotOrientation", "Plot orientation",
203: SheetProperty.COMBOBOX_NK, "2");
204: nsp.getTags().add(
205: new it.businesslogic.ireport.gui.sheet.Tag(1,
206: "Horizontal"));
207: nsp.getTags().add(
208: new it.businesslogic.ireport.gui.sheet.Tag(2,
209: "Vertical"));
210: cd6.getSheetProperties().add(nsp);
211: cd6.getSheetProperties().add(
212: new SheetProperty("foregroundAlpha",
213: "Foreground Alpha", SheetProperty.NUMBER,
214: "0.33"));
215: cd6.getSheetProperties().add(
216: new SheetProperty("valueLabel", "Y Label label",
217: SheetProperty.STRING, ""));
218: cd6.getSheetProperties().add(
219: new SheetProperty("categoryLabel", "X Label",
220: SheetProperty.STRING, ""));
221: charts.add(cd6);
222:
223: genericChart = new javax.swing.ImageIcon(
224: AvailableCharts.class
225: .getClass()
226: .getResource(
227: "/it/businesslogic/ireport/icons/charts/genericChart.png"));
228: }
229:
230: /**
231: Return a vector of chart definitions
232: */
233: public static java.util.Vector getAvailableCharts() {
234: return charts;
235: }
236:
237: public static javax.swing.ImageIcon getChartIcon(String chartName) {
238: for (int i = 0; i < charts.size(); ++i) {
239: ChartDefinition cd = (ChartDefinition) charts.elementAt(i);
240: if (cd.getChartName().equals("" + chartName))
241: return cd.getIcon();
242: }
243: return genericChart;
244: }
245:
246: public static void addChartSheetProperties(ChartDefinition cd) {
247: cd.getSheetProperties().add(
248: new SheetProperty("width", "Width",
249: SheetProperty.INTEGER));
250: cd.getSheetProperties().add(
251: new SheetProperty("height", "Height",
252: SheetProperty.INTEGER));
253: cd.getSheetProperties().add(
254: new SheetProperty("quality", "Zoom",
255: SheetProperty.INTEGER, "2"));
256: cd.getSheetProperties().add(
257: new SheetProperty("title", "Chart title",
258: SheetProperty.STRING));
259: cd.getSheetProperties().add(
260: new SheetProperty("subtitle", "Subtitle",
261: SheetProperty.STRING));
262: SheetProperty nsp = new SheetProperty("titlePosition",
263: "Title position", SheetProperty.COMBOBOX_NK, "1");
264: nsp.getTags().add(
265: new it.businesslogic.ireport.gui.sheet.Tag(1, "Top"));
266: nsp.getTags()
267: .add(
268: new it.businesslogic.ireport.gui.sheet.Tag(2,
269: "Bottom"));
270: nsp.getTags().add(
271: new it.businesslogic.ireport.gui.sheet.Tag(3, "Left"));
272: nsp.getTags().add(
273: new it.businesslogic.ireport.gui.sheet.Tag(4, "Right"));
274: cd.getSheetProperties().add(nsp);
275: cd.getSheetProperties().add(
276: new SheetProperty("chartBackground",
277: "Chart Background", SheetProperty.COLOR,
278: "[255,255,255]"));
279: cd.getSheetProperties().add(
280: new SheetProperty("plotBackground", "Plot Background",
281: SheetProperty.COLOR, "[255,255,255]"));
282: cd.getSheetProperties().add(
283: new SheetProperty("antialias", "Antialias",
284: SheetProperty.BOOLEAN, "true"));
285: cd.getSheetProperties().add(
286: new SheetProperty("tooltips", "Show tooltips",
287: SheetProperty.BOOLEAN, "false"));
288: cd.getSheetProperties().add(
289: new SheetProperty("legend", "Show legend",
290: SheetProperty.BOOLEAN, "false"));
291: }
292: }
|