Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/AbstractSInfoProcessor.java @ 8916:5d5d0051723f
Working on outputmodes of tkh calculation
author | gernotbelger |
---|---|
date | Wed, 28 Feb 2018 18:55:39 +0100 |
parents | artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/AbstractSInfoProcessor.java@cc86b0f9b3c3 |
children | 5294114b1df4 |
comparison
equal
deleted
inserted
replaced
8915:d9dbf0b74bc2 | 8916:5d5d0051723f |
---|---|
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.Set; | |
14 | |
15 import org.apache.log4j.Logger; | |
16 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; | |
17 import org.dive4elements.river.exports.DiagramGenerator; | |
18 import org.dive4elements.river.exports.process.DefaultProcessor; | |
19 import org.dive4elements.river.themes.ThemeDocument; | |
20 | |
21 /** | |
22 * Abstraction for some processor implementation within S-INFO. Probably this abstraction could also be used for other | |
23 * cases as well. | |
24 * | |
25 * @author Gernot Belger | |
26 * | |
27 */ | |
28 public abstract class AbstractSInfoProcessor extends DefaultProcessor { | |
29 | |
30 private final static Logger log = Logger.getLogger(AbstractSInfoProcessor.class); | |
31 | |
32 private String yAxisLabel; | |
33 | |
34 private final Set<String> handled_facet_types; | |
35 | |
36 private final String i18n_axis_label; | |
37 | |
38 public AbstractSInfoProcessor(final String i18n_axis_label, final Set<String> handled_facet_types) { | |
39 this.i18n_axis_label = i18n_axis_label; | |
40 this.handled_facet_types = handled_facet_types; | |
41 } | |
42 | |
43 @Override | |
44 public final void doOut(final DiagramGenerator generator, final ArtifactAndFacet bundle, final ThemeDocument theme, final boolean visible) { | |
45 try { | |
46 this.yAxisLabel = generateSeries(generator, bundle, theme, visible); | |
47 } | |
48 catch (final Exception e) { | |
49 log.error(e.getMessage(), e); | |
50 } | |
51 } | |
52 | |
53 /** | |
54 * @return The axis label | |
55 */ | |
56 protected abstract String generateSeries(final DiagramGenerator generator, final ArtifactAndFacet bundle, final ThemeDocument theme, final boolean visible); | |
57 | |
58 @Override | |
59 public final boolean canHandle(final String facettype) { | |
60 return this.handled_facet_types.contains(facettype); | |
61 } | |
62 | |
63 @Override | |
64 public final String getAxisLabel(final DiagramGenerator generator) { | |
65 if (this.yAxisLabel != null && !this.yAxisLabel.isEmpty()) { | |
66 // REMARK/UNINTENDED: yAxisLabel may also be a resolved message (side-effect of StyledXYSeries#putMetadata), | |
67 // and cannot be resolved, so we need to give the resolved value as default | |
68 // FIXME: In other implementations (i.e. FlowVelocityProcessor), an explicit (German) default label is given here, | |
69 // probably the English version will also show German (CHECK) | |
70 return generator.msg(this.yAxisLabel, this.yAxisLabel); | |
71 } | |
72 return generator.msg(this.i18n_axis_label, "MISSING"); | |
73 } | |
74 } |