Mercurial > dive4elements > river
changeset 7891:4fe290eddb43 facet-metadata
Added metadata to styled series.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Wed, 21 May 2014 11:36:21 +0200 |
parents | d4792d01480d |
children | e844be34a606 |
files | artifacts/src/main/java/org/dive4elements/river/jfree/StyledXYSeries.java |
diffstat | 1 files changed, 43 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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@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 :