[PATCH 2 of 5] Added metadata to styled series
Wald Commits
scm-commit at wald.intevation.org
Wed May 21 11:43:49 CEST 2014
# HG changeset patch
# User Raimund Renkert <rrenkert at intevation.de>
# Date 1400664981 -7200
# Branch facet-metadata
# Node ID 4fe290eddb43f614448f0acd547ff030c5edc834
# Parent d4792d01480d09a771a5255e26be61139cde0eb9
Added metadata to styled series.
diff -r d4792d01480d -r 4fe290eddb43 artifacts/src/main/java/org/dive4elements/river/jfree/StyledXYSeries.java
--- a/artifacts/src/main/java/org/dive4elements/river/jfree/StyledXYSeries.java Wed May 21 11:35:09 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/jfree/StyledXYSeries.java Wed May 21 11:36:21 2014 +0200
@@ -9,9 +9,17 @@
package org.dive4elements.river.jfree;
import java.util.List;
+import java.util.Map;
import org.apache.log4j.Logger;
+import org.dive4elements.artifacts.Artifact;
+import org.dive4elements.artifacts.CallContext;
+import org.dive4elements.river.artifacts.D4EArtifact;
+import org.dive4elements.river.artifacts.access.RiverAccess;
+import org.dive4elements.river.artifacts.resources.Resources;
+import org.dive4elements.river.model.Unit;
import org.dive4elements.river.themes.ThemeDocument;
+import org.dive4elements.river.utils.RiverUtils;
import org.jfree.data.xy.XYDataItem;
import org.jfree.data.xy.XYSeries;
@@ -21,7 +29,9 @@
/**
* @author <a href="mailto:ingo.weinzierl at intevation.de">Ingo Weinzierl</a>
*/
-public class StyledXYSeries extends XYSeries implements StyledSeries, HasLabel {
+public class StyledXYSeries
+extends XYSeries
+implements StyledSeries, HasLabel, XYMetaDataset {
private static final Logger logger = Logger.getLogger(StyledXYSeries.class);
@@ -30,6 +40,8 @@
/** If this Series is to be labelled, use this String as label. */
protected String label;
+ /** The meta data for this series. */
+ protected Map<String, String> metaData;
public StyledXYSeries(String key, ThemeDocument theme) {
this(key, true, theme, (Shape)null);
@@ -115,5 +127,35 @@
add(item.getXValue(), item.getYValue());
}
}
+
+
+ @Override
+ public Map<String, String> getMetaData() {
+ return metaData;
+ }
+
+
+ @Override
+ public void putMetaData(Map<String, String> metaData,
+ Artifact artifact,
+ CallContext context) {
+ this.metaData = metaData;
+ D4EArtifact d4e = (D4EArtifact) artifact;
+ RiverAccess access = new RiverAccess(d4e);
+ Unit unit = RiverUtils.getRiver(d4e).getWstUnit();
+ if (metaData.containsKey("X")) {
+ this.metaData.put("X",
+ Resources.getMsg(
+ context.getMeta(),
+ metaData.get("X"),
+ new Object[] { access.getRiverName() }));
+ }
+ if (metaData.containsKey("Y")) {
+ this.metaData.put("Y",
+ Resources.getMsg(
+ context.getMeta(),
+ metaData.get("Y"), new Object[] { unit.getName() }));
+ }
+ }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
More information about the Dive4Elements-commits
mailing list