1 39 40 41 package org.krysalis.jcharts.properties; 42 43 44 import org.krysalis.jcharts.test.HTMLGenerator; 45 import org.krysalis.jcharts.test.HTMLTestable; 46 import org.krysalis.jcharts.properties.util.ChartStroke; 47 import org.krysalis.jcharts.axisChart.axis.scale.ScaleCalculator; 48 49 import java.lang.reflect.Field ; 50 51 52 public final class DataAxisProperties extends LabelAxisProperties implements HTMLTestable 53 { 54 private int roundToNearest = 0; 56 57 private boolean showZeroLine = true; 58 private ChartStroke zeroLineChartStroke= ChartStroke.DEFAULT_ZERO_LINE; 59 60 private boolean userDefinedScale = false; 62 private double userDefinedMinimumValue; 63 private double userDefinedIncrement; 64 65 private int numItems = 5; 67 68 private boolean useDollarSigns = false; 69 private boolean useCommas = true; 70 private boolean usePercentSigns = false; 71 72 73 private ScaleCalculator scaleCalculator; 75 76 77 78 79 82 public DataAxisProperties() 83 { 84 super(); 85 } 86 87 88 94 public void setUserDefinedScale( double axisMinimum, double axisIncrement ) throws PropertyException 95 { 96 if( axisIncrement <= 0 ) 97 { 98 throw new PropertyException( "The Axis Increment can not be a negative value or zero." ); 99 } 100 101 this.userDefinedScale = true; 102 this.userDefinedMinimumValue = axisMinimum; 103 this.userDefinedIncrement = axisIncrement; 104 } 105 106 107 108 public int getRoundToNearest() 109 { 110 return roundToNearest; 111 } 112 113 114 public void setRoundToNearest( int roundToNearest ) 115 { 116 this.roundToNearest = roundToNearest; 117 } 118 119 120 public boolean showZeroLine() 121 { 122 return showZeroLine; 123 } 124 125 126 public void setShowZeroLine( boolean showZeroLine ) 127 { 128 this.showZeroLine = showZeroLine; 129 } 130 131 132 public ChartStroke getZeroLineChartStroke() 133 { 134 return this.zeroLineChartStroke; 135 } 136 137 138 public void setZeroLineChartStroke( ChartStroke zeroLine ) 139 { 140 this.zeroLineChartStroke = zeroLine; 141 } 142 143 144 public boolean hasUserDefinedScale() 145 { 146 return userDefinedScale; 147 } 148 149 150 public double getUserDefinedMinimumValue() 151 { 152 return this.userDefinedMinimumValue; 153 } 154 155 156 public double getUserDefinedIncrement() 157 { 158 return this.userDefinedIncrement; 159 } 160 161 162 public int getNumItems() 163 { 164 return numItems; 165 } 166 167 168 public void setNumItems( int numItems ) 169 { 170 this.numItems = numItems; 171 } 172 173 174 public boolean useDollarSigns() 175 { 176 return useDollarSigns; 177 } 178 179 180 public void setUseDollarSigns( boolean useDollarSigns ) 181 { 182 this.useDollarSigns = useDollarSigns; 183 } 184 185 186 public boolean useCommas() 187 { 188 return useCommas; 189 } 190 191 192 public void setUseCommas( boolean useCommas ) 193 { 194 this.useCommas = useCommas; 195 } 196 197 198 public boolean usePercentSigns() 199 { 200 return usePercentSigns; 201 } 202 203 204 public void setUsePercentSigns( boolean usePercentSigns ) 205 { 206 this.usePercentSigns = usePercentSigns; 207 } 208 209 210 public ScaleCalculator getScaleCalculator() 211 { 212 return scaleCalculator; 213 } 214 215 216 223 public void setScaleCalculator( ScaleCalculator scaleCalculator ) 224 { 225 this.scaleCalculator = scaleCalculator; 226 } 227 228 229 234 public void toHTML( HTMLGenerator htmlGenerator ) 235 { 236 htmlGenerator.propertiesTableStart( DataAxisProperties.class.getName() ); 237 239 Field [] fields = this.getClass().getDeclaredFields(); 240 for( int i = 0; i < fields.length; i++ ) 241 { 242 try 243 { 244 htmlGenerator.addField( fields[ i ].getName(), fields[ i ].get( this ) ); 245 } 246 catch( IllegalAccessException illegalAccessException ) 247 { 248 illegalAccessException.printStackTrace(); 249 } 250 } 251 252 htmlGenerator.propertiesTableEnd(); 253 } 254 255 256 } 257 | Popular Tags |