Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/exports/process/SedimentLoadTAProcessor.java @ 7503:e11bf92bca4a
issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Fri, 01 Nov 2013 16:30:52 +0100 |
parents | artifacts/src/main/java/org/dive4elements/river/exports/process/SedimentLoadProcessor.java@4c8ce0c41dc2 |
children | e97867879a45 |
comparison
equal
deleted
inserted
replaced
7502:f2d97537f48a | 7503:e11bf92bca4a |
---|---|
1 /* Copyright (C) 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.Set; | |
12 | |
13 import org.apache.log4j.Logger; | |
14 import org.jfree.data.xy.XYSeries; | |
15 import org.dive4elements.river.artifacts.D4EArtifact; | |
16 | |
17 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; | |
18 import org.dive4elements.artifacts.CallContext; | |
19 import org.dive4elements.river.artifacts.access.SedimentLoadAccess; | |
20 import org.dive4elements.river.artifacts.model.FacetTypes; | |
21 import org.dive4elements.river.exports.DiagramGenerator; | |
22 import org.dive4elements.river.exports.StyledSeriesBuilder; | |
23 import org.dive4elements.river.jfree.StyledXYSeries; | |
24 import org.dive4elements.river.themes.ThemeDocument; | |
25 | |
26 import org.dive4elements.river.artifacts.model.minfo.SedimentLoad; | |
27 import org.dive4elements.river.artifacts.model.minfo.SedimentLoadFraction; | |
28 | |
29 public class SedimentLoadTAProcessor extends DefaultProcessor { | |
30 | |
31 private final static Logger logger = | |
32 Logger.getLogger(SedimentLoadTAProcessor.class); | |
33 | |
34 public static final String I18N_YAXIS_LABEL = | |
35 "chart.sedimentload.ls.yaxis.label.tpera"; | |
36 public static final String I18N_YAXIS_LABEL_DEFAULT = "[t/a]"; | |
37 | |
38 @Override | |
39 public void doOut( | |
40 DiagramGenerator generator, | |
41 ArtifactAndFacet bundle, | |
42 ThemeDocument theme, | |
43 boolean visible) { | |
44 logger.debug("doOut " + bundle.getFacetName()); | |
45 CallContext context = generator.getCallContext(); | |
46 XYSeries series = new StyledXYSeries(bundle.getFacetDescription(), | |
47 theme); | |
48 Object data = bundle.getData(context); | |
49 String facetName = bundle.getFacetName(); | |
50 double [][] points; | |
51 | |
52 if (FacetTypes.IS.SEDIMENT_LOAD_TA(facetName)) { | |
53 points = (double[][]) data; | |
54 } else if (FacetTypes.IS.SEDIMENT_LOAD_UNKNOWN(facetName)) { | |
55 SedimentLoad load = (SedimentLoad) data; | |
56 Set<Double> kms = load.getKms(); | |
57 points = new double[2][kms.size()]; | |
58 int counter = 0; | |
59 for (Double km: kms) { | |
60 SedimentLoadFraction fraction = load.getFraction(km); | |
61 points[0][counter] = km; | |
62 points[1][counter] = fraction.getUnknown(); | |
63 counter++; | |
64 } | |
65 } else { | |
66 logger.error("Unknown facet name: " + facetName); | |
67 return; | |
68 } | |
69 | |
70 StyledSeriesBuilder.addPoints(series, points, true); | |
71 | |
72 generator.addAxisSeries(series, axisName, visible); | |
73 } | |
74 | |
75 @Override | |
76 public boolean canHandle(String facettype) { | |
77 return FacetTypes.IS.SEDIMENT_LOAD_TA(facettype) || | |
78 FacetTypes.SEDIMENT_LOAD_TA_UNKNOWN.equals(facettype); | |
79 } | |
80 | |
81 @Override | |
82 public String getAxisLabel(DiagramGenerator generator) { | |
83 return generator.msg(I18N_YAXIS_LABEL, I18N_YAXIS_LABEL_DEFAULT); | |
84 } | |
85 } |