8884
|
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 |
8916
|
11 package org.dive4elements.river.artifacts.sinfo.common; |
8884
|
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 */ |
8916
|
28 public abstract class AbstractSInfoProcessor extends DefaultProcessor { |
8884
|
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) { |
8886
|
45 try { |
|
46 this.yAxisLabel = generateSeries(generator, bundle, theme, visible); |
8884
|
47 } |
8886
|
48 catch (final Exception e) { |
|
49 log.error(e.getMessage(), e); |
|
50 } |
8884
|
51 } |
|
52 |
|
53 /** |
8886
|
54 * @return The axis label |
8884
|
55 */ |
8886
|
56 protected abstract String generateSeries(final DiagramGenerator generator, final ArtifactAndFacet bundle, final ThemeDocument theme, final boolean visible); |
8884
|
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 |
9040
|
68 // TODO: In other implementations (i.e. FlowVelocityProcessor), an explicit (German) default label is given here, |
8884
|
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 } |