Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/exports/process/FlowVelocityProcessor.java @ 7162:4683bdf77ff9
Handle flow velocity measurements in the FlowVelocity processor
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Thu, 26 Sep 2013 10:38:21 +0200 |
parents | 1508ee33f85f |
children | 440c55b9634e |
comparison
equal
deleted
inserted
replaced
7161:b7b839557282 | 7162:4683bdf77ff9 |
---|---|
16 import org.dive4elements.river.artifacts.model.FacetTypes; | 16 import org.dive4elements.river.artifacts.model.FacetTypes; |
17 import org.dive4elements.river.exports.DiagramGenerator; | 17 import org.dive4elements.river.exports.DiagramGenerator; |
18 import org.dive4elements.river.exports.StyledSeriesBuilder; | 18 import org.dive4elements.river.exports.StyledSeriesBuilder; |
19 import org.dive4elements.river.jfree.StyledXYSeries; | 19 import org.dive4elements.river.jfree.StyledXYSeries; |
20 import org.dive4elements.river.themes.ThemeDocument; | 20 import org.dive4elements.river.themes.ThemeDocument; |
21 import org.dive4elements.river.model.FlowVelocityMeasurementValue.FastFlowVelocityMeasurementValue; | |
21 | 22 |
22 import org.dive4elements.river.artifacts.model.FlowVelocityData; | 23 import org.dive4elements.river.artifacts.model.FlowVelocityData; |
23 | 24 |
24 public class FlowVelocityProcessor extends DefaultProcessor { | 25 public class FlowVelocityProcessor extends DefaultProcessor { |
25 | 26 |
38 ThemeDocument theme, | 39 ThemeDocument theme, |
39 boolean visible) { | 40 boolean visible) { |
40 CallContext context = generator.getCallContext(); | 41 CallContext context = generator.getCallContext(); |
41 XYSeries series = new StyledXYSeries(bundle.getFacetDescription(), | 42 XYSeries series = new StyledXYSeries(bundle.getFacetDescription(), |
42 theme); | 43 theme); |
43 FlowVelocityData data = (FlowVelocityData) bundle.getData(context); | 44 String facetName = bundle.getFacetName(); |
45 Object data = bundle.getData(context); | |
44 if (data == null) { | 46 if (data == null) { |
45 /* Check was there in the old generator */ | 47 // Check has been here before so we keep it for security reasons |
46 logger.error("Flow velocity data is null. Bad facet."); | 48 // this should never happen though. |
49 logger.error("Data is null for facet: " + facetName); | |
47 return; | 50 return; |
48 } | 51 } |
49 String facetName = bundle.getFacetName(); | |
50 double [][] points; | 52 double [][] points; |
51 | 53 |
52 if (facetName.equals(FacetTypes.FLOW_VELOCITY_TOTALCHANNEL) || | 54 if (facetName.equals(FacetTypes.FLOW_VELOCITY_TOTALCHANNEL) || |
53 facetName.equals(FacetTypes.FLOW_VELOCITY_TOTALCHANNEL_FILTERED)) { | 55 facetName.equals(FacetTypes.FLOW_VELOCITY_TOTALCHANNEL_FILTERED)) { |
54 points = data.getTotalChannelPoints(); | 56 FlowVelocityData fData = (FlowVelocityData) data; |
57 points = fData.getTotalChannelPoints(); | |
55 } else if (facetName.equals(FacetTypes.FLOW_VELOCITY_MAINCHANNEL) || | 58 } else if (facetName.equals(FacetTypes.FLOW_VELOCITY_MAINCHANNEL) || |
56 facetName.equals(FacetTypes.FLOW_VELOCITY_MAINCHANNEL_FILTERED)) { | 59 facetName.equals(FacetTypes.FLOW_VELOCITY_MAINCHANNEL_FILTERED)) { |
57 points = data.getMainChannelPoints(); // I hate facets! | 60 FlowVelocityData fData = (FlowVelocityData) data; |
61 points = fData.getMainChannelPoints(); // I hate facets! | |
62 } else if (facetName.equals(FacetTypes.FLOW_VELOCITY_MEASUREMENT)) { | |
63 FastFlowVelocityMeasurementValue fData = | |
64 (FastFlowVelocityMeasurementValue) data; | |
65 points = new double[][] {{fData.getStation()},{fData.getV()}}; | |
58 } else { | 66 } else { |
59 logger.error("Unknown facet name: " + facetName); | 67 logger.error("Unknown facet name: " + facetName); |
60 return; | 68 return; |
61 } | 69 } |
62 StyledSeriesBuilder.addPoints(series, points, true); | 70 StyledSeriesBuilder.addPoints(series, points, true); |
67 @Override | 75 @Override |
68 public boolean canHandle(String facettype) { | 76 public boolean canHandle(String facettype) { |
69 return facettype.equals(FacetTypes.FLOW_VELOCITY_MAINCHANNEL_FILTERED) || | 77 return facettype.equals(FacetTypes.FLOW_VELOCITY_MAINCHANNEL_FILTERED) || |
70 facettype.equals(FacetTypes.FLOW_VELOCITY_MAINCHANNEL) || | 78 facettype.equals(FacetTypes.FLOW_VELOCITY_MAINCHANNEL) || |
71 facettype.equals(FacetTypes.FLOW_VELOCITY_TOTALCHANNEL_FILTERED) || | 79 facettype.equals(FacetTypes.FLOW_VELOCITY_TOTALCHANNEL_FILTERED) || |
72 facettype.equals(FacetTypes.FLOW_VELOCITY_TOTALCHANNEL); | 80 facettype.equals(FacetTypes.FLOW_VELOCITY_TOTALCHANNEL) || |
81 facettype.equals(FacetTypes.FLOW_VELOCITY_MEASUREMENT); | |
73 } | 82 } |
74 | 83 |
75 @Override | 84 @Override |
76 public String getAxisLabel(DiagramGenerator generator) { | 85 public String getAxisLabel(DiagramGenerator generator) { |
77 return generator.msg( | 86 return generator.msg( |