comparison gnv-artifacts/src/main/java/de/intevation/gnv/chart/VerticalCrossSectionChart.java @ 767:79401c871da4

Added and repaired javadoc in de.intevation.gnv.chart package. gnv-artifacts/trunk@823 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 24 Mar 2010 14:48:55 +0000
parents 92d7a8cd1ef1
children 9a828e5a2390
comparison
equal deleted inserted replaced
766:a23ce49423d5 767:79401c871da4
33 33
34 import org.jfree.ui.RectangleEdge; 34 import org.jfree.ui.RectangleEdge;
35 import org.jfree.ui.RectangleInsets; 35 import org.jfree.ui.RectangleInsets;
36 36
37 /** 37 /**
38 * @author Ingo Weinzierl (ingo.weinzierl@intevation.de) 38 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
39 * @author Sascha L. Teichmann (sascha.teichmann@intevation.de) 39 * @author <a href="mailto:sascha.teichmann@intevation.de">Sascha L. Teichmann</a>
40 */ 40 */
41 public class VerticalCrossSectionChart 41 public class VerticalCrossSectionChart
42 implements Chart 42 implements Chart
43 { 43 {
44 /**
45 * Lookup class for retrieving a color which corresponds to a specific
46 * integer value.
47 */
44 public static final class PalettePaintLookup 48 public static final class PalettePaintLookup
45 implements PolygonRenderer.PaintLookup 49 implements PolygonRenderer.PaintLookup
46 { 50 {
51 /**
52 * Object storing information about value ranges and its coresponding
53 * colors and descriptions.
54 */
47 private Palette palette; 55 private Palette palette;
56
57 /**
58 * Map containing some special <code>Paint</code> like ground fillcolor.
59 */
48 private Map<Integer, Paint> special; 60 private Map<Integer, Paint> special;
49 61
62 /**
63 * Constructor
64 *
65 * @param palette See {@link #palette}
66 */
50 public PalettePaintLookup(Palette palette) { 67 public PalettePaintLookup(Palette palette) {
51 this(palette, null); 68 this(palette, null);
52 } 69 }
53 70
71 /**
72 * Constructor
73 *
74 * @param palette See {@link #palette}
75 * @param special See {@link #special}
76 */
54 public PalettePaintLookup( 77 public PalettePaintLookup(
55 Palette palette, 78 Palette palette,
56 Map<Integer, Paint> special 79 Map<Integer, Paint> special
57 ) { 80 ) {
58 this.palette = palette; 81 this.palette = palette;
59 this.special = special; 82 this.special = special;
60 } 83 }
61 84
85 /**
86 * @param index Index of a <code>Paint</code>
87 *
88 * @return <code>Paint</code> object for a given index.
89 */
62 public Paint getPaint(int index) { 90 public Paint getPaint(int index) {
63 if (special != null) { 91 if (special != null) {
64 Paint paint = special.get(index); 92 Paint paint = special.get(index);
65 if (paint != null) { 93 if (paint != null) {
66 return paint; 94 return paint;
70 ? Color.black 98 ? Color.black
71 : palette.getColor(index); 99 : palette.getColor(index);
72 } 100 }
73 } // class PalettePaintLookup 101 } // class PalettePaintLookup
74 102
103 /**
104 * This class is used to turn labels which represent a number into a
105 * specific format.
106 */
75 public static class LocalizedLabelGenerator 107 public static class LocalizedLabelGenerator
76 extends PolygonRenderer.DefaultLabelGenerator 108 extends PolygonRenderer.DefaultLabelGenerator
77 { 109 {
110 /**
111 * <code>NumberFormat</code> which is used to turn a number into a
112 * specific format.
113 */
78 protected NumberFormat format; 114 protected NumberFormat format;
79 115
116 /**
117 * Constructor
118 */
80 public LocalizedLabelGenerator() { 119 public LocalizedLabelGenerator() {
81 } 120 }
82 121
122 /**
123 * Constructor
124 *
125 * @param format See {@link #format}
126 */
83 public LocalizedLabelGenerator(NumberFormat format) { 127 public LocalizedLabelGenerator(NumberFormat format) {
84 this.format = format; 128 this.format = format;
85 } 129 }
86 130
131 /**
132 * If label is a <code>Number</code>, it is turned into a format
133 * specified by {@link #format}.
134 *
135 * @param label Label to format.
136 *
137 * @return String representation of label.
138 */
139 @Override
87 protected String toString(Object label) { 140 protected String toString(Object label) {
88 return label instanceof Number 141 return label instanceof Number
89 ? format.format(((Number)label).doubleValue()) 142 ? format.format(((Number)label).doubleValue())
90 : super.toString(label); 143 : super.toString(label);
91 } 144 }
92 } // class LocalizedLabelGenerator 145 } // class LocalizedLabelGenerator
93 146
147 /**
148 * JFreeChart object stored at this place after chart creation.
149 */
94 protected JFreeChart chart; 150 protected JFreeChart chart;
95 151
152 /**
153 * Stores {@link de.intevation.gnv.jfreechart.PolygonDataset} which is used
154 * to create a vertical cross chart.
155 */
96 protected AttributedXYColumns columns; 156 protected AttributedXYColumns columns;
157
158 /**
159 * Map which contains colors to fill polygons draw by this chart.
160 */
97 protected Map<Integer, Paint> special; 161 protected Map<Integer, Paint> special;
162
163 /**
164 * Object used to map value intervals to specific colors and descriptions.
165 */
98 protected Palette palette; 166 protected Palette palette;
167
168 /**
169 * Locale object used for i18n support.
170 */
99 protected Locale locale; 171 protected Locale locale;
172
173 /**
174 * Labels for decorating the chart.
175 */
100 protected ChartLabels labels; 176 protected ChartLabels labels;
101 177
178 /**
179 * Default Constructor
180 */
102 public VerticalCrossSectionChart() { 181 public VerticalCrossSectionChart() {
103 } 182 }
104 183
184 /**
185 * Constructor for VerticalCrossSectionChart creation.
186 *
187 * @param columns See {@link #columns}
188 * @param palette See {@link #palette}
189 * @param locale See {@link #locale}
190 * @param labels See {@link #labels}
191 */
105 public VerticalCrossSectionChart( 192 public VerticalCrossSectionChart(
106 AttributedXYColumns columns, 193 AttributedXYColumns columns,
107 Palette palette, 194 Palette palette,
108 Locale locale, 195 Locale locale,
109 ChartLabels labels 196 ChartLabels labels
110 ) { 197 ) {
111 this(columns, palette, null, locale, labels); 198 this(columns, palette, null, locale, labels);
112 } 199 }
113 200
201 /**
202 * Constructor for VerticalCrossSectionChart creation.
203 *
204 * @param columns See {@link #columns}
205 * @param palette See {@link #palette}
206 * @param special See {@link #special}
207 * @param locale See {@link #locale}
208 * @param labels See {@link #labels}
209 */
114 public VerticalCrossSectionChart( 210 public VerticalCrossSectionChart(
115 AttributedXYColumns columns, 211 AttributedXYColumns columns,
116 Palette palette, 212 Palette palette,
117 Map<Integer, Paint> special, 213 Map<Integer, Paint> special,
118 Locale locale, 214 Locale locale,
123 this.special = special; 219 this.special = special;
124 this.locale = locale; 220 this.locale = locale;
125 this.labels = labels; 221 this.labels = labels;
126 } 222 }
127 223
224 /**
225 * This method is used to create a JFreeChart from this object. A 2D plot is
226 * drawn and a legend panel is created containing each value range.
227 *
228 * @return JFreeChart object
229 */
128 protected JFreeChart createChart() { 230 protected JFreeChart createChart() {
129 231
130 boolean legendB = false; 232 boolean legendB = false;
131 boolean tooltips = false; 233 boolean tooltips = false;
132 boolean urls = false; 234 boolean urls = false;
206 chart.addSubtitle(legend); 308 chart.addSubtitle(legend);
207 309
208 return chart; 310 return chart;
209 } 311 }
210 312
313 /**
314 * @see de.intevation.gnv.chart.Chart#generateChart()
315 */
211 public JFreeChart generateChart() { 316 public JFreeChart generateChart() {
212 if (chart == null) { 317 if (chart == null) {
213 chart = createChart(); 318 chart = createChart();
214 } 319 }
215 320
216 return chart; 321 return chart;
217 } 322 }
218 323
324 /**
325 * Set the background paint of {@link #chart}.
326 */
219 public void setBackgroundPaint(Paint paint) { 327 public void setBackgroundPaint(Paint paint) {
220 chart.setBackgroundPaint(paint); 328 chart.setBackgroundPaint(paint);
221 } 329 }
222 } 330 }
223 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : 331 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org