Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/exports/process/SedimentLoadTAProcessor.java @ 7685:270946b97539
(issue1614) Handle NaN in Styled Series created by SedimentLoadProcessors
This also removes duplicated code by basing the TA and MA processors
on the same class
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Wed, 11 Dec 2013 17:13:26 +0100 |
parents | e97867879a45 |
children | ca072278ad02 |
comparison
equal
deleted
inserted
replaced
7684:0141908fafe0 | 7685:270946b97539 |
---|---|
6 * documentation coming with Dive4Elements River for details. | 6 * documentation coming with Dive4Elements River for details. |
7 */ | 7 */ |
8 | 8 |
9 package org.dive4elements.river.exports.process; | 9 package org.dive4elements.river.exports.process; |
10 | 10 |
11 import java.util.Set; | 11 import org.apache.log4j.Logger; |
12 | 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.FacetTypes; | 13 import org.dive4elements.river.artifacts.model.FacetTypes; |
19 import org.dive4elements.river.exports.DiagramGenerator; | 14 import org.dive4elements.river.exports.DiagramGenerator; |
20 import org.dive4elements.river.exports.StyledSeriesBuilder; | |
21 import org.dive4elements.river.jfree.StyledXYSeries; | |
22 import org.dive4elements.river.themes.ThemeDocument; | |
23 | 15 |
24 import org.dive4elements.river.artifacts.model.minfo.SedimentLoad; | 16 public class SedimentLoadTAProcessor extends SedimentLoadProcessor{ |
25 import org.dive4elements.river.artifacts.model.minfo.SedimentLoadFraction; | |
26 | |
27 public class SedimentLoadTAProcessor extends DefaultProcessor { | |
28 | 17 |
29 private final static Logger logger = | 18 private final static Logger logger = |
30 Logger.getLogger(SedimentLoadTAProcessor.class); | 19 Logger.getLogger(SedimentLoadTAProcessor.class); |
31 | 20 |
32 public static final String I18N_YAXIS_LABEL = | 21 public static final String I18N_YAXIS_LABEL = |
33 "chart.sedimentload.ls.yaxis.label.tpera"; | 22 "chart.sedimentload.ls.yaxis.label.tpera"; |
34 public static final String I18N_YAXIS_LABEL_DEFAULT = "[t/a]"; | 23 public static final String I18N_YAXIS_LABEL_DEFAULT = "[t/a]"; |
35 | |
36 @Override | |
37 public void doOut( | |
38 DiagramGenerator generator, | |
39 ArtifactAndFacet bundle, | |
40 ThemeDocument theme, | |
41 boolean visible) { | |
42 logger.debug("doOut " + bundle.getFacetName()); | |
43 CallContext context = generator.getCallContext(); | |
44 XYSeries series = new StyledXYSeries(bundle.getFacetDescription(), | |
45 theme); | |
46 Object data = bundle.getData(context); | |
47 String facetName = bundle.getFacetName(); | |
48 double [][] points; | |
49 | |
50 if (FacetTypes.IS.SEDIMENT_LOAD_TA(facetName)) { | |
51 points = (double[][]) data; | |
52 } else if (FacetTypes.IS.SEDIMENT_LOAD_UNKNOWN(facetName)) { | |
53 SedimentLoad load = (SedimentLoad) data; | |
54 Set<Double> kms = load.getKms(); | |
55 points = new double[2][kms.size()]; | |
56 int counter = 0; | |
57 for (Double km: kms) { | |
58 SedimentLoadFraction fraction = load.getFraction(km); | |
59 points[0][counter] = km; | |
60 points[1][counter] = fraction.getUnknown(); | |
61 counter++; | |
62 } | |
63 } else { | |
64 logger.error("Unknown facet name: " + facetName); | |
65 return; | |
66 } | |
67 | |
68 StyledSeriesBuilder.addPoints(series, points, true); | |
69 | |
70 generator.addAxisSeries(series, axisName, visible); | |
71 } | |
72 | 24 |
73 @Override | 25 @Override |
74 public boolean canHandle(String facettype) { | 26 public boolean canHandle(String facettype) { |
75 return FacetTypes.IS.SEDIMENT_LOAD_TA(facettype) || | 27 return FacetTypes.IS.SEDIMENT_LOAD_TA(facettype) || |
76 FacetTypes.SEDIMENT_LOAD_TA_UNKNOWN.equals(facettype); | 28 FacetTypes.SEDIMENT_LOAD_TA_UNKNOWN.equals(facettype); |