Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineProcessor.java @ 9295:385b52ccde23
Work on U-Info salix line calculation and chart (no scenario case)
author | mschaefer |
---|---|
date | Tue, 24 Jul 2018 18:51:47 +0200 |
parents | |
children | 72b3270e1568 |
comparison
equal
deleted
inserted
replaced
9294:7a8b9331a946 | 9295:385b52ccde23 |
---|---|
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.uinfo.salix; | |
12 | |
13 import java.util.HashSet; | |
14 import java.util.Set; | |
15 | |
16 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; | |
17 import org.dive4elements.artifactdatabase.state.Facet; | |
18 import org.dive4elements.artifacts.CallContext; | |
19 import org.dive4elements.river.artifacts.D4EArtifact; | |
20 import org.dive4elements.river.artifacts.common.AbstractCalculationResult; | |
21 import org.dive4elements.river.artifacts.uinfo.commons.UInfoResultType; | |
22 import org.dive4elements.river.exports.DiagramGenerator; | |
23 import org.dive4elements.river.exports.StyledSeriesBuilder; | |
24 import org.dive4elements.river.exports.process.DefaultProcessor; | |
25 import org.dive4elements.river.exports.process.WOutProcessor; | |
26 import org.dive4elements.river.jfree.StyledXYSeries; | |
27 import org.dive4elements.river.themes.ThemeDocument; | |
28 import org.dive4elements.river.utils.RiverUtils; | |
29 import org.jfree.data.xy.XYSeries; | |
30 | |
31 /** | |
32 * Processor to generate the facets and data series of salix line | |
33 * | |
34 * @author Matthias Schäfer | |
35 * | |
36 */ | |
37 public final class SalixLineProcessor extends DefaultProcessor { | |
38 | |
39 private static final String FACET_SALIX_LINE = "uinfo_facet_salix"; | |
40 | |
41 private static final String FACET_SALIX_MNWMW = "uinfo_facet_mnwmw"; | |
42 | |
43 private static final Set<String> HANDLED_FACET_TYPES = new HashSet<>(); | |
44 | |
45 static { | |
46 HANDLED_FACET_TYPES.add(FACET_SALIX_LINE); | |
47 HANDLED_FACET_TYPES.add(FACET_SALIX_MNWMW); | |
48 } | |
49 | |
50 public static Facet createSalixLineFacet(final CallContext context, final String hash, final String id, final AbstractCalculationResult result, | |
51 final int facetIndex, final int resultIndex, final String description) { | |
52 | |
53 return new SalixLineResultFacet(FACET_SALIX_LINE, description); | |
54 } | |
55 | |
56 public static Facet createSalixMnwMwFacet(final CallContext context, final String hash, final String id, final AbstractCalculationResult result, | |
57 final int facetIndex, final int resultIndex, final String description) { | |
58 | |
59 return new SalixMnwMwResultFacet(FACET_SALIX_MNWMW, description); | |
60 } | |
61 | |
62 @Override | |
63 public final String getAxisLabel(final DiagramGenerator generator) { | |
64 | |
65 final D4EArtifact flys = (D4EArtifact) generator.getMaster(); | |
66 final String unit = RiverUtils.getRiver(flys).getWstUnit().getName(); | |
67 return generator.msg(WOutProcessor.I18N_AXIS_LABEL, WOutProcessor.I18N_AXIS_LABEL_DEFAULT, unit); | |
68 } | |
69 | |
70 @Override | |
71 public final boolean canHandle(final String facettype) { | |
72 return HANDLED_FACET_TYPES.contains(facettype); | |
73 } | |
74 | |
75 @Override | |
76 public void doOut(final DiagramGenerator generator, final ArtifactAndFacet bundle, final ThemeDocument theme, final boolean visible) { | |
77 | |
78 // log.debug("Processing facet: " + bundle.getFacetName()); | |
79 final CallContext context = generator.getContext(); | |
80 final Object data = bundle.getData(context); | |
81 | |
82 final XYSeries series = new StyledXYSeries(bundle.getFacetDescription(), theme); | |
83 | |
84 if (bundle.getFacetName().equals(FACET_SALIX_LINE)) { | |
85 StyledSeriesBuilder.addPoints(series, ((SalixLineCalculationNoScenarioResult) data).getStationPoints(UInfoResultType.salixline), true); | |
86 generator.addAxisSeries(series, this.axisName, visible); | |
87 return; | |
88 } | |
89 | |
90 if (bundle.getFacetName().equals(FACET_SALIX_MNWMW)) { | |
91 StyledSeriesBuilder.addPoints(series, ((SalixLineCalculationNoScenarioResult) data).getStationPoints(UInfoResultType.salix_delta_mw), true); | |
92 generator.addAxisSeries(series, this.axisName, visible); | |
93 return; | |
94 } | |
95 } | |
96 } |