comparison artifacts/src/main/java/org/dive4elements/river/exports/HistoricalDischargeWQCurveGenerator.java @ 5838:5aa05a7a34b7

Rename modules to more fitting names.
author Sascha L. Teichmann <teichmann@intevation.de>
date Thu, 25 Apr 2013 15:23:37 +0200
parents flys-artifacts/src/main/java/org/dive4elements/river/exports/HistoricalDischargeWQCurveGenerator.java@bd047b71ab37
children 4897a58c8746
comparison
equal deleted inserted replaced
5837:d9901a08d0a6 5838:5aa05a7a34b7
1 package org.dive4elements.river.exports;
2
3 import org.apache.log4j.Logger;
4 import org.jfree.data.xy.XYSeries;
5 import org.w3c.dom.Document;
6
7 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
8 import org.dive4elements.river.artifacts.FLYSArtifact;
9 import org.dive4elements.river.artifacts.access.HistoricalDischargeAccess;
10 import org.dive4elements.river.artifacts.model.FacetTypes;
11 import org.dive4elements.river.artifacts.model.Timerange;
12 import org.dive4elements.river.artifacts.model.WQKms;
13
14 import org.dive4elements.river.jfree.FLYSAnnotation;
15 import org.dive4elements.river.jfree.StyledValueMarker;
16 import org.dive4elements.river.jfree.StyledXYSeries;
17 import org.dive4elements.river.utils.FLYSUtils;
18
19
20 /**
21 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
22 */
23 public class HistoricalDischargeWQCurveGenerator
24 extends XYChartGenerator
25 implements FacetTypes {
26
27 /** Private logger. */
28 private static Logger logger = Logger
29 .getLogger(HistoricalDischargeWQCurveGenerator.class);
30
31 public static final String I18N_CHART_TITLE = "chart.historical.discharge.wq.title";
32
33 public static final String I18N_CHART_SUBTITLE = "chart.historical.discharge.wq.subtitle";
34
35 public static final String I18N_XAXIS_LABEL = "chart.historical.discharge.wq.xaxis.label";
36
37 public static final String I18N_YAXIS_LABEL = "chart.historical.discharge.wq.yaxis.label";
38
39 /** One Y-Axis only, in this chart. */
40 public static enum YAXIS {
41 W(0);
42
43 protected int idx;
44
45 private YAXIS(int c) {
46 idx = c;
47 }
48 }
49
50 @Override
51 protected YAxisWalker getYAxisWalker() {
52 return new YAxisWalker() {
53
54 @Override
55 public int length() {
56 return YAXIS.values().length;
57 }
58
59 @Override
60 public String getId(int idx) {
61 YAXIS[] yaxes = YAXIS.values();
62 return yaxes[idx].toString();
63 }
64 };
65 }
66
67 @Override
68 protected String getDefaultChartTitle() {
69 return msg(I18N_CHART_TITLE, I18N_CHART_TITLE);
70 }
71
72 @Override
73 protected String getDefaultChartSubtitle() {
74 FLYSArtifact flys = (FLYSArtifact) master;
75 Timerange evalTime = new HistoricalDischargeAccess(flys)
76 .getEvaluationTimerange();
77
78 Object[] args = new Object[] { FLYSUtils.getReferenceGaugeName(flys),
79 evalTime.getStart(), evalTime.getEnd() };
80
81 return msg(I18N_CHART_SUBTITLE, "", args);
82 }
83
84 @Override
85 protected String getDefaultXAxisLabel() {
86 return msg(I18N_XAXIS_LABEL, I18N_XAXIS_LABEL);
87 }
88
89 @Override
90 protected String getDefaultYAxisLabel(int pos) {
91 if (pos == 0) {
92 return msg(I18N_YAXIS_LABEL, I18N_YAXIS_LABEL);
93 }
94 else {
95 return "NO TITLE FOR Y AXIS: " + pos;
96 }
97 }
98
99 @Override
100 public void doOut(ArtifactAndFacet artifactFacet, Document theme,
101 boolean visible) {
102 String name = artifactFacet.getFacetName();
103 logger.debug("HistoricalDischargeWQCurveGenerator.doOut: " + name);
104 logger.debug("Theme description is: "
105 + artifactFacet.getFacetDescription());
106
107 if (name.equals(HISTORICAL_DISCHARGE_WQ_Q)) {
108 doHistoricalDischargeOutQ(
109 (FLYSArtifact) artifactFacet.getArtifact(),
110 artifactFacet.getData(context),
111 artifactFacet.getFacetDescription(), theme, visible);
112 }
113 else if (name.equals(HISTORICAL_DISCHARGE_WQ_W)) {
114 doHistoricalDischargeOutW(
115 (FLYSArtifact) artifactFacet.getArtifact(),
116 artifactFacet.getData(context),
117 artifactFacet.getFacetDescription(), theme, visible);
118 }
119 else if (name.equals(HISTORICAL_DISCHARGE_WQ_CURVE)) {
120 doHistoricalDischargeCurveOut(
121 (FLYSArtifact) artifactFacet.getArtifact(),
122 artifactFacet.getData(context),
123 artifactFacet.getFacetDescription(), theme, visible);
124 }
125 else if (FacetTypes.IS.MANUALPOINTS(name)) {
126 doPoints(artifactFacet.getData(context), artifactFacet, theme,
127 visible, YAXIS.W.idx);
128 }
129 else if (HISTORICAL_DISCHARGE_MAINVALUES_Q.equals(name)) {
130 doAnnotations((FLYSAnnotation)
131 artifactFacet.getData(context), artifactFacet, theme, visible);
132 }
133 else if (HISTORICAL_DISCHARGE_MAINVALUES_W.equals(name)) {
134 doAnnotations((FLYSAnnotation)
135 artifactFacet.getData(context), artifactFacet, theme, visible);
136 }
137 else {
138 logger.warn("doOut(): unknown facet name: " + name);
139 return;
140 }
141 }
142
143 protected void doHistoricalDischargeOutQ(FLYSArtifact artifact,
144 Object data, String desc, Document theme, boolean visible) {
145 double value = Double.valueOf(data.toString());
146 addDomainMarker(new StyledValueMarker(value, theme), visible);
147 }
148
149 protected void doHistoricalDischargeOutW(FLYSArtifact artifact,
150 Object data, String desc, Document theme, boolean visible) {
151 double value = Double.valueOf(data.toString());
152 addValueMarker(new StyledValueMarker(value, theme), visible);
153 }
154
155 protected void doHistoricalDischargeCurveOut(FLYSArtifact artifact,
156 Object data, String desc, Document theme, boolean visible) {
157 XYSeries series = new StyledXYSeries(desc, theme);
158 StyledSeriesBuilder.addPointsQW(series, (WQKms) data);
159
160 addAxisSeries(series, YAXIS.W.idx, visible);
161 }
162 }
163 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org