1 28 package net.sf.jasperreports.engine.base; 29 30 import java.awt.Color ; 31 import java.io.Serializable ; 32 import java.util.SortedSet ; 33 import java.util.TreeSet ; 34 35 import net.sf.jasperreports.engine.JRChartPlot; 36 import net.sf.jasperreports.engine.JRConstants; 37 38 import org.jfree.chart.plot.PlotOrientation; 39 40 41 45 public abstract class JRBaseChartPlot implements JRChartPlot, Serializable 46 { 47 48 49 52 private static final long serialVersionUID = JRConstants.SERIAL_VERSION_UID; 53 54 protected Color backcolor = null; 55 protected PlotOrientation orientation = PlotOrientation.VERTICAL; 56 protected float backgroundAlpha = 1; 57 protected float foregroundAlpha = 1; 58 protected double labelRotation = 0.0; 59 protected SortedSet seriesColors = null; 60 61 62 65 protected JRBaseChartPlot(JRChartPlot plot) 66 { 67 if (plot != null) { 68 backcolor = plot.getBackcolor(); 69 orientation = plot.getOrientation(); 70 backgroundAlpha = plot.getBackgroundAlpha(); 71 foregroundAlpha = plot.getForegroundAlpha(); 72 labelRotation = plot.getLabelRotation(); 73 seriesColors = new TreeSet (plot.getSeriesColors()); 74 } 75 else 76 { 77 seriesColors = new TreeSet (); 78 } 79 } 80 81 82 85 protected JRBaseChartPlot(JRChartPlot plot, JRBaseObjectFactory factory) 86 { 87 factory.put(plot, this); 88 89 backcolor = plot.getBackcolor(); 90 orientation = plot.getOrientation(); 91 backgroundAlpha = plot.getBackgroundAlpha(); 92 foregroundAlpha = plot.getForegroundAlpha(); 93 labelRotation = plot.getLabelRotation(); 94 seriesColors = new TreeSet (plot.getSeriesColors()); 95 } 96 97 98 101 public Color getBackcolor() 102 { 103 return this.backcolor; 104 } 105 106 109 public void setBackcolor(Color backcolor) 110 { 111 this.backcolor = backcolor; 112 } 113 114 117 public PlotOrientation getOrientation() 118 { 119 return orientation; 120 } 121 122 125 public void setOrientation(PlotOrientation orientation) 126 { 127 this.orientation = orientation; 128 } 129 130 133 public float getBackgroundAlpha() 134 { 135 return backgroundAlpha; 136 } 137 138 141 public void setBackgroundAlpha(float backgroundAlpha) 142 { 143 this.backgroundAlpha = backgroundAlpha; 144 } 145 146 149 public float getForegroundAlpha() 150 { 151 return foregroundAlpha; 152 } 153 154 157 public void setForegroundAlpha(float foregroundAlpha) 158 { 159 this.foregroundAlpha = foregroundAlpha; 160 } 161 162 167 public double getLabelRotation() 168 { 169 return labelRotation; 170 } 171 172 177 public void setLabelRotation(double labelRotation) 178 { 179 this.labelRotation = labelRotation; 180 } 181 182 183 187 public SortedSet getSeriesColors() 188 { 189 return seriesColors; 190 } 191 192 195 public void clearSeriesColors() 196 { 197 seriesColors.clear(); 198 } 199 200 203 public void addSeriesColor(JRSeriesColor seriesColor) 204 { 205 seriesColors.add(seriesColor); 206 } 207 208 public static class JRBaseSeriesColor implements JRChartPlot.JRSeriesColor, Serializable , Comparable 209 { 210 213 private static final long serialVersionUID = JRConstants.SERIAL_VERSION_UID; 214 215 protected int seriesOrder = -1; 216 protected Color color = null; 217 218 public JRBaseSeriesColor(int seriesOrder, Color color) 219 { 220 this.seriesOrder = seriesOrder; 221 this.color = color; 222 } 223 224 227 public int getSeriesOrder() 228 { 229 return seriesOrder; 230 } 231 232 235 public Color getColor() 236 { 237 return color; 238 } 239 240 public int compareTo(Object obj) { 241 if (obj == null) 242 { 243 throw new NullPointerException (); 244 } 245 246 return seriesOrder - ((JRBaseSeriesColor)obj).getSeriesOrder(); 247 } 248 } 249 } 250 | Popular Tags |