KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > it > businesslogic > ireport > chart > AvailableCharts


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  * AvailableCharts.java
28  *
29  * Created on 2 ottobre 2004, 10.29
30  *
31  */

32
33 package it.businesslogic.ireport.chart;
34 import java.util.*;
35 import it.businesslogic.ireport.gui.sheet.SheetProperty;
36
37 /**
38  * @author Administrator
39  */

40 public class AvailableCharts {
41     
42     static private java.util.Vector JavaDoc charts;
43     static private javax.swing.ImageIcon JavaDoc genericChart = null;
44     static {
45         
46         charts = new Vector();
47         
48
49         ChartDefinition cd = new ChartDefinition();
50         cd.setNeededSeries(new String JavaDoc[]{"Labels","Serie1"});
51         cd.setChartName("Pie");
52         cd.setIcon( new javax.swing.ImageIcon JavaDoc( AvailableCharts.class.getClass().getResource("/it/businesslogic/ireport/icons/charts/pie.png") ) );
53         cd.setType("Pie charts");
54         cd.setFactory("JFreeChart-0.21");
55         addChartSheetProperties(cd);
56               
57         charts.add(cd);
58         
59         ChartDefinition cd2 = new ChartDefinition();
60         
61         cd2.setNeededSeries(new String JavaDoc[]{"Labels","Serie1"});
62         cd2.setChartName("Pie3D");
63         cd2.setIcon( new javax.swing.ImageIcon JavaDoc( AvailableCharts.class.getClass().getResource("/it/businesslogic/ireport/icons/charts/pie3d.png") ) );
64         cd2.setType("Pie charts");
65         cd2.setFactory("JFreeChart-0.21");
66         addChartSheetProperties(cd2);
67         cd2.getSheetProperties().add(new SheetProperty("depthFactor","Depth factor", SheetProperty.NUMBER ,"0.2"));
68         cd2.getSheetProperties().add(new SheetProperty("foregroundAlpha","Foreground Alpha", SheetProperty.NUMBER ,"0.33"));
69         
70         charts.add(cd2);
71         
72         ChartDefinition cd3 = new ChartDefinition();
73         cd3.setNeededSeries(new String JavaDoc[]{"Values","Categories","Series"});
74         cd3.setChartName("Bar");
75         cd3.setIcon( new javax.swing.ImageIcon JavaDoc( AvailableCharts.class.getClass().getResource("/it/businesslogic/ireport/icons/charts/bar.png") ) );
76         cd3.setType("Bar charts");
77         cd3.setFactory("JFreeChart-0.21");
78         addChartSheetProperties(cd3);
79         SheetProperty nsp = new SheetProperty("plotOrientation","Plot orientation",SheetProperty.COMBOBOX_NK,"2");
80         nsp.getTags().add(new it.businesslogic.ireport.gui.sheet.Tag(1,"Horizontal"));
81         nsp.getTags().add(new it.businesslogic.ireport.gui.sheet.Tag(2,"Vertical"));
82         cd3.getSheetProperties().add(nsp);
83         cd3.getSheetProperties().add(new SheetProperty("foregroundAlpha","Foreground Alpha", SheetProperty.NUMBER ,"0.33"));
84         cd3.getSheetProperties().add(new SheetProperty("valueLabel","Value label", SheetProperty.STRING,"" ));
85         cd3.getSheetProperties().add(new SheetProperty("categoryLabel","Category label", SheetProperty.STRING,"" ));
86         charts.add(cd3);
87         
88         ChartDefinition cd4 = new ChartDefinition();
89         cd4.setNeededSeries(new String JavaDoc[]{"Values","Categories","Series"});
90         cd4.setChartName("Bar3D");
91         cd4.setIcon( new javax.swing.ImageIcon JavaDoc( AvailableCharts.class.getClass().getResource("/it/businesslogic/ireport/icons/charts/bar3d.png") ) );
92         cd4.setType("Bar charts");
93         cd4.setFactory("JFreeChart-0.21");
94         addChartSheetProperties(cd4);
95         nsp = new SheetProperty("plotOrientation","Plot orientation",SheetProperty.COMBOBOX_NK,"2");
96         nsp.getTags().add(new it.businesslogic.ireport.gui.sheet.Tag(1,"Horizontal"));
97         nsp.getTags().add(new it.businesslogic.ireport.gui.sheet.Tag(2,"Vertical"));
98         cd4.getSheetProperties().add(nsp);
99         cd4.getSheetProperties().add(new SheetProperty("foregroundAlpha","Foreground Alpha", SheetProperty.NUMBER ,"0.33"));
100         cd4.getSheetProperties().add(new SheetProperty("valueLabel","Value label", SheetProperty.STRING,"" ));
101         cd4.getSheetProperties().add(new SheetProperty("categoryLabel","Category label", SheetProperty.STRING,"" ));
102         charts.add(cd4);
103         
104         ChartDefinition cd5 = new ChartDefinition();
105         cd5.setNeededSeries(new String JavaDoc[]{"Values","Categories","Series"});
106         cd5.setChartName("Line");
107         cd5.setIcon( new javax.swing.ImageIcon JavaDoc( AvailableCharts.class.getClass().getResource("/it/businesslogic/ireport/icons/charts/line.png") ) );
108         cd5.setType("Bar charts");
109         cd5.setFactory("JFreeChart-0.21");
110         addChartSheetProperties(cd5);
111         nsp = new SheetProperty("plotOrientation","Plot orientation",SheetProperty.COMBOBOX_NK,"2");
112         nsp.getTags().add(new it.businesslogic.ireport.gui.sheet.Tag(1,"Horizontal"));
113         nsp.getTags().add(new it.businesslogic.ireport.gui.sheet.Tag(2,"Vertical"));
114         cd5.getSheetProperties().add(nsp);
115         cd5.getSheetProperties().add(new SheetProperty("foregroundAlpha","Foreground Alpha", SheetProperty.NUMBER ,"0.33"));
116         cd5.getSheetProperties().add(new SheetProperty("valueLabel","Y Label label", SheetProperty.STRING,"" ));
117         cd5.getSheetProperties().add(new SheetProperty("categoryLabel","X Label", SheetProperty.STRING,"" ));
118         charts.add(cd5);
119         
120         
121         ChartDefinition cd6 = new ChartDefinition();
122         cd6.setNeededSeries(new String JavaDoc[]{"Values","Categories","Series"});
123         cd6.setChartName("Area");
124         cd6.setIcon( new javax.swing.ImageIcon JavaDoc( AvailableCharts.class.getClass().getResource("/it/businesslogic/ireport/icons/charts/area.png") ) );
125         cd6.setType("Bar charts");
126         cd6.setFactory("JFreeChart-0.21");
127         addChartSheetProperties(cd6);
128         nsp = new SheetProperty("plotOrientation","Plot orientation",SheetProperty.COMBOBOX_NK,"2");
129         nsp.getTags().add(new it.businesslogic.ireport.gui.sheet.Tag(1,"Horizontal"));
130         nsp.getTags().add(new it.businesslogic.ireport.gui.sheet.Tag(2,"Vertical"));
131         cd6.getSheetProperties().add(nsp);
132         cd6.getSheetProperties().add(new SheetProperty("foregroundAlpha","Foreground Alpha", SheetProperty.NUMBER ,"0.33"));
133         cd6.getSheetProperties().add(new SheetProperty("valueLabel","Y Label label", SheetProperty.STRING,"" ));
134         cd6.getSheetProperties().add(new SheetProperty("categoryLabel","X Label", SheetProperty.STRING,"" ));
135         charts.add(cd6);
136         
137         genericChart = new javax.swing.ImageIcon JavaDoc( AvailableCharts.class.getClass().getResource("/it/businesslogic/ireport/icons/charts/genericChart.png"));
138     }
139     
140     /**
141         Return a vector of chart definitions
142     */

143     public static java.util.Vector JavaDoc getAvailableCharts() {
144         return charts;
145     }
146     
147     public static javax.swing.ImageIcon JavaDoc getChartIcon(String JavaDoc chartName)
148     {
149         for (int i=0; i<charts.size(); ++i)
150         {
151             ChartDefinition cd = (ChartDefinition)charts.elementAt(i);
152             if (cd.getChartName().equals(""+chartName)) return cd.getIcon();
153         }
154         return genericChart;
155     }
156     
157     public static void addChartSheetProperties(ChartDefinition cd)
158     {
159         cd.getSheetProperties().add(new SheetProperty("width","Width", SheetProperty.INTEGER ));
160         cd.getSheetProperties().add(new SheetProperty("height","Height", SheetProperty.INTEGER ));
161         cd.getSheetProperties().add(new SheetProperty("quality","Zoom", SheetProperty.INTEGER,"2"));
162         cd.getSheetProperties().add(new SheetProperty("title","Chart title", SheetProperty.STRING ));
163         cd.getSheetProperties().add(new SheetProperty("subtitle","Subtitle", SheetProperty.STRING ));
164         SheetProperty nsp = new SheetProperty("titlePosition","Title position",SheetProperty.COMBOBOX_NK,"1");
165         nsp.getTags().add(new it.businesslogic.ireport.gui.sheet.Tag(1,"Top"));
166         nsp.getTags().add(new it.businesslogic.ireport.gui.sheet.Tag(2,"Bottom"));
167         nsp.getTags().add(new it.businesslogic.ireport.gui.sheet.Tag(3,"Left"));
168         nsp.getTags().add(new it.businesslogic.ireport.gui.sheet.Tag(4,"Right"));
169         cd.getSheetProperties().add(nsp);
170         cd.getSheetProperties().add(new SheetProperty("chartBackground","Chart Background", SheetProperty.COLOR ,"[255,255,255]"));
171         cd.getSheetProperties().add(new SheetProperty("plotBackground","Plot Background", SheetProperty.COLOR ,"[255,255,255]"));
172         cd.getSheetProperties().add(new SheetProperty("antialias","Antialias", SheetProperty.BOOLEAN ,"true"));
173         cd.getSheetProperties().add(new SheetProperty("tooltips","Show tooltips", SheetProperty.BOOLEAN ,"false"));
174         cd.getSheetProperties().add(new SheetProperty("legend","Show legend", SheetProperty.BOOLEAN ,"false"));
175     }
176 }
177
Popular Tags