comparison 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
comparison
equal deleted inserted replaced
7154:e7690ed60b4c 7155:34b5e7ef2a36
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.List;
12 import java.util.Set;
13
14 import org.apache.log4j.Logger;
15 import org.jfree.data.xy.XYSeries;
16 import org.dive4elements.river.artifacts.D4EArtifact;
17
18 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
19 import org.dive4elements.artifacts.CallContext;
20 import org.dive4elements.river.artifacts.access.SedimentLoadAccess;
21 import org.dive4elements.river.artifacts.model.FacetTypes;
22 import org.dive4elements.river.exports.DiagramGenerator;
23 import org.dive4elements.river.exports.StyledSeriesBuilder;
24 import org.dive4elements.river.jfree.StyledXYSeries;
25 import org.dive4elements.river.themes.ThemeDocument;
26
27 import org.dive4elements.river.artifacts.model.FlowVelocityData;
28
29 public class FlowVelocityProcessor extends DefaultProcessor {
30
31 private final static Logger logger =
32 Logger.getLogger(FlowVelocityProcessor.class);
33
34 public static final String I18N_AXIS_LABEL =
35 "chart.flow_velocity.section.yaxis.label";
36 public static final String I18N_AXIS_LABEL_DEFAULT =
37 "Geschwindigkeit v [m/s]";
38
39 @Override
40 public void doOut(
41 DiagramGenerator generator,
42 ArtifactAndFacet bundle,
43 ThemeDocument theme,
44 boolean visible) {
45 CallContext context = generator.getCallContext();
46 XYSeries series = new StyledXYSeries(bundle.getFacetDescription(),
47 theme);
48 FlowVelocityData data = (FlowVelocityData) bundle.getData(context);
49 if (data == null) {
50 /* Check was there in the old generator */
51 logger.error("Flow velocity data is null. Bad facet.");
52 return;
53 }
54 String facetName = bundle.getFacetName();
55 double [][] points;
56
57 if (facetName.equals(FacetTypes.FLOW_VELOCITY_TOTALCHANNEL) ||
58 facetName.equals(FacetTypes.FLOW_VELOCITY_TOTALCHANNEL_FILTERED)) {
59 points = data.getTotalChannelPoints();
60 } else if (facetName.equals(FacetTypes.FLOW_VELOCITY_MAINCHANNEL) ||
61 facetName.equals(FacetTypes.FLOW_VELOCITY_MAINCHANNEL_FILTERED)) {
62 points = data.getMainChannelPoints(); // I hate facets!
63 } else {
64 logger.error("Unknown facet name: " + facetName);
65 return;
66 }
67 StyledSeriesBuilder.addPoints(series, points, true);
68
69 generator.addAxisSeries(series, axisName, visible);
70 }
71
72 @Override
73 public boolean canHandle(String facettype) {
74 return facettype.equals(FacetTypes.FLOW_VELOCITY_MAINCHANNEL_FILTERED) ||
75 facettype.equals(FacetTypes.FLOW_VELOCITY_MAINCHANNEL) ||
76 facettype.equals(FacetTypes.FLOW_VELOCITY_TOTALCHANNEL_FILTERED) ||
77 facettype.equals(FacetTypes.FLOW_VELOCITY_TOTALCHANNEL);
78 }
79
80 @Override
81 public String getAxisLabel(DiagramGenerator generator) {
82 return generator.msg(
83 I18N_AXIS_LABEL,
84 I18N_AXIS_LABEL_DEFAULT);
85 }
86 }

http://dive4elements.wald.intevation.org