Mercurial > dive4elements > gnv-client
comparison gnv-artifacts/src/main/java/de/intevation/gnv/chart/VerticalCrossSectionChart.java @ 521:1bf058f1a2d1
Generate seabed polygon to "Profilschnitte".
gnv-artifacts/trunk@615 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Sun, 24 Jan 2010 20:24:03 +0000 |
parents | 79e80c289018 |
children | f598702b2a10 |
comparison
equal
deleted
inserted
replaced
520:a8f6ca59b26e | 521:1bf058f1a2d1 |
---|---|
1 package de.intevation.gnv.chart; | 1 package de.intevation.gnv.chart; |
2 | 2 |
3 import java.util.Locale; | 3 import de.intevation.gnv.jfreechart.PolygonDataset; |
4 | 4 import de.intevation.gnv.jfreechart.PolygonPlot; |
5 import java.text.NumberFormat; | 5 import de.intevation.gnv.jfreechart.PolygonRenderer; |
6 import de.intevation.gnv.jfreechart.PolygonSeries; | |
7 | |
8 import de.intevation.gnv.math.AttributedXYColumns; | |
9 | |
10 import de.intevation.gnv.raster.Palette; | |
6 | 11 |
7 import java.awt.Color; | 12 import java.awt.Color; |
8 import java.awt.Paint; | 13 import java.awt.Paint; |
9 | 14 |
15 import java.text.NumberFormat; | |
16 | |
10 import java.util.HashSet; | 17 import java.util.HashSet; |
11 | 18 import java.util.Locale; |
12 import de.intevation.gnv.math.AttributedXYColumns; | 19 import java.util.Map; |
13 | |
14 import de.intevation.gnv.jfreechart.PolygonDataset; | |
15 import de.intevation.gnv.jfreechart.PolygonPlot; | |
16 import de.intevation.gnv.jfreechart.PolygonSeries; | |
17 import de.intevation.gnv.jfreechart.PolygonRenderer; | |
18 | |
19 import de.intevation.gnv.raster.Palette; | |
20 | 20 |
21 import org.jfree.chart.JFreeChart; | 21 import org.jfree.chart.JFreeChart; |
22 | 22 |
23 import org.jfree.chart.plot.PlotOrientation; | |
24 | |
25 import org.jfree.chart.axis.ValueAxis; | |
26 import org.jfree.chart.axis.NumberAxis; | 23 import org.jfree.chart.axis.NumberAxis; |
27 import org.jfree.chart.axis.SymbolAxis; | 24 import org.jfree.chart.axis.SymbolAxis; |
25 import org.jfree.chart.axis.ValueAxis; | |
26 | |
27 import org.jfree.chart.plot.PlotOrientation; | |
28 | |
29 import org.jfree.chart.renderer.LookupPaintScale; | |
28 | 30 |
29 import org.jfree.chart.title.PaintScaleLegend; | 31 import org.jfree.chart.title.PaintScaleLegend; |
30 import org.jfree.chart.title.TextTitle; | 32 import org.jfree.chart.title.TextTitle; |
31 | |
32 import org.jfree.chart.renderer.LookupPaintScale; | |
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 /** |
42 implements Chart | 42 implements Chart |
43 { | 43 { |
44 public static final class PalettePaintLookup | 44 public static final class PalettePaintLookup |
45 implements PolygonRenderer.PaintLookup | 45 implements PolygonRenderer.PaintLookup |
46 { | 46 { |
47 private Palette palette; | 47 private Palette palette; |
48 private Map<Integer, Paint> special; | |
48 | 49 |
49 public PalettePaintLookup(Palette palette) { | 50 public PalettePaintLookup(Palette palette) { |
51 this(palette, null); | |
52 } | |
53 | |
54 public PalettePaintLookup( | |
55 Palette palette, | |
56 Map<Integer, Paint> special | |
57 ) { | |
50 this.palette = palette; | 58 this.palette = palette; |
59 this.special = special; | |
51 } | 60 } |
52 | 61 |
53 public Paint getPaint(int index) { | 62 public Paint getPaint(int index) { |
63 if (special != null) { | |
64 Paint paint = special.get(index); | |
65 if (paint != null) { | |
66 return paint; | |
67 } | |
68 } | |
54 return index < 0 | 69 return index < 0 |
55 ? Color.black | 70 ? Color.black |
56 : palette.getColor(index); | 71 : palette.getColor(index); |
57 } | 72 } |
58 } // class PalettePaintLookup | 73 } // class PalettePaintLookup |
77 } // class LocalizedLabelGenerator | 92 } // class LocalizedLabelGenerator |
78 | 93 |
79 protected JFreeChart chart; | 94 protected JFreeChart chart; |
80 | 95 |
81 protected AttributedXYColumns columns; | 96 protected AttributedXYColumns columns; |
97 protected Map<Integer, Paint> special; | |
82 protected Palette palette; | 98 protected Palette palette; |
83 protected Locale locale; | 99 protected Locale locale; |
84 protected ChartLabels labels; | 100 protected ChartLabels labels; |
85 | 101 |
86 public VerticalCrossSectionChart() { | 102 public VerticalCrossSectionChart() { |
90 AttributedXYColumns columns, | 106 AttributedXYColumns columns, |
91 Palette palette, | 107 Palette palette, |
92 Locale locale, | 108 Locale locale, |
93 ChartLabels labels | 109 ChartLabels labels |
94 ) { | 110 ) { |
111 this(columns, palette, null, locale, labels); | |
112 } | |
113 | |
114 public VerticalCrossSectionChart( | |
115 AttributedXYColumns columns, | |
116 Palette palette, | |
117 Map<Integer, Paint> special, | |
118 Locale locale, | |
119 ChartLabels labels | |
120 ) { | |
95 this.columns = columns; | 121 this.columns = columns; |
96 this.palette = palette; | 122 this.palette = palette; |
123 this.special = special; | |
97 this.locale = locale; | 124 this.locale = locale; |
98 this.labels = labels; | 125 this.labels = labels; |
99 } | 126 } |
100 | 127 |
101 protected JFreeChart createChart() { | 128 protected JFreeChart createChart() { |
110 HashSet<Integer> usedColors = new HashSet<Integer>(); | 137 HashSet<Integer> usedColors = new HashSet<Integer>(); |
111 | 138 |
112 for (int i = data.getSeriesCount()-1; i >= 0; --i) { | 139 for (int i = data.getSeriesCount()-1; i >= 0; --i) { |
113 PolygonSeries ps = data.getSeries(i); | 140 PolygonSeries ps = data.getSeries(i); |
114 Integer fill = (Integer)ps.getAttribute("fill"); | 141 Integer fill = (Integer)ps.getAttribute("fill"); |
115 if (fill != null) { | 142 if (fill != null |
143 && (special != null && !special.containsKey(fill))) { | |
116 usedColors.add(fill); | 144 usedColors.add(fill); |
117 } | 145 } |
118 } | 146 } |
119 | 147 |
120 NumberFormat format = NumberFormat.getInstance(locale); | 148 NumberFormat format = NumberFormat.getInstance(locale); |
121 format.setMinimumFractionDigits(0); | 149 format.setMinimumFractionDigits(0); |
122 format.setMaximumFractionDigits(2); | 150 format.setMaximumFractionDigits(2); |
123 | 151 |
124 PolygonRenderer renderer = new PolygonRenderer( | 152 PolygonRenderer renderer = new PolygonRenderer( |
125 new PalettePaintLookup(palette), | 153 new PalettePaintLookup(palette, special), |
126 new LocalizedLabelGenerator(format)); | 154 new LocalizedLabelGenerator(format)); |
127 | 155 |
128 ValueAxis domainAxis = new NumberAxis(this.labels.getDomainAxisLabel()); | 156 ValueAxis domainAxis = new NumberAxis(this.labels.getDomainAxisLabel()); |
129 ValueAxis rangeAxis = new NumberAxis(this.labels.getRangeAxisLabel()); | 157 ValueAxis rangeAxis = new NumberAxis(this.labels.getRangeAxisLabel()); |
130 | 158 |