# HG changeset patch # User Raimund Renkert # Date 1412163604 -7200 # Node ID 9f9857f6c464eaa4888aa0b1afca847c75e4c836 # Parent a82f24b773e7147d53a656cdf9b151251fcbe8f8 Added y axis label to discharge processors. diff -r a82f24b773e7 -r 9f9857f6c464 artifacts/src/main/java/org/dive4elements/river/exports/process/ComputedDischargeProcessor.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/process/ComputedDischargeProcessor.java Wed Oct 01 13:37:27 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/ComputedDischargeProcessor.java Wed Oct 01 13:40:04 2014 +0200 @@ -1,15 +1,20 @@ package org.dive4elements.river.exports.process; +import java.util.Map; + import org.apache.log4j.Logger; import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; import org.dive4elements.artifacts.CallContext; +import org.dive4elements.artifacts.CallMeta; +import org.dive4elements.river.artifacts.D4EArtifact; +import org.dive4elements.river.artifacts.access.RiverAccess; import org.dive4elements.river.artifacts.model.FacetTypes; import org.dive4elements.river.artifacts.model.WQKms; +import org.dive4elements.river.artifacts.resources.Resources; import org.dive4elements.river.exports.DiagramGenerator; import org.dive4elements.river.exports.StyledSeriesBuilder; import org.dive4elements.river.jfree.StyledXYSeries; import org.dive4elements.river.themes.ThemeDocument; -import org.jfree.data.xy.XYSeries; public class ComputedDischargeProcessor @@ -19,6 +24,9 @@ private static Logger log = Logger.getLogger(ComputedDischargeProcessor.class); + private String yAxisLabel = ""; + + private String I18N_AXIS_LABEL = "chart.discharge.curve.yaxis.label"; @Override public void doOut( @@ -36,7 +44,19 @@ @Override public String getAxisLabel(DiagramGenerator generator) { - return null; + CallMeta meta = generator.getCallContext().getMeta(); + RiverAccess access = new RiverAccess((D4EArtifact)generator.getMaster()); + String unit = access.getRiver().getWstUnit().getName(); + if (yAxisLabel != null && !yAxisLabel.isEmpty()) { + return Resources.getMsg( + meta, + yAxisLabel, + new Object[] { unit }); + } + return Resources.getMsg( + meta, + I18N_AXIS_LABEL, + new Object[] { unit }); } /** @@ -57,8 +77,15 @@ boolean visible ) { CallContext context = generator.getCallContext(); - XYSeries series = new StyledXYSeries(bundle.getFacetDescription(), theme); + Map metaData = bundle.getFacet().getMetaData( + bundle.getArtifact(), context); + StyledXYSeries series = + new StyledXYSeries(bundle.getFacetDescription(), theme); Object data = bundle.getData(context); + + series.putMetaData(metaData, bundle.getArtifact(), context); + yAxisLabel = metaData.get("Y"); + WQKms wqkms = (WQKms) data; double[][] wqData = new double[2][wqkms.size()]; for (int i = 0; i < wqkms.size(); i++) { @@ -67,6 +94,5 @@ } StyledSeriesBuilder.addPoints(series, wqData, false); generator.addAxisSeries(series, axisName, visible); - } } diff -r a82f24b773e7 -r 9f9857f6c464 artifacts/src/main/java/org/dive4elements/river/exports/process/DischargeProcessor.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/process/DischargeProcessor.java Wed Oct 01 13:37:27 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/DischargeProcessor.java Wed Oct 01 13:40:04 2014 +0200 @@ -8,15 +8,19 @@ package org.dive4elements.river.exports.process; +import java.util.Map; + import org.apache.log4j.Logger; import org.jfree.data.xy.XYSeries; import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; import org.dive4elements.artifacts.CallContext; +import org.dive4elements.artifacts.CallMeta; import org.dive4elements.river.artifacts.D4EArtifact; import org.dive4elements.river.artifacts.access.RiverAccess; import org.dive4elements.river.artifacts.model.FacetTypes; import org.dive4elements.river.artifacts.model.WQKms; +import org.dive4elements.river.artifacts.resources.Resources; import org.dive4elements.river.exports.DiagramGenerator; import org.dive4elements.river.exports.StyledSeriesBuilder; import org.dive4elements.river.jfree.StyledXYSeries; @@ -38,6 +42,10 @@ /** Tolerance for comparison of kilometers. */ public static final double KM_EPSILON = 0.001d; + private String yAxisLabel = ""; + + private String I18N_AXIS_LABEL = "chart.discharge.curve.yaxis.label"; + /** This processor needs to be constructed with a given km. */ public DischargeProcessor() { @@ -100,8 +108,10 @@ { log.debug("DischargeCurveGenerator.doDischargeOut"); CallContext context = generator.getCallContext(); + Map metaData = bundle.getFacet().getMetaData( + bundle.getArtifact(), context); WQKms data = (WQKms)bundle.getData(context); - XYSeries series = new StyledXYSeries(name, theme); + StyledXYSeries series = new StyledXYSeries(name, theme); double[][] wqData = new double[2][data.size()]; for (int i = 0; i < data.size(); i++) { wqData[0][i] = data.getQ(i); @@ -109,6 +119,9 @@ } StyledSeriesBuilder.addPoints(series, wqData, false); + series.putMetaData(metaData, bundle.getArtifact(), context); + yAxisLabel = metaData.get("Y"); + String gaugeName = data.getName(); RiverAccess access = new RiverAccess((D4EArtifact)bundle.getArtifact()); River river = access.getRiver(); @@ -127,5 +140,23 @@ generator.addAxisSeries(series, axisName, visible); } + + @Override + public String getAxisLabel(DiagramGenerator generator) { + CallMeta meta = generator.getCallContext().getMeta(); + RiverAccess access = new RiverAccess((D4EArtifact)generator.getMaster()); + String unit = access.getRiver().getWstUnit().getName(); + + if (yAxisLabel != null && !yAxisLabel.isEmpty()) { + return Resources.getMsg( + meta, + yAxisLabel, + new Object[] { unit }); + } + return Resources.getMsg( + meta, + I18N_AXIS_LABEL, + new Object[] { unit }); + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r a82f24b773e7 -r 9f9857f6c464 artifacts/src/main/java/org/dive4elements/river/exports/process/FixDerivedProcessor.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/process/FixDerivedProcessor.java Wed Oct 01 13:37:27 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/FixDerivedProcessor.java Wed Oct 01 13:40:04 2014 +0200 @@ -1,10 +1,17 @@ package org.dive4elements.river.exports.process; +import java.util.Map; + import org.apache.log4j.Logger; import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; +import org.dive4elements.artifacts.CallContext; +import org.dive4elements.artifacts.CallMeta; +import org.dive4elements.river.artifacts.D4EArtifact; +import org.dive4elements.river.artifacts.access.RiverAccess; import org.dive4elements.river.artifacts.model.FacetTypes; import org.dive4elements.river.artifacts.model.fixings.FixDerivateFacet; import org.dive4elements.river.artifacts.model.fixings.FixFunction; +import org.dive4elements.river.artifacts.resources.Resources; import org.dive4elements.river.exports.DiagramGenerator; import org.dive4elements.river.jfree.JFreeUtil; import org.dive4elements.river.jfree.StyledXYSeries; @@ -18,6 +25,11 @@ private static Logger log = Logger.getLogger(FixDerivedProcessor.class); + private String yAxisLabel = ""; + + private String I18N_AXIS_LABEL = "chart.discharge.curve.yaxis.label"; + + public FixDerivedProcessor() { } @@ -28,10 +40,16 @@ ThemeDocument theme, boolean visible ) { + CallContext context = generator.getCallContext(); + Map metaData = bundle.getFacet().getMetaData( + bundle.getArtifact(), context); FixDerivateFacet facet = (FixDerivateFacet)bundle.getFacet(); FixFunction func = (FixFunction)facet.getData( bundle.getArtifact(), generator.getCallContext()); + yAxisLabel = metaData.get("Y"); + + if (func == null) { log.warn("doOut: Facet does not contain FixFunction"); return; @@ -48,6 +66,7 @@ 0.0 , // start maxQ); // end generator.addAxisSeries(series, axisName, visible); + series.putMetaData(metaData, bundle.getArtifact(), context); } } @@ -55,4 +74,22 @@ public boolean canHandle(String facettype) { return FIX_DERIVATE_CURVE.equals(facettype); } + + @Override + public String getAxisLabel(DiagramGenerator generator) { + CallMeta meta = generator.getCallContext().getMeta(); + RiverAccess access = new RiverAccess((D4EArtifact)generator.getMaster()); + String unit = access.getRiver().getWstUnit().getName(); + + if (yAxisLabel != null && !yAxisLabel.isEmpty()) { + return Resources.getMsg( + meta, + yAxisLabel, + new Object[] { unit }); + } + return Resources.getMsg( + meta, + I18N_AXIS_LABEL, + new Object[] { unit }); + } } diff -r a82f24b773e7 -r 9f9857f6c464 artifacts/src/main/java/org/dive4elements/river/exports/process/FixWQProcessor.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/process/FixWQProcessor.java Wed Oct 01 13:37:27 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/FixWQProcessor.java Wed Oct 01 13:40:04 2014 +0200 @@ -8,6 +8,9 @@ import org.apache.log4j.Logger; import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; +import org.dive4elements.artifacts.CallMeta; +import org.dive4elements.river.artifacts.D4EArtifact; +import org.dive4elements.river.artifacts.access.RiverAccess; import org.dive4elements.river.artifacts.model.FacetTypes; import org.dive4elements.river.artifacts.model.NamedDouble; import org.dive4elements.river.artifacts.model.QWDDateRange; @@ -16,6 +19,7 @@ import org.dive4elements.river.artifacts.model.fixings.FixWQCurveFacet; import org.dive4elements.river.artifacts.model.fixings.QWD; import org.dive4elements.river.artifacts.model.fixings.QWI; +import org.dive4elements.river.artifacts.resources.Resources; import org.dive4elements.river.exports.DiagramGenerator; import org.dive4elements.river.exports.StyledSeriesBuilder; import org.dive4elements.river.exports.fixings.FixChartGenerator; @@ -43,6 +47,8 @@ private static Logger logger = Logger.getLogger(FixWQProcessor.class); + private String I18N_AXIS_LABEL = "chart.discharge.curve.yaxis.label"; + public FixWQProcessor() { } @@ -528,4 +534,16 @@ || STATIC_WKMS_INTERPOL.equals(facettype) || FIX_WQ_LS.equals(facettype); } + + @Override + public String getAxisLabel(DiagramGenerator generator) { + CallMeta meta = generator.getCallContext().getMeta(); + + RiverAccess access = new RiverAccess((D4EArtifact)generator.getMaster()); + String unit = access.getRiver().getWstUnit().getName(); + return Resources.getMsg( + meta, + I18N_AXIS_LABEL, + new Object[] { unit }); + } } diff -r a82f24b773e7 -r 9f9857f6c464 artifacts/src/main/java/org/dive4elements/river/exports/process/MiscDischargeProcessor.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/process/MiscDischargeProcessor.java Wed Oct 01 13:37:27 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/MiscDischargeProcessor.java Wed Oct 01 13:40:04 2014 +0200 @@ -16,8 +16,12 @@ import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; import org.dive4elements.artifacts.CallContext; +import org.dive4elements.artifacts.CallMeta; +import org.dive4elements.river.artifacts.D4EArtifact; +import org.dive4elements.river.artifacts.access.RiverAccess; import org.dive4elements.river.artifacts.model.FacetTypes; import org.dive4elements.river.artifacts.model.WQKms; +import org.dive4elements.river.artifacts.resources.Resources; import org.dive4elements.river.exports.DiagramGenerator; import org.dive4elements.river.exports.DischargeCurveGenerator; import org.dive4elements.river.exports.StyledSeriesBuilder; @@ -45,6 +49,7 @@ /** Tolerance for comparison of kilometers. */ public static final double KM_EPSILON = 0.001d; + private String I18N_AXIS_LABEL = "chart.discharge.curve.yaxis.label"; /** This processor needs to be constructed with a given km. */ public MiscDischargeProcessor() { @@ -356,5 +361,17 @@ generator.addAnnotations(annotations); } } + + @Override + public String getAxisLabel(DiagramGenerator generator) { + CallMeta meta = generator.getCallContext().getMeta(); + RiverAccess access = new RiverAccess((D4EArtifact)generator.getMaster()); + String unit = access.getRiver().getWstUnit().getName(); + + return Resources.getMsg( + meta, + I18N_AXIS_LABEL, + new Object[] { unit }); + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :