Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthProcessor.java @ 8886:cc86b0f9b3c3
SINFO-FlowDepth - work on tkh themes
author | gernotbelger |
---|---|
date | Wed, 14 Feb 2018 18:10:53 +0100 |
parents | 7a8c12706834 |
children | 90b7f45ff4ae |
comparison
equal
deleted
inserted
replaced
8885:e5f688820951 | 8886:cc86b0f9b3c3 |
---|---|
9 */ | 9 */ |
10 | 10 |
11 package org.dive4elements.river.artifacts.sinfo.flowdepth; | 11 package org.dive4elements.river.artifacts.sinfo.flowdepth; |
12 | 12 |
13 import java.util.HashSet; | 13 import java.util.HashSet; |
14 import java.util.Map; | |
14 import java.util.Set; | 15 import java.util.Set; |
16 | |
17 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; | |
18 import org.dive4elements.artifacts.CallContext; | |
19 import org.dive4elements.river.exports.DiagramGenerator; | |
20 import org.dive4elements.river.exports.StyledSeriesBuilder; | |
21 import org.dive4elements.river.jfree.StyledXYSeries; | |
22 import org.dive4elements.river.themes.ThemeDocument; | |
15 | 23 |
16 public final class FlowDepthProcessor extends AbstractSInfoProcessor { | 24 public final class FlowDepthProcessor extends AbstractSInfoProcessor { |
17 | 25 |
18 /* Theme name, usually defined in 'FacetTypes', but that is soooo bad dependencies... */ | 26 /* Theme name, usually defined in 'FacetTypes', but that is soooo bad dependencies... */ |
19 // REMARK: these mustend with 'filtered' so extra handling happens in chart: point are always recalculated, because data | 27 // REMARK: these mustend with 'filtered' so extra handling happens in chart: point are always recalculated, because data |
33 | 41 |
34 public FlowDepthProcessor() { | 42 public FlowDepthProcessor() { |
35 super(I18N_AXIS_LABEL, HANDLED_FACET_TYPES); | 43 super(I18N_AXIS_LABEL, HANDLED_FACET_TYPES); |
36 } | 44 } |
37 | 45 |
46 @Override | |
47 protected final String generateSeries(final DiagramGenerator generator, final ArtifactAndFacet bundle, final ThemeDocument theme, final boolean visible) { | |
48 | |
49 final CallContext context = generator.getCallContext(); | |
50 final Map<String, String> metaData = bundle.getFacet().getMetaData(); | |
51 | |
52 final StyledXYSeries series = new StyledXYSeries(bundle.getFacetDescription(), theme); | |
53 series.putMetaData(metaData, bundle.getArtifact(), context); | |
54 | |
55 final String facetName = bundle.getFacetName(); | |
56 final FlowDepthCalculationResult data = (FlowDepthCalculationResult) bundle.getData(context); | |
57 if (data == null) { | |
58 // Check has been here before so we keep it for security reasons | |
59 // this should never happen though. | |
60 throw new IllegalStateException("Data is null for facet: " + facetName); | |
61 } | |
62 | |
63 final double[][] points = generatePoints(data, facetName); | |
64 | |
65 StyledSeriesBuilder.addPoints(series, points, true); | |
66 generator.addAxisSeries(series, getAxisName(), visible); | |
67 | |
68 return metaData.get("Y"); | |
69 } | |
70 | |
38 // FIXME: do filtering | 71 // FIXME: do filtering |
39 @Override | 72 private double[][] generatePoints(final FlowDepthCalculationResult data, final String facetName) { |
40 protected double[][] generatePoints(final FlowDepthCalculationResult data, final String facetName) { | |
41 | 73 |
42 if (FACET_FLOW_DEPTH_FILTERED.contentEquals(facetName)) | 74 if (FACET_FLOW_DEPTH_FILTERED.contentEquals(facetName)) |
43 return data.getFlowDepthPoints(); | 75 return data.getFlowDepthPoints(); |
44 | 76 |
45 if (FACET_FLOW_DEPTH_TKH_FILTERED.contentEquals(facetName)) | 77 if (FACET_FLOW_DEPTH_TKH_FILTERED.contentEquals(facetName)) |
46 return data.getFlowDepthTkhPoints(); | 78 return data.getFlowDepthTkhPoints(); |
47 | 79 |
48 return super.generatePoints(data, facetName); | 80 final String error = String.format("Unknown facet name: %s", facetName); |
81 throw new UnsupportedOperationException(error); | |
49 } | 82 } |
50 } | 83 } |