Mercurial > dive4elements > gnv-client
annotate gnv-artifacts/src/main/java/de/intevation/gnv/chart/VerticalCrossSectionChart.java @ 474:ab29e4ff2fda
Added area interpolation needed for "Horizontalschnitt"
gnv-artifacts/trunk@540 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Thu, 14 Jan 2010 10:34:05 +0000 |
parents | 20a480753ff9 |
children | 79e80c289018 |
rev | line source |
---|---|
446
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.gnv.chart; |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
2 |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
3 import java.util.Locale; |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
4 |
450
20a480753ff9
Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
449
diff
changeset
|
5 import java.text.NumberFormat; |
20a480753ff9
Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
449
diff
changeset
|
6 |
446
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
7 import java.awt.Color; |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
8 import java.awt.Paint; |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
9 |
449
c7ca2fce041f
Add only color to scale of vertical cross section which are in the chart.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
446
diff
changeset
|
10 import java.util.HashSet; |
c7ca2fce041f
Add only color to scale of vertical cross section which are in the chart.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
446
diff
changeset
|
11 |
446
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
12 import de.intevation.gnv.math.AttributedXYColumns; |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
13 |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
14 import de.intevation.gnv.jfreechart.PolygonDataset; |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
15 import de.intevation.gnv.jfreechart.PolygonPlot; |
449
c7ca2fce041f
Add only color to scale of vertical cross section which are in the chart.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
446
diff
changeset
|
16 import de.intevation.gnv.jfreechart.PolygonSeries; |
446
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
17 import de.intevation.gnv.jfreechart.PolygonRenderer; |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
18 |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
19 import de.intevation.gnv.raster.Palette; |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
20 |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
21 import org.jfree.chart.JFreeChart; |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
22 |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
23 import org.jfree.chart.plot.PlotOrientation; |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
24 |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
25 import org.jfree.chart.axis.ValueAxis; |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
26 import org.jfree.chart.axis.NumberAxis; |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
27 import org.jfree.chart.axis.SymbolAxis; |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
28 |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
29 import org.jfree.chart.title.PaintScaleLegend; |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
30 |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
31 import org.jfree.chart.renderer.LookupPaintScale; |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
32 |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
33 import org.jfree.ui.RectangleEdge; |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
34 import org.jfree.ui.RectangleInsets; |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
35 |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
36 /** |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
37 * @author Ingo Weinzierl (ingo.weinzierl@intevation.de) |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
38 * @author Sascha L. Teichmann (sascha.teichmann@intevation.de) |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
39 */ |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
40 public class VerticalCrossSectionChart |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
41 implements Chart |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
42 { |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
43 public static final class PalettePaintLookup |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
44 implements PolygonRenderer.PaintLookup |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
45 { |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
46 private Palette palette; |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
47 |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
48 public PalettePaintLookup(Palette palette) { |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
49 this.palette = palette; |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
50 } |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
51 |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
52 public Paint getPaint(int index) { |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
53 return index < 0 |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
54 ? Color.black |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
55 : palette.getColor(index); |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
56 } |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
57 } // class PalettePaintLookup |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
58 |
450
20a480753ff9
Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
449
diff
changeset
|
59 public static class LocalizedLabelGenerator |
20a480753ff9
Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
449
diff
changeset
|
60 extends PolygonRenderer.DefaultLabelGenerator |
20a480753ff9
Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
449
diff
changeset
|
61 { |
20a480753ff9
Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
449
diff
changeset
|
62 protected NumberFormat format; |
20a480753ff9
Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
449
diff
changeset
|
63 |
20a480753ff9
Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
449
diff
changeset
|
64 public LocalizedLabelGenerator() { |
20a480753ff9
Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
449
diff
changeset
|
65 } |
20a480753ff9
Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
449
diff
changeset
|
66 |
20a480753ff9
Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
449
diff
changeset
|
67 public LocalizedLabelGenerator(NumberFormat format) { |
20a480753ff9
Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
449
diff
changeset
|
68 this.format = format; |
20a480753ff9
Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
449
diff
changeset
|
69 } |
20a480753ff9
Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
449
diff
changeset
|
70 |
20a480753ff9
Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
449
diff
changeset
|
71 protected String toString(Object label) { |
20a480753ff9
Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
449
diff
changeset
|
72 return label instanceof Number |
20a480753ff9
Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
449
diff
changeset
|
73 ? format.format(((Number)label).doubleValue()) |
20a480753ff9
Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
449
diff
changeset
|
74 : super.toString(label); |
20a480753ff9
Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
449
diff
changeset
|
75 } |
20a480753ff9
Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
449
diff
changeset
|
76 } // class LocalizedLabelGenerator |
20a480753ff9
Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
449
diff
changeset
|
77 |
446
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
78 protected JFreeChart chart; |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
79 |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
80 protected AttributedXYColumns columns; |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
81 protected Palette palette; |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
82 protected Locale locale; |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
83 |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
84 public VerticalCrossSectionChart() { |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
85 } |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
86 |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
87 public VerticalCrossSectionChart( |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
88 AttributedXYColumns columns, |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
89 Palette palette, |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
90 Locale locale |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
91 ) { |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
92 this.columns = columns; |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
93 this.palette = palette; |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
94 this.locale = locale; |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
95 } |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
96 |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
97 protected JFreeChart createChart() { |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
98 |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
99 String title = "Neues 2D-Diagramm"; |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
100 String xAxis = "x-Achse des Diagramms"; |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
101 String yAxis = "y-Achse des Diagramms"; |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
102 boolean legendB = false; |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
103 boolean tooltips = false; |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
104 boolean urls = false; |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
105 |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
106 PlotOrientation po = PlotOrientation.HORIZONTAL; |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
107 PolygonDataset data = columns.getPolygonDataset(); |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
108 |
449
c7ca2fce041f
Add only color to scale of vertical cross section which are in the chart.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
446
diff
changeset
|
109 HashSet<Integer> usedColors = new HashSet<Integer>(); |
c7ca2fce041f
Add only color to scale of vertical cross section which are in the chart.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
446
diff
changeset
|
110 |
c7ca2fce041f
Add only color to scale of vertical cross section which are in the chart.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
446
diff
changeset
|
111 for (int i = data.getSeriesCount()-1; i >= 0; --i) { |
c7ca2fce041f
Add only color to scale of vertical cross section which are in the chart.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
446
diff
changeset
|
112 PolygonSeries ps = data.getSeries(i); |
c7ca2fce041f
Add only color to scale of vertical cross section which are in the chart.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
446
diff
changeset
|
113 Integer fill = (Integer)ps.getAttribute("fill"); |
c7ca2fce041f
Add only color to scale of vertical cross section which are in the chart.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
446
diff
changeset
|
114 if (fill != null) { |
c7ca2fce041f
Add only color to scale of vertical cross section which are in the chart.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
446
diff
changeset
|
115 usedColors.add(fill); |
c7ca2fce041f
Add only color to scale of vertical cross section which are in the chart.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
446
diff
changeset
|
116 } |
c7ca2fce041f
Add only color to scale of vertical cross section which are in the chart.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
446
diff
changeset
|
117 } |
c7ca2fce041f
Add only color to scale of vertical cross section which are in the chart.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
446
diff
changeset
|
118 |
450
20a480753ff9
Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
449
diff
changeset
|
119 NumberFormat format = NumberFormat.getInstance(locale); |
20a480753ff9
Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
449
diff
changeset
|
120 format.setMinimumFractionDigits(0); |
20a480753ff9
Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
449
diff
changeset
|
121 format.setMaximumFractionDigits(2); |
20a480753ff9
Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
449
diff
changeset
|
122 |
446
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
123 PolygonRenderer renderer = new PolygonRenderer( |
450
20a480753ff9
Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
449
diff
changeset
|
124 new PalettePaintLookup(palette), |
20a480753ff9
Render labels in vertical cross section charts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
449
diff
changeset
|
125 new LocalizedLabelGenerator(format)); |
446
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
126 |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
127 ValueAxis domainAxis = new NumberAxis(xAxis); |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
128 ValueAxis rangeAxis = new NumberAxis(yAxis); |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
129 |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
130 PolygonPlot plot = new PolygonPlot( |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
131 data, |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
132 renderer, |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
133 domainAxis, |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
134 rangeAxis, |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
135 null); |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
136 |
449
c7ca2fce041f
Add only color to scale of vertical cross section which are in the chart.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
446
diff
changeset
|
137 String [] labels = new String[usedColors.size()]; |
c7ca2fce041f
Add only color to scale of vertical cross section which are in the chart.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
446
diff
changeset
|
138 |
446
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
139 int colors = palette.getSize(); |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
140 LookupPaintScale lookupPaint = |
449
c7ca2fce041f
Add only color to scale of vertical cross section which are in the chart.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
446
diff
changeset
|
141 new LookupPaintScale(-0.5d, labels.length-0.5d, Color.white); |
446
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
142 |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
143 Color color = null; |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
144 |
449
c7ca2fce041f
Add only color to scale of vertical cross section which are in the chart.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
446
diff
changeset
|
145 for (int i = 0, j = labels.length-1; i < colors && j >= 0; i++) { |
c7ca2fce041f
Add only color to scale of vertical cross section which are in the chart.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
446
diff
changeset
|
146 if (usedColors.contains(i)) { |
c7ca2fce041f
Add only color to scale of vertical cross section which are in the chart.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
446
diff
changeset
|
147 Palette.Entry entry = palette.getEntryByIndex(i); |
c7ca2fce041f
Add only color to scale of vertical cross section which are in the chart.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
446
diff
changeset
|
148 color = entry.getColor(); |
c7ca2fce041f
Add only color to scale of vertical cross section which are in the chart.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
446
diff
changeset
|
149 labels[j] = entry.getDescription(); |
c7ca2fce041f
Add only color to scale of vertical cross section which are in the chart.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
446
diff
changeset
|
150 lookupPaint.add(j-0.5d, color); |
c7ca2fce041f
Add only color to scale of vertical cross section which are in the chart.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
446
diff
changeset
|
151 --j; |
c7ca2fce041f
Add only color to scale of vertical cross section which are in the chart.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
446
diff
changeset
|
152 } |
446
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
153 } |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
154 |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
155 JFreeChart chart = new JFreeChart( |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
156 title, |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
157 JFreeChart.DEFAULT_TITLE_FONT, |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
158 plot, |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
159 legendB); |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
160 |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
161 chart.removeLegend(); |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
162 |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
163 SymbolAxis scale = new SymbolAxis("Temperatur", labels); |
449
c7ca2fce041f
Add only color to scale of vertical cross section which are in the chart.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
446
diff
changeset
|
164 scale.setRange(-1.5d, labels.length+0.5d); |
446
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
165 scale.setGridBandsVisible(false); |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
166 scale.setPlot(plot); |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
167 |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
168 PaintScaleLegend legend = new PaintScaleLegend( |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
169 lookupPaint, scale); |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
170 legend.setMargin(new RectangleInsets(3d, 10d, 3d, 10d)); |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
171 legend.setPosition(RectangleEdge.LEFT); |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
172 legend.setAxisOffset(5d); |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
173 |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
174 chart.addSubtitle(legend); |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
175 |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
176 return chart; |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
177 } |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
178 |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
179 public JFreeChart generateChart() { |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
180 if (chart == null) { |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
181 chart = createChart(); |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
182 } |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
183 return chart; |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
184 } |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
185 } |
f5a041000357
Connected vertical cross section with chart generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
186 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |