Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/exports/process/BedDiffYearProcessor.java @ 7985:10debf4b82be facet-metadata
Split bed differences facet into data specific facets.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Tue, 01 Jul 2014 15:09:56 +0200 |
parents | e844be34a606 |
children | b57db3a231ba |
comparison
equal
deleted
inserted
replaced
7984:cf674b03901a | 7985:10debf4b82be |
---|---|
48 @Override | 48 @Override |
49 public void doOut( | 49 public void doOut( |
50 DiagramGenerator generator, | 50 DiagramGenerator generator, |
51 ArtifactAndFacet bundle, | 51 ArtifactAndFacet bundle, |
52 ThemeDocument theme, | 52 ThemeDocument theme, |
53 boolean visible) { | 53 boolean visible |
54 ) { | |
54 CallContext context = generator.getCallContext(); | 55 CallContext context = generator.getCallContext(); |
55 Object data = bundle.getData(context); | 56 Object data = bundle.getData(context); |
56 Map<String, String> metaData = | 57 Map<String, String> metaData = |
57 bundle.getFacet().getMetaData(bundle.getArtifact(), context); | 58 bundle.getFacet().getMetaData(bundle.getArtifact(), context); |
58 yAxisLabel = metaData.get("Y"); | 59 yAxisLabel = metaData.get("Y"); |
59 if (data instanceof BedDiffYearResult) { | 60 if (!(data instanceof double[][])) { |
60 Double start = (Double)context.getContextValue("startkm"); | 61 logger.error("Can't process " + data.getClass().getName() + " objects"); |
61 Double end = (Double)context.getContextValue("endkm"); | |
62 if (start != null && end != null) { | |
63 D4EArtifact artifact = (D4EArtifact)bundle.getArtifact(); | |
64 RiverContext fc = (RiverContext)context.globalContext(); | |
65 // Adaptive smoothing, based on zoom factor/diagram extents. | |
66 ZoomScale scales = (ZoomScale)fc.get("zoomscale"); | |
67 RiverAccess access = new RiverAccess((D4EArtifact)artifact); | |
68 String river = access.getRiverName(); | |
69 | |
70 double radius = scales.getRadius(river, start, end); | |
71 generator.addSubtitle(Resources.getMsg( | |
72 context.getMeta(), | |
73 I18N_SUBTITLE_RADIUS, | |
74 new Object[] { radius })); | |
75 } | |
76 BedDiffYearResult bData = (BedDiffYearResult) data; | |
77 | |
78 StyledXYSeries series = new StyledXYSeries(bundle.getFacetDescription(), theme); | |
79 series.putMetaData(metaData, bundle.getArtifact(), context); | |
80 StyledSeriesBuilder.addPointsFactorY(series, | |
81 bData.getDifferencesData(), | |
82 false, | |
83 GAP_TOLERANCE, | |
84 100d); | |
85 | |
86 generator.addAxisSeries(series, axisName, visible); | |
87 | |
88 return; | 62 return; |
89 } | 63 } |
90 logger.error("Can't process " + data.getClass().getName() + " objects"); | 64 |
65 setSubtitleRadius(generator, bundle, context); | |
66 | |
67 double[][] bData = (double[][]) data; | |
68 | |
69 StyledXYSeries series = new StyledXYSeries(bundle.getFacetDescription(), theme); | |
70 series.putMetaData(metaData, bundle.getArtifact(), context); | |
71 StyledSeriesBuilder.addPointsFactorY(series, | |
72 bData, | |
73 false, | |
74 GAP_TOLERANCE, | |
75 100d); | |
76 | |
77 generator.addAxisSeries(series, axisName, visible); | |
78 | |
79 return; | |
80 } | |
81 | |
82 private void setSubtitleRadius( | |
83 DiagramGenerator generator, | |
84 ArtifactAndFacet bundle, | |
85 CallContext context | |
86 ) { | |
87 Double start = (Double)context.getContextValue("startkm"); | |
88 Double end = (Double)context.getContextValue("endkm"); | |
89 if (start != null && end != null) { | |
90 D4EArtifact artifact = (D4EArtifact)bundle.getArtifact(); | |
91 RiverContext fc = (RiverContext)context.globalContext(); | |
92 // Adaptive smoothing, based on zoom factor/diagram extents. | |
93 ZoomScale scales = (ZoomScale)fc.get("zoomscale"); | |
94 RiverAccess access = new RiverAccess((D4EArtifact)artifact); | |
95 String river = access.getRiverName(); | |
96 | |
97 double radius = scales.getRadius(river, start, end); | |
98 generator.addSubtitle(Resources.getMsg( | |
99 context.getMeta(), | |
100 I18N_SUBTITLE_RADIUS, | |
101 new Object[] { radius })); | |
102 } | |
91 } | 103 } |
92 | 104 |
93 @Override | 105 @Override |
94 public boolean canHandle(String facetType) { | 106 public boolean canHandle(String facetType) { |
95 return BED_DIFFERENCE_YEAR.equals(facetType) // from BedDifferencesYear | 107 return BED_DIFFERENCE_YEAR.equals(facetType) // from BedDifferencesYear |