comparison gnv-artifacts/src/main/java/de/intevation/gnv/chart/VerticalCrossSectionChart.java @ 492:79e80c289018

Added labels and titles to 'Profilschnitt' charts. gnv-artifacts/trunk@569 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 19 Jan 2010 10:06:03 +0000
parents 20a480753ff9
children 1bf058f1a2d1
comparison
equal deleted inserted replaced
491:cbb6b592bc6f 492:79e80c289018
25 import org.jfree.chart.axis.ValueAxis; 25 import org.jfree.chart.axis.ValueAxis;
26 import org.jfree.chart.axis.NumberAxis; 26 import org.jfree.chart.axis.NumberAxis;
27 import org.jfree.chart.axis.SymbolAxis; 27 import org.jfree.chart.axis.SymbolAxis;
28 28
29 import org.jfree.chart.title.PaintScaleLegend; 29 import org.jfree.chart.title.PaintScaleLegend;
30 import org.jfree.chart.title.TextTitle;
30 31
31 import org.jfree.chart.renderer.LookupPaintScale; 32 import org.jfree.chart.renderer.LookupPaintScale;
32 33
33 import org.jfree.ui.RectangleEdge; 34 import org.jfree.ui.RectangleEdge;
34 import org.jfree.ui.RectangleInsets; 35 import org.jfree.ui.RectangleInsets;
78 protected JFreeChart chart; 79 protected JFreeChart chart;
79 80
80 protected AttributedXYColumns columns; 81 protected AttributedXYColumns columns;
81 protected Palette palette; 82 protected Palette palette;
82 protected Locale locale; 83 protected Locale locale;
84 protected ChartLabels labels;
83 85
84 public VerticalCrossSectionChart() { 86 public VerticalCrossSectionChart() {
85 } 87 }
86 88
87 public VerticalCrossSectionChart( 89 public VerticalCrossSectionChart(
88 AttributedXYColumns columns, 90 AttributedXYColumns columns,
89 Palette palette, 91 Palette palette,
90 Locale locale 92 Locale locale,
93 ChartLabels labels
91 ) { 94 ) {
92 this.columns = columns; 95 this.columns = columns;
93 this.palette = palette; 96 this.palette = palette;
94 this.locale = locale; 97 this.locale = locale;
98 this.labels = labels;
95 } 99 }
96 100
97 protected JFreeChart createChart() { 101 protected JFreeChart createChart() {
98 102
99 String title = "Neues 2D-Diagramm"; 103 boolean legendB = false;
100 String xAxis = "x-Achse des Diagramms"; 104 boolean tooltips = false;
101 String yAxis = "y-Achse des Diagramms"; 105 boolean urls = false;
102 boolean legendB = false;
103 boolean tooltips = false;
104 boolean urls = false;
105 106
106 PlotOrientation po = PlotOrientation.HORIZONTAL; 107 PlotOrientation po = PlotOrientation.HORIZONTAL;
107 PolygonDataset data = columns.getPolygonDataset(); 108 PolygonDataset data = columns.getPolygonDataset();
108 109
109 HashSet<Integer> usedColors = new HashSet<Integer>(); 110 HashSet<Integer> usedColors = new HashSet<Integer>();
122 123
123 PolygonRenderer renderer = new PolygonRenderer( 124 PolygonRenderer renderer = new PolygonRenderer(
124 new PalettePaintLookup(palette), 125 new PalettePaintLookup(palette),
125 new LocalizedLabelGenerator(format)); 126 new LocalizedLabelGenerator(format));
126 127
127 ValueAxis domainAxis = new NumberAxis(xAxis); 128 ValueAxis domainAxis = new NumberAxis(this.labels.getDomainAxisLabel());
128 ValueAxis rangeAxis = new NumberAxis(yAxis); 129 ValueAxis rangeAxis = new NumberAxis(this.labels.getRangeAxisLabel());
129 130
130 PolygonPlot plot = new PolygonPlot( 131 PolygonPlot plot = new PolygonPlot(
131 data, 132 data,
132 renderer, 133 renderer,
133 domainAxis, 134 domainAxis,
151 --j; 152 --j;
152 } 153 }
153 } 154 }
154 155
155 JFreeChart chart = new JFreeChart( 156 JFreeChart chart = new JFreeChart(
156 title, 157 this.labels.getTitle(),
157 JFreeChart.DEFAULT_TITLE_FONT, 158 JFreeChart.DEFAULT_TITLE_FONT,
158 plot, 159 plot,
159 legendB); 160 legendB);
160 161
161 chart.removeLegend(); 162 chart.removeLegend();
163 chart.addSubtitle(new TextTitle(this.labels.getSubtitle()));
162 164
163 SymbolAxis scale = new SymbolAxis("Temperatur", labels); 165 SymbolAxis scale = new SymbolAxis(this.labels.getParameterName(), labels);
164 scale.setRange(-1.5d, labels.length+0.5d); 166 scale.setRange(-1.5d, labels.length+0.5d);
165 scale.setGridBandsVisible(false); 167 scale.setGridBandsVisible(false);
166 scale.setPlot(plot); 168 scale.setPlot(plot);
167 169
168 PaintScaleLegend legend = new PaintScaleLegend( 170 PaintScaleLegend legend = new PaintScaleLegend(

http://dive4elements.wald.intevation.org