Mercurial > dive4elements > river
changeset 7076:7f600001c807 generator-refactoring
Add LTR inversion code to diagram generator.
This code is used in serveral diagrams and as it modifies a
whole diagram it should be central. (This should also make
maintenance easier). This function can be called by processors
to make sure that their data is plotted with an LTR waterflow.
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Fri, 20 Sep 2013 16:33:22 +0200 |
parents | 253d80af5b7f |
children | b780cf1148c3 |
files | artifacts/src/main/java/org/dive4elements/river/exports/DiagramGenerator.java |
diffstat | 1 files changed, 33 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/exports/DiagramGenerator.java Fri Sep 20 16:25:43 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/DiagramGenerator.java Fri Sep 20 16:33:22 2013 +0200 @@ -42,6 +42,7 @@ import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; import org.dive4elements.artifactdatabase.state.Facet; import org.dive4elements.river.artifacts.D4EArtifact; +import org.dive4elements.river.artifacts.model.WKms; import org.dive4elements.river.exports.process.Processor; import org.dive4elements.river.jfree.AxisDataset; import org.dive4elements.river.jfree.AnnotationHelper; @@ -52,6 +53,7 @@ import org.dive4elements.river.jfree.StyledAreaSeriesCollection; import org.dive4elements.river.jfree.StyledXYSeries; import org.dive4elements.river.themes.ThemeDocument; +import org.dive4elements.river.utils.DataUtil; import org.w3c.dom.Element; @@ -1081,6 +1083,37 @@ return diagramAttributes.getAxisName(index); } + /** Guess if the axis should be inverted to ensure ltr diagram water flow. + * + * A processor should decide if it is appropiate to activate this + * handling in a diagram by calling this function. + * + * Merke: In Deutschland fliesst Wasser in Diagrammen immer von + * links nach rechts!!! + */ + public void handleLTRWaterFlowInversion(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("handleLTRWaterFlowInversion: (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("Not inverting because we have just one km"); + } + logger.debug("inv: " + inv); + } + setInverted(inv); + } + /** Add the acutal data to the diagram according to the processors. * For every outable facets, this function is * called and handles the data accordingly. */