Mercurial > dive4elements > river
changeset 7705:f1257717fa4b
(issue1594) Move Bed differences absolute height into the correct processor
This also fixes that the filtered data of Height2 was never shown because
of a to wide else clause.
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Tue, 17 Dec 2013 18:27:13 +0100 (2013-12-17) |
parents | a877d2680a4a |
children | 8f1a5d0802b5 |
files | artifacts/src/main/java/org/dive4elements/river/exports/process/BedDiffYearProcessor.java artifacts/src/main/java/org/dive4elements/river/exports/process/BedHeightProcessor.java |
diffstat | 2 files changed, 32 insertions(+), 55 deletions(-) [+] |
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/BedDiffYearProcessor.java Tue Dec 17 17:59:37 2013 +0100 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/BedDiffYearProcessor.java Tue Dec 17 18:27:13 2013 +0100 @@ -47,15 +47,9 @@ String facetType = bundle.getFacetName(); BedDiffYearResult bData = (BedDiffYearResult) data; - double[][] points; - if (BED_DIFFERENCE_YEAR_HEIGHT1.equals(facetType)) { - points = bData.getHeights1Data(); - } else { - points = bData.getHeights2Data(); - } XYSeries series = new StyledXYSeries(bundle.getFacetDescription(), theme); StyledSeriesBuilder.addPointsFactorY(series, - points, + bData.getHeightPerYearData(), false, GAP_TOLERANCE, 100d); @@ -68,51 +62,8 @@ } @Override - public void doOut( - XYChartGenerator generator, - ArtifactAndFacet bundle, - ThemeDocument theme, - boolean visible, - int axidx - ) { - CallContext context = generator.getCallContext(); - Object data = bundle.getData(context); - if (data instanceof BedDiffYearResult) { - String facetType = bundle.getFacetName(); - BedDiffYearResult bData = (BedDiffYearResult) data; - - double[][] points; - if (BED_DIFFERENCE_YEAR.equals(facetType) - || BED_DIFFERENCE_YEAR_FILTERED.equals(facetType)) { - points = bData.getHeightPerYearData(); - } - else if (BED_DIFFERENCE_YEAR_HEIGHT1.equals(facetType)) { - points = bData.getHeights1Data(); - } else { - points = bData.getHeights2Data(); - } - XYSeries series = new StyledXYSeries(bundle.getFacetDescription(), theme); - StyledSeriesBuilder.addPointsFactorY(series, - points, - false, - GAP_TOLERANCE, - 100d); - - generator.addAxisSeries(series, axidx, visible); - - return; - } - logger.error("Can't process " + data.getClass().getName() + " objects"); - } - - @Override public boolean canHandle(String facetType) { - return - BED_DIFFERENCE_YEAR_HEIGHT1.equals(facetType) - || BED_DIFFERENCE_YEAR_HEIGHT2.equals(facetType) - || BED_DIFFERENCE_YEAR_HEIGHT1_FILTERED.equals(facetType) - || BED_DIFFERENCE_YEAR_HEIGHT2_FILTERED.equals(facetType) - || BED_DIFFERENCE_YEAR.equals(facetType) // from BedDifferencesYear + return BED_DIFFERENCE_YEAR.equals(facetType) // from BedDifferencesYear || BED_DIFFERENCE_YEAR_FILTERED.equals(facetType); // from BedDifferencesYear }
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/BedHeightProcessor.java Tue Dec 17 17:59:37 2013 +0100 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/BedHeightProcessor.java Tue Dec 17 18:27:13 2013 +0100 @@ -17,9 +17,11 @@ import org.dive4elements.artifacts.CallContext; import org.dive4elements.river.artifacts.D4EArtifact; import org.dive4elements.river.artifacts.model.minfo.BedHeightSingleData; +import org.dive4elements.river.artifacts.model.minfo.BedDiffYearResult; import org.dive4elements.river.artifacts.model.FacetTypes; import org.dive4elements.river.exports.XYChartGenerator; import org.dive4elements.river.exports.DiagramGenerator; +import org.dive4elements.river.exports.StyledSeriesBuilder; import org.dive4elements.river.jfree.StyledXYSeries; import org.dive4elements.river.model.BedHeightSingleValue; import org.dive4elements.river.themes.ThemeDocument; @@ -35,6 +37,8 @@ public static final String I18N_AXIS_LABEL = "chart.bedheight.height.yaxis.label"; + protected static double GAP_TOLERANCE = 0.101d; + @Override public void doOut( DiagramGenerator generator, @@ -63,7 +67,24 @@ Object data = bundle.getData(context); XYSeries series = new StyledXYSeries(bundle.getFacetDescription(), theme); - if (data instanceof BedHeightSingleData) { + if (data instanceof BedDiffYearResult) { + BedDiffYearResult bData = (BedDiffYearResult) data; + + double[][] points; + String facetType = bundle.getFacetName(); + + if (FacetTypes.BED_DIFFERENCE_YEAR_HEIGHT1.equals(facetType) || + FacetTypes.BED_DIFFERENCE_YEAR_HEIGHT1_FILTERED.equals(facetType)) { + points = bData.getHeights1Data(); + } else { + points = bData.getHeights2Data(); + } + StyledSeriesBuilder.addPointsFactorY(series, + points, + false, + GAP_TOLERANCE, + 1d); + } else if (data instanceof BedHeightSingleData) { BedHeightSingleData bData = (BedHeightSingleData)data; double[] heights = bData.getHeights(); double[] stations = bData.getStations().toNativeArray(); @@ -73,7 +94,8 @@ for (int i = 0; i < heights.length; i++) { series.add(stations[i], heights[i], false); } - } else if (data instanceof List<?>) { + } + else if (data instanceof List<?>) { List<BedHeightSingleValue> bData = (List<BedHeightSingleValue>)data; logger.debug("doBedheightSingleValueOut"); @@ -90,8 +112,12 @@ @Override - public boolean canHandle(String facettype) { - return FacetTypes.BEDHEIGHT.equals(facettype); + public boolean canHandle(String facetType) { + return FacetTypes.BEDHEIGHT.equals(facetType) + || FacetTypes.BED_DIFFERENCE_YEAR_HEIGHT1.equals(facetType) + || FacetTypes.BED_DIFFERENCE_YEAR_HEIGHT2.equals(facetType) + || FacetTypes.BED_DIFFERENCE_YEAR_HEIGHT1_FILTERED.equals(facetType) + || FacetTypes.BED_DIFFERENCE_YEAR_HEIGHT2_FILTERED.equals(facetType); } @Override