1 22 23 24 package net.sourceforge.chart2d; 25 26 27 32 public abstract class Chart2D extends Object2D { 33 34 35 private Chart2DProperties chart2DProps; 36 private LegendProperties legendProps; 37 private boolean needsUpdate; 38 39 40 45 public Chart2D() { 46 needsUpdate = true; 47 } 48 49 50 54 public final void setChart2DProperties (Chart2DProperties props) { 55 56 needsUpdate = true; 57 props.addChart2D (this); 58 if (chart2DProps != null) chart2DProps.removeChart2D (this); 59 chart2DProps = props; 60 } 61 62 63 67 public final void setLegendProperties (LegendProperties props) { 68 69 needsUpdate = true; 70 props.addChart2D (this); 71 if (legendProps != null) legendProps.removeChart2D (this); 72 legendProps = props; 73 } 74 75 76 80 public final Chart2DProperties getChart2DProperties() { 81 return chart2DProps; 82 } 83 84 85 89 public final LegendProperties getLegendProperties() { 90 return legendProps; 91 } 92 93 94 98 final boolean getNeedsUpdateChart2D() { 99 return (needsUpdate || getNeedsUpdateObject2D() || 100 chart2DProps.getChart2DNeedsUpdate (this) || legendProps.getChart2DNeedsUpdate (this)); 101 } 102 103 104 111 final boolean validateChart2D (boolean debug) { 112 113 if (debug) System.out.println ("Validating Chart2D"); 114 115 boolean valid = true; 116 117 if (!validateObject2D (debug)) valid = false; 118 119 if (chart2DProps == null) { 120 valid = false; 121 if (debug) System.out.println ("Chart2DProperties is null"); 122 } 123 else if (!chart2DProps.validate (debug)) valid = false; 124 125 if (legendProps == null) { 126 valid = false; 127 if (debug) System.out.println ("LegendProperties is null"); 128 } 129 else if (!legendProps.validate (debug)) valid = false; 130 131 if (debug) { 132 if (valid) System.out.println ("Chart2D was valid"); 133 else System.out.println ("Chart2D was invalid"); 134 } 135 136 return valid; 137 } 138 139 140 143 final void updateChart2D() { 144 145 if (getNeedsUpdateChart2D()) { 146 147 needsUpdate = false; 148 149 updateObject2D(); 150 151 chart2DProps.updateChart2D (this); 152 legendProps.updateChart2D (this); 153 154 ChartArea chart = (ChartArea)getObjectArea(); 155 LegendArea legend = chart.getLegend(); 156 157 chart.setLabelsPrecisionNum (chart2DProps.getChartDataLabelsPrecision()); 158 chart.setBetweenChartAndLegendGapExistence ( 159 chart2DProps.getChartBetweenChartAndLegendGapExistence()); 160 chart.setBetweenChartAndLegendGapThicknessModel ( 161 chart2DProps.getChartBetweenChartAndLegendGapThicknessModel()); 162 163 chart.setLegendExistence (legendProps.getLegendExistence()); 164 legend.setBorderExistence (legendProps.getLegendBorderExistence()); 165 legend.setBorderThicknessModel (legendProps.getLegendBorderThicknessModel()); 166 legend.setBorderColor (legendProps.getLegendBorderColor()); 167 legend.setGapExistence (legendProps.getLegendGapExistence()); 168 legend.setGapThicknessModel (legendProps.getLegendGapThicknessModel()); 169 legend.setBackgroundExistence (legendProps.getLegendBackgroundExistence()); 170 legend.setBackgroundColor (legendProps.getLegendBackgroundColor()); 171 legend.setLabels (legendProps.getLegendLabelsTexts()); 172 legend.setFontPointModel (legendProps.getLegendLabelsFontPointModel()); 173 legend.setFontName (legendProps.getLegendLabelsFontName()); 174 legend.setFontColor (legendProps.getLegendLabelsFontColor()); 175 legend.setFontStyle (legendProps.getLegendLabelsFontStyle()); 176 legend.setBetweenBulletsGapExistence ( 177 legendProps.getLegendBetweenLabelsOrBulletsGapExistence()); 178 legend.setBetweenBulletsGapThicknessModel ( 179 legendProps.getLegendBetweenLabelsOrBulletsGapThicknessModel()); 180 legend.setBetweenLabelsGapExistence ( 181 legendProps.getLegendBetweenLabelsOrBulletsGapExistence()); 182 legend.setBetweenLabelsGapThicknessModel ( 183 legendProps.getLegendBetweenLabelsOrBulletsGapThicknessModel()); 184 legend.setBetweenBulletsAndLabelsGapExistence ( 185 legendProps.getLegendBetweenLabelsAndBulletsGapExistence()); 186 legend.setBetweenBulletsAndLabelsGapThicknessModel ( 187 legendProps.getLegendBetweenLabelsAndBulletsGapThicknessModel()); 188 legend.setBulletsOutline (legendProps.getLegendBulletsOutlineExistence()); 189 legend.setBulletsOutlineColor (legendProps.getLegendBulletsOutlineColor()); 190 legend.setBulletsSizeModel (legendProps.getLegendBulletsSizeModel()); 191 } 192 } 193 } | Popular Tags |