Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/PredefinedTkhProcessor.java @ 9033:384eee4b4135
Added datacage select and chart display for flow depth evolution series loaded from database, and a correction for the tkh data
author | mschaefer |
---|---|
date | Fri, 27 Apr 2018 17:41:59 +0200 |
parents | 6e5ff436febe |
children | 1cc7653ca84f |
comparison
equal
deleted
inserted
replaced
9032:1f63e9d3b0ec | 9033:384eee4b4135 |
---|---|
9 */ | 9 */ |
10 | 10 |
11 package org.dive4elements.river.artifacts.sinfo.common; | 11 package org.dive4elements.river.artifacts.sinfo.common; |
12 | 12 |
13 import java.util.HashSet; | 13 import java.util.HashSet; |
14 import java.util.Map; | |
15 import java.util.Set; | 14 import java.util.Set; |
16 | 15 |
17 import org.apache.log4j.Logger; | 16 import org.apache.log4j.Logger; |
18 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; | 17 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; |
19 import org.dive4elements.artifacts.CallContext; | 18 import org.dive4elements.artifacts.CallContext; |
35 | 34 |
36 public static final String FACET_PREDEFINED_TKH = "sinfo_facet_predefined_tkh"; | 35 public static final String FACET_PREDEFINED_TKH = "sinfo_facet_predefined_tkh"; |
37 | 36 |
38 private static final String I18N_AXIS_LABEL = "sinfo.chart.tkh.section.yaxis.label"; | 37 private static final String I18N_AXIS_LABEL = "sinfo.chart.tkh.section.yaxis.label"; |
39 | 38 |
40 private static final String I18N_FACET_TKH_DESCRIPTION = "sinfo.facet.tkh.description"; | |
41 | |
42 private static final String SINFO_CHART_TKH_YAXIS_LABEL = "sinfo.chart.tkh.yaxis.label"; | |
43 | |
44 private static final Set<String> HANDLED_FACET_TYPES = new HashSet<>(); | 39 private static final Set<String> HANDLED_FACET_TYPES = new HashSet<>(); |
45 | 40 |
46 static { | 41 static { |
47 HANDLED_FACET_TYPES.add(FACET_PREDEFINED_TKH); | 42 HANDLED_FACET_TYPES.add(FACET_PREDEFINED_TKH); |
48 } | 43 } |
49 | 44 |
50 public PredefinedTkhProcessor() { | 45 public PredefinedTkhProcessor() { |
51 super(I18N_AXIS_LABEL, HANDLED_FACET_TYPES); | 46 super(I18N_AXIS_LABEL, HANDLED_FACET_TYPES); |
52 } | |
53 | |
54 protected String generateSeries1(final DiagramGenerator generator, final ArtifactAndFacet bundle, final ThemeDocument theme, final boolean visible) { | |
55 final CallContext context = generator.getCallContext(); | |
56 final Map<String, String> metaData = bundle.getFacet().getMetaData(bundle.getArtifact(), context); | |
57 final StyledXYSeries series = new StyledXYSeries(bundle.getFacetDescription(), theme); | |
58 series.putMetaData(metaData, bundle.getArtifact(), context); | |
59 | |
60 final Object raw = bundle.getData(context); | |
61 if (raw == null) { | |
62 return null; | |
63 } | |
64 if (!(raw instanceof double[][])) { | |
65 log.error("Unkown datatype: " + raw.getClass().getName()); | |
66 return null; | |
67 } | |
68 final double[][] data = (double[][]) raw; | |
69 StyledSeriesBuilder.addPoints(series, data, true); | |
70 | |
71 // REMARK: we add " " because the description is misused as id, which must be unique. | |
72 final StyledXYSeries seriesDown = new StyledXYSeries(bundle.getFacetDescription() + " ", theme); | |
73 // final double[][] pointsDown = data.getTkhDownPoints(); | |
74 final double[][] datadown = (double[][]) raw; | |
75 for (int i = 0; i <= datadown[0].length - 1; i++) | |
76 datadown[1][i] = 0; | |
77 StyledSeriesBuilder.addPoints(seriesDown, datadown, true); | |
78 | |
79 final StyledAreaSeriesCollection area = new StyledAreaSeriesCollection(theme); | |
80 area.setMode(StyledAreaSeriesCollection.FILL_MODE.BETWEEN); | |
81 area.addSeries(series); | |
82 area.addSeries(seriesDown); | |
83 generator.addAreaSeries(area, getAxisName(), visible); | |
84 // generator.addAxisSeries(series, getAxisName(), visible); | |
85 return null; | |
86 } | 47 } |
87 | 48 |
88 @Override | 49 @Override |
89 protected String generateSeries(final DiagramGenerator generator, final ArtifactAndFacet bundle, final ThemeDocument theme, final boolean visible) { | 50 protected String generateSeries(final DiagramGenerator generator, final ArtifactAndFacet bundle, final ThemeDocument theme, final boolean visible) { |
90 final CallContext context = generator.getCallContext(); | 51 final CallContext context = generator.getCallContext(); |