Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/exports/process/BedWidthProcessor.java @ 7713:dfe3f78fd3e5
(issue1622) Paint W Differences on diffW Axis
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Thu, 19 Dec 2013 18:36:00 +0100 |
parents | 4374a8d26706 |
children | 8faa8cfd2385 |
rev | line source |
---|---|
7145
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
2 * Software engineering by Intevation GmbH |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
3 * |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
4 * This file is Free Software under the GNU AGPL (>=v3) |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
6 * documentation coming with Dive4Elements River for details. |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
7 */ |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
8 |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
9 package org.dive4elements.river.exports.process; |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
10 |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
11 import org.apache.log4j.Logger; |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
12 import org.jfree.data.xy.XYSeries; |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
13 |
7689
4374a8d26706
(issue1225) Unify "Width" processor
Andre Heinecke <aheinecke@intevation.de>
parents:
7159
diff
changeset
|
14 import java.util.List; |
4374a8d26706
(issue1225) Unify "Width" processor
Andre Heinecke <aheinecke@intevation.de>
parents:
7159
diff
changeset
|
15 |
7145
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
16 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
17 import org.dive4elements.artifacts.CallContext; |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
18 import org.dive4elements.river.artifacts.model.FacetTypes; |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
19 import org.dive4elements.river.exports.DiagramGenerator; |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
20 import org.dive4elements.river.exports.StyledSeriesBuilder; |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
21 import org.dive4elements.river.jfree.StyledXYSeries; |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
22 import org.dive4elements.river.themes.ThemeDocument; |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
23 |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
24 import org.dive4elements.river.artifacts.model.minfo.BedDiffYearResult; |
7689
4374a8d26706
(issue1225) Unify "Width" processor
Andre Heinecke <aheinecke@intevation.de>
parents:
7159
diff
changeset
|
25 import org.dive4elements.river.model.BedHeightSingleValue; |
4374a8d26706
(issue1225) Unify "Width" processor
Andre Heinecke <aheinecke@intevation.de>
parents:
7159
diff
changeset
|
26 import org.dive4elements.river.artifacts.model.minfo.BedHeightSingleData; |
4374a8d26706
(issue1225) Unify "Width" processor
Andre Heinecke <aheinecke@intevation.de>
parents:
7159
diff
changeset
|
27 |
7145
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
28 import org.dive4elements.river.artifacts.model.minfo.MorphologicWidth; |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
29 |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
30 public class BedWidthProcessor extends DefaultProcessor { |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
31 |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
32 private final static Logger logger = |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
33 Logger.getLogger(BedWidthProcessor.class); |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
34 |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
35 public static final String I18N_AXIS_LABEL_DEFAULT = |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
36 "Breite [m]"; |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
37 public static final String I18N_AXIS_LABEL = |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
38 "chart.beddifference.yaxis.label.morph"; |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
39 |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
40 @Override |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
41 public void doOut( |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
42 DiagramGenerator generator, |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
43 ArtifactAndFacet bundle, |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
44 ThemeDocument theme, |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
45 boolean visible) { |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
46 CallContext context = generator.getCallContext(); |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
47 XYSeries series = new StyledXYSeries(bundle.getFacetDescription(), |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
48 theme); |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
49 Object data = bundle.getData(context); |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
50 |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
51 if (data instanceof BedDiffYearResult) { |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
52 BedDiffYearResult bData = (BedDiffYearResult) data; |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
53 StyledSeriesBuilder.addPoints(series, bData.getMorphWidthData(), true); |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
54 } else if (data instanceof MorphologicWidth) { |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
55 MorphologicWidth bData = (MorphologicWidth) data; |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
56 StyledSeriesBuilder.addPoints(series, bData.getAsArray(), true); |
7689
4374a8d26706
(issue1225) Unify "Width" processor
Andre Heinecke <aheinecke@intevation.de>
parents:
7159
diff
changeset
|
57 } else if (data instanceof BedHeightSingleData) { |
4374a8d26706
(issue1225) Unify "Width" processor
Andre Heinecke <aheinecke@intevation.de>
parents:
7159
diff
changeset
|
58 BedHeightSingleData bData = (BedHeightSingleData)data; |
4374a8d26706
(issue1225) Unify "Width" processor
Andre Heinecke <aheinecke@intevation.de>
parents:
7159
diff
changeset
|
59 double[] width = bData.getMorphWidths(); |
4374a8d26706
(issue1225) Unify "Width" processor
Andre Heinecke <aheinecke@intevation.de>
parents:
7159
diff
changeset
|
60 double[] stations = bData.getStations().toNativeArray(); |
4374a8d26706
(issue1225) Unify "Width" processor
Andre Heinecke <aheinecke@intevation.de>
parents:
7159
diff
changeset
|
61 |
4374a8d26706
(issue1225) Unify "Width" processor
Andre Heinecke <aheinecke@intevation.de>
parents:
7159
diff
changeset
|
62 for (int i = 0; i < width.length; i++) { |
4374a8d26706
(issue1225) Unify "Width" processor
Andre Heinecke <aheinecke@intevation.de>
parents:
7159
diff
changeset
|
63 series.add(stations[i], width[i], false); |
4374a8d26706
(issue1225) Unify "Width" processor
Andre Heinecke <aheinecke@intevation.de>
parents:
7159
diff
changeset
|
64 } |
4374a8d26706
(issue1225) Unify "Width" processor
Andre Heinecke <aheinecke@intevation.de>
parents:
7159
diff
changeset
|
65 } else if (data instanceof List<?>) { |
4374a8d26706
(issue1225) Unify "Width" processor
Andre Heinecke <aheinecke@intevation.de>
parents:
7159
diff
changeset
|
66 List<BedHeightSingleValue> bData = (List<BedHeightSingleValue>)data; |
4374a8d26706
(issue1225) Unify "Width" processor
Andre Heinecke <aheinecke@intevation.de>
parents:
7159
diff
changeset
|
67 |
4374a8d26706
(issue1225) Unify "Width" processor
Andre Heinecke <aheinecke@intevation.de>
parents:
7159
diff
changeset
|
68 for(BedHeightSingleValue bvalue: bData) { |
4374a8d26706
(issue1225) Unify "Width" processor
Andre Heinecke <aheinecke@intevation.de>
parents:
7159
diff
changeset
|
69 series.add(bvalue.getStation(), bvalue.getSoundingWidth()); |
4374a8d26706
(issue1225) Unify "Width" processor
Andre Heinecke <aheinecke@intevation.de>
parents:
7159
diff
changeset
|
70 } |
7148
cde7db30847f
Add BedQuality Processors
Andre Heinecke <aheinecke@intevation.de>
parents:
7145
diff
changeset
|
71 } else { |
cde7db30847f
Add BedQuality Processors
Andre Heinecke <aheinecke@intevation.de>
parents:
7145
diff
changeset
|
72 logger.error("Unknown data for facet: " + bundle.getFacetName()); |
7145
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
73 } |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
74 |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
75 generator.addAxisSeries(series, axisName, visible); |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
76 } |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
77 |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
78 @Override |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
79 public boolean canHandle(String facettype) { |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
80 return facettype.equals(FacetTypes.BED_DIFFERENCE_MORPH_WIDTH) || |
7689
4374a8d26706
(issue1225) Unify "Width" processor
Andre Heinecke <aheinecke@intevation.de>
parents:
7159
diff
changeset
|
81 facettype.equals(FacetTypes.MORPHOLOGIC_WIDTH) || |
4374a8d26706
(issue1225) Unify "Width" processor
Andre Heinecke <aheinecke@intevation.de>
parents:
7159
diff
changeset
|
82 facettype.equals(FacetTypes.BEDHEIGHT_SOUNDING_WIDTH); |
7145
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
83 } |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
84 |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
85 @Override |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
86 public String getAxisLabel(DiagramGenerator generator) { |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
87 return generator.msg( |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
88 I18N_AXIS_LABEL, |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
89 I18N_AXIS_LABEL_DEFAULT); |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
90 } |
432047ee5b4b
Add BedWidthProcessor to handle width facets
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
91 } |