# HG changeset patch # User Andre Heinecke # Date 1379681666 -7200 # Node ID eb24d5203d17b9340527adb78d74ba8fbfbf2578 # Parent 4310c612a986cbfba9ddb3cdfbf1bc354e4bf0fc Add second doOut implementations to work with diagram generator diff -r 4310c612a986 -r eb24d5203d17 artifacts/src/main/java/org/dive4elements/river/exports/process/AnnotationProcessor.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/process/AnnotationProcessor.java Fri Sep 20 12:35:14 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/AnnotationProcessor.java Fri Sep 20 14:54:26 2013 +0200 @@ -14,7 +14,7 @@ import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; import org.dive4elements.artifacts.CallContext; import org.dive4elements.river.artifacts.model.FacetTypes; -//import org.dive4elements.river.exports.DiagramGenerator; +import org.dive4elements.river.exports.DiagramGenerator; import org.dive4elements.river.exports.XYChartGenerator; import org.dive4elements.river.jfree.RiverAnnotation; import org.dive4elements.river.themes.ThemeDocument; @@ -31,6 +31,28 @@ @Override public void doOut( + DiagramGenerator generator, + ArtifactAndFacet aaf, + ThemeDocument theme, + boolean visible) { + if (!visible) { + // Nothing to do + return; + } + CallContext context = generator.getCallContext(); + if (!(aaf.getData(context) instanceof RiverAnnotation)) { + // Just a bit defensive should not happen + logger.error("Incompatible facet in doOut"); + return; + } + RiverAnnotation ra = (RiverAnnotation)aaf.getData(context); + ra.setTheme(theme); + ra.setLabel(aaf.getFacetDescription()); + generator.addAnnotations(ra); + } + + @Override + public void doOut( XYChartGenerator generator, ArtifactAndFacet aaf, ThemeDocument theme, diff -r 4310c612a986 -r eb24d5203d17 artifacts/src/main/java/org/dive4elements/river/exports/process/WOutProcessor.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/process/WOutProcessor.java Fri Sep 20 12:35:14 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/WOutProcessor.java Fri Sep 20 14:54:26 2013 +0200 @@ -17,6 +17,7 @@ import org.dive4elements.river.artifacts.model.WKms; import org.dive4elements.river.exports.StyledSeriesBuilder; import org.dive4elements.river.exports.XYChartGenerator; +import org.dive4elements.river.exports.DiagramGenerator; import org.dive4elements.river.jfree.StyledAreaSeriesCollection; import org.dive4elements.river.jfree.StyledXYSeries; import org.dive4elements.river.themes.ThemeDocument; @@ -35,6 +36,48 @@ @Override public void doOut( + DiagramGenerator generator, + ArtifactAndFacet aaf, + ThemeDocument theme, + boolean visible) { + CallContext context = generator.getCallContext(); + WKms wkms = (WKms) aaf.getData(context); + + logger.debug("doOut"); + + XYSeries series = new StyledXYSeries(aaf.getFacetDescription(), theme); + + StyledSeriesBuilder.addPoints(series, wkms); + generator.addAxisSeries(series, axisName, visible); + + // If a "band around the curve shall be drawn, add according area. + double bandWidth = theme.parseBandWidth(); + if (bandWidth > 0 ) { + XYSeries seriesDown = new StyledXYSeries( + "band " + aaf.getFacetDescription(), false, theme); + XYSeries seriesUp = new StyledXYSeries( + aaf.getFacetDescription()+"+/-"+bandWidth, false, theme); + StyledSeriesBuilder.addUpperBand(seriesUp, wkms, bandWidth); + StyledSeriesBuilder.addLowerBand(seriesDown, wkms, bandWidth); + + StyledAreaSeriesCollection area = new StyledAreaSeriesCollection(theme); + area.addSeries(seriesUp); + area.addSeries(seriesDown); + area.setMode(StyledAreaSeriesCollection.FILL_MODE.BETWEEN); + generator.addAreaSeries(area, axisName, visible); + } + + if (aaf.getFacetName().equals(FacetTypes.LONGITUDINAL_W) || + aaf.getFacetName().equals(FacetTypes.DISCHARGE_LONGITUDINAL_W) || + aaf.getFacetName().equals(FacetTypes.STATIC_WQKMS_W)) { + /* Only use W values to check if the diagram should be inverted + * see flys/issue1290 for details */ + invertAxis(generator, wkms); + } + } + + @Override + public void doOut( XYChartGenerator generator, ArtifactAndFacet aaf, ThemeDocument theme, @@ -106,6 +149,7 @@ * @param wkms The data object that stores the x and y values used for this * chart. */ + // TODO Remove public void invertAxis(XYChartGenerator generator, WKms wkms) { boolean wsUp = wkms.guessWaterIncreasing(); boolean kmUp = DataUtil.guessWaterIncreasing(wkms.allKms()); @@ -127,5 +171,26 @@ } generator.setInverted(inv); } + public void invertAxis(DiagramGenerator generator, WKms wkms) { + boolean wsUp = wkms.guessWaterIncreasing(); + boolean kmUp = DataUtil.guessWaterIncreasing(wkms.allKms()); + int size = wkms.size(); + boolean inv = ((wsUp && kmUp) || (!wsUp && !kmUp)) && size > 1; + + if (logger.isDebugEnabled()) { + logger.debug("(Wkms)Values : " + size); + if (size > 0) { + logger.debug("Start km: " + wkms.getKm(0)); + logger.debug("End km: " + wkms.getKm(size-1)); + } + logger.debug("wsUp: " + wsUp); + logger.debug("kmUp: " + kmUp); + if (size == 1) { + logger.debug("InvertAxis not inverting because we have just one km"); + } + logger.debug("inv: " + inv); + } + generator.setInverted(inv); + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :