annotate artifacts/src/main/java/org/dive4elements/river/exports/process/SedimentLoadM3AProcessor.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
children e97867879a45
rev   line source
7503
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
1 /* Copyright (C) 2013 by Bundesanstalt für Gewässerkunde
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
2 * Software engineering by Intevation GmbH
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
3 *
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
4 * This file is Free Software under the GNU AGPL (>=v3)
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
6 * documentation coming with Dive4Elements River for details.
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
7 */
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
8
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
9 package org.dive4elements.river.exports.process;
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
10
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
11 import java.util.Set;
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
12
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
13 import org.apache.log4j.Logger;
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
14 import org.jfree.data.xy.XYSeries;
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
15 import org.dive4elements.river.artifacts.D4EArtifact;
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
16
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
17 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
18 import org.dive4elements.artifacts.CallContext;
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
19 import org.dive4elements.river.artifacts.access.SedimentLoadAccess;
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
20 import org.dive4elements.river.artifacts.model.FacetTypes;
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
21 import org.dive4elements.river.exports.DiagramGenerator;
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
22 import org.dive4elements.river.exports.StyledSeriesBuilder;
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
23 import org.dive4elements.river.jfree.StyledXYSeries;
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
24 import org.dive4elements.river.themes.ThemeDocument;
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
25
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
26 import org.dive4elements.river.artifacts.model.minfo.SedimentLoad;
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
27 import org.dive4elements.river.artifacts.model.minfo.SedimentLoadFraction;
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
28
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
29 public class SedimentLoadM3AProcessor extends DefaultProcessor {
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
30
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
31 private final static Logger logger =
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
32 Logger.getLogger(SedimentLoadM3AProcessor.class);
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
33
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
34 public static final String I18N_YAXIS_LABEL =
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
35 "chart.sedimentload.ls.yaxis.label.m3pera";
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
36 public static final String I18N_YAXIS_LABEL_DEFAULT = "[m\u00b3/a]";
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
37
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
38 @Override
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
39 public void doOut(
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
40 DiagramGenerator generator,
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
41 ArtifactAndFacet bundle,
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
42 ThemeDocument theme,
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
43 boolean visible) {
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
44 logger.debug("doOut " + bundle.getFacetName());
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
45 CallContext context = generator.getCallContext();
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
46 XYSeries series = new StyledXYSeries(bundle.getFacetDescription(),
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
47 theme);
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
48 Object data = bundle.getData(context);
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
49 String facetName = bundle.getFacetName();
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
50 double [][] points;
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
51
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
52 if (FacetTypes.IS.SEDIMENT_LOAD_M3A(facetName)) {
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
53 points = (double[][]) data;
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
54 } else if (FacetTypes.IS.SEDIMENT_LOAD_UNKNOWN(facetName)) {
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
55 SedimentLoad load = (SedimentLoad) data;
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
56 Set<Double> kms = load.getKms();
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
57 points = new double[2][kms.size()];
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
58 int counter = 0;
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
59 for (Double km: kms) {
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
60 SedimentLoadFraction fraction = load.getFraction(km);
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
61 points[0][counter] = km;
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
62 points[1][counter] = fraction.getUnknown();
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
63 counter++;
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
64 }
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
65 } else {
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
66 logger.error("Unknown facet name: " + facetName);
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
67 return;
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
68 }
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
69
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
70 StyledSeriesBuilder.addPoints(series, points, true);
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
71
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
72 generator.addAxisSeries(series, axisName, visible);
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
73 }
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
74
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
75 @Override
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
76 public boolean canHandle(String facettype) {
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
77 return FacetTypes.IS.SEDIMENT_LOAD_M3A(facettype) ||
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
78 FacetTypes.SEDIMENT_LOAD_M3A_UNKNOWN.equals(facettype);
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
79 }
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
80
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
81 @Override
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
82 public String getAxisLabel(DiagramGenerator generator) {
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
83 return generator.msg(I18N_YAXIS_LABEL, I18N_YAXIS_LABEL_DEFAULT);
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
84 }
e11bf92bca4a issue1658: New Processors for t/a and m^3/a -axis (stripped down from SedimentLoadProcessor).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
85 }

http://dive4elements.wald.intevation.org