Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/exports/minfo/BedDifferenceEpochGenerator.java @ 3898:95d699c769fb
Bedheight difference calculation has chart outpus now.
flys-artifacts/trunk@5562 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Fri, 21 Sep 2012 14:29:32 +0000 |
parents | |
children | da48e33f4241 |
comparison
equal
deleted
inserted
replaced
3897:bce2dd4310a6 | 3898:95d699c769fb |
---|---|
1 package de.intevation.flys.exports.minfo; | |
2 | |
3 import org.apache.log4j.Logger; | |
4 import org.jfree.data.xy.XYSeries; | |
5 import org.w3c.dom.Document; | |
6 | |
7 import de.intevation.artifactdatabase.state.ArtifactAndFacet; | |
8 import de.intevation.artifactdatabase.state.Facet; | |
9 import de.intevation.flys.artifacts.model.FacetTypes; | |
10 import de.intevation.flys.artifacts.model.minfo.BedDiffEpochResult; | |
11 import de.intevation.flys.exports.StyledSeriesBuilder; | |
12 import de.intevation.flys.exports.XYChartGenerator; | |
13 import de.intevation.flys.jfree.FLYSAnnotation; | |
14 import de.intevation.flys.jfree.StyledXYSeries; | |
15 | |
16 | |
17 public class BedDifferenceEpochGenerator | |
18 extends XYChartGenerator | |
19 implements FacetTypes | |
20 { | |
21 public enum YAXIS { | |
22 D(0), H(1); | |
23 | |
24 protected int idx; | |
25 | |
26 private YAXIS(int c) { | |
27 idx = c; | |
28 } | |
29 } | |
30 | |
31 /** The logger that is used in this generator. */ | |
32 private static Logger logger = Logger.getLogger(BedQualityGenerator.class); | |
33 | |
34 public static final String I18N_CHART_TITLE = "chart.beddifference.epoch.title"; | |
35 public static final String I18N_XAXIS_LABEL = "chart.beddifference.xaxis.label"; | |
36 public static final String I18N_YAXIS_LABEL = "chart.beddifference.yaxis.label.diff"; | |
37 public static final String I18N_SECOND_YAXIS_LABEL = "chart.beddifference.yaxis.label.height"; | |
38 | |
39 public static final String I18N_CHART_TITLE_DEFAULT = "Sohlenhöhen Differenz"; | |
40 public static final String I18N_XAXIS_LABEL_DEFAULT = "Fluss-Km"; | |
41 public static final String I18N_YAXIS_LABEL_DEFAULT = "delta S [m]"; | |
42 public static final String I18N_SECOND_YAXIS_LABEL_DEFAULT = "Höhe [m]"; | |
43 | |
44 @Override | |
45 protected YAxisWalker getYAxisWalker() { | |
46 return new YAxisWalker() { | |
47 | |
48 @Override | |
49 public int length() { | |
50 return YAXIS.values().length; | |
51 } | |
52 | |
53 @Override | |
54 public String getId(int idx) { | |
55 YAXIS[] yaxes = YAXIS.values(); | |
56 return yaxes[idx].toString(); | |
57 } | |
58 }; | |
59 } | |
60 | |
61 @Override | |
62 public void doOut(ArtifactAndFacet bundle, Document attr, boolean visible) { | |
63 String name = bundle.getFacetName(); | |
64 | |
65 logger.debug("doOut: " + name); | |
66 | |
67 if (name == null) { | |
68 logger.error("No facet name for doOut(). No output generated!"); | |
69 return; | |
70 } | |
71 | |
72 Facet facet = bundle.getFacet(); | |
73 | |
74 if (facet == null) { | |
75 return; | |
76 } | |
77 | |
78 if (name.equals(BED_DIFFERENCE_EPOCH)) { | |
79 doBedDifferenceEpochOut( | |
80 (BedDiffEpochResult) bundle.getData(context), | |
81 bundle, attr, visible); | |
82 } | |
83 else if (name.equals(BED_DIFFERENCE_EPOCH_HEIGHT1)) { | |
84 doBedDifferenceHeightsOut((BedDiffEpochResult)bundle.getData(context), | |
85 bundle, attr, visible, 0); | |
86 } | |
87 else if (name.equals(BED_DIFFERENCE_EPOCH_HEIGHT2)) { | |
88 doBedDifferenceHeightsOut((BedDiffEpochResult)bundle.getData(context), | |
89 bundle, attr, visible, 1); | |
90 } | |
91 else if (name.equals(LONGITUDINAL_ANNOTATION)) { | |
92 doAnnotations( | |
93 (FLYSAnnotation) bundle.getData(context), | |
94 bundle, | |
95 attr, | |
96 visible); | |
97 } | |
98 } | |
99 | |
100 @Override | |
101 protected String getDefaultChartTitle() { | |
102 return msg(I18N_CHART_TITLE, I18N_CHART_TITLE_DEFAULT); | |
103 } | |
104 | |
105 @Override | |
106 protected String getDefaultXAxisLabel() { | |
107 return msg(I18N_XAXIS_LABEL, I18N_XAXIS_LABEL_DEFAULT); | |
108 } | |
109 | |
110 @Override | |
111 protected String getDefaultYAxisLabel(int pos) { | |
112 String label = "default"; | |
113 if (pos == YAXIS.D.idx) { | |
114 label = msg(I18N_YAXIS_LABEL, I18N_YAXIS_LABEL_DEFAULT); | |
115 } | |
116 else if (pos == YAXIS.H.idx) { | |
117 label = msg(I18N_SECOND_YAXIS_LABEL, I18N_SECOND_YAXIS_LABEL_DEFAULT); | |
118 } | |
119 | |
120 return label; | |
121 } | |
122 | |
123 protected void doBedDifferenceEpochOut(BedDiffEpochResult data, | |
124 ArtifactAndFacet aandf, Document theme, boolean visible) { | |
125 | |
126 XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), theme); | |
127 StyledSeriesBuilder.addPoints(series, data.getDifferencesData(), true); | |
128 | |
129 addAxisSeries(series, YAXIS.D.idx, visible); | |
130 } | |
131 | |
132 private void doBedDifferenceHeightsOut( | |
133 BedDiffEpochResult data, | |
134 ArtifactAndFacet bundle, | |
135 Document attr, | |
136 boolean visible, | |
137 int idx) { | |
138 logger.debug("doBedDifferenceHeightOut()"); | |
139 | |
140 XYSeries series = new StyledXYSeries(bundle.getFacetDescription(), attr); | |
141 if (idx == 0) { | |
142 StyledSeriesBuilder.addPoints(series, data.getHeights1Data(), true); | |
143 } | |
144 else { | |
145 StyledSeriesBuilder.addPoints(series, data.getHeights2Data(), true); | |
146 } | |
147 | |
148 addAxisSeries(series, YAXIS.H.idx, visible); | |
149 } | |
150 | |
151 } |