comparison flys-artifacts/src/main/java/de/intevation/flys/exports/DischargeCurveGenerator.java @ 1933:9e9cfc036a3f

Better use multiple axis feature in chart generators. flys-artifacts/trunk@3314 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Thu, 24 Nov 2011 11:03:33 +0000
parents 7c52e9cb2a72
children 06d8d371d244
comparison
equal deleted inserted replaced
1932:17e18948fe5e 1933:9e9cfc036a3f
1 package de.intevation.flys.exports; 1 package de.intevation.flys.exports;
2 2
3 import org.apache.log4j.Logger; 3 import org.apache.log4j.Logger;
4 4
5 import java.awt.Font;
6
5 import org.w3c.dom.Document; 7 import org.w3c.dom.Document;
6 8
7 import org.jfree.chart.JFreeChart; 9 import org.jfree.chart.JFreeChart;
10 import org.jfree.chart.axis.NumberAxis;
8 import org.jfree.chart.axis.ValueAxis; 11 import org.jfree.chart.axis.ValueAxis;
9 import org.jfree.chart.plot.XYPlot; 12 import org.jfree.chart.plot.XYPlot;
10 import org.jfree.data.Range; 13 import org.jfree.data.Range;
11 import org.jfree.data.xy.XYSeries; 14 import org.jfree.data.xy.XYSeries;
12 15
33 */ 36 */
34 public class DischargeCurveGenerator 37 public class DischargeCurveGenerator
35 extends XYChartGenerator 38 extends XYChartGenerator
36 implements FacetTypes { 39 implements FacetTypes {
37 40
41 public static enum YAXIS {
42 W(0);
43 protected int idx;
44 private YAXIS(int c) {
45 idx = c;
46 }
47 }
48
38 /** The logger used in this generator. */ 49 /** The logger used in this generator. */
39 private static Logger logger = 50 private static Logger logger =
40 Logger.getLogger(DischargeCurveGenerator.class); 51 Logger.getLogger(DischargeCurveGenerator.class);
41 52
42 public static final String I18N_CHART_TITLE = 53 public static final String I18N_CHART_TITLE =
54 public static final String I18N_CHART_TITLE_DEFAULT = "Abflusskurven"; 65 public static final String I18N_CHART_TITLE_DEFAULT = "Abflusskurven";
55 public static final String I18N_XAXIS_LABEL_DEFAULT = "Q [m\u00b3/s]"; 66 public static final String I18N_XAXIS_LABEL_DEFAULT = "Q [m\u00b3/s]";
56 public static final String I18N_YAXIS_LABEL_DEFAULT = "W [cm]"; 67 public static final String I18N_YAXIS_LABEL_DEFAULT = "W [cm]";
57 68
58 69
59
60 public DischargeCurveGenerator() { 70 public DischargeCurveGenerator() {
61 super(); 71 super();
62 } 72 }
63 73
64 74
73 @Override 83 @Override
74 protected void addSubtitles(JFreeChart chart) { 84 protected void addSubtitles(JFreeChart chart) {
75 } 85 }
76 86
77 87
88 /**
89 * i18n-Label for X-Axis.
90 */
78 protected String getXAxisLabel() { 91 protected String getXAxisLabel() {
79 return msg(I18N_XAXIS_LABEL, I18N_XAXIS_LABEL_DEFAULT); 92 return msg(I18N_XAXIS_LABEL, I18N_XAXIS_LABEL_DEFAULT);
80 } 93 }
81 94
82 95 /**
96 * i18n-Label for X-Axis (W).
97 */
83 protected String getYAxisLabel() { 98 protected String getYAxisLabel() {
84 return msg(I18N_YAXIS_LABEL, I18N_YAXIS_LABEL_DEFAULT); 99 return msg(I18N_YAXIS_LABEL, I18N_YAXIS_LABEL_DEFAULT);
85 } 100 }
86 101
87 102
92 if (!zoomin) { 107 if (!zoomin) {
93 axis.setLowerBound(0d); 108 axis.setLowerBound(0d);
94 } 109 }
95 110
96 return zoomin; 111 return zoomin;
112 }
113
114 /**
115 * Create Y-Axis.
116 * First Axis: W.
117 * @return Y-Axis with label.
118 */
119 @Override
120 protected NumberAxis createYAxis(int index) {
121 Font labelFont = new Font("Tahoma", Font.BOLD, 14);
122 String label = "default";
123 if (index == YAXIS.W.idx) {
124 label = getYAxisLabel();
125 }
126 NumberAxis axis = new NumberAxis(label);
127 axis.setLabelFont(labelFont);
128 return axis;
97 } 129 }
98 130
99 131
100 public void doOut( 132 public void doOut(
101 Artifact artifact, 133 Artifact artifact,
169 201
170 XYSeries series = new StyledXYSeries(description, theme); 202 XYSeries series = new StyledXYSeries(description, theme);
171 203
172 StyledSeriesBuilder.addPointsQW(series, wqkms); 204 StyledSeriesBuilder.addPointsQW(series, wqkms);
173 205
174 addAxisSeries(series, 0, visible); 206 addAxisSeries(series, YAXIS.W.idx, visible);
175 } 207 }
176 } 208 }
177 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : 209 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org