Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/PredefinedFlowDepthProcessor.java @ 9035:c16e90a0baf7
Added datacage select and chart display for modelled flow depth series loaded from database
author | mschaefer |
---|---|
date | Mon, 30 Apr 2018 16:00:12 +0200 |
parents | |
children | 1cc7653ca84f |
comparison
equal
deleted
inserted
replaced
9034:8aa7d9eaaa21 | 9035:c16e90a0baf7 |
---|---|
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.apache.log4j.Logger; | |
18 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; | |
19 import org.dive4elements.artifacts.Artifact; | |
20 import org.dive4elements.artifacts.CallContext; | |
21 import org.dive4elements.river.artifacts.sinfo.predefinedflowdepth.PredefinedFlowDepthQueryCalculationResult; | |
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 /** | |
28 * Processor to generate a data series for flow depth data loaded from the database | |
29 * | |
30 * @author Matthias Schäfer | |
31 * | |
32 */ | |
33 public class PredefinedFlowDepthProcessor extends AbstractSInfoProcessor { | |
34 | |
35 private final static Logger log = Logger.getLogger(PredefinedFlowDepthProcessor.class); | |
36 | |
37 public static final String FACET_PREDEFINED_FLOW_DEPTH = "sinfo_facet_predefined_flowdepth"; | |
38 | |
39 private static final String I18N_AXIS_LABEL = "sinfo.chart.flow_depth.section.yaxis.label"; | |
40 | |
41 private static final Set<String> HANDLED_FACET_TYPES = new HashSet<>(); | |
42 | |
43 static { | |
44 HANDLED_FACET_TYPES.add(FACET_PREDEFINED_FLOW_DEPTH); | |
45 } | |
46 | |
47 public PredefinedFlowDepthProcessor() { | |
48 super(I18N_AXIS_LABEL, HANDLED_FACET_TYPES); | |
49 } | |
50 | |
51 @Override | |
52 protected String generateSeries(final DiagramGenerator generator, final ArtifactAndFacet bundle, final ThemeDocument theme, final boolean visible) { | |
53 | |
54 final CallContext context = generator.getCallContext(); | |
55 final Map<String, String> metaData = bundle.getFacet().getMetaData(); | |
56 | |
57 final Artifact artifact = bundle.getArtifact(); | |
58 | |
59 final StyledXYSeries series = new StyledXYSeries(bundle.getFacetDescription(), theme); | |
60 series.putMetaData(metaData, artifact, context); | |
61 | |
62 final String facetName = bundle.getFacetName(); | |
63 final PredefinedFlowDepthQueryCalculationResult data = (PredefinedFlowDepthQueryCalculationResult) bundle.getData(context); | |
64 if (data == null) { | |
65 // Check has been here before so we keep it for security reasons | |
66 // this should never happen though. | |
67 throw new IllegalStateException("Data is null for facet: " + facetName); | |
68 } | |
69 | |
70 final double[][] points = data.getStationPoints(SInfoResultType.flowdepth); | |
71 | |
72 StyledSeriesBuilder.addPoints(series, points, true); | |
73 generator.addAxisSeries(series, getAxisName(), visible); | |
74 | |
75 return null; | |
76 } | |
77 } |