Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/exports/CrossSectionGenerator.java @ 6905:1b35b2ddfc28
Artifacts: Introduce ThemeDocument & make stuff compileable again. THIS BREAKS THE SYSTEM! TODO: Move ThemeUtils into ThemeDocument.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 22 Aug 2013 23:31:38 +0200 |
parents | af13ceeba52a |
children | 7a9cbb3a3d5a |
comparison
equal
deleted
inserted
replaced
6904:d710bd3df387 | 6905:1b35b2ddfc28 |
---|---|
19 import org.jfree.chart.LegendItemCollection; | 19 import org.jfree.chart.LegendItemCollection; |
20 import org.jfree.chart.annotations.XYBoxAnnotation; | 20 import org.jfree.chart.annotations.XYBoxAnnotation; |
21 import org.jfree.chart.annotations.XYTextAnnotation; | 21 import org.jfree.chart.annotations.XYTextAnnotation; |
22 import org.jfree.chart.plot.XYPlot; | 22 import org.jfree.chart.plot.XYPlot; |
23 import org.jfree.data.xy.XYSeries; | 23 import org.jfree.data.xy.XYSeries; |
24 import org.w3c.dom.Document; | |
25 | 24 |
26 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; | 25 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; |
27 import org.dive4elements.artifacts.DataProvider; | 26 import org.dive4elements.artifacts.DataProvider; |
28 import org.dive4elements.river.artifacts.D4EArtifact; | 27 import org.dive4elements.river.artifacts.D4EArtifact; |
29 import org.dive4elements.river.artifacts.geom.Lines; | 28 import org.dive4elements.river.artifacts.geom.Lines; |
34 import org.dive4elements.river.jfree.RiverAnnotation; | 33 import org.dive4elements.river.jfree.RiverAnnotation; |
35 import org.dive4elements.river.jfree.StyledXYSeries; | 34 import org.dive4elements.river.jfree.StyledXYSeries; |
36 import org.dive4elements.river.model.FastCrossSectionLine; | 35 import org.dive4elements.river.model.FastCrossSectionLine; |
37 import org.dive4elements.river.themes.LineStyle; | 36 import org.dive4elements.river.themes.LineStyle; |
38 import org.dive4elements.river.themes.TextStyle; | 37 import org.dive4elements.river.themes.TextStyle; |
39 import org.dive4elements.river.themes.ThemeAccess; | 38 import org.dive4elements.river.themes.ThemeDocument; |
40 import org.dive4elements.river.utils.RiverUtils; | 39 import org.dive4elements.river.utils.RiverUtils; |
41 import org.dive4elements.river.utils.Formatter; | 40 import org.dive4elements.river.utils.Formatter; |
42 import org.dive4elements.river.utils.ThemeUtil; | |
43 | 41 |
44 | 42 |
45 /** | 43 /** |
46 * An OutGenerator that generates cross section graphs. | 44 * An OutGenerator that generates cross section graphs. |
47 */ | 45 */ |
183 plot.getRangeAxis().getRange()); | 181 plot.getRangeAxis().getRange()); |
184 | 182 |
185 for(RiverAnnotation fa : this.annotations) { | 183 for(RiverAnnotation fa : this.annotations) { |
186 | 184 |
187 // Access text styling, if any. | 185 // Access text styling, if any. |
188 Document theme = fa.getTheme(); | 186 ThemeDocument theme = fa.getTheme(); |
189 TextStyle textStyle = null; | 187 TextStyle textStyle = null; |
190 // XXX: DEAD CODE // LineStyle lineStyle = null; | 188 // XXX: DEAD CODE // LineStyle lineStyle = null; |
191 | 189 |
192 // Get Themeing information and add legend item. | 190 // Get Themeing information and add legend item. |
193 if (theme != null) { | 191 if (theme != null) { |
194 ThemeAccess themeAccess = new ThemeAccess(theme); | 192 textStyle = theme.parseTextStyle(); |
195 textStyle = themeAccess.parseTextStyle(); | |
196 // XXX: DEAD CODE // lineStyle = themeAccess.parseLineStyle(); | 193 // XXX: DEAD CODE // lineStyle = themeAccess.parseLineStyle(); |
197 if (fa.getLabel() != null) { | 194 if (fa.getLabel() != null) { |
198 LegendItemCollection lic = new LegendItemCollection(); | 195 LegendItemCollection lic = new LegendItemCollection(); |
199 LegendItemCollection old = plot.getFixedLegendItems(); | 196 LegendItemCollection old = plot.getFixedLegendItems(); |
200 lic.add(createLegendItem(theme, fa.getLabel())); | 197 lic.add(createLegendItem(theme, fa.getLabel())); |
256 * Let one facet do its job. | 253 * Let one facet do its job. |
257 */ | 254 */ |
258 @Override | 255 @Override |
259 public void doOut( | 256 public void doOut( |
260 ArtifactAndFacet artifactFacet, | 257 ArtifactAndFacet artifactFacet, |
261 Document attr, | 258 ThemeDocument attr, |
262 boolean visible | 259 boolean visible |
263 ) { | 260 ) { |
264 String name = artifactFacet.getFacetName(); | 261 String name = artifactFacet.getFacetName(); |
265 | 262 |
266 logger.debug("CrossSectionGenerator.doOut: " + name); | 263 logger.debug("CrossSectionGenerator.doOut: " + name); |
330 * @param theme Theme for the data series. | 327 * @param theme Theme for the data series. |
331 */ | 328 */ |
332 protected void doCrossSectionWaterLineOut( | 329 protected void doCrossSectionWaterLineOut( |
333 Object o, | 330 Object o, |
334 String seriesName, | 331 String seriesName, |
335 Document theme, | 332 ThemeDocument theme, |
336 boolean visible | 333 boolean visible |
337 ) { | 334 ) { |
338 logger.debug("CrossSectionGenerator.doCrossSectionWaterLineOut"); | 335 logger.debug("CrossSectionGenerator.doCrossSectionWaterLineOut"); |
339 | 336 |
340 Lines.LineData lines = (Lines.LineData) o; | 337 Lines.LineData lines = (Lines.LineData) o; |
341 // DO NOT SORT DATA! This destroys the gaps indicated by NaNs. | 338 // DO NOT SORT DATA! This destroys the gaps indicated by NaNs. |
342 StyledXYSeries series = new StyledXYSeries(seriesName, false, theme); | 339 StyledXYSeries series = new StyledXYSeries(seriesName, false, theme); |
343 | 340 |
344 if (!ThemeUtil.parseShowLineLabel(theme)) { | 341 if (!theme.parseShowLineLabel()) { |
345 series.setLabel(""); | 342 series.setLabel(""); |
346 } | 343 } |
347 if (ThemeUtil.parseShowWidth(theme)) { | 344 if (theme.parseShowWidth()) { |
348 NumberFormat nf = Formatter.getMeterFormat(this.context); | 345 NumberFormat nf = Formatter.getMeterFormat(this.context); |
349 String labelAdd = "b=" + nf.format(lines.width) + "m"; | 346 String labelAdd = "b=" + nf.format(lines.width) + "m"; |
350 if (series.getLabel().length() == 0) { | 347 if (series.getLabel().length() == 0) { |
351 series.setLabel(labelAdd); | 348 series.setLabel(labelAdd); |
352 } | 349 } |
353 else { | 350 else { |
354 series.setLabel(series.getLabel() + ", " + labelAdd); | 351 series.setLabel(series.getLabel() + ", " + labelAdd); |
355 } | 352 } |
356 } | 353 } |
357 if (ThemeUtil.parseShowLevel(theme) && lines.points.length > 1 | 354 if (theme.parseShowLevel() && lines.points.length > 1 |
358 && lines.points[1].length > 0) { | 355 && lines.points[1].length > 0) { |
359 NumberFormat nf = Formatter.getMeterFormat(this.context); | 356 NumberFormat nf = Formatter.getMeterFormat(this.context); |
360 D4EArtifact flys = (D4EArtifact) master; | 357 D4EArtifact flys = (D4EArtifact) master; |
361 | 358 |
362 String unit = RiverUtils.getRiver(flys).getWstUnit().getName(); | 359 String unit = RiverUtils.getRiver(flys).getWstUnit().getName(); |
367 } | 364 } |
368 else { | 365 else { |
369 series.setLabel(series.getLabel() + ", " + labelAdd); | 366 series.setLabel(series.getLabel() + ", " + labelAdd); |
370 } | 367 } |
371 } | 368 } |
372 if (ThemeUtil.parseShowMiddleHeight(theme) && lines.width != 0) { | 369 if (theme.parseShowMiddleHeight() && lines.width != 0) { |
373 NumberFormat nf = Formatter.getMeterFormat(this.context); | 370 NumberFormat nf = Formatter.getMeterFormat(this.context); |
374 String labelAdd = "T=" + nf.format(lines.area / lines.width) + "m"; | 371 String labelAdd = "T=" + nf.format(lines.area / lines.width) + "m"; |
375 // : " + lines.area + "/" + lines.width); | 372 // : " + lines.area + "/" + lines.width); |
376 if (series.getLabel().length() == 0) { | 373 if (series.getLabel().length() == 0) { |
377 series.setLabel(labelAdd); | 374 series.setLabel(labelAdd); |
389 | 386 |
390 /** Add HYK-Annotations (colorize and label some areas, draw lines. */ | 387 /** Add HYK-Annotations (colorize and label some areas, draw lines. */ |
391 protected void doHyk( | 388 protected void doHyk( |
392 Object o, | 389 Object o, |
393 String seriesName, | 390 String seriesName, |
394 Document theme, | 391 ThemeDocument theme, |
395 boolean visible | 392 boolean visible |
396 ) { | 393 ) { |
397 logger.debug("CrossSectionGenerator.doHyk"); | 394 logger.debug("CrossSectionGenerator.doHyk"); |
398 | 395 |
399 List<HYKFactory.Zone> zones = (List<HYKFactory.Zone>) o; | 396 List<HYKFactory.Zone> zones = (List<HYKFactory.Zone>) o; |
417 * @param theme Theme for the data series. | 414 * @param theme Theme for the data series. |
418 */ | 415 */ |
419 protected void doCrossSectionOut( | 416 protected void doCrossSectionOut( |
420 Object o, | 417 Object o, |
421 String seriesName, | 418 String seriesName, |
422 Document theme, | 419 ThemeDocument theme, |
423 boolean visible | 420 boolean visible |
424 ) { | 421 ) { |
425 logger.debug("CrossSectionGenerator.doCrossSectionOut"); | 422 logger.debug("CrossSectionGenerator.doCrossSectionOut"); |
426 | 423 |
427 XYSeries series = new StyledXYSeries(seriesName, theme); | 424 XYSeries series = new StyledXYSeries(seriesName, theme); |