comparison artifacts/src/main/java/org/dive4elements/river/exports/process/BedDiffYearProcessor.java @ 7892:e844be34a606 facet-metadata

Add metadata to chart series and datasets.
author Raimund Renkert <rrenkert@intevation.de>
date Wed, 21 May 2014 11:40:14 +0200
parents ea6b441b4872
children 10debf4b82be
comparison
equal deleted inserted replaced
7891:4fe290eddb43 7892:e844be34a606
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the 5 * and comes with ABSOLUTELY NO WARRANTY! Check out the
6 * documentation coming with Dive4Elements River for details. 6 * documentation coming with Dive4Elements River for details.
7 */ 7 */
8 8
9 package org.dive4elements.river.exports.process; 9 package org.dive4elements.river.exports.process;
10
11 import java.util.Map;
10 12
11 import org.apache.log4j.Logger; 13 import org.apache.log4j.Logger;
12 import org.jfree.data.xy.XYSeries; 14 import org.jfree.data.xy.XYSeries;
13 15
14 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; 16 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
32 private final static Logger logger = 34 private final static Logger logger =
33 Logger.getLogger(BedDiffYearProcessor.class); 35 Logger.getLogger(BedDiffYearProcessor.class);
34 36
35 protected static double GAP_TOLERANCE = 0.101d; 37 protected static double GAP_TOLERANCE = 0.101d;
36 38
39 protected String yAxisLabel;
40
37 public static final String I18N_AXIS_LABEL = 41 public static final String I18N_AXIS_LABEL =
38 "chart.beddifference.yaxis.label.diff"; 42 "chart.beddifference.yaxis.label.diff";
39 public static final String I18N_AXIS_LABEL_DEFAULT = 43 public static final String I18N_AXIS_LABEL_DEFAULT =
40 "delta S [cm]"; 44 "delta S [cm]";
41 public static final String I18N_SUBTITLE_RADIUS = 45 public static final String I18N_SUBTITLE_RADIUS =
47 ArtifactAndFacet bundle, 51 ArtifactAndFacet bundle,
48 ThemeDocument theme, 52 ThemeDocument theme,
49 boolean visible) { 53 boolean visible) {
50 CallContext context = generator.getCallContext(); 54 CallContext context = generator.getCallContext();
51 Object data = bundle.getData(context); 55 Object data = bundle.getData(context);
56 Map<String, String> metaData =
57 bundle.getFacet().getMetaData(bundle.getArtifact(), context);
58 yAxisLabel = metaData.get("Y");
52 if (data instanceof BedDiffYearResult) { 59 if (data instanceof BedDiffYearResult) {
53 Double start = (Double)context.getContextValue("startkm"); 60 Double start = (Double)context.getContextValue("startkm");
54 Double end = (Double)context.getContextValue("endkm"); 61 Double end = (Double)context.getContextValue("endkm");
55 if (start != null && end != null) { 62 if (start != null && end != null) {
56 D4EArtifact artifact = (D4EArtifact)bundle.getArtifact(); 63 D4EArtifact artifact = (D4EArtifact)bundle.getArtifact();
64 generator.addSubtitle(Resources.getMsg( 71 generator.addSubtitle(Resources.getMsg(
65 context.getMeta(), 72 context.getMeta(),
66 I18N_SUBTITLE_RADIUS, 73 I18N_SUBTITLE_RADIUS,
67 new Object[] { radius })); 74 new Object[] { radius }));
68 } 75 }
69 String facetType = bundle.getFacetName();
70 BedDiffYearResult bData = (BedDiffYearResult) data; 76 BedDiffYearResult bData = (BedDiffYearResult) data;
71 77
72 XYSeries series = new StyledXYSeries(bundle.getFacetDescription(), theme); 78 StyledXYSeries series = new StyledXYSeries(bundle.getFacetDescription(), theme);
79 series.putMetaData(metaData, bundle.getArtifact(), context);
73 StyledSeriesBuilder.addPointsFactorY(series, 80 StyledSeriesBuilder.addPointsFactorY(series,
74 bData.getDifferencesData(), 81 bData.getDifferencesData(),
75 false, 82 false,
76 GAP_TOLERANCE, 83 GAP_TOLERANCE,
77 100d); 84 100d);
89 || BED_DIFFERENCE_YEAR_FILTERED.equals(facetType); // from BedDifferencesYear 96 || BED_DIFFERENCE_YEAR_FILTERED.equals(facetType); // from BedDifferencesYear
90 } 97 }
91 98
92 @Override 99 @Override
93 public String getAxisLabel(DiagramGenerator generator) { 100 public String getAxisLabel(DiagramGenerator generator) {
101 if (yAxisLabel != null && !yAxisLabel.isEmpty()) {
102 return generator.msg(yAxisLabel, I18N_AXIS_LABEL_DEFAULT);
103 }
94 return generator.msg( 104 return generator.msg(
95 I18N_AXIS_LABEL, 105 I18N_AXIS_LABEL,
96 I18N_AXIS_LABEL_DEFAULT); 106 I18N_AXIS_LABEL_DEFAULT);
97 } 107 }
98 } 108 }
99 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : 109 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org