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 47 import java.lang.reflect.Field ; 48 49 50 final public class AxisProperties extends Properties implements HTMLTestable 51 { 52 private AxisTypeProperties xAxisProperties; 53 private AxisTypeProperties yAxisProperties; 54 55 private boolean isPlotHorizontal= false; 56 57 private boolean xAxisLabelsAreVertical= false; 58 59 60 65 public AxisProperties( LabelAxisProperties xAxis, LabelAxisProperties yAxis ) 66 { 67 this.xAxisProperties= xAxis; 68 this.yAxisProperties= yAxis; 69 } 70 71 72 76 public AxisProperties( boolean isHorizontalPlot ) 77 { 78 super(); 79 80 this.isPlotHorizontal= isHorizontalPlot; 81 82 if( isHorizontalPlot ) 83 { 84 this.xAxisProperties= new DataAxisProperties(); 85 this.yAxisProperties= new LabelAxisProperties(); 86 } 87 else 88 { 89 this.xAxisProperties= new LabelAxisProperties(); 90 this.yAxisProperties= new DataAxisProperties(); 91 } 92 } 93 94 95 98 public AxisProperties() 99 { 100 super(); 101 102 this.isPlotHorizontal= false; 103 this.xAxisProperties= new LabelAxisProperties(); 104 this.yAxisProperties= new DataAxisProperties(); 105 } 106 107 108 public AxisTypeProperties getXAxisProperties() 109 { 110 return xAxisProperties; 111 } 112 113 114 public AxisTypeProperties getYAxisProperties() 115 { 116 return yAxisProperties; 117 } 118 119 120 public boolean isPlotHorizontal() 121 { 122 return isPlotHorizontal; 123 } 124 125 126 public boolean xAxisLabelsAreVertical() 127 { 128 return xAxisLabelsAreVertical; 129 } 130 131 132 public void setXAxisLabelsAreVertical( boolean xAxisLabelsAreVertical ) 133 { 134 this.xAxisLabelsAreVertical = xAxisLabelsAreVertical; 135 } 136 137 138 143 public void toHTML( HTMLGenerator htmlGenerator ) 144 { 145 htmlGenerator.propertiesTableStart( this.getClass().getName() ); 146 super.toHTML( htmlGenerator ); 147 148 Field [] fields = this.getClass().getDeclaredFields(); 149 for( int i = 0; i < fields.length; i++ ) 150 { 151 try 152 { 153 htmlGenerator.addField( fields[ i ].getName(), fields[ i ].get( this ) ); 154 } 155 catch( IllegalAccessException illegalAccessException ) 156 { 157 illegalAccessException.printStackTrace(); 158 } 159 } 160 161 162 htmlGenerator.innerTableRowStart(); 163 this.xAxisProperties.toHTML( htmlGenerator ); 164 htmlGenerator.innerTableRowEnd(); 165 166 167 htmlGenerator.innerTableRowStart(); 168 this.yAxisProperties.toHTML( htmlGenerator ); 169 htmlGenerator.innerTableRowEnd(); 170 171 htmlGenerator.propertiesTableEnd(); 172 } 173 174 175 } 176 | Popular Tags |