annotate artifacts/src/main/java/org/dive4elements/river/exports/process/FlowVelocityProcessor.java @ 7155:34b5e7ef2a36

Add FlowVelocity Processor
author Andre Heinecke <aheinecke@intevation.de>
date Wed, 25 Sep 2013 18:04:14 +0200
parents
children 1508ee33f85f
rev   line source
7155
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
1 /* Copyright (C) 2013 by Bundesanstalt für Gewässerkunde
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
2 * Software engineering by Intevation GmbH
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
3 *
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
4 * This file is Free Software under the GNU AGPL (>=v3)
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
6 * documentation coming with Dive4Elements River for details.
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
7 */
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
8
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
9 package org.dive4elements.river.exports.process;
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
10
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
11 import java.util.List;
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
12 import java.util.Set;
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
13
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
14 import org.apache.log4j.Logger;
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
15 import org.jfree.data.xy.XYSeries;
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
16 import org.dive4elements.river.artifacts.D4EArtifact;
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
17
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
18 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
19 import org.dive4elements.artifacts.CallContext;
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
20 import org.dive4elements.river.artifacts.access.SedimentLoadAccess;
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
21 import org.dive4elements.river.artifacts.model.FacetTypes;
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
22 import org.dive4elements.river.exports.DiagramGenerator;
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
23 import org.dive4elements.river.exports.StyledSeriesBuilder;
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
24 import org.dive4elements.river.jfree.StyledXYSeries;
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
25 import org.dive4elements.river.themes.ThemeDocument;
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
26
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
27 import org.dive4elements.river.artifacts.model.FlowVelocityData;
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
28
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
29 public class FlowVelocityProcessor extends DefaultProcessor {
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
30
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
31 private final static Logger logger =
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
32 Logger.getLogger(FlowVelocityProcessor.class);
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
33
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
34 public static final String I18N_AXIS_LABEL =
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
35 "chart.flow_velocity.section.yaxis.label";
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
36 public static final String I18N_AXIS_LABEL_DEFAULT =
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
37 "Geschwindigkeit v [m/s]";
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
38
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
39 @Override
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
40 public void doOut(
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
41 DiagramGenerator generator,
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
42 ArtifactAndFacet bundle,
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
43 ThemeDocument theme,
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
44 boolean visible) {
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
45 CallContext context = generator.getCallContext();
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
46 XYSeries series = new StyledXYSeries(bundle.getFacetDescription(),
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
47 theme);
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
48 FlowVelocityData data = (FlowVelocityData) bundle.getData(context);
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
49 if (data == null) {
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
50 /* Check was there in the old generator */
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
51 logger.error("Flow velocity data is null. Bad facet.");
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
52 return;
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
53 }
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
54 String facetName = bundle.getFacetName();
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
55 double [][] points;
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
56
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
57 if (facetName.equals(FacetTypes.FLOW_VELOCITY_TOTALCHANNEL) ||
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
58 facetName.equals(FacetTypes.FLOW_VELOCITY_TOTALCHANNEL_FILTERED)) {
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
59 points = data.getTotalChannelPoints();
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
60 } else if (facetName.equals(FacetTypes.FLOW_VELOCITY_MAINCHANNEL) ||
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
61 facetName.equals(FacetTypes.FLOW_VELOCITY_MAINCHANNEL_FILTERED)) {
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
62 points = data.getMainChannelPoints(); // I hate facets!
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
63 } else {
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
64 logger.error("Unknown facet name: " + facetName);
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
65 return;
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
66 }
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
67 StyledSeriesBuilder.addPoints(series, points, true);
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
68
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
69 generator.addAxisSeries(series, axisName, visible);
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
70 }
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
71
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
72 @Override
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
73 public boolean canHandle(String facettype) {
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
74 return facettype.equals(FacetTypes.FLOW_VELOCITY_MAINCHANNEL_FILTERED) ||
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
75 facettype.equals(FacetTypes.FLOW_VELOCITY_MAINCHANNEL) ||
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
76 facettype.equals(FacetTypes.FLOW_VELOCITY_TOTALCHANNEL_FILTERED) ||
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
77 facettype.equals(FacetTypes.FLOW_VELOCITY_TOTALCHANNEL);
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
78 }
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
79
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
80 @Override
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
81 public String getAxisLabel(DiagramGenerator generator) {
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
82 return generator.msg(
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
83 I18N_AXIS_LABEL,
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
84 I18N_AXIS_LABEL_DEFAULT);
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
85 }
34b5e7ef2a36 Add FlowVelocity Processor
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
86 }

http://dive4elements.wald.intevation.org