Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstDepthProcessor.java @ 9444:ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
author | mschaefer |
---|---|
date | Tue, 21 Aug 2018 13:41:18 +0200 |
parents | d194c5b24bf8 |
children | 3fa8551c3d1b |
comparison
equal
deleted
inserted
replaced
9443:515643b2c49a | 9444:ecadc9ed0ba0 |
---|---|
20 import org.dive4elements.river.artifacts.common.AbstractProcessor; | 20 import org.dive4elements.river.artifacts.common.AbstractProcessor; |
21 import org.dive4elements.river.artifacts.common.AbstractResultType; | 21 import org.dive4elements.river.artifacts.common.AbstractResultType; |
22 import org.dive4elements.river.artifacts.resources.Resources; | 22 import org.dive4elements.river.artifacts.resources.Resources; |
23 import org.dive4elements.river.artifacts.sinfo.common.SInfoResultType; | 23 import org.dive4elements.river.artifacts.sinfo.common.SInfoResultType; |
24 import org.dive4elements.river.exports.DiagramGenerator; | 24 import org.dive4elements.river.exports.DiagramGenerator; |
25 import org.dive4elements.river.model.BedHeightValueType; | |
25 import org.dive4elements.river.themes.ThemeDocument; | 26 import org.dive4elements.river.themes.ThemeDocument; |
26 | 27 |
27 /** | 28 /** |
28 * Processor to generate the facets and data series of a bundu bezugswst depth longitudinal section | 29 * Processor to generate the facets and data series of a bundu bezugswst depth longitudinal section |
29 * | 30 * |
38 | 39 |
39 public static final String FACET_CHANNELDEPTH = "bundu_facet_channeldepth"; | 40 public static final String FACET_CHANNELDEPTH = "bundu_facet_channeldepth"; |
40 | 41 |
41 private static final String FACET_CHANNELDEPTH_DESCRIPTION = "bundu_facet_channeldepth.description"; | 42 private static final String FACET_CHANNELDEPTH_DESCRIPTION = "bundu_facet_channeldepth.description"; |
42 | 43 |
44 public static final String FACET_FIELD_DEPTH_PREFIX = "bundu_facet_depth_"; | |
45 | |
46 private static final String FACET_FIELD_DEPTH_FORMAT = FACET_FIELD_DEPTH_PREFIX + "%02d.filtered"; | |
47 | |
48 private static final String FACET_FIELD_DEPTH_DESCRIPTION = "bundu_facet_field_depth.description"; | |
49 | |
43 private static final String AXIS_LABEL = "sinfo.chart.flow_depth.section.yaxis.label"; | 50 private static final String AXIS_LABEL = "sinfo.chart.flow_depth.section.yaxis.label"; |
44 | 51 |
45 private static final Set<String> HANDLED_FACET_TYPES = new HashSet<>(); | 52 private static final Set<String> HANDLED_FACET_TYPES = new HashSet<>(); |
46 | 53 |
47 static { | 54 static { |
48 HANDLED_FACET_TYPES.add(FACET_FLOWDEPTH_FILTERED); | 55 HANDLED_FACET_TYPES.add(FACET_FLOWDEPTH_FILTERED); |
49 HANDLED_FACET_TYPES.add(FACET_CHANNELDEPTH); | 56 HANDLED_FACET_TYPES.add(FACET_CHANNELDEPTH); |
57 for (int i = BedHeightValueType.FIELD_FIRST_INDEX; i <= BedHeightValueType.FIELD_LAST_INDEX; i++) | |
58 HANDLED_FACET_TYPES.add(String.format(FACET_FIELD_DEPTH_FORMAT, i)); | |
50 } | 59 } |
51 | 60 |
52 public BezugswstDepthProcessor() { | 61 public BezugswstDepthProcessor() { |
53 super(AXIS_LABEL, HANDLED_FACET_TYPES); | 62 super(AXIS_LABEL, HANDLED_FACET_TYPES); |
54 } | 63 } |
65 | 74 |
66 final String description = Resources.getMsg(context.getMeta(), FACET_CHANNELDEPTH_DESCRIPTION, FACET_CHANNELDEPTH_DESCRIPTION); | 75 final String description = Resources.getMsg(context.getMeta(), FACET_CHANNELDEPTH_DESCRIPTION, FACET_CHANNELDEPTH_DESCRIPTION); |
67 return new BezugswstResultFacet(facetIndex, resultIndex, FACET_CHANNELDEPTH, description, AXIS_LABEL, id, hash); | 76 return new BezugswstResultFacet(facetIndex, resultIndex, FACET_CHANNELDEPTH, description, AXIS_LABEL, id, hash); |
68 } | 77 } |
69 | 78 |
79 public static Facet createFieldDepthFacet(final CallContext context, final String hash, final String id, final int facetIndex, | |
80 final int resultIndex, final int fieldIndex) { | |
81 | |
82 final String description = Resources.getMsg(context.getMeta(), FACET_FIELD_DEPTH_DESCRIPTION, FACET_FIELD_DEPTH_DESCRIPTION, fieldIndex); | |
83 final String facetName = String.format(FACET_FIELD_DEPTH_FORMAT, fieldIndex); | |
84 return new BezugswstResultFacet(facetIndex, resultIndex, facetName, description, AXIS_LABEL, id, hash); | |
85 } | |
86 | |
70 @Override | 87 @Override |
71 protected String generateSeries(final DiagramGenerator generator, final ArtifactAndFacet bundle, final ThemeDocument theme, final boolean visible) { | 88 protected String generateSeries(final DiagramGenerator generator, final ArtifactAndFacet bundle, final ThemeDocument theme, final boolean visible) { |
72 | 89 |
73 return buildSeriesForType(generator, bundle, theme, visible, doGetType(bundle.getFacetName()), GAP_DISTANCE); | 90 if (bundle.getFacetName().startsWith(FACET_FIELD_DEPTH_PREFIX)) { |
91 final int fieldIndex = Integer.parseInt(bundle.getFacetName().substring(FACET_FIELD_DEPTH_PREFIX.length(), FACET_FIELD_DEPTH_PREFIX.length() + 2)); | |
92 return generateFieldDepthSeries(generator, bundle, theme, visible, fieldIndex); | |
93 } | |
94 | |
95 return buildSeriesForType(generator, bundle, theme, visible, doGetType(bundle.getFacetName()), null); | |
74 } | 96 } |
75 | 97 |
76 protected AbstractResultType doGetType(final String facetName) { | 98 protected AbstractResultType doGetType(final String facetName) { |
77 | 99 |
78 if (FACET_FLOWDEPTH_FILTERED.contentEquals(facetName)) | 100 if (FACET_FLOWDEPTH_FILTERED.contentEquals(facetName)) |
81 return BunduResultType.channelDepth; | 103 return BunduResultType.channelDepth; |
82 | 104 |
83 final String error = String.format("Unknown facet name: %s", facetName); | 105 final String error = String.format("Unknown facet name: %s", facetName); |
84 throw new UnsupportedOperationException(error); | 106 throw new UnsupportedOperationException(error); |
85 } | 107 } |
108 | |
109 private final String generateFieldDepthSeries(final DiagramGenerator generator, final ArtifactAndFacet bundle, final ThemeDocument theme, | |
110 final boolean visible, final int fieldIndex) { | |
111 | |
112 final BezugswstMainCalculationResult data = (BezugswstMainCalculationResult) getResult(generator, bundle); | |
113 final double[][] points = data.getFieldValuePoints(fieldIndex, BunduResultType.depthFields); | |
114 | |
115 return buildSeriesForPoints(points, generator, bundle, theme, visible, null); | |
116 } | |
86 } | 117 } |