Mercurial > dive4elements > gnv-client
comparison gnv-artifacts/src/main/java/de/intevation/gnv/chart/HorizontalProfileChart.java @ 846:8b6ef091d38c
It is possible to draw VerticalProfileCharts with just one single data point (issue229).
gnv-artifacts/trunk@962 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Wed, 21 Apr 2010 08:46:23 +0000 |
parents | 22c18083225e |
children | 38c8cc586a85 |
comparison
equal
deleted
inserted
replaced
845:797a6264b89b | 846:8b6ef091d38c |
---|---|
15 | 15 |
16 import org.apache.log4j.Logger; | 16 import org.apache.log4j.Logger; |
17 | 17 |
18 import org.jfree.chart.ChartTheme; | 18 import org.jfree.chart.ChartTheme; |
19 | 19 |
20 import org.jfree.chart.axis.Axis; | |
21 import org.jfree.chart.axis.AxisLocation; | |
22 import org.jfree.chart.axis.NumberAxis; | |
23 import org.jfree.chart.axis.NumberTickUnit; | |
24 | |
20 import org.jfree.chart.plot.PlotOrientation; | 25 import org.jfree.chart.plot.PlotOrientation; |
26 import org.jfree.chart.plot.XYPlot; | |
27 | |
28 import org.jfree.data.Range; | |
21 | 29 |
22 import org.jfree.data.general.Series; | 30 import org.jfree.data.general.Series; |
23 | 31 |
24 import org.jfree.data.xy.XYSeries; | 32 import org.jfree.data.xy.XYSeries; |
25 | 33 |
171 firstPoint = null; | 179 firstPoint = null; |
172 } | 180 } |
173 | 181 |
174 | 182 |
175 @Override | 183 @Override |
184 protected void prepareAxis(String seriesKey,int idx) { | |
185 log.debug("prepare axis of xychart"); | |
186 | |
187 XYPlot plot = chart.getXYPlot(); | |
188 Axis xAxis = plot.getDomainAxis(); | |
189 NumberAxis yAxis = new NumberAxis(seriesKey); | |
190 | |
191 localizeDomainAxis(xAxis, locale); | |
192 localizeRangeAxis(yAxis, locale); | |
193 | |
194 // litte workarround to adjust the max range of axes. | |
195 // NumberAxis.setAutoRange(true) doesn't seem to work properly. | |
196 Range yRange = (Range) ranges.get(seriesKey); | |
197 yAxis.setRange(Range.expand(yRange, LOWER_MARGIN, UPPER_MARGIN)); | |
198 log.debug("Max Range of dataset is: " + yRange.toString()); | |
199 | |
200 if (seriesKey.contains("richtung")) { | |
201 yAxis.setTickUnit(new NumberTickUnit(30.0)); | |
202 yAxis.setUpperBound(360.0); | |
203 yAxis.setLowerBound(0.0); | |
204 } | |
205 else { | |
206 yAxis.setFixedDimension(10.0); | |
207 yAxis.setAutoRangeIncludesZero(false); | |
208 } | |
209 | |
210 plot.setRangeAxis(idx, yAxis); | |
211 yAxis.configure(); | |
212 | |
213 if (idx % 2 != 0) | |
214 plot.setRangeAxisLocation(idx, AxisLocation.BOTTOM_OR_RIGHT); | |
215 else | |
216 plot.setRangeAxisLocation(idx, AxisLocation.BOTTOM_OR_LEFT); | |
217 | |
218 plot.mapDatasetToRangeAxis(idx, idx); | |
219 } | |
220 | |
221 | |
222 @Override | |
176 protected void prepareRangeAxis(String seriesKey, int idx) { | 223 protected void prepareRangeAxis(String seriesKey, int idx) { |
177 return; | 224 return; |
178 // do nothing here | 225 // do nothing here |
179 } | 226 } |
180 | 227 |