Mercurial > dive4elements > gnv-client
comparison gnv-artifacts/src/main/java/de/intevation/gnv/chart/VerticalCrossSectionChart.java @ 841:9cbc8343a04d
Implemented a workaround to avoid an amount of cut axis labels in 2D charts (issue163).
gnv-artifacts/trunk@955 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Tue, 20 Apr 2010 08:45:01 +0000 |
parents | 3f447e92024a |
children | 31f63a14a2c3 |
comparison
equal
deleted
inserted
replaced
840:47578d91c4f0 | 841:9cbc8343a04d |
---|---|
28 | 28 |
29 import org.jfree.chart.renderer.LookupPaintScale; | 29 import org.jfree.chart.renderer.LookupPaintScale; |
30 | 30 |
31 import org.jfree.chart.title.PaintScaleLegend; | 31 import org.jfree.chart.title.PaintScaleLegend; |
32 import org.jfree.chart.title.TextTitle; | 32 import org.jfree.chart.title.TextTitle; |
33 | |
34 import org.jfree.data.Range; | |
33 | 35 |
34 import org.jfree.ui.RectangleEdge; | 36 import org.jfree.ui.RectangleEdge; |
35 import org.jfree.ui.RectangleInsets; | 37 import org.jfree.ui.RectangleInsets; |
36 | 38 |
37 /** | 39 /** |
143 return label instanceof Number | 145 return label instanceof Number |
144 ? format.format(((Number)label).doubleValue()) | 146 ? format.format(((Number)label).doubleValue()) |
145 : super.toString(label); | 147 : super.toString(label); |
146 } | 148 } |
147 } // class LocalizedLabelGenerator | 149 } // class LocalizedLabelGenerator |
150 | |
151 public static double MARGIN_TOP = 0.05d; | |
152 public static double MARGIN_BOTTOM = 0.05d; | |
153 public static double MARGIN_LEFT = 0.05d; | |
154 public static double MARGIN_RIGHT = 0.05d; | |
148 | 155 |
149 /** | 156 /** |
150 * JFreeChart object stored at this place after chart creation. | 157 * JFreeChart object stored at this place after chart creation. |
151 */ | 158 */ |
152 protected JFreeChart chart; | 159 protected JFreeChart chart; |
307 legend.setPosition(RectangleEdge.LEFT); | 314 legend.setPosition(RectangleEdge.LEFT); |
308 legend.setAxisOffset(5d); | 315 legend.setAxisOffset(5d); |
309 | 316 |
310 chart.addSubtitle(legend); | 317 chart.addSubtitle(legend); |
311 | 318 |
319 // XXX Workaround, because Axes labels are cut at the | |
320 // left/right/top/bottom edge. The following lines add a white border | |
321 // between data area and plot border. | |
322 ValueAxis xAxis = plot.getDomainAxis(); | |
323 Range xRange = xAxis.getRange(); | |
324 xRange = Range.expand(xRange, MARGIN_LEFT, MARGIN_RIGHT); | |
325 xAxis.setRange(xRange); | |
326 plot.setDomainAxis(xAxis); | |
327 | |
328 ValueAxis yAxis = plot.getRangeAxis(); | |
329 Range yRange = yAxis.getRange(); | |
330 yRange = Range.expand(yRange, MARGIN_BOTTOM, MARGIN_TOP); | |
331 yAxis.setRange(yRange); | |
332 plot.setRangeAxis(yAxis); | |
333 | |
312 return chart; | 334 return chart; |
313 } | 335 } |
314 | 336 |
315 /** | 337 /** |
316 * @see de.intevation.gnv.chart.Chart#generateChart() | 338 * @see de.intevation.gnv.chart.Chart#generateChart() |