Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/exports/process/BedHeightProcessor.java @ 7390:45e3bb00ce1a
Stub for new BedHeightProcessor.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Thu, 17 Oct 2013 11:12:14 +0200 |
parents | |
children | 9513d1af7d58 |
comparison
equal
deleted
inserted
replaced
7389:2c3031b6a831 | 7390:45e3bb00ce1a |
---|---|
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde | |
2 * Software engineering by Intevation GmbH | |
3 * | |
4 * This file is Free Software under the GNU AGPL (>=v3) | |
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the | |
6 * documentation coming with Dive4Elements River for details. | |
7 */ | |
8 | |
9 package org.dive4elements.river.exports.process; | |
10 | |
11 import java.util.List; | |
12 | |
13 import org.apache.log4j.Logger; | |
14 import org.jfree.data.xy.XYSeries; | |
15 | |
16 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; | |
17 import org.dive4elements.artifacts.CallContext; | |
18 import org.dive4elements.river.artifacts.model.minfo.BedHeightSingle; | |
19 import org.dive4elements.river.exports.XYChartGenerator; | |
20 import org.dive4elements.river.exports.DiagramGenerator; | |
21 import org.dive4elements.river.jfree.StyledXYSeries; | |
22 import org.dive4elements.river.model.BedHeightSingleValue; | |
23 import org.dive4elements.river.themes.ThemeDocument; | |
24 | |
25 public class BedHeightProcessor extends DefaultProcessor { | |
26 | |
27 private final static Logger logger = | |
28 Logger.getLogger(BedHeightProcessor.class); | |
29 | |
30 private final static String BEDHEIGHT = "bedheight"; | |
31 | |
32 public static final String I18N_AXIS_LABEL_DEFAULT | |
33 = "Gepeilte Breite [m]"; | |
34 public static final String I18N_AXIS_LABEL = | |
35 "chart.bedheight_middle.sounding.yaxis.label"; | |
36 | |
37 @Override | |
38 public void doOut( | |
39 DiagramGenerator generator, | |
40 ArtifactAndFacet bundle, | |
41 ThemeDocument theme, | |
42 boolean visible) { | |
43 XYSeries series = prepareSeries(bundle, theme, generator.getCallContext()); | |
44 generator.addAxisSeries(series, axisName, visible); | |
45 } | |
46 | |
47 @Override | |
48 public void doOut( | |
49 XYChartGenerator generator, | |
50 ArtifactAndFacet bundle, | |
51 ThemeDocument theme, | |
52 boolean visible, | |
53 int index | |
54 ) { | |
55 XYSeries series = prepareSeries(bundle, theme, generator.getCallContext()); | |
56 generator.addAxisSeries(series, index, visible); | |
57 } | |
58 | |
59 /** Prepare an series, independent of axis. */ | |
60 private XYSeries prepareSeries(ArtifactAndFacet bundle, | |
61 ThemeDocument theme, CallContext context) { | |
62 Object data = bundle.getData(context); | |
63 XYSeries series = new StyledXYSeries(bundle.getFacetDescription(), | |
64 theme); | |
65 if (data instanceof BedHeightSingle) { | |
66 BedHeightSingle bData = (BedHeightSingle)data; | |
67 double[] width = bData.getMorphWidths(); | |
68 double[] stations = bData.getStations().toNativeArray(); | |
69 | |
70 logger.debug("doBedheightSingleOut"); | |
71 | |
72 for (int i = 0; i < width.length; i++) { | |
73 series.add(stations[i], width[i], false); | |
74 } | |
75 } else if (data instanceof List<?>) { | |
76 List<BedHeightSingleValue> bData = (List<BedHeightSingleValue>)data; | |
77 | |
78 logger.debug("doBedheightSingleValueOut"); | |
79 | |
80 for(BedHeightSingleValue bvalue: bData) { | |
81 series.add(bvalue.getStation(), bvalue.getSoundingWidth()); | |
82 } | |
83 } | |
84 else { | |
85 logger.error("Unknown data type " + data.getClass()); | |
86 } | |
87 return series; | |
88 } | |
89 | |
90 | |
91 @Override | |
92 public boolean canHandle(String facettype) { | |
93 return BEDHEIGHT.equals(facettype); | |
94 } | |
95 | |
96 @Override | |
97 public String getAxisLabel(DiagramGenerator generator) { | |
98 return generator.msg( | |
99 I18N_AXIS_LABEL, | |
100 I18N_AXIS_LABEL_DEFAULT); | |
101 } | |
102 } |