Mercurial > dive4elements > river
changeset 8886:cc86b0f9b3c3
SINFO-FlowDepth - work on tkh themes
line wrap: on
line diff
--- a/artifacts/doc/conf/generators/longitudinal-diagram-defaults.xml Wed Feb 14 18:10:28 2018 +0100 +++ b/artifacts/doc/conf/generators/longitudinal-diagram-defaults.xml Wed Feb 14 18:10:53 2018 +0100 @@ -14,7 +14,7 @@ <axis name="Velocity"/> <axis name="Tau"/> <axis name="Q" include-zero="true"/> - <axis name="Flowdepth"/> + <axis name="FlowdepthAxis" include-zero="true"/> <axis name="tkhAxis" include-zero="true" /> <domain-axis key="chart.longitudinal.section.xaxis.label" default="Fluss-Km" inverted="org.dive4elements.river.exports.IsKmUpEvaluator()"> <arg expr="artifact.river"/> @@ -45,6 +45,6 @@ <processor class="org.dive4elements.river.exports.process.BedHeightProcessor" axis="W"/> <!-- S-INFO --> - <processor class="org.dive4elements.river.artifacts.sinfo.flowdepth.FlowDepthProcessor" axis="Flowdepth"/> + <processor class="org.dive4elements.river.artifacts.sinfo.flowdepth.FlowDepthProcessor" axis="FlowdepthAxis"/> <processor class="org.dive4elements.river.artifacts.sinfo.flowdepth.TkhProcessor" axis="tkhAxis"/> </longitudinal-defaults> \ No newline at end of file
--- a/artifacts/doc/conf/themes/default.xml Wed Feb 14 18:10:28 2018 +0100 +++ b/artifacts/doc/conf/themes/default.xml Wed Feb 14 18:10:53 2018 +0100 @@ -143,12 +143,16 @@ <inherit from="Areas" /> </inherits> <fields> + <!-- 'areashowbg': no code exits that reads it... --> <field name="areashowbg" type="boolean" display="Hintergrund anzeigen" default="true" hints="hidden" /> + <!-- FIXME: "areashowborder" does not exist, the constant in ThemeDocument is 'showborder" --> <field name="areashowborder" type="boolean" display="Begrenzung" default="false" hints="hidden" /> + <!-- 'areabordercolor' is not used in the code... --> <field name="areabordercolor" type="Color" default="0, 0, 0" display="Begrenzungslinienfarbe" hints="hidden" /> + <!-- 'showarea' is not used in the code... --> <field name="showarea" type="boolean" display="Flaeche anzeigen" default="true" hints="hidden" /> <field name="showarealabel" type="boolean" @@ -2879,8 +2883,7 @@ <inherit from="LongitudinalSection" /> </inherits> <fields> - <field name="linecolor" type="Color" display="Linienfarbe" - default="0, 0, 255" /> + <field name="linecolor" type="Color" display="Linienfarbe" default="0, 0, 255" /> </fields> </theme> <theme name="SInfoFlowDepthTkh"> @@ -2888,17 +2891,24 @@ <inherit from="LongitudinalSection" /> </inherits> <fields> - <field name="linecolor" type="Color" display="Linienfarbe" - default="0, 0, 128" /> + <field name="linecolor" type="Color" display="Linienfarbe" default="0, 0, 128" /> </fields> </theme> <theme name="SInfoTkh"> <inherits> - <inherit from="LongitudinalSection" /> + <inherit from="LongitudinalSectionArea" /> </inherits> <fields> - <field name="linecolor" type="Color" display="Linienfarbe" - default="128, 0, 128" /> + <field name="calculateRange" type="boolean" display="Ausdehnung berechnen" default="true" hints="hidden" /> + + <field name="showborder" type="boolean" display="Begrenzung" default="true" hints="hidden" /> + <field name="linecolor" type="Color" display="Linienfarbe" default="241, 195, 155" /> + <field name="linesize" type="int" display="Liniendicke" default="2"/> + + <field name="areabgcolor" type="Color" default="241, 195, 155" display="Füllfarbe" /> + <field name="areatransparency" type="int" default="85" /> + + <field name="showarealabel" type="boolean" display="Flächenbeschriftung anzeigen" default="false" hint="hidden"/> </fields> </theme> </themegroup>
--- a/artifacts/doc/conf/themes/second.xml Wed Feb 14 18:10:28 2018 +0100 +++ b/artifacts/doc/conf/themes/second.xml Wed Feb 14 18:10:53 2018 +0100 @@ -2891,11 +2891,19 @@ </theme> <theme name="SInfoTkh"> <inherits> - <inherit from="LongitudinalSection" /> + <inherit from="LongitudinalSectionArea" /> </inherits> <fields> - <field name="linecolor" type="Color" display="Linienfarbe" - default="128, 0, 128" /> + <field name="calculateRange" type="boolean" display="Ausdehnung berechnen" default="true" hints="hidden" /> + + <field name="showborder" type="boolean" display="Begrenzung" default="true" hints="hidden" /> + <field name="linecolor" type="Color" display="Linienfarbe" default="241, 195, 155" /> + <field name="linesize" type="int" display="Liniendicke" default="2"/> + + <field name="areabgcolor" type="Color" default="241, 195, 155" display="Füllfarbe" /> + <field name="areatransparency" type="int" default="85" /> + + <field name="showarealabel" type="boolean" display="Flächenbeschriftung anzeigen" default="false" hint="hidden"/> </fields> - </theme> + </theme> </themegroup> \ No newline at end of file
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/AbstractSInfoProcessor.java Wed Feb 14 18:10:28 2018 +0100 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/AbstractSInfoProcessor.java Wed Feb 14 18:10:53 2018 +0100 @@ -10,16 +10,12 @@ package org.dive4elements.river.artifacts.sinfo.flowdepth; -import java.util.Map; import java.util.Set; import org.apache.log4j.Logger; import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; -import org.dive4elements.artifacts.CallContext; import org.dive4elements.river.exports.DiagramGenerator; -import org.dive4elements.river.exports.StyledSeriesBuilder; import org.dive4elements.river.exports.process.DefaultProcessor; -import org.dive4elements.river.jfree.StyledXYSeries; import org.dive4elements.river.themes.ThemeDocument; /** @@ -46,38 +42,18 @@ @Override public final void doOut(final DiagramGenerator generator, final ArtifactAndFacet bundle, final ThemeDocument theme, final boolean visible) { - - final CallContext context = generator.getCallContext(); - final Map<String, String> metaData = bundle.getFacet().getMetaData(); - - final StyledXYSeries series = new StyledXYSeries(bundle.getFacetDescription(), theme); - series.putMetaData(metaData, bundle.getArtifact(), context); - - this.yAxisLabel = metaData.get("Y"); - - final String facetName = bundle.getFacetName(); - final FlowDepthCalculationResult data = (FlowDepthCalculationResult) bundle.getData(context); - if (data == null) { - // Check has been here before so we keep it for security reasons - // this should never happen though. - log.error("Data is null for facet: " + facetName); - return; + try { + this.yAxisLabel = generateSeries(generator, bundle, theme, visible); } - - final double[][] points = generatePoints(data, facetName); - - StyledSeriesBuilder.addPoints(series, points, true); - generator.addAxisSeries(series, this.axisName, visible); + catch (final Exception e) { + log.error(e.getMessage(), e); + } } /** - * Override to implement, call super as last line for default case. + * @return The axis label */ - protected double[][] generatePoints(@SuppressWarnings("unused") final FlowDepthCalculationResult data, final String facetName) { - final String error = String.format("Unknown facet name: %s", facetName); - log.error(error); - throw new UnsupportedOperationException(error); - } + protected abstract String generateSeries(final DiagramGenerator generator, final ArtifactAndFacet bundle, final ThemeDocument theme, final boolean visible); @Override public final boolean canHandle(final String facettype) {
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthCalculation.java Wed Feb 14 18:10:28 2018 +0100 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthCalculation.java Wed Feb 14 18:10:53 2018 +0100 @@ -155,6 +155,8 @@ final List<BedHeightValue> sortedValues = new ArrayList<>(values); Collections.sort(sortedValues, new BedHeightStationComparator()); + SoilKind lastKind = SoilKind.mobil; + for (final BedHeightValue bedHeightValue : sortedValues) { final Double station = bedHeightValue.getStation(); @@ -179,8 +181,46 @@ final double discharge = Double.NaN; // FIXME: calculate tkh - final double tkh = 0; - final double flowDepthTkh = flowDepth - tkh; + + // REMARK: bissl spielerei zum testen damit die sohlart nicht zu schnell wechselt + final boolean changeKind = Math.random() > 0.95; + SoilKind kind; + if (changeKind) { + switch (lastKind) { + case starr: + kind = SoilKind.mobil; + break; + + case mobil: + default: + kind = SoilKind.starr; + break; + + } + } else + kind = lastKind; + lastKind = kind; + + final double tkh = 100 + 10 * (Math.random() - 0.5); + + final double flowDepthTkh; + final double tkhUp; + final double tkhDown; + switch (kind) { + case starr: + flowDepthTkh = wst - (meanBedHeight + tkh / 100); + tkhUp = tkh; + tkhDown = 0; + break; + + case mobil: + default: + flowDepthTkh = wst - (meanBedHeight + tkh / 200); + tkhUp = tkh / 2; + tkhDown = -tkh / 2; + break; + } + // REMARK: access the location once only during calculation final String location = LocationProvider.getLocation(river.getName(), km); @@ -190,7 +230,8 @@ final String gaugeLabel = gauge == null ? notinrange : gauge.getName(); - resultData.addRow(km, flowDepth, flowDepthTkh, tkh, wst, discharge, wstLabel, gaugeLabel, meanBedHeight, bedHeightLabel, location); + resultData.addRow(km, flowDepth, flowDepthTkh, kind, tkh, tkhUp, tkhDown, wst, discharge, wstLabel, gaugeLabel, meanBedHeight, bedHeightLabel, + location); } catch (final FunctionEvaluationException e) { /* should only happen if out of range */
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthCalculationResult.java Wed Feb 14 18:10:28 2018 +0100 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthCalculationResult.java Wed Feb 14 18:10:53 2018 +0100 @@ -13,6 +13,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.List; import gnu.trove.TDoubleArrayList; @@ -21,8 +22,7 @@ * * @author Gernot Belger */ -class FlowDepthCalculationResult -implements Serializable { +class FlowDepthCalculationResult implements Serializable { private static final long serialVersionUID = 1L; @@ -40,8 +40,11 @@ this.sounding = sounding; } - public void addRow(final double station, final double flowDepth, final double flowDepthWithTkh, final double tkh, final double waterlevel, final double discharge, final String waterlevelLabel, final String gauge, final double meanBedHeight, final String sondageLabel, final String location) { - this.rows.add(new FlowDepthRow(station, flowDepth, flowDepthWithTkh, tkh, waterlevel, discharge, waterlevelLabel, gauge, meanBedHeight, sondageLabel, location)); + public void addRow(final double station, final double flowDepth, final double flowDepthWithTkh, final SoilKind tkhKind, final double tkh, + final double tkhUp, final double tkhDown, final double waterlevel, final double discharge, final String waterlevelLabel, final String gauge, + final double meanBedHeight, final String sondageLabel, final String location) { + this.rows.add(new FlowDepthRow(station, flowDepth, flowDepthWithTkh, tkhKind, tkh, tkhUp, tkhDown, waterlevel, discharge, waterlevelLabel, gauge, + meanBedHeight, sondageLabel, location)); } public String getLabel() { @@ -57,7 +60,7 @@ } public Collection<FlowDepthRow> getRows() { - return Collections.unmodifiableCollection( this.rows ); + return Collections.unmodifiableCollection(this.rows); } public double[][] getFlowDepthPoints() { @@ -86,15 +89,74 @@ return new double[][] { xPoints.toNativeArray(), yPoints.toNativeArray() }; } - public double[][] getTkhPoints() { + public double[][] getTkhUpPoints() { final TDoubleArrayList xPoints = new TDoubleArrayList(this.rows.size()); final TDoubleArrayList yPoints = new TDoubleArrayList(this.rows.size()); + final List<SoilKind> kinds = new ArrayList<>(this.rows.size()); for (final FlowDepthRow row : this.rows) { xPoints.add(row.getStation()); - yPoints.add(row.getTkh()); + yPoints.add(row.getTkhUp()); + kinds.add(row.getTkhKind()); } - return new double[][] { xPoints.toNativeArray(), yPoints.toNativeArray() }; + return adjustTkhVisualization(xPoints, yPoints, kinds); + } + + public double[][] getTkhDownPoints() { + final TDoubleArrayList xPoints = new TDoubleArrayList(this.rows.size()); + final TDoubleArrayList yPoints = new TDoubleArrayList(this.rows.size()); + final List<SoilKind> kinds = new ArrayList<>(this.rows.size()); + + for (final FlowDepthRow row : this.rows) { + xPoints.add(row.getStation()); + yPoints.add(row.getTkhDown()); + kinds.add(row.getTkhKind()); + } + + return adjustTkhVisualization(xPoints, yPoints, kinds); + } + + /** + * the up and down points must be further adjusted for visualization, see Mail Hr. Reiß + * basically we need to introduce extra points when the kind changes, so we get vertical lines in that case + */ + private double[][] adjustTkhVisualization(final TDoubleArrayList xPoints, final TDoubleArrayList yPoints, final List<SoilKind> kinds) { + + final TDoubleArrayList adjustedX = new TDoubleArrayList(xPoints.size()); + final TDoubleArrayList adjustedY = new TDoubleArrayList(yPoints.size()); + + adjustedX.add(xPoints.get(0)); + adjustedY.add(yPoints.get(0)); + + for (int i = 1; i < xPoints.size(); i++) { + + final SoilKind kind1 = kinds.get(i - 1); + final SoilKind kind2 = kinds.get(i); + + if (kind1 != kind2) { + /* introduce two extra points in order to create a vertical line in the middle of the two adjacent points */ + final double x1 = xPoints.get(i - 1); + final double y1 = yPoints.get(i - 1); + final double x2 = xPoints.get(i); + final double y2 = yPoints.get(i); + + final double middleX = (x1 + x2) / 2; + + // REMARK: we can't produce a 100% vertical line, as the area-renderer will not work correctly + adjustedX.add(middleX - 0.0001); + adjustedY.add(y1); + + adjustedX.add(middleX + 0.0001); + adjustedY.add(y2); + } + + /* always add the real point now */ + adjustedX.add(xPoints.get(i)); + adjustedY.add(yPoints.get(i)); + } + + + return new double[][] { adjustedX.toNativeArray(), adjustedY.toNativeArray() }; } } \ No newline at end of file
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthProcessor.java Wed Feb 14 18:10:28 2018 +0100 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthProcessor.java Wed Feb 14 18:10:53 2018 +0100 @@ -11,8 +11,16 @@ package org.dive4elements.river.artifacts.sinfo.flowdepth; import java.util.HashSet; +import java.util.Map; import java.util.Set; +import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; +import org.dive4elements.artifacts.CallContext; +import org.dive4elements.river.exports.DiagramGenerator; +import org.dive4elements.river.exports.StyledSeriesBuilder; +import org.dive4elements.river.jfree.StyledXYSeries; +import org.dive4elements.river.themes.ThemeDocument; + public final class FlowDepthProcessor extends AbstractSInfoProcessor { /* Theme name, usually defined in 'FacetTypes', but that is soooo bad dependencies... */ @@ -35,9 +43,33 @@ super(I18N_AXIS_LABEL, HANDLED_FACET_TYPES); } + @Override + protected final String generateSeries(final DiagramGenerator generator, final ArtifactAndFacet bundle, final ThemeDocument theme, final boolean visible) { + + final CallContext context = generator.getCallContext(); + final Map<String, String> metaData = bundle.getFacet().getMetaData(); + + final StyledXYSeries series = new StyledXYSeries(bundle.getFacetDescription(), theme); + series.putMetaData(metaData, bundle.getArtifact(), context); + + final String facetName = bundle.getFacetName(); + final FlowDepthCalculationResult data = (FlowDepthCalculationResult) bundle.getData(context); + if (data == null) { + // Check has been here before so we keep it for security reasons + // this should never happen though. + throw new IllegalStateException("Data is null for facet: " + facetName); + } + + final double[][] points = generatePoints(data, facetName); + + StyledSeriesBuilder.addPoints(series, points, true); + generator.addAxisSeries(series, getAxisName(), visible); + + return metaData.get("Y"); + } + // FIXME: do filtering - @Override - protected double[][] generatePoints(final FlowDepthCalculationResult data, final String facetName) { + private double[][] generatePoints(final FlowDepthCalculationResult data, final String facetName) { if (FACET_FLOW_DEPTH_FILTERED.contentEquals(facetName)) return data.getFlowDepthPoints(); @@ -45,6 +77,7 @@ if (FACET_FLOW_DEPTH_TKH_FILTERED.contentEquals(facetName)) return data.getFlowDepthTkhPoints(); - return super.generatePoints(data, facetName); + final String error = String.format("Unknown facet name: %s", facetName); + throw new UnsupportedOperationException(error); } } \ No newline at end of file
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthRow.java Wed Feb 14 18:10:28 2018 +0100 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthRow.java Wed Feb 14 18:10:53 2018 +0100 @@ -1,6 +1,6 @@ /* Copyright (C) 2017 by Bundesanstalt für Gewässerkunde - * Software engineering by - * Björnsen Beratende Ingenieure GmbH + * Software engineering by + * Björnsen Beratende Ingenieure GmbH * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt * * This file is Free Software under the GNU AGPL (>=v3) @@ -13,78 +13,113 @@ /** * Part of {@link FlowDepthCalculationResult} which represents one calculated row of flow depth data. - * + * * @author Gernot Belger */ -final class FlowDepthRow -implements Serializable { - private final double station; - private final double flowDepth; - private final double flowDepthWithTkh; - private final double tkh; - private final double waterlevel; - private final double discharge; - private final String waterlevelLabel; - private final String gauge; - private final double meanBedHeight; - private final String soundageLabel; - private final String location; - - public FlowDepthRow( double station, double flowDepth, double flowDepthWithTkh, double tkh, double waterlevel, double discharge, String waterlevelLabel, String gauge, double meanBedHeight, String soundageLabel, String location ) { - this.station = station; - this.flowDepth = flowDepth; - this.flowDepthWithTkh = flowDepthWithTkh; - this.tkh = tkh; - this.waterlevel = waterlevel; - this.discharge = discharge; - this.waterlevelLabel = waterlevelLabel; - this.gauge = gauge; - this.meanBedHeight = meanBedHeight; - this.soundageLabel = soundageLabel; - this.location = location; - } - - public double getStation() { - return station; - } - - public double getFlowDepth() { - return flowDepth; - } +final class FlowDepthRow implements Serializable { + private static final long serialVersionUID = 1L; - public double getFlowDepthWithTkh() { - return flowDepthWithTkh; - } - - public double getTkh() { - return tkh; - } - - public double getWaterlevel() { - return waterlevel; - } - - public double getDischarge() { - return discharge; - } + private final double station; - public String getWaterlevelLabel() { - return waterlevelLabel; - } - - public String getGauge() { - return gauge; - } + private final double flowDepth; - public double getMeanBedHeight() { - return meanBedHeight; - } + private final double flowDepthWithTkh; - public String getSoundageLabel() { - return soundageLabel; - } + private final SoilKind tkhKind; - public String getLocation() { - return location; - } + private final double tkh; + + private final double tkhUp; + + private final double tkhDown; + + private final double waterlevel; + + private final double discharge; + + private final String waterlevelLabel; + + private final String gauge; + + private final double meanBedHeight; + + private final String soundageLabel; + + private final String location; + + public FlowDepthRow(final double station, final double flowDepth, final double flowDepthWithTkh, final SoilKind tkhKind, final double tkh, + final double tkhUp, final double tkhDown, + final double waterlevel, final double discharge, final String waterlevelLabel, final String gauge, final double meanBedHeight, + final String soundageLabel, final String location) { + this.station = station; + this.flowDepth = flowDepth; + this.flowDepthWithTkh = flowDepthWithTkh; + this.tkhKind = tkhKind; + this.tkh = tkh; + this.tkhUp = tkhUp; + this.tkhDown = tkhDown; + this.waterlevel = waterlevel; + this.discharge = discharge; + this.waterlevelLabel = waterlevelLabel; + this.gauge = gauge; + this.meanBedHeight = meanBedHeight; + this.soundageLabel = soundageLabel; + this.location = location; + } + + public double getStation() { + return this.station; + } + + public double getFlowDepth() { + return this.flowDepth; + } + + public double getFlowDepthWithTkh() { + return this.flowDepthWithTkh; + } + + public SoilKind getTkhKind() { + return this.tkhKind; + } + + public double getTkh() { + return this.tkh; + } + + public double getTkhUp() { + return this.tkhUp; + } + + public double getTkhDown() { + return this.tkhDown; + } + + public double getWaterlevel() { + return this.waterlevel; + } + + public double getDischarge() { + return this.discharge; + } + + public String getWaterlevelLabel() { + return this.waterlevelLabel; + } + + public String getGauge() { + return this.gauge; + } + + public double getMeanBedHeight() { + return this.meanBedHeight; + } + + public String getSoundageLabel() { + return this.soundageLabel; + } + + public String getLocation() { + return this.location; + } } \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/SoilKind.java Wed Feb 14 18:10:53 2018 +0100 @@ -0,0 +1,14 @@ +/** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde + * Software engineering by + * Björnsen Beratende Ingenieure GmbH + * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt + * + * This file is Free Software under the GNU AGPL (>=v3) + * and comes with ABSOLUTELY NO WARRANTY! Check out the + * documentation coming with Dive4Elements River for details. + */ +package org.dive4elements.river.artifacts.sinfo.flowdepth; + +public enum SoilKind { + mobil, starr +} \ No newline at end of file
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/TkhProcessor.java Wed Feb 14 18:10:28 2018 +0100 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/TkhProcessor.java Wed Feb 14 18:10:53 2018 +0100 @@ -13,6 +13,14 @@ import java.util.HashSet; import java.util.Set; +import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; +import org.dive4elements.artifacts.CallContext; +import org.dive4elements.river.exports.DiagramGenerator; +import org.dive4elements.river.exports.StyledSeriesBuilder; +import org.dive4elements.river.jfree.StyledAreaSeriesCollection; +import org.dive4elements.river.jfree.StyledXYSeries; +import org.dive4elements.river.themes.ThemeDocument; + public final class TkhProcessor extends AbstractSInfoProcessor { static String FACET_TKH = "sinfo_flow_depth.tkh"; @@ -30,10 +38,33 @@ } @Override - protected double[][] generatePoints(final FlowDepthCalculationResult data, final String facetName) { - if (FACET_TKH.contentEquals(facetName)) - return data.getTkhPoints(); + protected String generateSeries(final DiagramGenerator generator, final ArtifactAndFacet bundle, final ThemeDocument theme, final boolean visible) { + final CallContext context = generator.getCallContext(); - return super.generatePoints(data, facetName); + final String facetName = bundle.getFacetName(); + final FlowDepthCalculationResult data = (FlowDepthCalculationResult) bundle.getData(context); + if (data == null) { + // Check has been here before so we keep it for security reasons + // this should never happen though. + throw new IllegalStateException("Data is null for facet: " + facetName); + } + + final StyledXYSeries seriesUp = new StyledXYSeries(bundle.getFacetDescription(), theme); + final double[][] pointsUp = data.getTkhUpPoints(); + StyledSeriesBuilder.addPoints(seriesUp, pointsUp, true); + + // REMARK: we add " " because the description is misused as id, which must be unique. + final StyledXYSeries seriesDown = new StyledXYSeries(bundle.getFacetDescription() + " ", theme); + final double[][] pointsDown = data.getTkhDownPoints(); + StyledSeriesBuilder.addPoints(seriesDown, pointsDown, true); + + final StyledAreaSeriesCollection area = new StyledAreaSeriesCollection(theme); + area.setMode(StyledAreaSeriesCollection.FILL_MODE.BETWEEN); + area.addSeries(seriesUp); + area.addSeries(seriesDown); + + generator.addAreaSeries(area, getAxisName(), visible); + + return null; } } \ No newline at end of file