1 32 33 package it.businesslogic.ireport.chart; 34 import java.util.*; 35 import it.businesslogic.ireport.gui.sheet.SheetProperty; 36 37 40 public class AvailableCharts { 41 42 static private java.util.Vector charts; 43 static private javax.swing.ImageIcon genericChart = null; 44 static { 45 46 charts = new Vector(); 47 48 49 ChartDefinition cd = new ChartDefinition(); 50 cd.setNeededSeries(new String []{"Labels","Serie1"}); 51 cd.setChartName("Pie"); 52 cd.setIcon( new javax.swing.ImageIcon ( 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 []{"Labels","Serie1"}); 62 cd2.setChartName("Pie3D"); 63 cd2.setIcon( new javax.swing.ImageIcon ( 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 []{"Values","Categories","Series"}); 74 cd3.setChartName("Bar"); 75 cd3.setIcon( new javax.swing.ImageIcon ( 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 []{"Values","Categories","Series"}); 90 cd4.setChartName("Bar3D"); 91 cd4.setIcon( new javax.swing.ImageIcon ( 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 []{"Values","Categories","Series"}); 106 cd5.setChartName("Line"); 107 cd5.setIcon( new javax.swing.ImageIcon ( 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 []{"Values","Categories","Series"}); 123 cd6.setChartName("Area"); 124 cd6.setIcon( new javax.swing.ImageIcon ( 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 ( AvailableCharts.class.getClass().getResource("/it/businesslogic/ireport/icons/charts/genericChart.png")); 138 } 139 140 143 public static java.util.Vector getAvailableCharts() { 144 return charts; 145 } 146 147 public static javax.swing.ImageIcon getChartIcon(String 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 |