comparison artifacts/src/main/java/org/dive4elements/river/exports/minfo/BedDiffHeightYearGenerator.java @ 6791:dd5355775ce1 longitudinal-symmetry

merge changes from default into longitudinal-symmetrie branch and make it build
author Tom Gottfried <tom@intevation.de>
date Wed, 07 Aug 2013 18:53:15 +0200
parents ef3b02034f6a aee8cb5c801a
children
comparison
equal deleted inserted replaced
6518:1a7f5d09b9d8 6791:dd5355775ce1
7 */ 7 */
8 8
9 package org.dive4elements.river.exports.minfo; 9 package org.dive4elements.river.exports.minfo;
10 10
11 import org.apache.log4j.Logger; 11 import org.apache.log4j.Logger;
12 import org.jfree.data.xy.XYSeries;
13 import org.w3c.dom.Document; 12 import org.w3c.dom.Document;
14 13
15 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; 14 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
16 import org.dive4elements.artifactdatabase.state.Facet; 15 import org.dive4elements.artifactdatabase.state.Facet;
17 import org.dive4elements.river.artifacts.model.FacetTypes; 16 import org.dive4elements.river.artifacts.model.FacetTypes;
18 import org.dive4elements.river.artifacts.model.minfo.BedDiffYearResult;
19 import org.dive4elements.river.artifacts.model.minfo.BedDifferencesResult; 17 import org.dive4elements.river.artifacts.model.minfo.BedDifferencesResult;
20 import org.dive4elements.river.exports.StyledSeriesBuilder;
21 import org.dive4elements.river.exports.LongitudinalSectionGenerator; 18 import org.dive4elements.river.exports.LongitudinalSectionGenerator;
19 import org.dive4elements.river.exports.process.BedDiffHeightYearProcessor;
22 import org.dive4elements.river.exports.process.KMIndexProcessor; 20 import org.dive4elements.river.exports.process.KMIndexProcessor;
23 import org.dive4elements.river.exports.process.Processor; 21 import org.dive4elements.river.exports.process.Processor;
24 import org.dive4elements.river.jfree.Bounds;
25 import org.dive4elements.river.jfree.DoubleBounds;
26 import org.dive4elements.river.jfree.RiverAnnotation; 22 import org.dive4elements.river.jfree.RiverAnnotation;
27 import org.dive4elements.river.jfree.StyledXYSeries;
28 23
29 24
30 public class BedDiffHeightYearGenerator 25 public class BedDiffHeightYearGenerator
31 extends LongitudinalSectionGenerator 26 extends BedDiffBaseGenerator
32 implements FacetTypes 27 implements FacetTypes
33 { 28 {
34 public enum YAXIS { 29 public enum YAXIS {
35 D(0), dW(1); 30 D(0), dW(1);
36 31
87 if (facet == null) { 82 if (facet == null) {
88 return; 83 return;
89 } 84 }
90 85
91 if (bundle.getData(context) instanceof BedDifferencesResult) { 86 if (bundle.getData(context) instanceof BedDifferencesResult) {
92 if (getXBounds(0) != null && getDomainAxisRange() != null) { 87 setContextBounds(bundle);
93 Bounds bounds =
94 calculateZoom(getXBounds(0), getDomainAxisRange());
95 context.putContextValue("startkm", bounds.getLower());
96 context.putContextValue("endkm", bounds.getUpper());
97 }
98 else if (getXBounds(0) != null && getDomainAxisRange() == null) {
99 context.putContextValue("startkm", getXBounds(0).getLower());
100 context.putContextValue("endkm", getXBounds(0).getUpper());
101 }
102 else if (getXBounds(0) == null && getDomainAxisRange() == null) {
103 BedDifferencesResult data = (BedDifferencesResult)bundle.getData(context);
104 context.putContextValue("startkm", data.getKms().min());
105 context.putContextValue("endkm", data.getKms().max());
106 }
107 else if (getXBounds(0) == null && getDomainAxisRange() != null){
108 BedDifferencesResult data = (BedDifferencesResult)bundle.getData(context);
109 Bounds b = new DoubleBounds(data.getKms().min(), data.getKms().max());
110 Bounds bounds =
111 calculateZoom(b, getDomainAxisRange());
112 context.putContextValue("startkm", bounds.getLower());
113 context.putContextValue("endkm", bounds.getUpper());
114 }
115 } 88 }
89
116 Processor processor = new KMIndexProcessor(); 90 Processor processor = new KMIndexProcessor();
117 if (name.equals(BED_DIFFERENCE_HEIGHT_YEAR)) { 91 Processor bdyProcessor = new BedDiffHeightYearProcessor();
118 doBedDifferenceYearOut( 92 if (name.equals(LONGITUDINAL_ANNOTATION)) {
119 (BedDiffYearResult) bundle.getData(context),
120 bundle, attr, visible);
121 }
122 else if (name.equals(BED_DIFFERENCE_HEIGHT_YEAR_FILTERED)) {
123 doBedDifferenceYearOut(
124 (BedDiffYearResult) bundle.getData(context),
125 bundle, attr, visible);
126 }
127 else if (name.equals(LONGITUDINAL_ANNOTATION)) {
128 doAnnotations( 93 doAnnotations(
129 (RiverAnnotation) bundle.getData(context), 94 (RiverAnnotation) bundle.getData(context),
130 bundle, 95 bundle,
131 attr, 96 attr,
132 visible); 97 visible);
133 } 98 }
134 else if (processor.canHandle(name)) { 99 else if (processor.canHandle(name)) {
135 processor.doOut(this, bundle, attr, visible, YAXIS.dW.idx); 100 processor.doOut(this, bundle, attr, visible, YAXIS.dW.idx);
136 } 101 }
102 else if (bdyProcessor.canHandle(name)) {
103 bdyProcessor.doOut(this, bundle, attr, visible, YAXIS.D.idx);
104 }
137 else { 105 else {
138 logger.warn("Unknown facet name " + name); 106 logger.warn("Unknown facet name " + name);
139 } 107 }
140 } 108 }
109
141 110
142 @Override 111 @Override
143 protected String getDefaultChartTitle() { 112 protected String getDefaultChartTitle() {
144 return msg(I18N_CHART_TITLE, I18N_CHART_TITLE_DEFAULT); 113 return msg(I18N_CHART_TITLE, I18N_CHART_TITLE_DEFAULT);
145 } 114 }
146 115
147 @Override
148 protected String getDefaultXAxisLabel() {
149 return msg(I18N_XAXIS_LABEL,
150 I18N_XAXIS_LABEL_DEFAULT,
151 new Object[] { getRiverName() });
152 }
153 116
154 @Override 117 @Override
155 protected String getDefaultYAxisLabel(int pos) { 118 protected String getDefaultYAxisLabel(int pos) {
156 if (pos == YAXIS.D.idx) { 119 if (pos == YAXIS.D.idx) {
157 return msg(I18N_YAXIS_LABEL, I18N_YAXIS_LABEL_DEFAULT); 120 return msg(I18N_YAXIS_LABEL, I18N_YAXIS_LABEL_DEFAULT);
159 else if (pos == YAXIS.dW.idx) { 122 else if (pos == YAXIS.dW.idx) {
160 return msg(I18N_DW_YAXIS_LABEL, I18N_DW_YAXIS_LABEL_DEFAULT); 123 return msg(I18N_DW_YAXIS_LABEL, I18N_DW_YAXIS_LABEL_DEFAULT);
161 } 124 }
162 return "default"; 125 return "default";
163 } 126 }
164
165 protected void doBedDifferenceYearOut(BedDiffYearResult data,
166 ArtifactAndFacet aandf, Document theme, boolean visible) {
167
168 XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), theme);
169 StyledSeriesBuilder.addPoints(series, data.getHeightPerYearData(), true);
170
171 addAxisSeries(series, YAXIS.D.idx, visible);
172 }
173 } 127 }

http://dive4elements.wald.intevation.org