Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/exports/DischargeCurveGenerator.java @ 6453:f11165468f0a
issue1370: swap default axis (now in cm), translate annotations if in cm.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Wed, 26 Jun 2013 22:06:15 +0200 |
parents | 192fbd23d97f |
children | 378b0d780e36 |
comparison
equal
deleted
inserted
replaced
6452:9cbe58704604 | 6453:f11165468f0a |
---|---|
12 import org.dive4elements.river.artifacts.D4EArtifact; | 12 import org.dive4elements.river.artifacts.D4EArtifact; |
13 import org.dive4elements.river.artifacts.model.FacetTypes; | 13 import org.dive4elements.river.artifacts.model.FacetTypes; |
14 import org.dive4elements.river.artifacts.model.WQKms; | 14 import org.dive4elements.river.artifacts.model.WQKms; |
15 import org.dive4elements.river.jfree.Bounds; | 15 import org.dive4elements.river.jfree.Bounds; |
16 import org.dive4elements.river.jfree.RiverAnnotation; | 16 import org.dive4elements.river.jfree.RiverAnnotation; |
17 import org.dive4elements.river.jfree.StickyAxisAnnotation; | |
17 import org.dive4elements.river.jfree.StyledXYSeries; | 18 import org.dive4elements.river.jfree.StyledXYSeries; |
18 import org.dive4elements.river.model.Gauge; | 19 import org.dive4elements.river.model.Gauge; |
19 import org.dive4elements.river.model.River; | 20 import org.dive4elements.river.model.River; |
20 import org.dive4elements.river.utils.RiverUtils; | 21 import org.dive4elements.river.utils.RiverUtils; |
21 | 22 |
22 import org.apache.log4j.Logger; | 23 import org.apache.log4j.Logger; |
24 import org.jfree.chart.annotations.XYTextAnnotation; | |
23 import org.jfree.chart.axis.ValueAxis; | 25 import org.jfree.chart.axis.ValueAxis; |
24 import org.jfree.chart.plot.XYPlot; | 26 import org.jfree.chart.plot.XYPlot; |
25 import org.jfree.data.Range; | 27 import org.jfree.data.Range; |
26 import org.jfree.data.xy.XYSeries; | 28 import org.jfree.data.xy.XYSeries; |
27 import org.w3c.dom.Document; | 29 import org.w3c.dom.Document; |
35 public class DischargeCurveGenerator | 37 public class DischargeCurveGenerator |
36 extends XYChartGenerator | 38 extends XYChartGenerator |
37 implements FacetTypes { | 39 implements FacetTypes { |
38 | 40 |
39 public static enum YAXIS { | 41 public static enum YAXIS { |
40 W(0), | 42 WCm(0), |
41 WCm(1); | 43 W(1); |
42 protected int idx; | 44 protected int idx; |
43 private YAXIS(int c) { | 45 private YAXIS(int c) { |
44 idx = c; | 46 idx = c; |
45 } | 47 } |
46 } | 48 } |
77 subtractPNP = gauge.getDatum().doubleValue(); | 79 subtractPNP = gauge.getDatum().doubleValue(); |
78 } | 80 } |
79 return subtractPNP; | 81 return subtractPNP; |
80 } | 82 } |
81 | 83 |
84 | |
82 public double getCurrentGaugeDatum() { | 85 public double getCurrentGaugeDatum() { |
83 return getCurrentGaugeDatum(getRange()[0], (D4EArtifact) getMaster()); | 86 return getCurrentGaugeDatum(getRange()[0], (D4EArtifact) getMaster()); |
84 } | 87 } |
85 | 88 |
86 | 89 |
134 if (!zoomin) { | 137 if (!zoomin) { |
135 axis.setLowerBound(0d); | 138 axis.setLowerBound(0d); |
136 } | 139 } |
137 | 140 |
138 return zoomin; | 141 return zoomin; |
142 } | |
143 | |
144 public void translateRiverAnnotation(RiverAnnotation riverAnnotation) { | |
145 if (getCurrentGaugeDatum() == 0d) { | |
146 return; | |
147 } | |
148 logger.debug("Translate some river annotation."); | |
149 double translate = getCurrentGaugeDatum(); | |
150 double factor = 100d; | |
151 for (StickyAxisAnnotation annotation: riverAnnotation.getAxisTextAnnotations()){ | |
152 if (!annotation.atX()) { | |
153 annotation.setPos((annotation.getPos() - translate)*factor); | |
154 } | |
155 } | |
156 for (XYTextAnnotation annotation: riverAnnotation.getTextAnnotations()) { | |
157 annotation.setY((annotation.getY() - translate)*factor); | |
158 } | |
139 } | 159 } |
140 | 160 |
141 | 161 |
142 @Override | 162 @Override |
143 public void doOut( | 163 public void doOut( |
160 else if (name.equals(COMPUTED_DISCHARGE_MAINVALUES_Q) | 180 else if (name.equals(COMPUTED_DISCHARGE_MAINVALUES_Q) |
161 || name.equals(MAINVALUES_Q) | 181 || name.equals(MAINVALUES_Q) |
162 || name.equals(COMPUTED_DISCHARGE_MAINVALUES_W) | 182 || name.equals(COMPUTED_DISCHARGE_MAINVALUES_W) |
163 || name.equals(MAINVALUES_W)) | 183 || name.equals(MAINVALUES_W)) |
164 { | 184 { |
165 doAnnotations((RiverAnnotation) artifactFacet.getData(context), | 185 RiverAnnotation mainValues = (RiverAnnotation) artifactFacet.getData(context); |
186 translateRiverAnnotation(mainValues); | |
187 doAnnotations( | |
188 mainValues, | |
166 artifactFacet, theme, visible); | 189 artifactFacet, theme, visible); |
167 } | 190 } |
168 else if (FacetTypes.IS.MANUALPOINTS(name)) { | 191 else if (FacetTypes.IS.MANUALPOINTS(name)) { |
169 doPoints(artifactFacet.getData(context), | 192 doPoints(artifactFacet.getData(context), |
170 artifactFacet, | 193 artifactFacet, |