Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/PredefinedChannelDepthProcessor.java @ 9112:189cc8ededbd
Added datacage select and chart display for river channel sizes loaded from database
author | mschaefer |
---|---|
date | Mon, 04 Jun 2018 08:36:09 +0200 |
parents | |
children | 1cc7653ca84f |
comparison
equal
deleted
inserted
replaced
9111:ee77e544e890 | 9112:189cc8ededbd |
---|---|
1 /** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde | |
2 * Software engineering by | |
3 * Björnsen Beratende Ingenieure GmbH | |
4 * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt | |
5 * | |
6 * This file is Free Software under the GNU AGPL (>=v3) | |
7 * and comes with ABSOLUTELY NO WARRANTY! Check out the | |
8 * documentation coming with Dive4Elements River for details. | |
9 */ | |
10 | |
11 package org.dive4elements.river.artifacts.sinfo.common; | |
12 | |
13 import java.util.HashSet; | |
14 import java.util.Map; | |
15 import java.util.Set; | |
16 | |
17 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; | |
18 import org.dive4elements.artifactdatabase.state.Facet; | |
19 import org.dive4elements.artifacts.Artifact; | |
20 import org.dive4elements.artifacts.CallContext; | |
21 import org.dive4elements.artifacts.CallMeta; | |
22 import org.dive4elements.river.artifacts.resources.Resources; | |
23 import org.dive4elements.river.artifacts.sinfo.predefinedchannel.PredefinedChannelFacet; | |
24 import org.dive4elements.river.artifacts.sinfo.predefinedchannel.PredefinedChannelQueryCalculationResult; | |
25 import org.dive4elements.river.exports.DiagramGenerator; | |
26 import org.dive4elements.river.exports.StyledSeriesBuilder; | |
27 import org.dive4elements.river.jfree.StyledXYSeries; | |
28 import org.dive4elements.river.themes.ThemeDocument; | |
29 | |
30 /** | |
31 * Processor to generate a data series for river channel depth data loaded from the database | |
32 * | |
33 * @author Matthias Schäfer | |
34 * | |
35 */ | |
36 public class PredefinedChannelDepthProcessor extends AbstractSInfoProcessor { | |
37 | |
38 // private final static Logger log = Logger.getLogger(PredefinedChannelDepthProcessor.class); | |
39 | |
40 public static final String FACET_PREDEFINED_CHANNEL_DEPTH = "sinfo_facet_predefined_channel_depth"; | |
41 | |
42 private static final String I18N_AXIS_LABEL = "sinfo.chart.flow_depth.section.yaxis.label"; | |
43 | |
44 private static final String I18N_SERIES_NAME_PATTERN = "predefinedchannel.depth.title"; | |
45 | |
46 private static final Set<String> HANDLED_FACET_TYPES = new HashSet<>(); | |
47 | |
48 static { | |
49 HANDLED_FACET_TYPES.add(FACET_PREDEFINED_CHANNEL_DEPTH); | |
50 } | |
51 | |
52 public PredefinedChannelDepthProcessor() { | |
53 super(I18N_AXIS_LABEL, HANDLED_FACET_TYPES); | |
54 } | |
55 | |
56 @Override | |
57 protected String generateSeries(final DiagramGenerator generator, final ArtifactAndFacet bundle, final ThemeDocument theme, final boolean visible) { | |
58 | |
59 final CallContext context = generator.getCallContext(); | |
60 final Map<String, String> metaData = bundle.getFacet().getMetaData(); | |
61 | |
62 final Artifact artifact = bundle.getArtifact(); | |
63 | |
64 final StyledXYSeries series = new StyledXYSeries(bundle.getFacetDescription(), theme); | |
65 series.putMetaData(metaData, artifact, context); | |
66 | |
67 final String facetName = bundle.getFacetName(); | |
68 final PredefinedChannelQueryCalculationResult data = (PredefinedChannelQueryCalculationResult) bundle.getData(context); | |
69 if (data == null) { | |
70 // Check has been here before so we keep it for security reasons | |
71 // this should never happen though. | |
72 throw new IllegalStateException("Data is null for facet: " + facetName); | |
73 } | |
74 | |
75 final double[][] points = data.getStationPoints(SInfoResultType.channelDepth); | |
76 | |
77 StyledSeriesBuilder.addPoints(series, points, true); | |
78 generator.addAxisSeries(series, getAxisName(), visible); | |
79 | |
80 return metaData.get("Y"); | |
81 } | |
82 | |
83 public static Facet createFacet(final CallMeta callMeta, final String seriesName) { | |
84 return new PredefinedChannelFacet(FACET_PREDEFINED_CHANNEL_DEPTH, | |
85 Resources.getMsg(callMeta, I18N_SERIES_NAME_PATTERN, I18N_SERIES_NAME_PATTERN, seriesName), I18N_AXIS_LABEL); | |
86 } | |
87 } |