Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/exports/minfo/BedDiffHeightYearGenerator.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/minfo/BedDiffHeightYearGenerator.java@bd047b71ab37 |
children | 4897a58c8746 |
comparison
equal
deleted
inserted
replaced
5837:d9901a08d0a6 | 5838:5aa05a7a34b7 |
---|---|
1 package org.dive4elements.river.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 org.dive4elements.artifactdatabase.state.ArtifactAndFacet; | |
8 import org.dive4elements.artifactdatabase.state.Facet; | |
9 import org.dive4elements.river.artifacts.model.FacetTypes; | |
10 import org.dive4elements.river.artifacts.model.minfo.BedDiffYearResult; | |
11 import org.dive4elements.river.artifacts.model.minfo.BedDifferencesResult; | |
12 import org.dive4elements.river.exports.StyledSeriesBuilder; | |
13 import org.dive4elements.river.exports.fixings.FixChartGenerator; | |
14 import org.dive4elements.river.exports.process.KMIndexProcessor; | |
15 import org.dive4elements.river.exports.process.Processor; | |
16 import org.dive4elements.river.jfree.Bounds; | |
17 import org.dive4elements.river.jfree.DoubleBounds; | |
18 import org.dive4elements.river.jfree.FLYSAnnotation; | |
19 import org.dive4elements.river.jfree.StyledXYSeries; | |
20 | |
21 | |
22 public class BedDiffHeightYearGenerator | |
23 extends FixChartGenerator | |
24 implements FacetTypes | |
25 { | |
26 public enum YAXIS { | |
27 D(0), dW(1); | |
28 | |
29 protected int idx; | |
30 | |
31 private YAXIS(int c) { | |
32 idx = c; | |
33 } | |
34 } | |
35 | |
36 /** The logger that is used in this generator. */ | |
37 private static Logger logger = Logger.getLogger(BedDiffHeightYearGenerator.class); | |
38 | |
39 public static final String I18N_CHART_TITLE = "chart.beddifference.height.title"; | |
40 public static final String I18N_XAXIS_LABEL = "chart.beddifference.height.xaxis.label"; | |
41 public static final String I18N_YAXIS_LABEL = "chart.beddifference.height.yaxis.label"; | |
42 | |
43 public static final String I18N_CHART_TITLE_DEFAULT = "Sohlenhöhen Differenz"; | |
44 public static final String I18N_XAXIS_LABEL_DEFAULT = "Fluss-Km"; | |
45 public static final String I18N_YAXIS_LABEL_DEFAULT = "delta S [cm / Jahr]"; | |
46 public static final String I18N_DW_YAXIS_LABEL_DEFAULT = | |
47 "delta W [cm]"; | |
48 public static final String I18N_DW_YAXIS_LABEL = | |
49 "chart.fixings.longitudinalsection.yaxis.label"; | |
50 | |
51 @Override | |
52 protected YAxisWalker getYAxisWalker() { | |
53 return new YAxisWalker() { | |
54 | |
55 @Override | |
56 public int length() { | |
57 return YAXIS.values().length; | |
58 } | |
59 | |
60 @Override | |
61 public String getId(int idx) { | |
62 YAXIS[] yaxes = YAXIS.values(); | |
63 return yaxes[idx].toString(); | |
64 } | |
65 }; | |
66 } | |
67 | |
68 @Override | |
69 public void doOut(ArtifactAndFacet bundle, Document attr, boolean visible) { | |
70 String name = bundle.getFacetName(); | |
71 | |
72 logger.debug("doOut: " + name); | |
73 | |
74 if (name == null) { | |
75 logger.error("No facet name for doOut(). No output generated!"); | |
76 return; | |
77 } | |
78 | |
79 Facet facet = bundle.getFacet(); | |
80 | |
81 if (facet == null) { | |
82 return; | |
83 } | |
84 | |
85 if (getXBounds(0) != null && getDomainAxisRange() != null) { | |
86 Bounds bounds = | |
87 calculateZoom(getXBounds(0), getDomainAxisRange()); | |
88 context.putContextValue("startkm", bounds.getLower()); | |
89 context.putContextValue("endkm", bounds.getUpper()); | |
90 } | |
91 else if (getXBounds(0) != null && getDomainAxisRange() == null) { | |
92 context.putContextValue("startkm", getXBounds(0).getLower()); | |
93 context.putContextValue("endkm", getXBounds(0).getUpper()); | |
94 } | |
95 else if (getXBounds(0) == null && getDomainAxisRange() == null) { | |
96 BedDifferencesResult data = (BedDifferencesResult)bundle.getData(context); | |
97 context.putContextValue("startkm", data.getKms().min()); | |
98 context.putContextValue("endkm", data.getKms().max()); | |
99 } | |
100 else if (getXBounds(0) == null && getDomainAxisRange() != null){ | |
101 BedDifferencesResult data = (BedDifferencesResult)bundle.getData(context); | |
102 Bounds b = new DoubleBounds(data.getKms().min(), data.getKms().max()); | |
103 Bounds bounds = | |
104 calculateZoom(b, getDomainAxisRange()); | |
105 context.putContextValue("startkm", bounds.getLower()); | |
106 context.putContextValue("endkm", bounds.getUpper()); | |
107 } | |
108 Processor processor = new KMIndexProcessor(); | |
109 if (name.equals(BED_DIFFERENCE_HEIGHT_YEAR)) { | |
110 doBedDifferenceYearOut( | |
111 (BedDiffYearResult) bundle.getData(context), | |
112 bundle, attr, visible); | |
113 } | |
114 else if (name.equals(BED_DIFFERENCE_HEIGHT_YEAR_FILTERED)) { | |
115 doBedDifferenceYearOut( | |
116 (BedDiffYearResult) bundle.getData(context), | |
117 bundle, attr, visible); | |
118 } | |
119 else if (name.equals(LONGITUDINAL_ANNOTATION)) { | |
120 doAnnotations( | |
121 (FLYSAnnotation) bundle.getData(context), | |
122 bundle, | |
123 attr, | |
124 visible); | |
125 } | |
126 else if (processor.canHandle(name)) { | |
127 processor.doOut(this, bundle, attr, visible, YAXIS.dW.idx); | |
128 } | |
129 else { | |
130 logger.warn("Unknown facet name " + name); | |
131 } | |
132 } | |
133 | |
134 @Override | |
135 protected String getDefaultChartTitle() { | |
136 return msg(I18N_CHART_TITLE, I18N_CHART_TITLE_DEFAULT); | |
137 } | |
138 | |
139 @Override | |
140 protected String getDefaultXAxisLabel() { | |
141 return msg(I18N_XAXIS_LABEL, I18N_XAXIS_LABEL_DEFAULT); | |
142 } | |
143 | |
144 @Override | |
145 protected String getDefaultYAxisLabel(int pos) { | |
146 if (pos == YAXIS.D.idx) { | |
147 return msg(I18N_YAXIS_LABEL, I18N_YAXIS_LABEL_DEFAULT); | |
148 } | |
149 else if (pos == YAXIS.dW.idx) { | |
150 return msg(I18N_DW_YAXIS_LABEL, I18N_DW_YAXIS_LABEL_DEFAULT); | |
151 } | |
152 return "default"; | |
153 } | |
154 | |
155 protected void doBedDifferenceYearOut(BedDiffYearResult data, | |
156 ArtifactAndFacet aandf, Document theme, boolean visible) { | |
157 | |
158 XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), theme); | |
159 StyledSeriesBuilder.addPoints(series, data.getHeightPerYearData(), true); | |
160 | |
161 addAxisSeries(series, YAXIS.D.idx, visible); | |
162 } | |
163 } |