Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/exports/process/DischargeProcessor.java @ 7075:253d80af5b7f generator-refactoring
More Processor refactoring
- Unify aandf aaf and bundle variable names to bundle
- Factor out diagram inversion code
- Add function with new signature to BedDiffYear and QOut processors
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Fri, 20 Sep 2013 16:25:43 +0200 |
parents | f9d5020af0af |
children | 67e87c2d3748 |
comparison
equal
deleted
inserted
replaced
7074:a2abd87c0d3b | 7075:253d80af5b7f |
---|---|
56 | 56 |
57 /** Process data, add it to plot. */ | 57 /** Process data, add it to plot. */ |
58 @Override | 58 @Override |
59 public void doOut( | 59 public void doOut( |
60 XYChartGenerator generator, | 60 XYChartGenerator generator, |
61 ArtifactAndFacet aandf, | 61 ArtifactAndFacet bundle, |
62 ThemeDocument theme, | 62 ThemeDocument theme, |
63 boolean visible, | 63 boolean visible, |
64 int axisIndex | 64 int axisIndex |
65 ) { | 65 ) { |
66 CallContext context = generator.getCallContext(); | 66 CallContext context = generator.getCallContext(); |
67 Object data = aandf.getData(context); | 67 Object data = bundle.getData(context); |
68 if (false && data instanceof WQKms) { | 68 if (false && data instanceof WQKms) { |
69 doWQKmsPointOut( | 69 doWQKmsPointOut( |
70 generator, (WQKms) data, aandf, theme, visible, axisIndex); | 70 generator, (WQKms) data, bundle, theme, visible, axisIndex); |
71 return; | 71 return; |
72 } | 72 } |
73 else if (data instanceof RiverAnnotation) { | 73 else if (data instanceof RiverAnnotation) { |
74 doRiverAnnotationOut( | 74 doRiverAnnotationOut( |
75 generator, (RiverAnnotation) data, aandf, theme, visible); | 75 generator, (RiverAnnotation) data, bundle, theme, visible); |
76 return; | 76 return; |
77 } | 77 } |
78 else if (data instanceof double[][]) { | 78 else if (data instanceof double[][]) { |
79 doMarksOut( | 79 doMarksOut( |
80 generator, (double[][]) data, aandf, theme, visible); | 80 generator, (double[][]) data, bundle, theme, visible); |
81 return; | 81 return; |
82 } | 82 } |
83 else { | 83 else { |
84 logger.error("Can't process " | 84 logger.error("Can't process " |
85 + data.getClass().getName() + " objects of facet " | 85 + data.getClass().getName() + " objects of facet " |
86 + aandf.getFacetName()); | 86 + bundle.getFacetName()); |
87 } | 87 } |
88 } | 88 } |
89 | 89 |
90 | 90 |
91 /** True if this processor knows how to deal with facetType. */ | 91 /** True if this processor knows how to deal with facetType. */ |
107 | 107 |
108 | 108 |
109 /** Handle WQKms data by finding w/q values at given km. */ | 109 /** Handle WQKms data by finding w/q values at given km. */ |
110 protected void doWQKmsPointOut(XYChartGenerator generator, | 110 protected void doWQKmsPointOut(XYChartGenerator generator, |
111 WQKms wqkms, | 111 WQKms wqkms, |
112 ArtifactAndFacet aandf, | 112 ArtifactAndFacet bundle, |
113 ThemeDocument theme, | 113 ThemeDocument theme, |
114 boolean visible, | 114 boolean visible, |
115 int axidx | 115 int axidx |
116 ) { | 116 ) { |
117 logger.debug("doWQKmsPointOut"); | 117 logger.debug("doWQKmsPointOut"); |
118 String title = aandf.getFacetDescription(); | 118 String title = bundle.getFacetDescription(); |
119 XYSeries series = new StyledXYSeries( | 119 XYSeries series = new StyledXYSeries( |
120 title, | 120 title, |
121 theme); | 121 theme); |
122 | 122 |
123 double[] kms = wqkms.getKms(); | 123 double[] kms = wqkms.getKms(); |
145 logger.warn("No WQ found for km " + getKm()); | 145 logger.warn("No WQ found for km " + getKm()); |
146 } | 146 } |
147 | 147 |
148 protected void doRiverAnnotationOut(XYChartGenerator generator, | 148 protected void doRiverAnnotationOut(XYChartGenerator generator, |
149 RiverAnnotation annotations, | 149 RiverAnnotation annotations, |
150 ArtifactAndFacet aandf, | 150 ArtifactAndFacet bundle, |
151 ThemeDocument theme, | 151 ThemeDocument theme, |
152 boolean visible | 152 boolean visible |
153 ) { | 153 ) { |
154 if (!(generator instanceof DischargeCurveGenerator)) { | 154 if (!(generator instanceof DischargeCurveGenerator)) { |
155 logger.error("DischargeProcessor can only be used in " + | 155 logger.error("DischargeProcessor can only be used in " + |
161 (DischargeCurveGenerator) generator; | 161 (DischargeCurveGenerator) generator; |
162 | 162 |
163 dGenerator.translateRiverAnnotation(annotations); | 163 dGenerator.translateRiverAnnotation(annotations); |
164 dGenerator.doAnnotations( | 164 dGenerator.doAnnotations( |
165 annotations, | 165 annotations, |
166 aandf, theme, visible); | 166 bundle, theme, visible); |
167 } | 167 } |
168 | 168 |
169 | 169 |
170 /** | 170 /** |
171 * Put Sticky Axis Markers to Y-axis for each value. | 171 * Put Sticky Axis Markers to Y-axis for each value. |
172 * @param data [[-,y1],[-,y2],...] ('x'-coordinates ignored) | 172 * @param data [[-,y1],[-,y2],...] ('x'-coordinates ignored) |
173 */ | 173 */ |
174 protected void doMarksOut(XYChartGenerator generator, | 174 protected void doMarksOut(XYChartGenerator generator, |
175 double[][] data, | 175 double[][] data, |
176 ArtifactAndFacet aandf, | 176 ArtifactAndFacet bundle, |
177 ThemeDocument theme, | 177 ThemeDocument theme, |
178 boolean visible | 178 boolean visible |
179 ) { | 179 ) { |
180 logger.debug("doMarksOut"); | 180 logger.debug("doMarksOut"); |
181 | 181 |
182 if (!visible) { | 182 if (!visible) { |
183 return; | 183 return; |
184 } | 184 } |
185 | 185 |
186 // TODO subtract gauge null point if at gauge. | 186 // TODO subtract gauge null point if at gauge. |
187 String title = aandf.getFacetDescription(); | 187 String title = bundle.getFacetDescription(); |
188 List<StickyAxisAnnotation> yMarks = new ArrayList<StickyAxisAnnotation>(); | 188 List<StickyAxisAnnotation> yMarks = new ArrayList<StickyAxisAnnotation>(); |
189 | 189 |
190 for (double yPos: data[1]) { | 190 for (double yPos: data[1]) { |
191 yMarks.add(new StickyAxisAnnotation( | 191 yMarks.add(new StickyAxisAnnotation( |
192 title, | 192 title, |
193 (float) yPos, | 193 (float) yPos, |
194 StickyAxisAnnotation.SimpleAxis.Y_AXIS)); | 194 StickyAxisAnnotation.SimpleAxis.Y_AXIS)); |
195 } | 195 } |
196 | 196 |
197 generator.doAnnotations(new RiverAnnotation(title, yMarks), | 197 generator.doAnnotations(new RiverAnnotation(title, yMarks), |
198 aandf, theme, visible); | 198 bundle, theme, visible); |
199 } | 199 } |
200 } | 200 } |
201 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 201 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |