changeset 9365:ba1e2e8f05d1

sinfo.flowdepth Results.isShowRefGauge==false->spalte ausblenden; result.isShowRefGauge==false&&results.isShowRefGauge==true->result.refGauge=""
author gernotbelger
date Thu, 02 Aug 2018 15:02:27 +0200
parents 0124d67ce5ab
children 3d006afee054
files artifacts/doc/conf/jasper/templates/sinfo.flowdepth.jrxml artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthCalculation.java artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthCalculationResult.java artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthCalculationResults.java artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthCalculator.java artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthExporter.java artifacts/src/main/java/org/dive4elements/river/artifacts/states/WaterlevelData.java
diffstat 7 files changed, 49 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/doc/conf/jasper/templates/sinfo.flowdepth.jrxml	Thu Aug 02 11:47:49 2018 +0200
+++ b/artifacts/doc/conf/jasper/templates/sinfo.flowdepth.jrxml	Thu Aug 02 15:02:27 2018 +0200
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!-- Created with Jaspersoft Studio version 6.5.1.final using JasperReports Library version 4.5.0  -->
-<!-- 2018-07-31T17:35:59 -->
+<!-- 2018-08-02T14:38:57 -->
 <jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="flysreport" language="groovy" pageWidth="842" pageHeight="595" columnWidth="515" leftMargin="60" rightMargin="20" topMargin="20" bottomMargin="20">
 	<property name="ireport.zoom" value="1.0"/>
 	<property name="ireport.x" value="0"/>
@@ -147,13 +147,13 @@
 				<textFieldExpression><![CDATA[$F{meta:discharge_header} + "<br/>[m³/s]"]]></textFieldExpression>
 			</textField>
 			<textField isStretchWithOverflow="true">
-				<reportElement key="6" style="htmlStyle" positionType="Float" stretchType="RelativeToBandHeight" x="300" y="0" width="80" height="24"/>
+				<reportElement key="6" style="htmlStyle" positionType="Float" stretchType="RelativeToBandHeight" x="300" y="0" width="100" height="24"/>
 				<box padding="5"/>
 				<textElement verticalAlignment="Bottom"/>
 				<textFieldExpression><![CDATA[$F{meta:waterlevel_name_header}]]></textFieldExpression>
 			</textField>
 			<textField isStretchWithOverflow="true">
-				<reportElement key="7" style="htmlStyle" positionType="Float" stretchType="RelativeToBandHeight" x="380" y="0" width="110" height="24"/>
+				<reportElement key="refgauge" style="htmlStyle" positionType="Float" stretchType="RelativeToBandHeight" x="400" y="0" width="90" height="24"/>
 				<box padding="5"/>
 				<textElement verticalAlignment="Bottom"/>
 				<textFieldExpression><![CDATA[$F{meta:gauge_header}]]></textFieldExpression>
@@ -165,13 +165,13 @@
 				<textFieldExpression><![CDATA[$F{meta:bedheight_header} +  "<br/>[" + $F{meta:river_unit} + "]"]]></textFieldExpression>
 			</textField>
 			<textField isStretchWithOverflow="true">
-				<reportElement key="9" style="htmlStyle" positionType="Float" stretchType="RelativeToBandHeight" x="550" y="0" width="95" height="24"/>
+				<reportElement key="9" style="htmlStyle" positionType="Float" stretchType="RelativeToBandHeight" x="550" y="0" width="137" height="24"/>
 				<box padding="5"/>
 				<textElement verticalAlignment="Bottom"/>
 				<textFieldExpression><![CDATA[$F{meta:sounding_name_header}]]></textFieldExpression>
 			</textField>
 			<textField isStretchWithOverflow="true">
-				<reportElement key="10" style="htmlStyle" positionType="Float" stretchType="RelativeToBandHeight" x="645" y="0" width="122" height="24"/>
+				<reportElement key="10" style="htmlStyle" positionType="Float" stretchType="RelativeToBandHeight" x="687" y="0" width="80" height="24"/>
 				<box padding="5"/>
 				<textElement verticalAlignment="Bottom"/>
 				<textFieldExpression><![CDATA[$F{meta:location_header}]]></textFieldExpression>
@@ -219,13 +219,13 @@
 				<textFieldExpression><![CDATA[$F{data:5}]]></textFieldExpression>
 			</textField>
 			<textField isStretchWithOverflow="true" isBlankWhenNull="true">
-				<reportElement key="6" style="htmlStyle" positionType="Float" stretchType="RelativeToBandHeight" x="300" y="0" width="80" height="15"/>
+				<reportElement key="6" style="htmlStyle" positionType="Float" stretchType="RelativeToBandHeight" x="300" y="0" width="100" height="15"/>
 				<box topPadding="2" leftPadding="5" bottomPadding="0" rightPadding="5"/>
 				<textElement verticalAlignment="Top"/>
 				<textFieldExpression><![CDATA[$F{data:6}]]></textFieldExpression>
 			</textField>
 			<textField isStretchWithOverflow="true" isBlankWhenNull="true">
-				<reportElement key="7" style="htmlStyle" positionType="Float" stretchType="RelativeToBandHeight" x="380" y="0" width="110" height="15"/>
+				<reportElement key="refgauge" style="htmlStyle" positionType="Float" stretchType="RelativeToBandHeight" x="400" y="0" width="90" height="15"/>
 				<box topPadding="2" leftPadding="5" bottomPadding="0" rightPadding="5"/>
 				<textElement verticalAlignment="Top"/>
 				<textFieldExpression><![CDATA[$F{data:7}]]></textFieldExpression>
@@ -237,7 +237,7 @@
 				<textFieldExpression><![CDATA[$F{data:8}]]></textFieldExpression>
 			</textField>
 			<textField isStretchWithOverflow="true" isBlankWhenNull="true">
-				<reportElement key="9" style="htmlStyle" positionType="Float" x="550" y="0" width="95" height="15" isRemoveLineWhenBlank="true" isPrintWhenDetailOverflows="true">
+				<reportElement key="9" style="htmlStyle" positionType="Float" x="550" y="0" width="137" height="15" isRemoveLineWhenBlank="true" isPrintWhenDetailOverflows="true">
 					<property name="net.sf.jasperreports.export.pdf.force.linebreak.policy" value="true"/>
 					<property name="net.sf.jasperreports.text.save.line.breaks" value="false"/>
 				</reportElement>
@@ -246,7 +246,7 @@
 				<textFieldExpression><![CDATA[$F{data:9}]]></textFieldExpression>
 			</textField>
 			<textField isStretchWithOverflow="true" isBlankWhenNull="true">
-				<reportElement key="10" style="htmlStyle" positionType="Float" stretchType="RelativeToBandHeight" x="645" y="0" width="122" height="15"/>
+				<reportElement key="10" style="htmlStyle" positionType="Float" stretchType="RelativeToBandHeight" x="687" y="0" width="80" height="15"/>
 				<box topPadding="2" leftPadding="5" bottomPadding="0" rightPadding="5"/>
 				<textElement verticalAlignment="Top"/>
 				<textFieldExpression><![CDATA[$F{data:10}]]></textFieldExpression>
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthCalculation.java	Thu Aug 02 11:47:49 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthCalculation.java	Thu Aug 02 15:02:27 2018 +0200
@@ -115,7 +115,7 @@
         final TkhCalculator tkhCalculator = TkhCalculator.buildTkhCalculator(useTkh, problems, label, river, calcRange, waterlevelProvider, dischargeProvider,
                 bedHeight);
 
-        final FlowDepthCalculator calculator = new FlowDepthCalculator(riverInfoProvider, wspLabel, bedHeight, tkhCalculator);
+        final FlowDepthCalculator calculator = new FlowDepthCalculator(riverInfoProvider, wspLabel, bedHeight, tkhCalculator, wstInfo.isShowRefGauges());
         return calculator.execute(label, wstInfo, calcRange);
     }
 }
\ No newline at end of file
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthCalculationResult.java	Thu Aug 02 11:47:49 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthCalculationResult.java	Thu Aug 02 15:02:27 2018 +0200
@@ -58,7 +58,7 @@
     public void writeCSVHeader(final ExportContextCSV exportContext, final RiverInfo river) {
         // getLog().info("FlowDepthExporter.writeCSVHeader");
 
-        final Collection<String> header = new ArrayList<>(11);
+        final Collection<String> header = new ArrayList<>(15);
 
         header.add(exportContext.formatCsvHeader(GeneralResultType.station));
         header.add(exportContext.msgUnitCSV(SInfoResultType.flowdepth));
@@ -71,7 +71,11 @@
         header.add(exportContext.msgUnitCSV(SInfoResultType.waterlevel, river.getWstUnit()));
         header.add(exportContext.msgUnitCSV(SInfoResultType.discharge));
         header.add(exportContext.formatCsvHeader(GeneralResultType.waterlevelLabel));
-        header.add(exportContext.formatCsvHeader(GeneralResultType.gaugeLabel));
+
+        if (((FlowDepthCalculationResults) exportContext.getResults()).isShowRefGauges()) {
+            header.add(exportContext.formatCsvHeader(GeneralResultType.gaugeLabel));
+        }
+
         header.add(exportContext.formatCsvHeader(SInfoResultType.meanBedHeight));
         header.add(exportContext.formatCsvHeader(SInfoResultType.soundingLabel));
         header.add(exportContext.formatCsvHeader(GeneralResultType.location));
@@ -144,7 +148,11 @@
         lines.add(exportContext.formatRowValue(row, SInfoResultType.waterlevel));
         lines.add(exportContext.formatRowValue(row, SInfoResultType.discharge));
         lines.add(exportContext.formatRowValue(row, GeneralResultType.waterlevelLabel));
-        lines.add(exportContext.formatRowValue(row, GeneralResultType.gaugeLabel));
+
+        if (mode == ExportMode.pdf || results.isShowRefGauges()) {
+            lines.add(exportContext.formatRowValue(row, GeneralResultType.gaugeLabel));
+        }
+
         lines.add(exportContext.formatRowValue(row, SInfoResultType.meanBedHeight));
         lines.add(exportContext.formatRowValue(row, SInfoResultType.soundingLabel));
         lines.add(exportContext.formatRowValue(row, GeneralResultType.location));
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthCalculationResults.java	Thu Aug 02 11:47:49 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthCalculationResults.java	Thu Aug 02 15:02:27 2018 +0200
@@ -42,4 +42,13 @@
 
         return false;
     }
+
+    public boolean isShowRefGauges() {
+        for (final FlowDepthCalculationResult result : getResults()) {
+            if (result.isShowRefGauges())
+                return true;
+        }
+
+        return false;
+    }
 }
\ No newline at end of file
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthCalculator.java	Thu Aug 02 11:47:49 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthCalculator.java	Thu Aug 02 15:02:27 2018 +0200
@@ -39,14 +39,17 @@
 
     private final String wstLabel;
 
+    private final boolean showRefGauges;
+
     public FlowDepthCalculator(final RiverInfoProvider riverInfoProvider, final String wstLabel, final BedHeightsFinder bedHeight,
-            final TkhCalculator tkhCalculator) {
+            final TkhCalculator tkhCalculator, final boolean showRefGauges) {
 
         this.riverInfoProvider = riverInfoProvider;
         this.wstLabel = wstLabel;
 
         this.bedHeight = bedHeight;
         this.tkhCalculator = tkhCalculator;
+        this.showRefGauges = showRefGauges;
 
         this.bedHeightLabel = bedHeight.getInfo().getDescription();
     }
@@ -72,8 +75,10 @@
         row.putValue(SInfoResultType.soundingLabel, this.bedHeightLabel);
 
         // REMARK: access the gauge once only during calculation
-        final String gaugeLabel = this.riverInfoProvider.findGauge(station);
-        row.putValue(GeneralResultType.gaugeLabel, gaugeLabel);
+        if (this.showRefGauges) {
+            final String gaugeLabel = this.riverInfoProvider.findGauge(station);
+            row.putValue(GeneralResultType.gaugeLabel, gaugeLabel);
+        }
 
         // REMARK: access the location once only during calculation
         final String location = this.riverInfoProvider.getLocation(station);
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthExporter.java	Thu Aug 02 11:47:49 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthExporter.java	Thu Aug 02 15:02:27 2018 +0200
@@ -41,5 +41,10 @@
                 design.removeColumn("tkh");
                 design.removeColumn("flowdepthtkh");
             }
+
+        if (result instanceof FlowDepthCalculationResult)
+            if (!result.isShowRefGauges()) {
+                design.removeColumn("refgauge");
+            }
     }
 }
\ No newline at end of file
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/WaterlevelData.java	Thu Aug 02 11:47:49 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/WaterlevelData.java	Thu Aug 02 15:02:27 2018 +0200
@@ -29,13 +29,13 @@
     /** If <code>true</code>, tabular export will show gauges for every station, else only for the first gauge */
     private final boolean showAllGauges;
 
-    private boolean showRefGauges;
+    private final boolean showRefGauges;
 
-    public WaterlevelData(final WKms wkms, final int year, final boolean showAllGauges, boolean showRefGauges) {
+    public WaterlevelData(final WKms wkms, final int year, final boolean showAllGauges, final boolean showRefGauges) {
         this(wkms.getName(), wkms, year, showAllGauges, showRefGauges);
     }
 
-    private WaterlevelData(final String name, final WKms wkms, final int year, final boolean showAllGauges, boolean showRefGauges) {
+    private WaterlevelData(final String name, final WKms wkms, final int year, final boolean showAllGauges, final boolean showRefGauges) {
         this.name = name;
         this.wkms = wkms;
         this.year = year;
@@ -49,11 +49,11 @@
         }
 
         final WKms filteredWkms = this.wkms.filteredKms(from, to);
-        return new WaterlevelData(this.name, filteredWkms, this.year, this.showAllGauges ,showRefGauges);
+        return new WaterlevelData(this.name, filteredWkms, this.year, this.showAllGauges, this.showRefGauges);
     }
 
     public WaterlevelData withName(final String nameToSet) {
-        return new WaterlevelData(nameToSet, this.wkms, this.year, this.showAllGauges, showRefGauges);
+        return new WaterlevelData(nameToSet, this.wkms, this.year, this.showAllGauges, this.showRefGauges);
     }
 
     public String getName() {
@@ -67,7 +67,7 @@
     public boolean isShowAllGauges() {
         return this.showAllGauges;
     }
-    
+
     public boolean isShowRefGauges() {
         return this.showRefGauges;
     }

http://dive4elements.wald.intevation.org