Mercurial > dive4elements > river
diff flys-artifacts/src/main/java/de/intevation/flys/exports/DischargeCurveGenerator.java @ 1812:dd084cf3f284
Refactored to allow mainvalues in discharge curve diagrams, too.
flys-artifacts/trunk@3141 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Wed, 02 Nov 2011 12:12:48 +0000 |
parents | 41ba2276d785 |
children | 3918bd7eb4e1 |
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/DischargeCurveGenerator.java Wed Nov 02 11:30:26 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/DischargeCurveGenerator.java Wed Nov 02 12:12:48 2011 +0000 @@ -14,21 +14,26 @@ import de.intevation.artifactdatabase.state.Facet; +import de.intevation.flys.artifacts.model.FacetTypes; import de.intevation.flys.model.Gauge; import de.intevation.flys.model.River; +import de.intevation.flys.artifacts.FLYSArtifact; import de.intevation.flys.artifacts.WINFOArtifact; import de.intevation.flys.artifacts.model.WQKms; import de.intevation.flys.utils.FLYSUtils; +import de.intevation.flys.jfree.FLYSAnnotation; /** * An OutGenerator that generates discharge curves. * * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> */ -public class DischargeCurveGenerator extends XYChartGenerator { +public class DischargeCurveGenerator +extends XYChartGenerator +implements FacetTypes { /** The logger used in this generator. */ private static Logger logger = @@ -62,9 +67,12 @@ } + /** + * Empty (suppress subtitle). + */ @Override protected void addSubtitles(JFreeChart chart) { - + ; } @@ -93,17 +101,14 @@ public void doOut( Artifact artifact, Facet facet, - Document attr, + Document theme, boolean visible ) { logger.debug("DischargeCurveGenerator.doOut: " + facet.getName()); - if (!(artifact instanceof WINFOArtifact)) { - logger.debug("Artifact is no instance of WINFOArtifact."); - return; - } + String name = facet.getName(); - WINFOArtifact flysArtifact = (WINFOArtifact) artifact; + FLYSArtifact flysArtifact = (FLYSArtifact) artifact; Facet nativeFacet = flysArtifact.getNativeFacet(facet); @@ -112,11 +117,48 @@ return; } - WQKms wqkms = (WQKms)nativeFacet.getData(flysArtifact, context); + if (name.equals(DISCHARGE_CURVE)) { + doDischargeOut( + (WINFOArtifact) flysArtifact, + nativeFacet.getData(flysArtifact, context), + nativeFacet.getDescription(), + theme, + visible); + } + else if (name.equals(COMPUTED_DISCHARGE_MAINVALUES_Q) + || name.equals(MAINVALUES_Q)) + { + doMainValueQAnnotations( + nativeFacet.getData(artifact, context), facet, theme, visible); + } + else if (name.equals(COMPUTED_DISCHARGE_MAINVALUES_W) + || name.equals(MAINVALUES_W)) + { + doMainValueWAnnotations( + nativeFacet.getData(artifact, context), facet, theme, visible); + } + else { + logger.warn("DischargeCurveGenerator.doOut: Unknown facet name: " + name); + return; + } + } + + + /** + * Add series with discharge curve to diagram. + */ + protected void doDischargeOut( + WINFOArtifact artifact, + Object o, + String description, + Document theme, + boolean visible) + { + WQKms wqkms = (WQKms) o; String gaugeName = wqkms.getName(); - River river = FLYSUtils.getRiver(flysArtifact); + River river = FLYSUtils.getRiver(artifact); if (river == null) { logger.debug("no river found"); @@ -130,18 +172,51 @@ return; } - double [][] values = new double [][] { - wqkms.getQs(), wqkms.getWs() }; - - int size = values != null ? values[0].length : 0; + XYSeries series = new StyledXYSeries(description, theme); - XYSeries series = new StyledXYSeries(facet.getDescription(), attr); - - for (int i = 0; i < size; i++) { - series.add(values[0][i], values[1][i]); - } + StyledSeriesBuilder.addPointsQW(series, wqkms); addFirstAxisSeries(series, visible); } + + + + /** + * Store W MainValues as annotations for later plotting. + */ + protected void doMainValueWAnnotations( + Object o, + Facet facet, + Document theme, + boolean visible + ) { + logger.debug("ComputedDischargeCurveGenerator set W MainValues."); + + FLYSAnnotation fa = (FLYSAnnotation) o; + fa.setTheme(theme); + fa.setLabel(facet.getDescription()); + addAnnotations(fa, visible); + } + + + /** + * Store Q MainValues as annotations for later plotting. + */ + protected void doMainValueQAnnotations( + Object o, + Facet facet, + Document theme, + boolean visible + ) { + logger.debug("ComputedDischargeCurveGenerator set Q MainValues."); + + FLYSAnnotation fa = (FLYSAnnotation) o; + fa.setTheme(theme); + fa.setLabel(facet.getDescription()); + addAnnotations(fa, visible); + } + + + } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :