Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/exports/ReferenceCurveGenerator.java @ 2218:39933df6d0fe
Addes stub for ReferenceCurve*Generator
flys-artifacts/trunk@3857 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Wed, 01 Feb 2012 13:32:10 +0000 |
parents | |
children | 9dc81827b187 |
comparison
equal
deleted
inserted
replaced
2217:54422e31dc27 | 2218:39933df6d0fe |
---|---|
1 package de.intevation.flys.exports; | |
2 | |
3 import java.awt.Font; | |
4 | |
5 import org.w3c.dom.Document; | |
6 | |
7 import org.apache.log4j.Logger; | |
8 | |
9 import org.jfree.chart.JFreeChart; | |
10 import org.jfree.chart.axis.NumberAxis; | |
11 import org.jfree.chart.axis.ValueAxis; | |
12 import org.jfree.chart.plot.XYPlot; | |
13 import org.jfree.chart.title.TextTitle; | |
14 import org.jfree.data.Range; | |
15 import org.jfree.data.xy.XYSeries; | |
16 | |
17 import de.intevation.artifactdatabase.state.ArtifactAndFacet; | |
18 | |
19 import de.intevation.flys.artifacts.model.FacetTypes; | |
20 import de.intevation.flys.artifacts.model.WQDay; | |
21 import de.intevation.flys.artifacts.resources.Resources; | |
22 | |
23 import de.intevation.flys.jfree.FLYSAnnotation; | |
24 import de.intevation.flys.jfree.StyledXYSeries; | |
25 | |
26 | |
27 /** | |
28 * An OutGenerator that generates reference curves. | |
29 */ | |
30 public class ReferenceCurveGenerator | |
31 extends XYChartGenerator | |
32 implements FacetTypes | |
33 { | |
34 public static enum YAXIS { | |
35 W(0); | |
36 public int idx; | |
37 private YAXIS(int c) { | |
38 idx = c; | |
39 } | |
40 } | |
41 | |
42 private static Logger logger = | |
43 Logger.getLogger(ReferenceCurveGenerator.class); | |
44 | |
45 /* | |
46 public static final String I18N_CHART_TITLE = | |
47 "chart.reference.curve.title"; | |
48 | |
49 public static final String I18N_CHART_SUBTITLE = | |
50 "chart.reference.curve.subtitle"; | |
51 | |
52 public static final String I18N_XAXIS_LABEL = | |
53 "chart.reference.curve.xaxis.label"; | |
54 | |
55 public static final String I18N_YAXIS_LABEL = | |
56 "chart.reference.curve.yaxis.label"; | |
57 | |
58 public static final String I18N_CHART_TITLE_DEFAULT = | |
59 "Bezugslinie"; | |
60 | |
61 public static final String I18N_XAXIS_LABEL_DEFAULT = | |
62 "W [NN+m]"; | |
63 | |
64 public static final String I18N_YAXIS_LABEL_DEFAULT = | |
65 "W [NN + m]"; | |
66 */ | |
67 | |
68 public ReferenceCurveGenerator() { | |
69 super(); | |
70 } | |
71 | |
72 | |
73 /** | |
74 * Create Axis for given index. | |
75 * @return axis with according internationalized label. | |
76 */ | |
77 @Override | |
78 protected NumberAxis createYAxis(int index) { | |
79 Font labelFont = new Font("Tahoma", Font.BOLD, 14); | |
80 String label = getYAxisLabel(index); | |
81 | |
82 NumberAxis axis = createNumberAxis(index, label); | |
83 if (index == YAXIS.W.idx) { | |
84 axis.setAutoRangeIncludesZero(false); | |
85 } | |
86 axis.setLabelFont(labelFont); | |
87 return axis; | |
88 } | |
89 | |
90 /** Get default chart title. */ | |
91 @Override | |
92 protected String getDefaultChartTitle() { | |
93 // TODO i18n return msg(I18N_CHART_TITLE, I18N_CHART_TITLE_DEFAULT); | |
94 return "Bezugslinien"; | |
95 } | |
96 | |
97 /* | |
98 // TODO i18n | |
99 @Override | |
100 protected String getDefaultChartSubtitle() { | |
101 double[] dist = getRange(); | |
102 | |
103 Object[] args = new Object[] { | |
104 getRiverName(), | |
105 dist[0] | |
106 }; | |
107 | |
108 return msg(I18N_CHART_SUBTITLE, "", args); | |
109 } | |
110 | |
111 | |
112 @Override | |
113 protected void addSubtitles(JFreeChart chart) { | |
114 String subtitle = getChartSubtitle(); | |
115 | |
116 if (subtitle != null && subtitle.length() > 0) { | |
117 chart.addSubtitle(new TextTitle(subtitle)); | |
118 } | |
119 } | |
120 */ | |
121 | |
122 | |
123 /** Get Label for X-axis (W). */ | |
124 @Override | |
125 protected String getDefaultXAxisLabel() { | |
126 // TODO i18nreturn msg(I18N_XAXIS_LABEL, I18N_XAXIS_LABEL_DEFAULT); | |
127 return "W!"; | |
128 } | |
129 | |
130 | |
131 /** | |
132 * Get Label for primary and other Y Axes. | |
133 * @param index Axis-Index (0-based). | |
134 */ | |
135 @Override | |
136 protected String getDefaultYAxisLabel(int index) { | |
137 String label = "default"; | |
138 if (index == YAXIS.W.idx) { | |
139 //label = msg(I18N_YAXIS_LABEL, I18N_YAXIS_LABEL_DEFAULT); | |
140 //TODO i18n | |
141 return "W over W over W"; | |
142 } | |
143 | |
144 return label; | |
145 } | |
146 | |
147 @Override | |
148 public void doOut( | |
149 ArtifactAndFacet artifactFacet, | |
150 Document attr, | |
151 boolean visible | |
152 ) { | |
153 String name = artifactFacet.getFacetName(); | |
154 | |
155 logger.debug("ReferenceCurveGenerator.doOut: " + name); | |
156 | |
157 if (name == null || name.length() == 0) { | |
158 logger.error("No facet given. Cannot create dataset."); | |
159 return; | |
160 } | |
161 | |
162 /* | |
163 if (name.equals(REFERENCE_W)) { | |
164 //doReference | |
165 } | |
166 */ | |
167 if (false) {} | |
168 else { | |
169 logger.warn("Unknown facet name: " + name); | |
170 return; | |
171 } | |
172 } | |
173 | |
174 | |
175 @Override | |
176 protected YAxisWalker getYAxisWalker() { | |
177 return new YAxisWalker() { | |
178 @Override | |
179 public int length() { | |
180 return YAXIS.values().length; | |
181 } | |
182 | |
183 @Override | |
184 public String getId(int idx) { | |
185 YAXIS[] yaxes = YAXIS.values(); | |
186 return yaxes[idx].toString(); | |
187 } | |
188 }; | |
189 } | |
190 } | |
191 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |