# HG changeset patch # User gernotbelger # Date 1532613260 -7200 # Node ID 740d65e4aa145895855f2d9ea73af609fe1d0794 # Parent 7c7f73e5e01ebe47f8e93e2e973a9ea6c1c73c76 Q [m³/s] one message diff -r 7c7f73e5e01e -r 740d65e4aa14 artifacts/src/main/java/org/dive4elements/river/artifacts/common/ExportContextCSV.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/common/ExportContextCSV.java Thu Jul 26 11:16:06 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/common/ExportContextCSV.java Thu Jul 26 15:54:20 2018 +0200 @@ -33,19 +33,19 @@ */ public final class ExportContextCSV extends AbstractExportContext { - private static final String CSV_META_HEADER_EVALUATOR = "sinfo.export.flow_depth.csv.meta.header.sounding.evaluator"; - - private static final String CSV_META_HEADER_SOUNDING = "sinfo.export.flow_depth.csv.meta.header.sounding"; - - private static final String CSV_META_HEADER_SOUNDING_YEAR = "sinfo.export.flow_depth.csv.meta.header.sounding.year"; + private static final String CSV_META_HEADER_EVALUATOR = "common.export.csv.meta.header.sounding.evaluator"; - private static final String CSV_META_HEADER_SOUNDING_TYPE = "sinfo.export.flow_depth.csv.meta.header.sounding.type"; + private static final String CSV_META_HEADER_SOUNDING = "common.export.csv.meta.header.sounding"; - private static final String CSV_META_HEADER_SOUNDING_PRJ = "sinfo.export.flow_depth.csv.meta.header.sounding.prj"; + private static final String CSV_META_HEADER_SOUNDING_YEAR = "common.export.csv.meta.header.sounding.year"; - private static final String CSV_META_HEADER_SOUNDING_ELEVATIOIN_MODEL = "sinfo.export.flow_depth.csv.meta.header.sounding.elevationmodel"; + private static final String CSV_META_HEADER_SOUNDING_TYPE = "common.export.csv.meta.header.sounding.type"; - private static final String CSV_META_HEADER_SOUNDING_ELEVATIOIN_MODEL_ORIGINAL = "sinfo.export.flow_depth.csv.meta.header.sounding.elevationmodel.original"; + private static final String CSV_META_HEADER_SOUNDING_PRJ = "common.export.csv.meta.header.sounding.prj"; + + private static final String CSV_META_HEADER_SOUNDING_ELEVATIOIN_MODEL = "common.export.csv.meta.header.sounding.elevationmodel"; + + private static final String CSV_META_HEADER_SOUNDING_ELEVATIOIN_MODEL_ORIGINAL = "common.export.csv.meta.header.sounding.elevationmodel.original"; private final CSVWriter writer; diff -r 7c7f73e5e01e -r 740d65e4aa14 artifacts/src/main/java/org/dive4elements/river/artifacts/common/GeneralResultType.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/common/GeneralResultType.java Thu Jul 26 11:16:06 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/common/GeneralResultType.java Thu Jul 26 15:54:20 2018 +0200 @@ -13,6 +13,7 @@ import java.util.Date; import org.dive4elements.artifacts.CallContext; +import org.dive4elements.river.artifacts.sinfo.common.SInfoI18NStrings; import org.dive4elements.river.utils.Formatter; /** @@ -56,4 +57,34 @@ private GeneralResultType(final String unit, final String csvHeader, final String pdfHeader) { super(unit, csvHeader, pdfHeader); } + + public static final GeneralResultType location = new GeneralResultType(I18NStrings.UNIT_NONE, SInfoI18NStrings.CSV_LOCATION_HEADER) { + private static final long serialVersionUID = 1L; + + @Override + public String exportValue(final CallContext context, final Object value) { + return exportStringValue(value); + } + + @Override + protected NumberFormat createFormatter(final CallContext context) { + throw new UnsupportedOperationException(); + } + }; + + public static final GeneralResultType dischargeQwithUnit = new GeneralResultType(I18NStrings.UNIT_NONE, "common.export.csv.header.q", + "common.export.csv.header.q") { // Q [m³/s] + private static final long serialVersionUID = 1L; + + @Override + public String exportValue(final CallContext context, final Object value) { + final double doubleValue = asDouble(value); + return exportDoubleValue(context, doubleValue); + } + + @Override + protected NumberFormat createFormatter(final CallContext context) { + return Formatter.getWaterlevelQ(context); + } + }; } \ No newline at end of file diff -r 7c7f73e5e01e -r 740d65e4aa14 artifacts/src/main/java/org/dive4elements/river/artifacts/services/DischargeTablesOverview.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/services/DischargeTablesOverview.java Thu Jul 26 11:16:06 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/services/DischargeTablesOverview.java Thu Jul 26 15:54:20 2018 +0200 @@ -18,6 +18,16 @@ import java.util.Locale; import org.apache.log4j.Logger; +import org.dive4elements.artifacts.CallMeta; +import org.dive4elements.artifacts.GlobalContext; +import org.dive4elements.river.artifacts.model.DischargeTables; +import org.dive4elements.river.artifacts.model.GaugesFactory; +import org.dive4elements.river.artifacts.resources.Resources; +import org.dive4elements.river.backend.SessionHolder; +import org.dive4elements.river.model.DischargeTable; +import org.dive4elements.river.model.Gauge; +import org.dive4elements.river.model.MainValue; +import org.dive4elements.river.model.TimeInterval; import org.jfree.chart.ChartFactory; import org.jfree.chart.JFreeChart; import org.jfree.chart.plot.Marker; @@ -29,50 +39,29 @@ import org.w3c.dom.Element; import org.w3c.dom.NodeList; -import org.dive4elements.artifacts.CallMeta; -import org.dive4elements.artifacts.GlobalContext; -import org.dive4elements.river.artifacts.model.DischargeTables; -import org.dive4elements.river.artifacts.model.GaugesFactory; -import org.dive4elements.river.artifacts.resources.Resources; -import org.dive4elements.river.backend.SessionHolder; -import org.dive4elements.river.model.DischargeTable; -import org.dive4elements.river.model.Gauge; -import org.dive4elements.river.model.MainValue; -import org.dive4elements.river.model.TimeInterval; - - /** Generate Discharge Table chart. */ public class DischargeTablesOverview extends AbstractChartService { - private static final Logger log = Logger - .getLogger(DischargeTablesOverview.class); + private static final Logger log = Logger.getLogger(DischargeTablesOverview.class); private static final long serialVersionUID = 1L; - public static final String I18N_CHART_TITLE = - "gauge.discharge.service.chart.title"; + public static final String I18N_CHART_TITLE = "gauge.discharge.service.chart.title"; public static final String DEFAULT_CHART_TITLE = "Pegel: XXX"; - public static final String I18N_CHART_X_AXIS_TITLE = - "gauge.discharge.service.chart.x.title"; + public static final String I18N_CHART_X_AXIS_TITLE = "common.export.csv.header.q"; public static final String DEFAULT_X_AXIS_TITLE = "Q [m^3/s]"; - public static final String I18N_CHART_Y_AXIS_TITLE = - "gauge.discharge.service.chart.y.title"; + public static final String I18N_CHART_Y_AXIS_TITLE = "gauge.discharge.service.chart.y.title"; public static final String DEFAULT_Y_AXIS_TITLE = "W [cm]"; - public static final String I18N_CHART_SERIES_TITLE = - "gauge.discharge.service.chart.series.title"; + public static final String I18N_CHART_SERIES_TITLE = "gauge.discharge.service.chart.series.title"; public static final String DEFAULT_CHART_SERIES_TITLE = "Abflusskurve"; - public static final String I18N_CHART_SERIES_TITLE_MASTER = - "gauge.discharge.service.chart.series.title.master"; - public static final String DEFAULT_CHART_SERIES_TITLE_MASTER = - "Aktuelle Abflusskurve"; + public static final String I18N_CHART_SERIES_TITLE_MASTER = "gauge.discharge.service.chart.series.title.master"; + public static final String DEFAULT_CHART_SERIES_TITLE_MASTER = "Aktuelle Abflusskurve"; - public static final DateFormat DATE_FORMAT = DateFormat.getDateInstance( - DateFormat.SHORT, Locale.GERMANY); - + public static final DateFormat DATE_FORMAT = DateFormat.getDateInstance(DateFormat.SHORT, Locale.GERMANY); @Override protected void init() { @@ -84,10 +73,10 @@ SessionHolder.release(); } - protected JFreeChart createChart(Document data, - GlobalContext globalContext, CallMeta callMeta) { + @Override + protected JFreeChart createChart(final Document data, final GlobalContext globalContext, final CallMeta callMeta) { - Gauge gauge = extractGauge(data); + final Gauge gauge = extractGauge(data); if (gauge == null) { log.warn("Could not determine Gauge from request!"); @@ -95,39 +84,34 @@ } log.info("create discharge chart for gauge '" + gauge.getName() + "'"); - TimeInterval timerange = extractTimeInterval(data); + final TimeInterval timerange = extractTimeInterval(data); - List dts = getDischargeTables(gauge, timerange); - XYSeriesCollection dataset = new XYSeriesCollection(); + final List dts = getDischargeTables(gauge, timerange); + final XYSeriesCollection dataset = new XYSeriesCollection(); - for (DischargeTable dt : dts) { + for (final DischargeTable dt : dts) { try { - XYSeries series = createSeries(callMeta, dt); + final XYSeries series = createSeries(callMeta, dt); if (series != null) { dataset.addSeries(series); } } - catch (IllegalArgumentException iae) { - log.warn("unable to create discharge curve: " - + iae.getMessage()); + catch (final IllegalArgumentException iae) { + log.warn("unable to create discharge curve: " + iae.getMessage()); } } - String title = Resources.format(callMeta, I18N_CHART_TITLE, - DEFAULT_CHART_TITLE, gauge.getName()); + final String title = Resources.format(callMeta, I18N_CHART_TITLE, DEFAULT_CHART_TITLE, gauge.getName()); - String xAxis = Resources.getMsg(callMeta, I18N_CHART_X_AXIS_TITLE, - DEFAULT_X_AXIS_TITLE); + final String xAxis = Resources.getMsg(callMeta, I18N_CHART_X_AXIS_TITLE, DEFAULT_X_AXIS_TITLE); - String yAxis = Resources.format(callMeta, I18N_CHART_Y_AXIS_TITLE, - DEFAULT_Y_AXIS_TITLE); + final String yAxis = Resources.format(callMeta, I18N_CHART_Y_AXIS_TITLE, DEFAULT_Y_AXIS_TITLE); - JFreeChart chart = ChartFactory.createXYLineChart(title, xAxis, yAxis, - null, PlotOrientation.VERTICAL, true, true, false); + final JFreeChart chart = ChartFactory.createXYLineChart(title, xAxis, yAxis, null, PlotOrientation.VERTICAL, true, true, false); chart.setBackgroundPaint(Color.white); - XYPlot plot = (XYPlot) chart.getPlot(); + final XYPlot plot = (XYPlot) chart.getPlot(); plot.setDataset(0, dataset); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.gray); @@ -135,22 +119,18 @@ plot.setDomainGridlinesVisible(true); plot.setRangeGridlinesVisible(true); - applyMainValueMarkers( - plot, - gauge, - callMeta); + applyMainValueMarkers(plot, gauge, callMeta); return chart; } - protected XYSeries createSeries(CallMeta callMeta, DischargeTable dt) - throws IllegalArgumentException { + protected XYSeries createSeries(final CallMeta callMeta, final DischargeTable dt) throws IllegalArgumentException { double[][] xy = null; xy = DischargeTables.loadDischargeTableValues(dt); - XYSeries series = new XYSeries(createSeriesTitle(callMeta, dt), false); + final XYSeries series = new XYSeries(createSeriesTitle(callMeta, dt), false); for (int i = 0, n = xy[0].length; i < n; i++) { series.add(xy[0][i], xy[1][i]); } @@ -158,74 +138,56 @@ return series; } - /** Add domain markers to plot that indicate mainvalues. */ - protected static void applyMainValueMarkers( - XYPlot plot, - Gauge gauge, - CallMeta meta - ) { - String river = gauge.getRiver().getName(); - double km = gauge.getStation().doubleValue(); + protected static void applyMainValueMarkers(final XYPlot plot, final Gauge gauge, final CallMeta meta) { + final String river = gauge.getRiver().getName(); + final double km = gauge.getStation().doubleValue(); // Get Gauge s mainvalues. - List mainValues = gauge.getMainValues(); - for (MainValue mainValue : mainValues) { + final List mainValues = gauge.getMainValues(); + for (final MainValue mainValue : mainValues) { if (mainValue.getMainValue().getType().getName().equals("Q")) { // Its a Q main value. - Marker m = FixingsKMChartService.createQSectorMarker( - mainValue.getValue().doubleValue(), - mainValue.getMainValue().getName()); + final Marker m = FixingsKMChartService.createQSectorMarker(mainValue.getValue().doubleValue(), mainValue.getMainValue().getName()); plot.addDomainMarker(m); - } - else if ( - mainValue.getMainValue().getType().getName().equals("W") - ) { + } else if (mainValue.getMainValue().getType().getName().equals("W")) { // Its a W main value. - Marker m = FixingsKMChartService.createQSectorMarker( - mainValue.getValue().doubleValue(), - mainValue.getMainValue().getName()); + final Marker m = FixingsKMChartService.createQSectorMarker(mainValue.getValue().doubleValue(), mainValue.getMainValue().getName()); plot.addRangeMarker(m); } } } - protected String createSeriesTitle(CallMeta callMeta, DischargeTable dt) - throws IllegalArgumentException { - TimeInterval timeInterval = dt.getTimeInterval(); + protected String createSeriesTitle(final CallMeta callMeta, final DischargeTable dt) throws IllegalArgumentException { + final TimeInterval timeInterval = dt.getTimeInterval(); if (timeInterval == null) { return Resources.format(callMeta, DEFAULT_CHART_SERIES_TITLE); } - Date start = timeInterval.getStartTime(); - Date end = timeInterval.getStopTime(); + final Date start = timeInterval.getStartTime(); + final Date end = timeInterval.getStopTime(); if (start != null && end != null) { - return Resources.format(callMeta, I18N_CHART_SERIES_TITLE, - DEFAULT_CHART_SERIES_TITLE, start, end); - } - else if (start != null) { - return Resources.format(callMeta, I18N_CHART_SERIES_TITLE_MASTER, - DEFAULT_CHART_SERIES_TITLE, start); - } - else { - throw new IllegalArgumentException( - "Missing start date of DischargeTable " + dt.getId()); + return Resources.format(callMeta, I18N_CHART_SERIES_TITLE, DEFAULT_CHART_SERIES_TITLE, start, end); + } else if (start != null) { + return Resources.format(callMeta, I18N_CHART_SERIES_TITLE_MASTER, DEFAULT_CHART_SERIES_TITLE, start); + } else { + throw new IllegalArgumentException("Missing start date of DischargeTable " + dt.getId()); } } - protected Gauge extractGauge(Document data) { - NodeList gauges = data.getElementsByTagName("gauge"); + protected Gauge extractGauge(final Document data) { + final NodeList gauges = data.getElementsByTagName("gauge"); if (gauges.getLength() > 0) { - String name = ((Element) gauges.item(0)).getAttribute("name"); + final String name = ((Element) gauges.item(0)).getAttribute("name"); try { - long officialNumber = Long.valueOf(name); + final long officialNumber = Long.valueOf(name); return Gauge.getGaugeByOfficialNumber(officialNumber); } - catch (NumberFormatException nfe) { + catch (final NumberFormatException nfe) { // it seems, that the client uses the name of the gauge instead // of its official number } @@ -238,23 +200,23 @@ return null; } - protected TimeInterval extractTimeInterval(Document data) { - NodeList timeranges = data.getElementsByTagName("timerange"); + protected TimeInterval extractTimeInterval(final Document data) { + final NodeList timeranges = data.getElementsByTagName("timerange"); if (timeranges != null && timeranges.getLength() > 0) { - Element timerange = (Element) timeranges.item(0); + final Element timerange = (Element) timeranges.item(0); - String lower = timerange.getAttribute("lower"); - String upper = timerange.getAttribute("upper"); + final String lower = timerange.getAttribute("lower"); + final String upper = timerange.getAttribute("upper"); if (lower != null && upper != null) { try { - Date d1 = DATE_FORMAT.parse(lower); - Date d2 = DATE_FORMAT.parse(upper); + final Date d1 = DATE_FORMAT.parse(lower); + final Date d2 = DATE_FORMAT.parse(upper); return new TimeInterval(d1, d2); } - catch (ParseException pe) { + catch (final ParseException pe) { log.warn("Wrong time format: " + pe.getMessage()); } } @@ -263,36 +225,33 @@ return null; } - protected List getDischargeTables(Gauge gauge, - TimeInterval timerange) { - List all = gauge.getDischargeTables(); + protected List getDischargeTables(final Gauge gauge, final TimeInterval timerange) { + final List all = gauge.getDischargeTables(); Collections.sort(all); if (timerange == null) { return all; } - List dts = new ArrayList(all.size()); - long startDate = timerange.getStartTime().getTime(); - long stopDate = timerange.getStopTime().getTime(); + final List dts = new ArrayList<>(all.size()); + final long startDate = timerange.getStartTime().getTime(); + final long stopDate = timerange.getStopTime().getTime(); - for (DischargeTable dt : all) { - TimeInterval tmp = dt.getTimeInterval(); + for (final DischargeTable dt : all) { + final TimeInterval tmp = dt.getTimeInterval(); if (tmp == null) { // this should never happen because all discharge tables should // have a time interval set! continue; } - Date start = tmp.getStartTime(); - Date stop = tmp.getStartTime(); + final Date start = tmp.getStartTime(); + final Date stop = tmp.getStartTime(); if (start.getTime() > startDate && start.getTime() < stopDate) { dts.add(dt); continue; - } - else if (stop != null && stop.getTime() < stopDate - && stop.getTime() > startDate) { + } else if (stop != null && stop.getTime() < stopDate && stop.getTime() > startDate) { dts.add(dt); continue; } diff -r 7c7f73e5e01e -r 740d65e4aa14 artifacts/src/main/java/org/dive4elements/river/artifacts/services/FixingsKMChartService.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/services/FixingsKMChartService.java Thu Jul 26 11:16:06 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/services/FixingsKMChartService.java Thu Jul 26 15:54:20 2018 +0200 @@ -8,255 +8,167 @@ package org.dive4elements.river.artifacts.services; -import org.dive4elements.artifactdatabase.DefaultService; - -import org.dive4elements.artifacts.CallMeta; -import org.dive4elements.artifacts.GlobalContext; -import org.dive4elements.artifacts.Service; - -import org.dive4elements.river.artifacts.model.FixingsColumn; -import org.dive4elements.river.artifacts.model.FixingsColumnFactory; -import org.dive4elements.river.artifacts.model.FixingsFilterBuilder; - -import org.dive4elements.river.artifacts.model.FixingsOverview.Fixing; - -import org.dive4elements.river.artifacts.model.FixingsOverview; -import org.dive4elements.river.artifacts.model.FixingsOverviewFactory; -import org.dive4elements.river.artifacts.model.GaugeFinder; -import org.dive4elements.river.artifacts.model.GaugeFinderFactory; -import org.dive4elements.river.artifacts.model.GaugeRange; - -import org.dive4elements.river.artifacts.model.fixings.QWI; - -import org.dive4elements.river.artifacts.resources.Resources; - -import org.dive4elements.river.backend.SessionHolder; - -import org.dive4elements.river.jfree.ShapeRenderer; - -import org.dive4elements.river.utils.Formatter; -import org.dive4elements.river.utils.Pair; - import java.awt.BasicStroke; import java.awt.Color; import java.awt.Dimension; import java.awt.Transparency; - import java.awt.geom.Rectangle2D; - import java.awt.image.BufferedImage; - import java.io.ByteArrayOutputStream; import java.io.IOException; - import java.util.ArrayList; import java.util.List; import javax.imageio.ImageIO; import org.apache.log4j.Logger; - +import org.dive4elements.artifactdatabase.DefaultService; +import org.dive4elements.artifacts.CallMeta; +import org.dive4elements.artifacts.GlobalContext; +import org.dive4elements.artifacts.Service; +import org.dive4elements.river.artifacts.model.FixingsColumn; +import org.dive4elements.river.artifacts.model.FixingsColumnFactory; +import org.dive4elements.river.artifacts.model.FixingsFilterBuilder; +import org.dive4elements.river.artifacts.model.FixingsOverview; +import org.dive4elements.river.artifacts.model.FixingsOverview.Fixing; +import org.dive4elements.river.artifacts.model.FixingsOverviewFactory; +import org.dive4elements.river.artifacts.model.GaugeFinder; +import org.dive4elements.river.artifacts.model.GaugeFinderFactory; +import org.dive4elements.river.artifacts.model.GaugeRange; +import org.dive4elements.river.artifacts.model.fixings.QWI; +import org.dive4elements.river.artifacts.resources.Resources; +import org.dive4elements.river.backend.SessionHolder; +import org.dive4elements.river.jfree.ShapeRenderer; +import org.dive4elements.river.utils.Formatter; +import org.dive4elements.river.utils.Pair; import org.jfree.chart.ChartFactory; import org.jfree.chart.JFreeChart; import org.jfree.chart.LegendItemCollection; - import org.jfree.chart.axis.NumberAxis; - import org.jfree.chart.plot.Marker; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.ValueMarker; import org.jfree.chart.plot.XYPlot; - import org.jfree.data.Range; - import org.jfree.ui.RectangleAnchor; import org.jfree.ui.TextAnchor; - import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NodeList; - /** Serve chart of Fixings at certain km. */ -public class FixingsKMChartService -extends DefaultService -{ - private static final Logger log = - Logger.getLogger(FixingsKMChartService.class); +public class FixingsKMChartService extends DefaultService { + private static final Logger log = Logger.getLogger(FixingsKMChartService.class); - public static final int DEFAULT_WIDTH = 240; + public static final int DEFAULT_WIDTH = 240; public static final int DEFAULT_HEIGHT = 180; - public static final String [] I18N_Q_SECTOR_BOARDERS = { - "fix.km.chart.q.sector.border0", - "fix.km.chart.q.sector.border1", - "fix.km.chart.q.sector.border2" - }; - - public static final String [] DEFAULT_Q_SECTOR_BORDERS = { - "(MNQ + MQ)/2", - "(MQ + MHQ)/2", - "HQ5" - }; - - public static final String I18N_CHART_LABEL_DATE = - "fix.km.chart.label.date"; - - public static final String DEFAULT_CHART_LABEL_DATE = - "yyyy/MM/dd"; - - public static final String I18N_CHART_TITLE = - "fix.km.chart.title"; + public static final String[] I18N_Q_SECTOR_BOARDERS = { "fix.km.chart.q.sector.border0", "fix.km.chart.q.sector.border1", "fix.km.chart.q.sector.border2" }; - public static final String DEFAULT_CHART_TITLE = - "Fixings {0} km {1,number,#.###}"; - - public static final String I18N_Q_AXIS = - "fix.km.chart.q.axis"; - - public static final String DEFAULT_Q_AXIS = - "Q [m\u00b3/s]"; - - public static final String I18N_W_AXIS = - "fix.km.chart.w.axis"; + public static final String[] DEFAULT_Q_SECTOR_BORDERS = { "(MNQ + MQ)/2", "(MQ + MHQ)/2", "HQ5" }; - public static final String DEFAULT_W_AXIS = - "W [NN + m]"; - - public static final String I18N_MEASURED = - "fix.km.chart.measured"; + public static final String I18N_CHART_LABEL_DATE = "fix.km.chart.label.date"; - public static final String DEFAULT_MEASURED = - "measured"; + public static final String DEFAULT_CHART_LABEL_DATE = "yyyy/MM/dd"; - public static final String I18N_INTERPOLATED = - "fix.km.chart.interpolated"; + public static final String I18N_CHART_TITLE = "fix.km.chart.title"; - public static final String DEFAULT_INTERPOLATED = - "interpolated"; + public static final String DEFAULT_CHART_TITLE = "Fixings {0} km {1,number,#.###}"; + + public static final String I18N_Q_AXIS = "common.export.csv.header.q"; + + public static final String DEFAULT_Q_AXIS = "Q [m\u00b3/s]"; + + public static final String I18N_W_AXIS = "fix.km.chart.w.axis"; + + public static final String DEFAULT_W_AXIS = "W [NN + m]"; + + public static final String I18N_MEASURED = "fix.km.chart.measured"; + + public static final String DEFAULT_MEASURED = "measured"; + + public static final String I18N_INTERPOLATED = "fix.km.chart.interpolated"; + + public static final String DEFAULT_INTERPOLATED = "interpolated"; public static final String DEFAULT_FORMAT = "png"; // TODO: Load fancy image from resources. - public static final byte [] EMPTY = { - (byte)0x89, (byte)0x50, (byte)0x4e, (byte)0x47, - (byte)0x0d, (byte)0x0a, (byte)0x1a, (byte)0x0a, - (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x0d, - (byte)0x49, (byte)0x48, (byte)0x44, (byte)0x52, - (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x01, - (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x01, - (byte)0x08, (byte)0x00, (byte)0x00, (byte)0x00, - (byte)0x00, (byte)0x3a, (byte)0x7e, (byte)0x9b, - (byte)0x55, (byte)0x00, (byte)0x00, (byte)0x00, - (byte)0x01, (byte)0x73, (byte)0x52, (byte)0x47, - (byte)0x42, (byte)0x00, (byte)0xae, (byte)0xce, - (byte)0x1c, (byte)0xe9, (byte)0x00, (byte)0x00, - (byte)0x00, (byte)0x09, (byte)0x70, (byte)0x48, - (byte)0x59, (byte)0x73, (byte)0x00, (byte)0x00, - (byte)0x0b, (byte)0x13, (byte)0x00, (byte)0x00, - (byte)0x0b, (byte)0x13, (byte)0x01, (byte)0x00, - (byte)0x9a, (byte)0x9c, (byte)0x18, (byte)0x00, - (byte)0x00, (byte)0x00, (byte)0x07, (byte)0x74, - (byte)0x49, (byte)0x4d, (byte)0x45, (byte)0x07, - (byte)0xdc, (byte)0x04, (byte)0x04, (byte)0x10, - (byte)0x30, (byte)0x15, (byte)0x7d, (byte)0x77, - (byte)0x36, (byte)0x0b, (byte)0x00, (byte)0x00, - (byte)0x00, (byte)0x08, (byte)0x74, (byte)0x45, - (byte)0x58, (byte)0x74, (byte)0x43, (byte)0x6f, - (byte)0x6d, (byte)0x6d, (byte)0x65, (byte)0x6e, - (byte)0x74, (byte)0x00, (byte)0xf6, (byte)0xcc, - (byte)0x96, (byte)0xbf, (byte)0x00, (byte)0x00, - (byte)0x00, (byte)0x0a, (byte)0x49, (byte)0x44, - (byte)0x41, (byte)0x54, (byte)0x08, (byte)0xd7, - (byte)0x63, (byte)0xf8, (byte)0x0f, (byte)0x00, - (byte)0x01, (byte)0x01, (byte)0x01, (byte)0x00, - (byte)0x1b, (byte)0xb6, (byte)0xee, (byte)0x56, - (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, - (byte)0x49, (byte)0x45, (byte)0x4e, (byte)0x44, - (byte)0xae, (byte)0x42, (byte)0x60, (byte)0x82 - }; + public static final byte[] EMPTY = { (byte) 0x89, (byte) 0x50, (byte) 0x4e, (byte) 0x47, (byte) 0x0d, (byte) 0x0a, (byte) 0x1a, (byte) 0x0a, (byte) 0x00, + (byte) 0x00, (byte) 0x00, (byte) 0x0d, (byte) 0x49, (byte) 0x48, (byte) 0x44, (byte) 0x52, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01, + (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0x08, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x3a, (byte) 0x7e, + (byte) 0x9b, (byte) 0x55, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0x73, (byte) 0x52, (byte) 0x47, (byte) 0x42, (byte) 0x00, + (byte) 0xae, (byte) 0xce, (byte) 0x1c, (byte) 0xe9, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x09, (byte) 0x70, (byte) 0x48, (byte) 0x59, + (byte) 0x73, (byte) 0x00, (byte) 0x00, (byte) 0x0b, (byte) 0x13, (byte) 0x00, (byte) 0x00, (byte) 0x0b, (byte) 0x13, (byte) 0x01, (byte) 0x00, + (byte) 0x9a, (byte) 0x9c, (byte) 0x18, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x07, (byte) 0x74, (byte) 0x49, (byte) 0x4d, (byte) 0x45, + (byte) 0x07, (byte) 0xdc, (byte) 0x04, (byte) 0x04, (byte) 0x10, (byte) 0x30, (byte) 0x15, (byte) 0x7d, (byte) 0x77, (byte) 0x36, (byte) 0x0b, + (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x08, (byte) 0x74, (byte) 0x45, (byte) 0x58, (byte) 0x74, (byte) 0x43, (byte) 0x6f, (byte) 0x6d, + (byte) 0x6d, (byte) 0x65, (byte) 0x6e, (byte) 0x74, (byte) 0x00, (byte) 0xf6, (byte) 0xcc, (byte) 0x96, (byte) 0xbf, (byte) 0x00, (byte) 0x00, + (byte) 0x00, (byte) 0x0a, (byte) 0x49, (byte) 0x44, (byte) 0x41, (byte) 0x54, (byte) 0x08, (byte) 0xd7, (byte) 0x63, (byte) 0xf8, (byte) 0x0f, + (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x00, (byte) 0x1b, (byte) 0xb6, (byte) 0xee, (byte) 0x56, (byte) 0x00, (byte) 0x00, + (byte) 0x00, (byte) 0x00, (byte) 0x49, (byte) 0x45, (byte) 0x4e, (byte) 0x44, (byte) 0xae, (byte) 0x42, (byte) 0x60, (byte) 0x82 }; private static final Output empty() { return new Output(EMPTY, "image/png"); } @Override - public Service.Output process( - Document data, - GlobalContext globalContext, - CallMeta callMeta - ) { + public Service.Output process(final Document data, final GlobalContext globalContext, final CallMeta callMeta) { log.debug("FixingsKMChartService.process"); SessionHolder.acquire(); try { return doProcess(data, globalContext, callMeta); - } - finally { + } finally { SessionHolder.release(); } } - protected Service.Output doProcess( - Document input, - GlobalContext globalContext, - CallMeta callMeta - ) { - String river = getRiverName(input); - Double km = getKM(input); - Dimension extent = getExtent(input); - String format = getFormat(input); + protected Service.Output doProcess(final Document input, final GlobalContext globalContext, final CallMeta callMeta) { + final String river = getRiverName(input); + final Double km = getKM(input); + final Dimension extent = getExtent(input); + final String format = getFormat(input); if (river == null || km == null) { log.warn("River and/or km invalid."); return empty(); } - FixingsOverview overview = FixingsOverviewFactory.getOverview(river); + final FixingsOverview overview = FixingsOverviewFactory.getOverview(river); if (overview == null) { log.warn("No overview found for river '" + river + "'"); return empty(); } - FixingsFilterBuilder ffb = new FixingsFilterBuilder(input); - - List columns = overview.filter( - ffb.getRange(), - ffb.getFilter()); + final FixingsFilterBuilder ffb = new FixingsFilterBuilder(input); - List> cols = - new ArrayList>(); + final List columns = overview.filter(ffb.getRange(), ffb.getFilter()); - for (Fixing.Column col: columns) { - FixingsColumn data = - FixingsColumnFactory.INSTANCE.getColumnData(col); + final List> cols = new ArrayList<>(); + + for (final Fixing.Column col : columns) { + final FixingsColumn data = FixingsColumnFactory.INSTANCE.getColumnData(col); if (data != null) { - cols.add(new Pair(col, data)); + cols.add(new Pair<>(col, data)); } } - JFreeChart chart = createChart(cols, river, km, callMeta); + final JFreeChart chart = createChart(cols, river, km, callMeta); return encode(chart, extent, format); } - protected static Output encode( - JFreeChart chart, - Dimension extent, - String format - ) { - BufferedImage image = chart.createBufferedImage( - extent.width, extent.height, - Transparency.BITMASK, - null); + protected static Output encode(final JFreeChart chart, final Dimension extent, final String format) { + final BufferedImage image = chart.createBufferedImage(extent.width, extent.height, Transparency.BITMASK, null); - ByteArrayOutputStream out = new ByteArrayOutputStream(); + final ByteArrayOutputStream out = new ByteArrayOutputStream(); try { ImageIO.write(image, format, out); } - catch (IOException ioe) { + catch (final IOException ioe) { log.warn("writing image failed", ioe); return empty(); } @@ -264,86 +176,60 @@ return new Output(out.toByteArray(), "image/" + format); } - protected static JFreeChart createChart( - List> cols, - String river, - double km, - CallMeta callMeta - ) { - String labelFormat = Resources.getMsg( - callMeta, I18N_CHART_LABEL_DATE, DEFAULT_CHART_LABEL_DATE); - - QWSeriesCollection.LabelGenerator lg = - new QWSeriesCollection.DateFormatLabelGenerator(labelFormat); + protected static JFreeChart createChart(final List> cols, final String river, final double km, final CallMeta callMeta) { + final String labelFormat = Resources.getMsg(callMeta, I18N_CHART_LABEL_DATE, DEFAULT_CHART_LABEL_DATE); - QWSeriesCollection dataset = new QWSeriesCollection(lg); + final QWSeriesCollection.LabelGenerator lg = new QWSeriesCollection.DateFormatLabelGenerator(labelFormat); - double [] w = new double[1]; - for (Pair col: cols) { - boolean interpolated = !col.getB().getW(km, w); - double q = col.getB().getQ(km); + final QWSeriesCollection dataset = new QWSeriesCollection(lg); + + final double[] w = new double[1]; + for (final Pair col : cols) { + final boolean interpolated = !col.getB().getW(km, w); + final double q = col.getB().getQ(km); if (!Double.isNaN(w[0]) && !Double.isNaN(q)) { - QWI qw = new QWI( - q, w[0], - col.getA().getDescription(), - col.getA().getStartTime(), - interpolated, 0); + final QWI qw = new QWI(q, w[0], col.getA().getDescription(), col.getA().getStartTime(), interpolated, 0); dataset.add(qw); } } - String title = Resources.format( - callMeta, I18N_CHART_TITLE, DEFAULT_CHART_TITLE, river, km); - - String qAxis = Resources.getMsg( - callMeta, I18N_Q_AXIS, DEFAULT_Q_AXIS); - - String wAxis = Resources.getMsg( - callMeta, I18N_W_AXIS, DEFAULT_W_AXIS); + final String title = Resources.format(callMeta, I18N_CHART_TITLE, DEFAULT_CHART_TITLE, river, km); - JFreeChart chart = ChartFactory.createXYLineChart( - title, - qAxis, - wAxis, - null, - PlotOrientation.VERTICAL, - true, - true, - false); + final String qAxis = Resources.getMsg(callMeta, I18N_Q_AXIS, DEFAULT_Q_AXIS); - XYPlot plot = (XYPlot)chart.getPlot(); + final String wAxis = Resources.getMsg(callMeta, I18N_W_AXIS, DEFAULT_W_AXIS); - NumberAxis qA = (NumberAxis)plot.getDomainAxis(); + final JFreeChart chart = ChartFactory.createXYLineChart(title, qAxis, wAxis, null, PlotOrientation.VERTICAL, true, true, false); + + final XYPlot plot = (XYPlot) chart.getPlot(); + + final NumberAxis qA = (NumberAxis) plot.getDomainAxis(); qA.setNumberFormatOverride(Formatter.getWaterlevelQ(callMeta)); - NumberAxis wA = (NumberAxis)plot.getRangeAxis(); + final NumberAxis wA = (NumberAxis) plot.getRangeAxis(); wA.setNumberFormatOverride(Formatter.getWaterlevelW(callMeta)); plot.setRenderer(0, dataset.createRenderer()); plot.setDataset(0, dataset); - Rectangle2D area = dataset.getArea(); + final Rectangle2D area = dataset.getArea(); if (area != null) { - double height = area.getHeight(); - double wInset = Math.max(height, 0.01) * 0.25d; + final double height = area.getHeight(); + final double wInset = Math.max(height, 0.01) * 0.25d; wA.setAutoRangeIncludesZero(false); - wA.setRange(new Range( - area.getMinY() - wInset, - area.getMaxY() + wInset)); + wA.setRange(new Range(area.getMinY() - wInset, area.getMaxY() + wInset)); } - final String measuredS = Resources.getMsg( - callMeta, I18N_MEASURED, DEFAULT_MEASURED); + final String measuredS = Resources.getMsg(callMeta, I18N_MEASURED, DEFAULT_MEASURED); - final String interpolatedS = Resources.getMsg( - callMeta, I18N_INTERPOLATED, DEFAULT_INTERPOLATED); + final String interpolatedS = Resources.getMsg(callMeta, I18N_INTERPOLATED, DEFAULT_INTERPOLATED); - LegendItemCollection lic = plot.getLegendItems(); + final LegendItemCollection lic = plot.getLegendItems(); dataset.addLegendItems(lic, new ShapeRenderer.LabelGenerator() { @Override - public String createLabel(ShapeRenderer.Entry entry) { + public String createLabel(final ShapeRenderer.Entry entry) { return entry.getFilled() ? measuredS : interpolatedS; } }); @@ -362,24 +248,18 @@ } /** Add domain markers to plot that indicate Q-sectors. */ - protected static void applyQSectorMarkers( - XYPlot plot, - String river, - double km, - CallMeta meta - ) { - GaugeFinderFactory ggf = GaugeFinderFactory.getInstance(); - GaugeFinder gf = ggf.getGaugeFinder(river); + protected static void applyQSectorMarkers(final XYPlot plot, final String river, final double km, final CallMeta meta) { + final GaugeFinderFactory ggf = GaugeFinderFactory.getInstance(); + final GaugeFinder gf = ggf.getGaugeFinder(river); if (gf == null) { log.warn("No gauge finder found for river '" + river + "'"); return; } - GaugeRange gr = gf.find(km); + final GaugeRange gr = gf.find(km); if (gr == null) { - log.debug("No gauge range found for km " - + km + " on river " + river + "."); + log.debug("No gauge range found for km " + km + " on river " + river + "."); return; } @@ -388,13 +268,11 @@ } for (int i = 0; i < I18N_Q_SECTOR_BOARDERS.length; ++i) { - String key = I18N_Q_SECTOR_BOARDERS[i]; - String def = DEFAULT_Q_SECTOR_BORDERS[i]; - String label = Resources.getMsg(meta, key, def); + final String key = I18N_Q_SECTOR_BOARDERS[i]; + final String def = DEFAULT_Q_SECTOR_BORDERS[i]; + final String label = Resources.getMsg(meta, key, def); - Marker m = createQSectorMarker( - gr.getSectorBorder(i), - label); + final Marker m = createQSectorMarker(gr.getSectorBorder(i), label); if (m != null) { plot.addDomainMarker(m); @@ -403,13 +281,11 @@ } /** Create Marker at value with label. */ - protected static Marker createQSectorMarker( - double value, String label - ) { + protected static Marker createQSectorMarker(final double value, final String label) { if (Double.isNaN(value)) { return null; } - Marker m = new ValueMarker(value); + final Marker m = new ValueMarker(value); m.setPaint(Color.black); m.setStroke(new BasicStroke()); m.setLabel(label); @@ -418,59 +294,59 @@ return m; } - protected static String getRiverName(Document input) { - NodeList rivers = input.getElementsByTagName("river"); + protected static String getRiverName(final Document input) { + final NodeList rivers = input.getElementsByTagName("river"); if (rivers.getLength() == 0) { return null; } - String river = ((Element)rivers.item(0)).getAttribute("name"); + final String river = ((Element) rivers.item(0)).getAttribute("name"); return river.length() > 0 ? river : null; } - protected static Double getKM(Document input) { - NodeList kms = input.getElementsByTagName("km"); + protected static Double getKM(final Document input) { + final NodeList kms = input.getElementsByTagName("km"); if (kms.getLength() == 0) { return null; } - String km = ((Element)kms.item(0)).getAttribute("value"); + final String km = ((Element) kms.item(0)).getAttribute("value"); try { return Double.valueOf(km); } - catch (NumberFormatException nfe) { + catch (final NumberFormatException nfe) { log.warn("Km '" + km + " is not a valid number."); return null; } } - protected static Dimension getExtent(Document input) { + protected static Dimension getExtent(final Document input) { - int width = DEFAULT_WIDTH; + int width = DEFAULT_WIDTH; int height = DEFAULT_HEIGHT; - NodeList extents = input.getElementsByTagName("extent"); + final NodeList extents = input.getElementsByTagName("extent"); if (extents.getLength() > 0) { - Element element = (Element)extents.item(0); - String w = element.getAttribute("width"); - String h = element.getAttribute("height"); + final Element element = (Element) extents.item(0); + final String w = element.getAttribute("width"); + final String h = element.getAttribute("height"); try { width = Math.max(1, Integer.parseInt(w)); } - catch (NumberFormatException nfe) { + catch (final NumberFormatException nfe) { log.warn("width '" + w + "' is not a valid."); } try { height = Math.max(1, Integer.parseInt(h)); } - catch (NumberFormatException nfe) { + catch (final NumberFormatException nfe) { log.warn("height '" + h + "' is not a valid"); } } @@ -478,13 +354,13 @@ return new Dimension(width, height); } - protected static String getFormat(Document input) { + protected static String getFormat(final Document input) { String format = DEFAULT_FORMAT; - NodeList formats = input.getElementsByTagName("format"); + final NodeList formats = input.getElementsByTagName("format"); if (formats.getLength() > 0) { - String type = ((Element)formats.item(0)).getAttribute("type"); + final String type = ((Element) formats.item(0)).getAttribute("type"); if (type.length() > 0) { format = type; } diff -r 7c7f73e5e01e -r 740d65e4aa14 artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/SInfoI18NStrings.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/SInfoI18NStrings.java Thu Jul 26 11:16:06 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/SInfoI18NStrings.java Thu Jul 26 15:54:20 2018 +0200 @@ -17,15 +17,15 @@ public interface SInfoI18NStrings { // TODO: MAKE interface package-visible again:-) // TODO: Strings werden nur einmal verwenden; direkte Verwendung auch denkbar. Liste ist nicht vollständig - String CSV_META_HEADER_WATERLEVEL_GAUGE = "sinfo.export.flow_depth.csv.meta.header.waterlevel.gauge"; + String CSV_META_HEADER_WATERLEVEL_GAUGE = "common.export.csv.meta.header.waterlevel.gauge"; - String CSV_META_HEADER_WATERLEVEL_YEAR = "sinfo.export.flow_depth.csv.meta.header.waterlevel.year"; + String CSV_META_HEADER_WATERLEVEL_YEAR = "common.export.csv.meta.header.waterlevel.year"; String CSV_MEAN_BED_HEIGHT_HEADER = "sinfo.export.flow_depth.csv.header.mean_bed_height"; String CSV_MEAN_BED_HEIGHT_HEADER_SHORT = "sinfo.export.flow_depth.csv.header.mean_bed_height.short"; - String CSV_WATERLEVEL_HEADER = "sinfo.export.flow_depth.csv.header.waterlevel"; + String CSV_WATERLEVEL_HEADER = "common.export.csv.header.waterlevel"; String CSV_DISCHARGE_HEADER = "sinfo.export.flow_depth.csv.header.discharge"; @@ -33,7 +33,7 @@ String CSV_GAUGE_HEADER = "sinfo.export.flow_depth.csv.header.gauge"; - String CSV_LOCATION_HEADER = "sinfo.export.flow_depth.csv.header.location"; + String CSV_LOCATION_HEADER = "common.export.csv.header.location"; String CSV_SOUNDING_HEADER = "sinfo.export.flow_depth.csv.header.sounding"; @@ -69,9 +69,9 @@ String CSV_FLOWDEPTH_HISTORICAL_HEADER = "sinfo.export.csv.header.flowdepth.historical"; - String CSV_META_HEADER_WATERLEVEL = "sinfo.export.flow_depth.csv.meta.header.waterlevel"; + String CSV_META_HEADER_WATERLEVEL = "common.export.csv.meta.header.waterlevel"; - String CSV_META_HEADER_WATERLEVEL_NAME = "sinfo.export.flow_depth.csv.meta.header.waterlevel.name"; + String CSV_META_HEADER_WATERLEVEL_NAME = "common.export.csv.meta.header.waterlevel.name"; String PREFIX_TKH_KIND = "sinfo.export.tkh.soilkind."; diff -r 7c7f73e5e01e -r 740d65e4aa14 artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/SInfoResultType.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/SInfoResultType.java Thu Jul 26 11:16:06 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/SInfoResultType.java Thu Jul 26 15:54:20 2018 +0200 @@ -365,20 +365,6 @@ } }; - public static final SInfoResultType location = new SInfoResultType(I18NStrings.UNIT_NONE, SInfoI18NStrings.CSV_LOCATION_HEADER) { - private static final long serialVersionUID = 1L; - - @Override - public String exportValue(final CallContext context, final Object value) { - return exportStringValue(value); - } - - @Override - protected NumberFormat createFormatter(final CallContext context) { - throw new UnsupportedOperationException(); - } - }; - public static final SInfoResultType soilkind = new SInfoResultType(I18NStrings.UNIT_NONE, SInfoI18NStrings.CSV_TKHKIND_HEADER, "sinfo.export.tkh.pdf.header.tkhkind") { private static final long serialVersionUID = 1L; diff -r 7c7f73e5e01e -r 740d65e4aa14 artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationCalculationResult.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationCalculationResult.java Thu Jul 26 11:16:06 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationCalculationResult.java Thu Jul 26 15:54:20 2018 +0200 @@ -140,7 +140,7 @@ } lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.gaugeLabel)); - lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.location)); + lines.add(exportContextCSV.formatRowValue(row, GeneralResultType.location)); return lines.toArray(new String[lines.size()]); } @@ -169,7 +169,7 @@ } header.add(exportContextCSV.formatCsvHeader(SInfoResultType.gaugeLabel)); - header.add(exportContextCSV.formatCsvHeader(SInfoResultType.location)); + header.add(exportContextCSV.formatCsvHeader(GeneralResultType.location)); exportContextCSV.writeCSVLine(header.toArray(new String[header.size()])); } @@ -213,7 +213,7 @@ } exportContextPDF.addJRMetadata(source, "gauge_header", SInfoResultType.gaugeLabel); - exportContextPDF.addJRMetadata(source, "location_header", SInfoResultType.location); + exportContextPDF.addJRMetadata(source, "location_header", GeneralResultType.location); } private final String getPdfHeader(final String rootStr, final int index) { diff -r 7c7f73e5e01e -r 740d65e4aa14 artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationCalculator.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationCalculator.java Thu Jul 26 11:16:06 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationCalculator.java Thu Jul 26 15:54:20 2018 +0200 @@ -261,10 +261,10 @@ private StickyAxisAnnotation calcInfrastructureQAnnotation(final ResultRow row) { final String label = Resources.getMsg(this.context.getMeta(), "sinfo.chart.flood_duration.curve.infrastructure", "sinfo.chart.flood_duration.curve.infrastructure", - SInfoResultType.infrastructuretype.exportValue(this.context, row.getValue(SInfoResultType.infrastructuretype)) - + ", " + SInfoResultType.riverside.exportValue(this.context, row.getValue(SInfoResultType.riverside))); - final StickyAxisAnnotation annotation = new StickyAxisAnnotation(label, (float) row.getDoubleValue(SInfoResultType.floodDischarge), - SimpleAxis.Y_AXIS, FloodDurationCurveGenerator.YAXIS.Q.idx); + SInfoResultType.infrastructuretype.exportValue(this.context, row.getValue(SInfoResultType.infrastructuretype)) + ", " + + SInfoResultType.riverside.exportValue(this.context, row.getValue(SInfoResultType.riverside))); + final StickyAxisAnnotation annotation = new StickyAxisAnnotation(label, (float) row.getDoubleValue(SInfoResultType.floodDischarge), SimpleAxis.Y_AXIS, + FloodDurationCurveGenerator.YAXIS.Q.idx); annotation.setHitPoint((float) row.getDoubleValue(SInfoResultType.floodDuration)); return annotation; } @@ -275,8 +275,8 @@ private StickyAxisAnnotation calcInfrastructureWAnnotation(final ResultRow row) { final String label = Resources.getMsg(this.context.getMeta(), "sinfo.chart.flood_duration.curve.infrastructure", "sinfo.chart.flood_duration.curve.infrastructure", - SInfoResultType.infrastructuretype.exportValue(this.context, row.getValue(SInfoResultType.infrastructuretype)) - + ", " + SInfoResultType.riverside.exportValue(this.context, row.getValue(SInfoResultType.riverside))); + SInfoResultType.infrastructuretype.exportValue(this.context, row.getValue(SInfoResultType.infrastructuretype)) + ", " + + SInfoResultType.riverside.exportValue(this.context, row.getValue(SInfoResultType.riverside))); final StickyAxisAnnotation annotation = new StickyAxisAnnotation(label, (float) row.getDoubleValue(SInfoResultType.infrastructureHeight), SimpleAxis.Y_AXIS, FloodDurationCurveGenerator.YAXIS.W.idx); annotation.setHitPoint((float) row.getDoubleValue(SInfoResultType.floodDuration)); @@ -378,8 +378,7 @@ return "Q=" + description; else return "W=" + description; - } - else + } else return description; } @@ -408,8 +407,8 @@ /** * Create a result row for a station and its gauge, and add w-q-values as selected */ - private ResultRow createRow(final Double station, final Gauge gauge, final Gauge firstGauge, final WQKms[] wqkmsArray, - final List gaugeDurations, final int kmIndex) { + private ResultRow createRow(final Double station, final Gauge gauge, final Gauge firstGauge, final WQKms[] wqkmsArray, final List gaugeDurations, + final int kmIndex) { final ResultRow row = ResultRow.create(); row.putValue(GeneralResultType.station, station); @@ -420,7 +419,7 @@ row.putValue(SInfoResultType.gaugeLabel, gaugeLabel); final String location = this.riverInfoProvider.getLocation(station); - row.putValue(SInfoResultType.location, location); + row.putValue(GeneralResultType.location, location); final List wsts = new ArrayList<>(wqkmsArray.length); diff -r 7c7f73e5e01e -r 740d65e4aa14 artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationCurveGenerator.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationCurveGenerator.java Thu Jul 26 11:16:06 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationCurveGenerator.java Thu Jul 26 15:54:20 2018 +0200 @@ -57,7 +57,7 @@ private static final String I18N_YAXIS_LABEL_W = "chart.duration.curve.yaxis.label.w"; - private static final String I18N_YAXIS_LABEL_Q = "chart.duration.curve.yaxis.label.q"; + private static final String I18N_YAXIS_LABEL_Q = "common.export.csv.header.q"; private static final String I18N_CHART_TITLE_DEFAULT = "Dauerlinie"; @@ -165,15 +165,12 @@ if (name.equals(DURATION_W)) { doWOut((WQDay) (artifactFacet.getData(context)), artifactFacet, attr, visible); - } - else if (name.equals(DURATION_Q)) { + } else if (name.equals(DURATION_Q)) { doQOut((WQDay) artifactFacet.getData(context), artifactFacet, attr, visible); - } - else if (name.equals(FloodDurationCurveProcessor.FACET_FLOOD_DURATION_MAINVALUES_Q) + } else if (name.equals(FloodDurationCurveProcessor.FACET_FLOOD_DURATION_MAINVALUES_Q) || name.equals(FloodDurationCurveProcessor.FACET_FLOOD_DURATION_MAINVALUES_W)) { doAnnotations((RiverAnnotation) artifactFacet.getData(context), artifactFacet, attr, visible); - } - else if (name.equals(FloodDurationCurveProcessor.FACET_FLOOD_DURATION_INFRASTRUCTURE) && (artifactFacet.getData(context) != null)) { + } else if (name.equals(FloodDurationCurveProcessor.FACET_FLOOD_DURATION_INFRASTRUCTURE) && (artifactFacet.getData(context) != null)) { doAnnotations((RiverAnnotation) artifactFacet.getData(context), artifactFacet, attr, visible); } // else if (name.equals(RELATIVE_POINT)) { @@ -181,8 +178,7 @@ // } else if (FacetTypes.IS.MANUALPOINTS(name)) { doPoints(artifactFacet.getData(context), artifactFacet, attr, visible, YAXIS.W.idx); - } - else { + } else { log.warn("Unknown facet name: " + name); return; } diff -r 7c7f73e5e01e -r 740d65e4aa14 artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthCalculationResult.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthCalculationResult.java Thu Jul 26 11:16:06 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthCalculationResult.java Thu Jul 26 15:54:20 2018 +0200 @@ -74,7 +74,7 @@ header.add(exportContextCSV.formatCsvHeader(SInfoResultType.gaugeLabel)); header.add(exportContextCSV.formatCsvHeader(SInfoResultType.meanBedHeight)); header.add(exportContextCSV.formatCsvHeader(SInfoResultType.soundingLabel)); - header.add(exportContextCSV.formatCsvHeader(SInfoResultType.location)); + header.add(exportContextCSV.formatCsvHeader(GeneralResultType.location)); exportContextCSV.writeCSVLine(header.toArray(new String[header.size()])); @@ -123,7 +123,7 @@ exportContextPDF.addJRMetadata(source, "gauge_header", SInfoResultType.gaugeLabel); exportContextPDF.addJRMetadata(source, "bedheight_header", SInfoResultType.meanBedHeight); exportContextPDF.addJRMetadata(source, "sounding_name_header", SInfoResultType.soundingLabel); - exportContextPDF.addJRMetadata(source, "location_header", SInfoResultType.location); + exportContextPDF.addJRMetadata(source, "location_header", GeneralResultType.location); } private String[] formatRow(final ExportMode mode, final IExportContext exportContext, final ResultRow row) { @@ -145,7 +145,7 @@ lines.add(exportContext.formatRowValue(row, SInfoResultType.gaugeLabel)); lines.add(exportContext.formatRowValue(row, SInfoResultType.meanBedHeight)); lines.add(exportContext.formatRowValue(row, SInfoResultType.soundingLabel)); - lines.add(exportContext.formatRowValue(row, SInfoResultType.location)); + lines.add(exportContext.formatRowValue(row, GeneralResultType.location)); return lines.toArray(new String[lines.size()]); } diff -r 7c7f73e5e01e -r 740d65e4aa14 artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthCalculator.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthCalculator.java Thu Jul 26 11:16:06 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthCalculator.java Thu Jul 26 15:54:20 2018 +0200 @@ -13,9 +13,9 @@ import java.util.Collection; import org.apache.commons.lang.math.DoubleRange; +import org.dive4elements.river.artifacts.common.GeneralResultType; import org.dive4elements.river.artifacts.common.ResultRow; import org.dive4elements.river.artifacts.sinfo.common.RiverInfoProvider; - import org.dive4elements.river.artifacts.sinfo.common.SInfoResultType; import org.dive4elements.river.artifacts.sinfo.tkhcalculation.TkhCalculator; import org.dive4elements.river.artifacts.sinfo.tkhstate.BedHeightsFinder; @@ -76,7 +76,7 @@ // REMARK: access the location once only during calculation final String location = this.riverInfoProvider.getLocation(station); - row.putValue(SInfoResultType.location, location); + row.putValue(GeneralResultType.location, location); if (this.tkhCalculator.calculateTkh(station, row)) this.rows.add(row); diff -r 7c7f73e5e01e -r 740d65e4aa14 artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepthdev/FlowDepthDevelopmentCalculation.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepthdev/FlowDepthDevelopmentCalculation.java Thu Jul 26 11:16:06 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepthdev/FlowDepthDevelopmentCalculation.java Thu Jul 26 15:54:20 2018 +0200 @@ -117,8 +117,7 @@ FlowDepthUtils.checkYearDifference(Resources.getMsg(this.context.getMeta(), "flowdepthdevelopmentcalculation.yearDifferenceCurrent"), currentWstYear, currentSoundingYear, problems); FlowDepthUtils.checkYearDifference(Resources.getMsg(this.context.getMeta(), "flowdepthdevelopmentcalculation.yearDifferenceHistorical"), - historicalWstYear, - historicalSoundingYear, problems); + historicalWstYear, historicalSoundingYear, problems); /* re-determine the reference gauge, in the same way as the WaterlevelArtifact would do it */ final RiverInfoProvider currentRiverInfoProvider = infoProvider.forWaterlevel(currentWaterlevel); @@ -139,7 +138,7 @@ final double diffYear = currentMeanYear - historcialMeanYear; /* real calculation loop */ - final Collection< ResultRow> rows = new ArrayList<>(); + final Collection rows = new ArrayList<>(); final Collection stations = determineCalculationSteps(currentSounding, historicalSounding); for (final double station : stations) { @@ -168,7 +167,7 @@ // REMARK: access the location once only during calculation final String location = currentRiverInfoProvider.getLocation(station); - final ResultRow row = ResultRow.create().// + final ResultRow row = ResultRow.create().// putValue(GeneralResultType.station, station). // putValue(SInfoResultType.flowdepthDevelopment, flowDepthDevelopment). // putValue(SInfoResultType.flowdepthDevelopmentPerYear, flowDepthDevelopmentPerYear). // @@ -176,15 +175,14 @@ putValue(SInfoResultType.bedHeightDifference, diffBedHeight). // putValue(SInfoResultType.flowdepthCurrent, currentFlowDepth). // putValue(SInfoResultType.flowdepthHistorical, historicalFlowDepth). // - putValue(SInfoResultType.location, location); + putValue(GeneralResultType.location, location); rows.add(row); } } final String label = buildLabel(currentWaterlevel, currentSoundingInfo, historicalWaterlevel, historicalSoundingInfo); - return new FlowDepthDevelopmentCalculationResult(label, currentWstInfo, historicalWstInfo, currentSoundingInfo, historicalSoundingInfo, - rows); + return new FlowDepthDevelopmentCalculationResult(label, currentWstInfo, historicalWstInfo, currentSoundingInfo, historicalSoundingInfo, rows); } /** diff -r 7c7f73e5e01e -r 740d65e4aa14 artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepthdev/FlowDepthDevelopmentCalculationResult.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepthdev/FlowDepthDevelopmentCalculationResult.java Thu Jul 26 11:16:06 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepthdev/FlowDepthDevelopmentCalculationResult.java Thu Jul 26 15:54:20 2018 +0200 @@ -140,7 +140,7 @@ lines.add(exportContext.formatRowValue(row, SInfoResultType.bedHeightDifference)); lines.add(exportContext.formatRowValue(row, SInfoResultType.flowdepthCurrent)); lines.add(exportContext.formatRowValue(row, SInfoResultType.flowdepthHistorical)); - lines.add(exportContext.formatRowValue(row, SInfoResultType.location)); + lines.add(exportContext.formatRowValue(row, GeneralResultType.location)); return lines.toArray(new String[lines.size()]); } @@ -157,7 +157,7 @@ header.add(exportContextCSV.msgUnitLabel(SInfoResultType.bedHeightDifference, getBedHeightDifferenceLabel())); header.add(exportContextCSV.msgUnitLabel(SInfoResultType.flowdepthCurrent, getFlowDepthCurrentLabel())); header.add(exportContextCSV.msgUnitLabel(SInfoResultType.flowdepthHistorical, getFlowDepthHistoricalLabel())); - header.add(exportContextCSV.formatCsvHeader(SInfoResultType.location)); + header.add(exportContextCSV.formatCsvHeader(GeneralResultType.location)); exportContextCSV.writeCSVLine(header.toArray(new String[header.size()])); @@ -194,7 +194,7 @@ exportContextPDF.addJRMetadata(source, "flowdepthhistorical_header", SInfoResultType.flowdepthHistorical); exportContextPDF.addJRMetadata(source, "flowdepthhistorical_header2", getFlowDepthHistoricalLabel()); - exportContextPDF.addJRMetadata(source, "location_header", SInfoResultType.location); + exportContextPDF.addJRMetadata(source, "location_header", GeneralResultType.location); } } \ No newline at end of file diff -r 7c7f73e5e01e -r 740d65e4aa14 artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepthdev/FlowDepthDevelopmentState.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepthdev/FlowDepthDevelopmentState.java Thu Jul 26 11:16:06 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepthdev/FlowDepthDevelopmentState.java Thu Jul 26 15:54:20 2018 +0200 @@ -78,7 +78,7 @@ final FlowDepthDevelopmentCalculationResults results = (FlowDepthDevelopmentCalculationResults) res.getData(); final FlowDepthDevelopmentCalculationResult result = results.getResult(); if (result != null) { - // final FlowDepthDevelopmentCalculationResult result = (FlowDepthDevelopmentCalculationResult) resultList.get(0); + // final BezugswstCalculationResult result = (BezugswstCalculationResult) resultList.get(0); /* add themes for chart, for each result */ final int index = 0; diff -r 7c7f73e5e01e -r 740d65e4aa14 artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepthminmax/FlowDepthMinMaxCalculation.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepthminmax/FlowDepthMinMaxCalculation.java Thu Jul 26 11:16:06 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepthminmax/FlowDepthMinMaxCalculation.java Thu Jul 26 15:54:20 2018 +0200 @@ -121,7 +121,7 @@ final String soundingLabel = bedHeightInfo.getDescription(); /* real calculation loop */ - final Collection< ResultRow> rows = new ArrayList<>(); + final Collection rows = new ArrayList<>(); final Collection stations = bedHeight.getStations(); for (final double station : stations) { @@ -147,7 +147,7 @@ if (Double.isNaN(wst) || Double.isNaN(minBedHeightValue) || Double.isNaN(maxBedHeightValue)) continue; - final ResultRow row = ResultRow.create().// + final ResultRow row = ResultRow.create().// putValue(GeneralResultType.station, station). // putValue(SInfoResultType.flowdepthmin, minFlowDepth). // putValue(SInfoResultType.flowdepthmax, maxFlowDepth). // @@ -157,7 +157,7 @@ putValue(SInfoResultType.gaugeLabel, gaugeLabel). // putValue(SInfoResultType.meanBedHeight, meanBedHeight). // putValue(SInfoResultType.soundingLabel, soundingLabel). // - putValue(SInfoResultType.location, location); + putValue(GeneralResultType.location, location); rows.add(row); } } diff -r 7c7f73e5e01e -r 740d65e4aa14 artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepthminmax/FlowDepthMinMaxCalculationResult.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepthminmax/FlowDepthMinMaxCalculationResult.java Thu Jul 26 11:16:06 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepthminmax/FlowDepthMinMaxCalculationResult.java Thu Jul 26 15:54:20 2018 +0200 @@ -61,7 +61,7 @@ header.add(exportContextCSV.formatCsvHeader(SInfoResultType.gaugeLabel)); header.add(exportContextCSV.msgUnitCSV(SInfoResultType.meanBedHeight, river.getWstUnit())); header.add(exportContextCSV.formatCsvHeader(SInfoResultType.soundingLabel)); - header.add(exportContextCSV.formatCsvHeader(SInfoResultType.location)); + header.add(exportContextCSV.formatCsvHeader(GeneralResultType.location)); exportContextCSV.writeCSVLine(header.toArray(new String[header.size()])); @@ -108,7 +108,7 @@ exportContextPDF.addJRMetadata(source, "gauge_header", SInfoResultType.gaugeLabel); exportContextPDF.addJRMetadata(source, "bedheight_header", SInfoResultType.meanBedHeight); exportContextPDF.addJRMetadata(source, "sounding_name_header", SInfoResultType.soundingLabel); - exportContextPDF.addJRMetadata(source, "location_header", SInfoResultType.location); + exportContextPDF.addJRMetadata(source, "location_header", GeneralResultType.location); } @@ -132,7 +132,7 @@ lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.gaugeLabel)); lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.meanBedHeight)); lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.soundingLabel)); - lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.location)); + lines.add(exportContextCSV.formatRowValue(row, GeneralResultType.location)); return lines.toArray(new String[lines.size()]); } diff -r 7c7f73e5e01e -r 740d65e4aa14 artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhstate/TkhCalculation.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhstate/TkhCalculation.java Thu Jul 26 11:16:06 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhstate/TkhCalculation.java Thu Jul 26 15:54:20 2018 +0200 @@ -23,6 +23,7 @@ import org.apache.commons.lang.math.NumberRange; import org.dive4elements.artifacts.CallContext; import org.dive4elements.river.artifacts.WINFOArtifact; +import org.dive4elements.river.artifacts.common.GeneralResultType; import org.dive4elements.river.artifacts.common.ResultRow; import org.dive4elements.river.artifacts.model.Calculation; import org.dive4elements.river.artifacts.model.Calculation.Problem; @@ -182,7 +183,7 @@ row.putValue(SInfoResultType.waterlevelLabel, waterlevelLabel); row.putValue(SInfoResultType.gaugeLabel, riverInfoProvider.findGauge(station)); - row.putValue(SInfoResultType.location, riverInfoProvider.getLocation(station)); + row.putValue(GeneralResultType.location, riverInfoProvider.getLocation(station)); if (tkhCalculator.calculateTkh(station, row)) rows.add(row); diff -r 7c7f73e5e01e -r 740d65e4aa14 artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhstate/TkhCalculationResult.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhstate/TkhCalculationResult.java Thu Jul 26 11:16:06 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhstate/TkhCalculationResult.java Thu Jul 26 15:54:20 2018 +0200 @@ -60,7 +60,7 @@ header.add(descriptionHeader); header.add(exportContext.formatCsvHeader(SInfoResultType.gaugeLabel)); - header.add(exportContext.formatCsvHeader(SInfoResultType.location)); + header.add(exportContext.formatCsvHeader(GeneralResultType.location)); exportContext.writeCSVLine(header.toArray(new String[header.size()])); @@ -109,7 +109,7 @@ exportContext.addJRMetadata(source, "waterlevel_name_header", waterlevelNameHeader); exportContext.addJRMetadata(source, "gauge_header", SInfoResultType.gaugeLabel); - exportContext.addJRMetadata(source, "location_header", SInfoResultType.location); + exportContext.addJRMetadata(source, "location_header", GeneralResultType.location); } @@ -131,7 +131,7 @@ lines.add(exportContext.formatRowValue(row, SInfoResultType.waterlevelLabel)); lines.add(exportContext.formatRowValue(row, SInfoResultType.gaugeLabel)); - lines.add(exportContext.formatRowValue(row, SInfoResultType.location)); + lines.add(exportContext.formatRowValue(row, GeneralResultType.location)); return lines.toArray(new String[lines.size()]); } diff -r 7c7f73e5e01e -r 740d65e4aa14 artifacts/src/main/java/org/dive4elements/river/exports/ComputedDischargeCurveExporter.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/ComputedDischargeCurveExporter.java Thu Jul 26 11:16:06 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/ComputedDischargeCurveExporter.java Thu Jul 26 15:54:20 2018 +0200 @@ -9,68 +9,55 @@ package org.dive4elements.river.exports; import java.io.OutputStream; +import java.text.DateFormat; import java.text.NumberFormat; import java.util.ArrayList; import java.util.Arrays; -import java.util.List; -import java.util.Map; +import java.util.Date; import java.util.HashMap; -import java.util.Date; -import java.text.DateFormat; +import java.util.List; import java.util.Locale; +import java.util.Map; import org.apache.log4j.Logger; +import org.dive4elements.artifacts.CallMeta; +import org.dive4elements.artifacts.common.utils.Config; +import org.dive4elements.river.artifacts.D4EArtifact; +import org.dive4elements.river.artifacts.access.RangeAccess; +import org.dive4elements.river.artifacts.model.CalculationResult; +import org.dive4elements.river.artifacts.model.WKmsJRDataSource; +import org.dive4elements.river.artifacts.model.WQ; +import org.dive4elements.river.artifacts.model.WQKms; +import org.dive4elements.river.artifacts.resources.Resources; +import org.dive4elements.river.model.Gauge; +import org.dive4elements.river.model.River; +import org.dive4elements.river.utils.Formatter; +import org.dive4elements.river.utils.RiverUtils; import au.com.bytecode.opencsv.CSVWriter; - +import net.sf.jasperreports.engine.JRException; import net.sf.jasperreports.engine.JasperExportManager; import net.sf.jasperreports.engine.JasperFillManager; import net.sf.jasperreports.engine.JasperPrint; -import net.sf.jasperreports.engine.JRException; - -import org.dive4elements.artifacts.common.utils.Config; - -import org.dive4elements.artifacts.CallMeta; - -import org.dive4elements.river.artifacts.D4EArtifact; - -import org.dive4elements.river.artifacts.access.RangeAccess; -import org.dive4elements.river.artifacts.model.CalculationResult; -import org.dive4elements.river.artifacts.model.WQ; -import org.dive4elements.river.artifacts.model.WQKms; -import org.dive4elements.river.artifacts.model.WKmsJRDataSource; -import org.dive4elements.river.artifacts.resources.Resources; - -import org.dive4elements.river.model.Gauge; -import org.dive4elements.river.model.River; - -import org.dive4elements.river.utils.RiverUtils; -import org.dive4elements.river.utils.Formatter; /** * @author Ingo Weinzierl */ public class ComputedDischargeCurveExporter extends AbstractExporter { - /** The log used in this exporter.*/ - private static Logger log = - Logger.getLogger(ComputedDischargeCurveExporter.class); - - public static final String CSV_W_HEADER = - "export.computed.discharge.curve.csv.header.w"; + /** The log used in this exporter. */ + private static Logger log = Logger.getLogger(ComputedDischargeCurveExporter.class); - public static final String CSV_Q_HEADER = - "export.computed.discharge.curve.csv.header.q"; - - public static final String DEFAULT_CSV_W_HEADER = "W [NN + m]"; - public static final String DEFAULT_CSV_Q_HEADER = "Q [m\u00b3/s]"; + public static final String CSV_W_HEADER = "export.computed.discharge.curve.csv.header.w"; - public static final String PDF_HEADER_MODE = - "export.computed.discharge.pdf.mode"; - public static final String PDF_HEADER_CALC_MODE = - "export.computed.discharge.pdf.calc.mode"; - public static final String JASPER_FILE = - "export.computed.discharge.pdf.file"; + public static final String CSV_Q_HEADER = "common.export.csv.header.q"; + + public static final String DEFAULT_CSV_W_HEADER = "W [NN + m]"; + public static final String DEFAULT_CSV_Q_HEADER = "Q [m\u00b3/s]"; + + public static final String PDF_HEADER_MODE = "export.computed.discharge.pdf.mode"; + public static final String PDF_HEADER_CALC_MODE = "export.computed.discharge.pdf.calc.mode"; + public static final String JASPER_FILE = "export.computed.discharge.pdf.file"; protected List data; @@ -81,157 +68,135 @@ protected Date validSince; public ComputedDischargeCurveExporter() { - data = new ArrayList(); + this.data = new ArrayList<>(); } @Override protected void addData(Object d) { if (d instanceof CalculationResult) { - d = ((CalculationResult)d).getData(); + d = ((CalculationResult) d).getData(); } WQKms referenceWQ = null; // used for gauge / unit observations - if (d instanceof WQKms[]){ - data.addAll(Arrays.asList((WQKms [])d)); + if (d instanceof WQKms[]) { + this.data.addAll(Arrays.asList((WQKms[]) d)); // If there is a unit mix in this list // we are screwed anyway. - referenceWQ = ((WQKms[])d)[0]; - } - else if (d instanceof WQKms) { - data.add((WQKms)d); - referenceWQ = (WQKms)d; + referenceWQ = ((WQKms[]) d)[0]; + } else if (d instanceof WQKms) { + this.data.add((WQKms) d); + referenceWQ = (WQKms) d; } else { - log.warn("Can't add data for export. Unkown data type " + - d.getClass().getName()); + log.warn("Can't add data for export. Unkown data type " + d.getClass().getName()); return; } if (referenceWQ != null) { - D4EArtifact arti = (D4EArtifact)master; - River river = RiverUtils.getRiver(arti); - riverUnit = river.getWstUnit().getName(); - RangeAccess rangeAccess = new RangeAccess(arti); + final D4EArtifact arti = (D4EArtifact) this.master; + final River river = RiverUtils.getRiver(arti); + this.riverUnit = river.getWstUnit().getName(); + final RangeAccess rangeAccess = new RangeAccess(arti); - double[] kms = rangeAccess.getKmRange(); + final double[] kms = rangeAccess.getKmRange(); - Gauge gauge = river.determineGaugeAtStation(kms[0]); + final Gauge gauge = river.determineGaugeAtStation(kms[0]); if (gauge != null) { - wUnit = "cm"; - gaugeName = gauge.getName(); - gaugeDatum = gauge.getDatum().doubleValue(); + this.wUnit = "cm"; + this.gaugeName = gauge.getName(); + this.gaugeDatum = gauge.getDatum().doubleValue(); // Now convert the data to cm because we are at gauge - List newData = new ArrayList(); - for (WQKms d2: data) { - newData.add(new WQKms(d2.getKms(), - WQ.getFixedWQforExportAtGauge( - (WQ)d2, - gauge.getDatum() - ))); + final List newData = new ArrayList<>(); + for (final WQKms d2 : this.data) { + newData.add(new WQKms(d2.getKms(), WQ.getFixedWQforExportAtGauge(d2, gauge.getDatum()))); } - data = newData; // All hail the garbage collector + this.data = newData; // All hail the garbage collector - validSince = gauge.fetchMasterDischargeTable() - .getTimeInterval().getStartTime(); + this.validSince = gauge.fetchMasterDischargeTable().getTimeInterval().getStartTime(); } else { - gaugeName = ""; - validSince = null; - gaugeDatum = Double.NaN; + this.gaugeName = ""; + this.validSince = null; + this.gaugeDatum = Double.NaN; } } } - protected void writeCSVData(CSVWriter writer) { + @Override + protected void writeCSVData(final CSVWriter writer) { log.info("ComputedDischargeCurveExporter.writeData"); writeCSVHeader(writer); - NumberFormat wf = getWFormatter(); - NumberFormat qf = getQFormatter(); + final NumberFormat wf = getWFormatter(); + final NumberFormat qf = getQFormatter(); double[] res = new double[3]; - for (WQKms wqkms: data) { - int size = wqkms.size(); + for (final WQKms wqkms : this.data) { + final int size = wqkms.size(); for (int i = 0; i < size; i++) { res = wqkms.get(i, res); - writer.writeNext(new String[] { - wf.format(res[0]), - qf.format(res[1]) - }); + writer.writeNext(new String[] { wf.format(res[0]), qf.format(res[1]) }); } } } - - protected void writeCSVHeader(CSVWriter writer) { + protected void writeCSVHeader(final CSVWriter writer) { log.debug("ComputedDischargeCurveExporter.writeCSVHeader"); - RangeAccess access = new RangeAccess((D4EArtifact)master); - double[] km = access.getLocations(); + final RangeAccess access = new RangeAccess((D4EArtifact) this.master); + final double[] km = access.getLocations(); // If we are not at gauge (cm) use the river unit - String realUnit = "cm".equals(wUnit) ? "cm" : riverUnit; - String header = - msg(CSV_W_HEADER, DEFAULT_CSV_W_HEADER, new Object[] {realUnit}); + final String realUnit = "cm".equals(this.wUnit) ? "cm" : this.riverUnit; + final String header = msg(CSV_W_HEADER, DEFAULT_CSV_W_HEADER, new Object[] { realUnit }); - writer.writeNext(new String[] { - header, - msg(CSV_Q_HEADER, DEFAULT_CSV_Q_HEADER) - }); + writer.writeNext(new String[] { header, msg(CSV_Q_HEADER, DEFAULT_CSV_Q_HEADER) }); } - /** * Returns the number formatter for W values. * * @return the number formatter for W values. */ + @Override protected NumberFormat getWFormatter() { - if ("cm".equals(wUnit)) { - return Formatter.getFormatter(context, 0, 0); + if ("cm".equals(this.wUnit)) { + return Formatter.getFormatter(this.context, 0, 0); } - return Formatter.getComputedDischargeW(context); + return Formatter.getComputedDischargeW(this.context); } - /** * Returns the number formatter for Q values. * * @return the number formatter for Q values. */ + @Override protected NumberFormat getQFormatter() { - return Formatter.getComputedDischargeQ(context); + return Formatter.getComputedDischargeQ(this.context); } - @Override - protected void writePDF(OutputStream out) { - WKmsJRDataSource source = createJRData(); + protected void writePDF(final OutputStream out) { + final WKmsJRDataSource source = createJRData(); - String jasperFile = Resources.getMsg( - context.getMeta(), - JASPER_FILE, - "/jasper/computed-discharge_en.jasper"); - String confPath = Config.getConfigDirectory().toString(); + final String jasperFile = Resources.getMsg(this.context.getMeta(), JASPER_FILE, "/jasper/computed-discharge_en.jasper"); + final String confPath = Config.getConfigDirectory().toString(); - Map parameters = new HashMap(); + final Map parameters = new HashMap(); parameters.put("ReportTitle", "Exported Data"); try { - JasperPrint print = JasperFillManager.fillReport( - confPath + jasperFile, - parameters, - source); + final JasperPrint print = JasperFillManager.fillReport(confPath + jasperFile, parameters, source); JasperExportManager.exportReportToPdfStream(print, out); } - catch(JRException je) { + catch (final JRException je) { log.warn("Error generating PDF Report!"); je.printStackTrace(); } } - protected WKmsJRDataSource createJRData() { - WKmsJRDataSource source = new WKmsJRDataSource(); + final WKmsJRDataSource source = new WKmsJRDataSource(); addMetaData(source); addWQData(source); @@ -239,68 +204,54 @@ return source; } - - protected void addMetaData(WKmsJRDataSource source) { - CallMeta meta = context.getMeta(); + protected void addMetaData(final WKmsJRDataSource source) { + final CallMeta meta = this.context.getMeta(); - D4EArtifact flys = (D4EArtifact) master; - source.addMetaData("gauge", gaugeName); - if (!Double.isNaN(gaugeDatum)) { - NumberFormat mf = Formatter.getMeterFormat(context); - source.addMetaData( - "datum", mf.format(gaugeDatum) + " " + riverUnit); + final D4EArtifact flys = (D4EArtifact) this.master; + source.addMetaData("gauge", this.gaugeName); + if (!Double.isNaN(this.gaugeDatum)) { + final NumberFormat mf = Formatter.getMeterFormat(this.context); + source.addMetaData("datum", mf.format(this.gaugeDatum) + " " + this.riverUnit); } else { source.addMetaData("datum", ""); } - source.addMetaData ("river", RiverUtils.getRivername(flys)); + source.addMetaData("river", RiverUtils.getRivername(flys)); - Locale locale = Resources.getLocale(meta); - DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, locale); + final Locale locale = Resources.getLocale(meta); + final DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, locale); source.addMetaData("date", df.format(new Date())); - source.addMetaData("wUnit", "cm".equals(wUnit) ? "cm" : riverUnit); + source.addMetaData("wUnit", "cm".equals(this.wUnit) ? "cm" : this.riverUnit); - RangeAccess rangeAccess = new RangeAccess(flys); - double[] kms = rangeAccess.getKmRange(); - source.addMetaData("range", - Formatter.getCalculationKm(context.getMeta()).format(kms[0])); + final RangeAccess rangeAccess = new RangeAccess(flys); + final double[] kms = rangeAccess.getKmRange(); + source.addMetaData("range", Formatter.getCalculationKm(this.context.getMeta()).format(kms[0])); - if (!"cm".equals(wUnit)) { + if (!"cm".equals(this.wUnit)) { source.addMetaData("valid_since", ""); - source.addMetaData("calculation", Resources.getMsg( - locale, - PDF_HEADER_CALC_MODE, - "Computed Discharge")); + source.addMetaData("calculation", Resources.getMsg(locale, PDF_HEADER_CALC_MODE, "Computed Discharge")); } else { - source.addMetaData( - "valid_since", - validSince == null ? "" : df.format(validSince)); - source.addMetaData("calculation", Resources.getMsg( - locale, - PDF_HEADER_MODE, - "Discharge")); + source.addMetaData("valid_since", this.validSince == null ? "" : df.format(this.validSince)); + source.addMetaData("calculation", Resources.getMsg(locale, PDF_HEADER_MODE, "Discharge")); } } - protected void addWQData(WKmsJRDataSource source) { - NumberFormat wf = getWFormatter(); - NumberFormat qf = getQFormatter(); + protected void addWQData(final WKmsJRDataSource source) { + final NumberFormat wf = getWFormatter(); + final NumberFormat qf = getQFormatter(); double[] res = new double[3]; - for (WQKms wqkms: data) { - int size = wqkms.size(); + for (final WQKms wqkms : this.data) { + final int size = wqkms.size(); for (int i = 0; i < size; i++) { res = wqkms.get(i, res); - source.addData(new String[] { - "", // Empty, the WKmsJRDtasource stores km here. - wf.format(res[0]), - qf.format(res[1]) - }); + source.addData(new String[] { "", // Empty, the WKmsJRDtasource stores km here. + wf.format(res[0]), qf.format(res[1]) }); } } } diff -r 7c7f73e5e01e -r 740d65e4aa14 artifacts/src/main/java/org/dive4elements/river/exports/DischargeCurveGenerator.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/DischargeCurveGenerator.java Thu Jul 26 11:16:06 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/DischargeCurveGenerator.java Thu Jul 26 15:54:20 2018 +0200 @@ -11,14 +11,18 @@ import java.util.ArrayList; import java.util.List; +import org.apache.log4j.Logger; import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; +import org.dive4elements.artifactdatabase.state.State; +import org.dive4elements.artifacts.CallContext; import org.dive4elements.river.artifacts.D4EArtifact; +import org.dive4elements.river.artifacts.GaugeDischargeCurveArtifact; import org.dive4elements.river.artifacts.access.RiverAccess; import org.dive4elements.river.artifacts.model.FacetTypes; import org.dive4elements.river.artifacts.model.WQKms; import org.dive4elements.river.exports.process.MiscDischargeProcessor; +import org.dive4elements.river.jfree.Bounds; import org.dive4elements.river.jfree.CollisionFreeXYTextAnnotation; -import org.dive4elements.river.jfree.Bounds; import org.dive4elements.river.jfree.DoubleBounds; import org.dive4elements.river.jfree.RiverAnnotation; import org.dive4elements.river.jfree.StickyAxisAnnotation; @@ -26,71 +30,51 @@ import org.dive4elements.river.model.Gauge; import org.dive4elements.river.model.River; import org.dive4elements.river.themes.ThemeDocument; - -import org.dive4elements.artifactdatabase.state.State; -import org.dive4elements.artifacts.CallContext; -import org.dive4elements.river.artifacts.GaugeDischargeCurveArtifact; - -import org.apache.log4j.Logger; import org.jfree.chart.annotations.XYTextAnnotation; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.plot.XYPlot; import org.jfree.data.Range; import org.jfree.data.xy.XYSeries; - /** * An OutGenerator that generates discharge curves. * * @author Ingo Weinzierl */ -public class DischargeCurveGenerator -extends XYChartGenerator -implements FacetTypes { +public class DischargeCurveGenerator extends XYChartGenerator implements FacetTypes { /** Beware, in this implementation, the W axis is also in cm! */ public static enum YAXIS { - WCm(0), - W(1); + WCm(0), W(1); protected int idx; - private YAXIS(int c) { - idx = c; + + private YAXIS(final int c) { + this.idx = c; } } /** The log used in this generator. */ - private static Logger log = - Logger.getLogger(DischargeCurveGenerator.class); - - public static final String I18N_CHART_TITLE = - "chart.discharge.curve.title"; - - public static final String I18N_CHART_SUBTITLE = - "chart.discharge.curve.subtitle"; + private static Logger log = Logger.getLogger(DischargeCurveGenerator.class); - public static final String I18N_XAXIS_LABEL = - "chart.discharge.curve.xaxis.label"; + public static final String I18N_CHART_TITLE = "chart.discharge.curve.title"; - public static final String I18N_YAXIS_LABEL = - "chart.discharge.curve.yaxis.label"; + public static final String I18N_CHART_SUBTITLE = "chart.discharge.curve.subtitle"; - public static final String I18N_CHART_TITLE_DEFAULT = "Abflusskurven"; - public static final String I18N_XAXIS_LABEL_DEFAULT = "Q [m\u00b3/s]"; - public static final String I18N_YAXIS_LABEL_DEFAULT = "W [cm]"; + public static final String I18N_XAXIS_LABEL = "common.export.csv.header.q"; + public static final String I18N_YAXIS_LABEL = "chart.discharge.curve.yaxis.label"; + + public static final String I18N_CHART_TITLE_DEFAULT = "Abflusskurven"; + public static final String I18N_XAXIS_LABEL_DEFAULT = "Q [m\u00b3/s]"; + public static final String I18N_YAXIS_LABEL_DEFAULT = "W [cm]"; /** * Returns the PNP (Datum) of gauge, if at gauge, 0 otherwise. */ - public static double getCurrentGaugeDatum( - double km, - D4EArtifact artifact, - double tolerance - ) { + public static double getCurrentGaugeDatum(final double km, final D4EArtifact artifact, final double tolerance) { // Look if there is a gauge at chosen km: // Get gauge which is defined for km - Gauge gauge = new RiverAccess(artifact).getRiver() - .determineGaugeAtStation(km); + final Gauge gauge = new RiverAccess(artifact).getRiver().determineGaugeAtStation(km); if (gauge == null) { log.error("No Gauge could be found at station " + km + "!"); return 0d; @@ -103,26 +87,22 @@ return subtractPNP; } - /** Get the current Gauge datum with default distance tolerance. */ public double getCurrentGaugeDatum() { - return getCurrentGaugeDatum(getRange()[0], - (D4EArtifact) getMaster(), 1e-4); + return getCurrentGaugeDatum(getRange()[0], (D4EArtifact) getMaster(), 1e-4); } - /** Overriden to show second axis also if no visible data present. */ @Override - protected void adjustAxes(XYPlot plot) { + protected void adjustAxes(final XYPlot plot) { super.adjustAxes(plot); // XXX Hacking around that there were two axes shown in official Gauge // Discharge, the one from the WINFO module. // This should be made unecessary in a Q Diagram refactoring with // decent inheritance. if (getMaster() instanceof GaugeDischargeCurveArtifact) { - GaugeDischargeCurveArtifact myMaster = - (GaugeDischargeCurveArtifact) getMaster(); - State state = myMaster.getCurrentState(getContext()); + final GaugeDischargeCurveArtifact myMaster = (GaugeDischargeCurveArtifact) getMaster(); + final State state = myMaster.getCurrentState(getContext()); if (GaugeDischargeCurveArtifact.STATIC_STATE_NAME.equals(state.getID())) { return; } @@ -150,49 +130,38 @@ // XXX Q-Symetry: I am assuming here that there can only // be a fixed Range for WinM as this is currently the only // thing that is configureable. - Range fixedWinMRange = getRangeForAxisFromSettings( - getYAxisWalker().getId(YAXIS.W.idx)); + final Range fixedWinMRange = getRangeForAxisFromSettings(getYAxisWalker().getId(YAXIS.W.idx)); // The combination of Range and Bounds is crazy.. if (fixedWinMRange != null) { - boundsInMGauge = new DoubleBounds(fixedWinMRange.getLowerBound(), - fixedWinMRange.getUpperBound()); + boundsInMGauge = new DoubleBounds(fixedWinMRange.getLowerBound(), fixedWinMRange.getUpperBound()); } - log.debug("Syncing Axis Bounds. Bounds W: " - + boundsInMGauge.toString() - + " Bounds Wcm: " + boundsInCM.toString()); + log.debug("Syncing Axis Bounds. Bounds W: " + boundsInMGauge.toString() + " Bounds Wcm: " + boundsInCM.toString()); - double datum = getCurrentGaugeDatum(); + final double datum = getCurrentGaugeDatum(); // Convert boundsInMGauge to Datum+cm - double convertedLower = - ((Double)boundsInMGauge.getLower() - datum) * 100; - double convertedUpper = - ((Double)boundsInMGauge.getUpper() - datum) * 100; - Bounds convertedBounds = - new DoubleBounds(convertedLower, convertedUpper); + final double convertedLower = ((Double) boundsInMGauge.getLower() - datum) * 100; + final double convertedUpper = ((Double) boundsInMGauge.getUpper() - datum) * 100; + final Bounds convertedBounds = new DoubleBounds(convertedLower, convertedUpper); // Now combine both Ranges boundsInCM = boundsInCM.combine(convertedBounds); // Recalculate absolute bounds - boundsInMGauge = new DoubleBounds( - (Double)boundsInCM.getLower() / 100d + datum, - (Double)boundsInCM.getUpper() / 100d + datum); + boundsInMGauge = new DoubleBounds((Double) boundsInCM.getLower() / 100d + datum, (Double) boundsInCM.getUpper() / 100d + datum); // Set the new combined bounds setYBounds(YAXIS.W.idx, boundsInMGauge); setYBounds(YAXIS.WCm.idx, boundsInCM); - log.debug("Synced Bounds W: " + boundsInMGauge.toString() + - " Bounds Wcm: " + boundsInCM.toString()); + log.debug("Synced Bounds W: " + boundsInMGauge.toString() + " Bounds Wcm: " + boundsInCM.toString()); } public DischargeCurveGenerator() { super(); } - @Override protected YAxisWalker getYAxisWalker() { return new YAxisWalker() { @@ -202,14 +171,13 @@ } @Override - public String getId(int idx) { - YAXIS[] yaxes = YAXIS.values(); + public String getId(final int idx) { + final YAXIS[] yaxes = YAXIS.values(); return yaxes[idx].toString(); } }; } - /** * Returns always null to suppress subtitles. */ @@ -218,27 +186,20 @@ return null; } - @Override protected String getDefaultXAxisLabel(final CallContext context) { return msg(I18N_XAXIS_LABEL, I18N_XAXIS_LABEL_DEFAULT); } @Override - protected String getDefaultYAxisLabel(int pos) { + protected String getDefaultYAxisLabel(final int pos) { return msg(I18N_YAXIS_LABEL, I18N_YAXIS_LABEL_DEFAULT); } - /* TODO is this one really needed? */ @Override - protected boolean zoomX( - XYPlot plot, - ValueAxis axis, - Bounds bounds, - Range x - ) { - boolean zoomin = super.zoom(plot, axis, bounds, x); + protected boolean zoomX(final XYPlot plot, final ValueAxis axis, final Bounds bounds, final Range x) { + final boolean zoomin = super.zoom(plot, axis, bounds, x); if (!zoomin) { axis.setLowerBound(0d); @@ -248,104 +209,70 @@ } /** Translate River annotations if a gauge. */ - public void translateRiverAnnotation(RiverAnnotation riverAnnotation) { + public void translateRiverAnnotation(final RiverAnnotation riverAnnotation) { if (getCurrentGaugeDatum() == 0d) { return; } log.debug("Translate some river annotation."); - double translate = getCurrentGaugeDatum(); - double factor = 100d; - for (StickyAxisAnnotation annotation: - riverAnnotation.getAxisTextAnnotations() - ){ + final double translate = getCurrentGaugeDatum(); + final double factor = 100d; + for (final StickyAxisAnnotation annotation : riverAnnotation.getAxisTextAnnotations()) { if (!annotation.atX()) { - annotation.setPos((annotation.getPos() - translate)*factor); + annotation.setPos((annotation.getPos() - translate) * factor); } } - for ( - XYTextAnnotation annotation: riverAnnotation.getTextAnnotations() - ) { - annotation.setY((annotation.getY() - translate)*factor); + for (final XYTextAnnotation annotation : riverAnnotation.getTextAnnotations()) { + annotation.setY((annotation.getY() - translate) * factor); } } - @Override - public void doOut( - ArtifactAndFacet artifactFacet, - ThemeDocument theme, - boolean visible - ) { - String name = artifactFacet.getFacetName(); + public void doOut(final ArtifactAndFacet artifactFacet, final ThemeDocument theme, final boolean visible) { + final String name = artifactFacet.getFacetName(); log.debug("DischargeCurveGenerator.doOut: " + name); final CallContext context = getContext(); - - MiscDischargeProcessor dProcessor = new MiscDischargeProcessor( - getRange()[0]); + + final MiscDischargeProcessor dProcessor = new MiscDischargeProcessor(getRange()[0]); if (dProcessor.canHandle(name)) { // In Base DischargeCurveGenerator, always at gauge, use WCm axis. - dProcessor.doOut( - this, artifactFacet, theme, visible, YAXIS.WCm.idx); - } - else if (name.equals(DISCHARGE_CURVE) - || name.equals(GAUGE_DISCHARGE_CURVE)) { - doDischargeOut( - (D4EArtifact)artifactFacet.getArtifact(), - artifactFacet.getData(context), - artifactFacet.getFacetDescription(), - theme, - visible); - } - else if (FacetTypes.IS.MANUALPOINTS(name)) { - doPoints(artifactFacet.getData(context), - artifactFacet, - theme, visible, YAXIS.W.idx); - } - else if (STATIC_WQ.equals(name)) { - doWQOut(artifactFacet.getData(context), - artifactFacet, - theme, - visible); - } - else { - log.warn("DischargeCurveGenerator.doOut: Unknown facet name: " - + name); - return; + dProcessor.doOut(this, artifactFacet, theme, visible, YAXIS.WCm.idx); + } else if (name.equals(DISCHARGE_CURVE) || name.equals(GAUGE_DISCHARGE_CURVE)) { + doDischargeOut((D4EArtifact) artifactFacet.getArtifact(), artifactFacet.getData(context), artifactFacet.getFacetDescription(), theme, visible); + } else if (FacetTypes.IS.MANUALPOINTS(name)) { + doPoints(artifactFacet.getData(context), artifactFacet, theme, visible, YAXIS.W.idx); + } else if (STATIC_WQ.equals(name)) { + doWQOut(artifactFacet.getData(context), artifactFacet, theme, visible); + } else { + log.warn("DischargeCurveGenerator.doOut: Unknown facet name: " + name); + return; } } - /** * Add series with discharge curve to diagram. */ - protected void doDischargeOut( - D4EArtifact artifact, - Object o, - String description, - ThemeDocument theme, - boolean visible) - { + protected void doDischargeOut(final D4EArtifact artifact, final Object o, final String description, final ThemeDocument theme, final boolean visible) { log.debug("DischargeCurveGenerator.doDischargeOut"); - WQKms wqkms = (WQKms) o; + final WQKms wqkms = (WQKms) o; - String gaugeName = wqkms.getName(); + final String gaugeName = wqkms.getName(); - River river = new RiverAccess(artifact).getRiver(); + final River river = new RiverAccess(artifact).getRiver(); if (river == null) { log.debug("no river found"); return; } - Gauge gauge = river.determineGaugeByName(gaugeName); + final Gauge gauge = river.determineGaugeByName(gaugeName); if (gauge == null) { log.debug("no gauge found"); return; } - XYSeries series = new StyledXYSeries(description, theme); + final XYSeries series = new StyledXYSeries(description, theme); StyledSeriesBuilder.addPointsQW(series, wqkms); @@ -354,56 +281,43 @@ /** * Add W/Q-Series to plot. - * @param wqkms actual data - * @param theme theme to use. + * + * @param wqkms + * actual data + * @param theme + * theme to use. */ - protected void doQOut( - Object wqkms, - ArtifactAndFacet aaf, - ThemeDocument theme, - boolean visible - ) { + protected void doQOut(final Object wqkms, final ArtifactAndFacet aaf, final ThemeDocument theme, final boolean visible) { log.debug("DischargeCurveGenerator: doQOut (add W/Q data)."); - XYSeries series = new StyledXYSeries(aaf.getFacetDescription(), theme); + final XYSeries series = new StyledXYSeries(aaf.getFacetDescription(), theme); StyledSeriesBuilder.addPointsQW(series, (WQKms) wqkms); addAxisSeries(series, YAXIS.W.idx, visible); } - /** Add a point annotation at given x and y coordinates. */ - protected void addPointTextAnnotation( - String title, - double x, - double y, - ThemeDocument theme - ) { + protected void addPointTextAnnotation(final String title, final double x, final double y, final ThemeDocument theme) { final List textAnnos = new ArrayList<>(); - XYTextAnnotation anno = new CollisionFreeXYTextAnnotation( - title, - x, - y); + final XYTextAnnotation anno = new CollisionFreeXYTextAnnotation(title, x, y); textAnnos.add(anno); - RiverAnnotation flysAnno = new RiverAnnotation( - null, null, null, theme); + final RiverAnnotation flysAnno = new RiverAnnotation(null, null, null, theme); flysAnno.setTextAnnotations(textAnnos); addAnnotations(flysAnno); } - /** * Return true if all values in data[0] are smaller than zero * (in imported data they are set to -1 symbolically). * Return false if data is null or empty */ - private static boolean hasNoDischarge(double[][] data) { + private static boolean hasNoDischarge(final double[][] data) { if (data == null || data.length == 0) { return false; } - double[] qs = data[0]; - for (double q: qs) { + final double[] qs = data[0]; + for (final double q : qs) { if (q > 0d) { return false; } @@ -412,67 +326,56 @@ return true; } - /** * Add WQ Data to plot. - * @param wq data as double[][] + * + * @param wq + * data as double[][] */ - protected void doWQOut( - Object wq, - ArtifactAndFacet aaf, - ThemeDocument theme, - boolean visible - ) { + protected void doWQOut(final Object wq, final ArtifactAndFacet aaf, final ThemeDocument theme, final boolean visible) { log.debug("DischargeCurveGenerator: doWQOut"); - double [][] data = (double [][]) wq; - String title = aaf.getFacetDescription(); + final double[][] data = (double[][]) wq; + final String title = aaf.getFacetDescription(); - double translate = getCurrentGaugeDatum(); + final double translate = getCurrentGaugeDatum(); // If no Q values (i.e. all -1) found, add annotations. if (hasNoDischarge(data)) { final List xy = new ArrayList<>(); - for (double y: data[1]) { + for (double y : data[1]) { if (translate != 0d) { - y = (y-translate)*100d; + y = (y - translate) * 100d; } - xy.add(new StickyAxisAnnotation( - title, - (float) y, - StickyAxisAnnotation.SimpleAxis.Y_AXIS)); + xy.add(new StickyAxisAnnotation(title, (float) y, StickyAxisAnnotation.SimpleAxis.Y_AXIS)); } - doAnnotations( - new RiverAnnotation(title, xy), - aaf, theme, visible); + doAnnotations(new RiverAnnotation(title, xy), aaf, theme, visible); return; } // Otherwise add points. - XYSeries series = new StyledXYSeries(title, theme); + final XYSeries series = new StyledXYSeries(title, theme); if (translate != 0d) { StyledSeriesBuilder.addPointsQW(series, data, -translate, 100d); addAxisSeries(series, YAXIS.W.idx, visible); - } - else { + } else { StyledSeriesBuilder.addPoints(series, data, true); addAxisSeries(series, YAXIS.W.idx, visible); } - if (visible && theme.parseShowPointLabel() - && data != null && data.length != 0) { + if (visible && theme.parseShowPointLabel() && data != null && data.length != 0) { - double[] xs = data[0]; - double[] ys = data[1]; + final double[] xs = data[0]; + final double[] ys = data[1]; for (int i = 0; i < xs.length; i++) { - double x = xs[i]; + final double x = xs[i]; double y = ys[i]; if (translate != 0d) { - y = (y-translate)*100d; + y = (y - translate) * 100d; } addPointTextAnnotation(title, x, y, theme); diff -r 7c7f73e5e01e -r 740d65e4aa14 artifacts/src/main/java/org/dive4elements/river/exports/DischargeLongitudinalSectionExporter.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/DischargeLongitudinalSectionExporter.java Thu Jul 26 11:16:06 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/DischargeLongitudinalSectionExporter.java Thu Jul 26 15:54:20 2018 +0200 @@ -8,132 +8,101 @@ package org.dive4elements.river.exports; -import au.com.bytecode.opencsv.CSVWriter; +import java.text.NumberFormat; +import org.apache.log4j.Logger; import org.dive4elements.river.artifacts.model.CalculationResult; import org.dive4elements.river.artifacts.model.WQCKms; import org.dive4elements.river.artifacts.model.WQKms; -import java.text.NumberFormat; - -import org.apache.log4j.Logger; +import au.com.bytecode.opencsv.CSVWriter; /** * @author Ingo Weinzierl */ public class DischargeLongitudinalSectionExporter extends WaterlevelExporter { - /** The log used in this exporter.*/ - private static Logger log = - Logger.getLogger(DischargeLongitudinalSectionExporter.class); - - - public static final String CSV_KM_HEADER = - "export.discharge.longitudinal.section.csv.header.km"; + /** The log used in this exporter. */ + private static Logger log = Logger.getLogger(DischargeLongitudinalSectionExporter.class); - public static final String CSV_W_HEADER = - "export.discharge.longitudinal.section.csv.header.w"; + public static final String CSV_KM_HEADER = "export.discharge.longitudinal.section.csv.header.km"; - public static final String CSV_CW_HEADER = - "export.discharge.longitudinal.section.csv.header.cw"; + public static final String CSV_W_HEADER = "export.discharge.longitudinal.section.csv.header.w"; - public static final String CSV_Q_HEADER = - "export.discharge.longitudinal.section.csv.header.q"; + public static final String CSV_CW_HEADER = "export.discharge.longitudinal.section.csv.header.cw"; + + public static final String CSV_Q_HEADER = "common.export.csv.header.q"; public static final String DEFAULT_CSV_KM_HEADER = "Fluss-Km"; - public static final String DEFAULT_CSV_W_HEADER = "W [NN + m]"; + public static final String DEFAULT_CSV_W_HEADER = "W [NN + m]"; public static final String DEFAULT_CSV_CW_HEADER = "W korr."; - public static final String DEFAULT_CSV_Q_HEADER = "Q [m\u00b3/s]"; - + public static final String DEFAULT_CSV_Q_HEADER = "Q [m\u00b3/s]"; @Override protected void addData(Object d) { if (d instanceof CalculationResult) { - d = ((CalculationResult)d).getData(); - if (d instanceof WQKms []) { - data.add((WQKms [])d); + d = ((CalculationResult) d).getData(); + if (d instanceof WQKms[]) { + this.data.add((WQKms[]) d); } } } - @Override - protected void writeCSVHeader( - CSVWriter writer, - boolean atGauge, - boolean isQ - ) { + protected void writeCSVHeader(final CSVWriter writer, final boolean atGauge, final boolean isQ) { log.info("WaterlevelExporter.writeCSVHeader"); - writer.writeNext(new String[] { - msg(CSV_KM_HEADER, DEFAULT_CSV_KM_HEADER), - msg(CSV_W_HEADER, DEFAULT_CSV_W_HEADER), - msg(CSV_CW_HEADER, DEFAULT_CSV_CW_HEADER), - msg(CSV_Q_HEADER, DEFAULT_CSV_Q_HEADER), - msg(CSV_Q_DESC_HEADER, DEFAULT_CSV_Q_DESC_HEADER) - }); + writer.writeNext(new String[] { msg(CSV_KM_HEADER, DEFAULT_CSV_KM_HEADER), msg(CSV_W_HEADER, DEFAULT_CSV_W_HEADER), + msg(CSV_CW_HEADER, DEFAULT_CSV_CW_HEADER), msg(CSV_Q_HEADER, DEFAULT_CSV_Q_HEADER), msg(CSV_Q_DESC_HEADER, DEFAULT_CSV_Q_DESC_HEADER) }); } - - protected void wQKms2CSV( - CSVWriter writer, - WQKms wqkms, - boolean atGauge, - boolean isQ - ) { + @Override + protected void wQKms2CSV(final CSVWriter writer, final WQKms wqkms, final boolean atGauge, final boolean isQ) { log.debug("WaterlevelExporter.wQKms2CSV"); - int size = wqkms.size(); + final int size = wqkms.size(); double[] result = new double[4]; - NumberFormat kmf = getKmFormatter(); - NumberFormat wf = getWFormatter(); - NumberFormat qf = getQFormatter(); + final NumberFormat kmf = getKmFormatter(); + final NumberFormat wf = getWFormatter(); + final NumberFormat qf = getQFormatter(); - for (int i = 0; i < size; i ++) { + for (int i = 0; i < size; i++) { result = wqkms.get(i, result); - String name = wqkms.getName(); + final String name = wqkms.getName(); String wc = ""; if (wqkms instanceof WQCKms) { wc = wf.format(result[3]); } - writer.writeNext(new String[] { - kmf.format(result[2]), - wf.format(result[0]), - wc, - qf.format(result[1]), - name - }); + writer.writeNext(new String[] { kmf.format(result[2]), wf.format(result[0]), wc, qf.format(result[1]), name }); } } - @Override - protected void addWSTColumn(WstWriter writer, WQKms wqkms) { - String name = wqkms.getName(); + protected void addWSTColumn(final WstWriter writer, final WQKms wqkms) { + final String name = wqkms.getName(); // is it a W or a Q mode? - int wIdx = name.indexOf("W"); - int qIdx = name.indexOf("Q"); + final int wIdx = name.indexOf("W"); + final int qIdx = name.indexOf("Q"); String wq = null; if (wIdx >= 0) { wq = "W"; - } - else if (qIdx >= 0) { + } else if (qIdx >= 0) { wq = "Q"; } // we just want to display the first W or Q value in the WST - int start = name.indexOf("("); - int end = name.indexOf(")"); + final int start = name.indexOf("("); + final int end = name.indexOf(")"); - String tmp = name.substring(start+1, end); - String[] values = tmp.split(";"); + final String tmp = name.substring(start + 1, end); + final String[] values = tmp.split(";"); - String column = wq + "=" + values[0]; + final String column = wq + "=" + values[0]; writer.addColumn(column); } diff -r 7c7f73e5e01e -r 740d65e4aa14 artifacts/src/main/java/org/dive4elements/river/exports/DurationCurveExporter.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/DurationCurveExporter.java Thu Jul 26 11:16:06 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/DurationCurveExporter.java Thu Jul 26 15:54:20 2018 +0200 @@ -9,39 +9,33 @@ package org.dive4elements.river.exports; import java.io.OutputStream; +import java.text.DateFormat; import java.text.NumberFormat; import java.util.ArrayList; -import java.util.List; -import java.util.Map; +import java.util.Date; import java.util.HashMap; -import java.util.Date; -import java.text.DateFormat; +import java.util.List; import java.util.Locale; +import java.util.Map; import org.apache.log4j.Logger; +import org.dive4elements.artifacts.CallMeta; +import org.dive4elements.artifacts.common.utils.Config; +import org.dive4elements.river.artifacts.D4EArtifact; +import org.dive4elements.river.artifacts.access.RangeAccess; +import org.dive4elements.river.artifacts.access.RiverAccess; +import org.dive4elements.river.artifacts.model.CalculationResult; +import org.dive4elements.river.artifacts.model.WKmsJRDataSource; +import org.dive4elements.river.artifacts.model.WQDay; +import org.dive4elements.river.artifacts.resources.Resources; +import org.dive4elements.river.utils.Formatter; +import org.dive4elements.river.utils.RiverUtils; import au.com.bytecode.opencsv.CSVWriter; - +import net.sf.jasperreports.engine.JRException; import net.sf.jasperreports.engine.JasperExportManager; import net.sf.jasperreports.engine.JasperFillManager; import net.sf.jasperreports.engine.JasperPrint; -import net.sf.jasperreports.engine.JRException; - -import org.dive4elements.artifacts.CallMeta; -import org.dive4elements.artifacts.common.utils.Config; - -import org.dive4elements.river.artifacts.D4EArtifact; - -import org.dive4elements.river.artifacts.access.RiverAccess; -import org.dive4elements.river.artifacts.access.RangeAccess; -import org.dive4elements.river.artifacts.model.WQDay; -import org.dive4elements.river.artifacts.model.CalculationResult; -import org.dive4elements.river.artifacts.model.WKmsJRDataSource; -import org.dive4elements.river.artifacts.resources.Resources; - -import org.dive4elements.river.utils.RiverUtils; -import org.dive4elements.river.utils.Formatter; - /** * @author Ingo Weinzierl @@ -51,15 +45,11 @@ /** The log used in this exporter. */ private static Logger log = Logger.getLogger(DurationCurveExporter.class); - - public static final String CSV_DURATION_HEADER = - "export.duration.curve.csv.header.duration"; + public static final String CSV_DURATION_HEADER = "export.duration.curve.csv.header.duration"; - public static final String CSV_W_HEADER = - "export.duration.curve.csv.header.w"; + public static final String CSV_W_HEADER = "export.duration.curve.csv.header.w"; - public static final String CSV_Q_HEADER = - "export.duration.curve.csv.header.q"; + public static final String CSV_Q_HEADER = "common.export.csv.header.q"; public static final String PDF_HEADER_MODE = "export.duration.pdf.mode"; public static final String JASPER_FILE = "export.duration.pdf.file"; @@ -68,75 +58,58 @@ protected List data; public DurationCurveExporter() { - data = new ArrayList(); + this.data = new ArrayList<>(); } @Override protected void addData(Object d) { if (d instanceof CalculationResult) { - d = ((CalculationResult)d).getData(); + d = ((CalculationResult) d).getData(); if (d instanceof WQDay) { - data.add((WQDay)d); + this.data.add((WQDay) d); } } } - - protected void writeCSVData(CSVWriter writer) { + @Override + protected void writeCSVData(final CSVWriter writer) { log.info("DurationCurveExporter.writeData"); writeCSVHeader(writer); - for (WQDay wqday: data) { + for (final WQDay wqday : this.data) { wQDay2CSV(writer, wqday); } } - - protected void writeCSVHeader(CSVWriter writer) { + protected void writeCSVHeader(final CSVWriter writer) { log.info("DurationCurveExporter.writeCSVHeader"); - String unit = new RiverAccess((D4EArtifact)master) - .getRiver().getWstUnit().getName(); + final String unit = new RiverAccess((D4EArtifact) this.master).getRiver().getWstUnit().getName(); - writer.writeNext(new String[] { - msg(CSV_W_HEADER, new Object[] { unit }), - msg(CSV_Q_HEADER), - msg(CSV_DURATION_HEADER) - }); + writer.writeNext(new String[] { msg(CSV_W_HEADER, new Object[] { unit }), msg(CSV_Q_HEADER), msg(CSV_DURATION_HEADER) }); } - - protected void wQDay2CSV(CSVWriter writer, WQDay wqday) { + protected void wQDay2CSV(final CSVWriter writer, final WQDay wqday) { log.debug("DurationCurveExporter.wQDay2CSV"); - int size = wqday.size(); + final int size = wqday.size(); - NumberFormat wf = getWFormatter(); - NumberFormat qf = getQFormatter(); - NumberFormat df = getDFormatter(); + final NumberFormat wf = getWFormatter(); + final NumberFormat qf = getQFormatter(); + final NumberFormat df = getDFormatter(); if (wqday.isIncreasing()) { - for (int i = size-1; i >= 0; i --) { - writer.writeNext(new String[] { - wf.format(wqday.getW(i)), - qf.format(wqday.getQ(i)), - df.format(wqday.getDay(i)) - }); + for (int i = size - 1; i >= 0; i--) { + writer.writeNext(new String[] { wf.format(wqday.getW(i)), qf.format(wqday.getQ(i)), df.format(wqday.getDay(i)) }); } - } - else { - for (int i = 0; i < size; i ++) { - writer.writeNext(new String[] { - wf.format(wqday.getW(i)), - qf.format(wqday.getQ(i)), - df.format(wqday.getDay(i)) - }); + } else { + for (int i = 0; i < size; i++) { + writer.writeNext(new String[] { wf.format(wqday.getW(i)), qf.format(wqday.getQ(i)), df.format(wqday.getDay(i)) }); } } } - /** * Returns the number formatter for W values. * @@ -144,10 +117,9 @@ */ @Override protected NumberFormat getWFormatter() { - return Formatter.getDurationW(context); + return Formatter.getDurationW(this.context); } - /** * Returns the number formatter for Q values. * @@ -155,106 +127,81 @@ */ @Override protected NumberFormat getQFormatter() { - return Formatter.getDurationQ(context); + return Formatter.getDurationQ(this.context); } - /** * Returns the number formatter for duration values. * * @return the number formatter for duration values. */ protected NumberFormat getDFormatter() { - return Formatter.getDurationD(context); + return Formatter.getDurationD(this.context); } - @Override - protected void writePDF(OutputStream out) { - WKmsJRDataSource source = createJRData(); + protected void writePDF(final OutputStream out) { + final WKmsJRDataSource source = createJRData(); - String jasperFile = Resources.getMsg( - context.getMeta(), - JASPER_FILE, - "/jasper/duration_en.jasper"); - String confPath = Config.getConfigDirectory().toString(); + final String jasperFile = Resources.getMsg(this.context.getMeta(), JASPER_FILE, "/jasper/duration_en.jasper"); + final String confPath = Config.getConfigDirectory().toString(); - Map parameters = new HashMap(); + final Map parameters = new HashMap(); parameters.put("ReportTitle", "Exported Data"); try { - JasperPrint print = JasperFillManager.fillReport( - confPath + jasperFile, - parameters, - source); + final JasperPrint print = JasperFillManager.fillReport(confPath + jasperFile, parameters, source); JasperExportManager.exportReportToPdfStream(print, out); } - catch(JRException je) { + catch (final JRException je) { log.warn("Error generating PDF Report!"); je.printStackTrace(); } } protected WKmsJRDataSource createJRData() { - WKmsJRDataSource source = new WKmsJRDataSource(); + final WKmsJRDataSource source = new WKmsJRDataSource(); addMetaData(source); - for (WQDay wqday: data) { + for (final WQDay wqday : this.data) { addWQDayData(source, wqday); } return source; } - - protected void addMetaData(WKmsJRDataSource source) { - CallMeta meta = context.getMeta(); + protected void addMetaData(final WKmsJRDataSource source) { + final CallMeta meta = this.context.getMeta(); - D4EArtifact flys = (D4EArtifact) master; + final D4EArtifact flys = (D4EArtifact) this.master; - source.addMetaData ("river", RiverUtils.getRivername(flys)); + source.addMetaData("river", RiverUtils.getRivername(flys)); - Locale locale = Resources.getLocale(meta); - DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, locale); + final Locale locale = Resources.getLocale(meta); + final DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, locale); source.addMetaData("date", df.format(new Date())); - RangeAccess rangeAccess = new RangeAccess(flys); - double[] kms = rangeAccess.getKmRange(); + final RangeAccess rangeAccess = new RangeAccess(flys); + final double[] kms = rangeAccess.getKmRange(); source.addMetaData("range", String.valueOf(kms[0])); - source.addMetaData("calculation", Resources.getMsg( - locale, - PDF_HEADER_MODE, - "Duration")); + source.addMetaData("calculation", Resources.getMsg(locale, PDF_HEADER_MODE, "Duration")); } - protected void addWQDayData(WKmsJRDataSource source, WQDay wqday) { - int size = wqday.size(); + protected void addWQDayData(final WKmsJRDataSource source, final WQDay wqday) { + final int size = wqday.size(); - NumberFormat wf = getWFormatter(); - NumberFormat qf = getQFormatter(); - NumberFormat df = getDFormatter(); + final NumberFormat wf = getWFormatter(); + final NumberFormat qf = getQFormatter(); + final NumberFormat df = getDFormatter(); if (wqday.isIncreasing()) { - for (int i = size-1; i >= 0; i --) { - source.addData(new String[] { - "", - wf.format(wqday.getW(i)), - qf.format(wqday.getQ(i)), - "", "", "", - df.format(wqday.getDay(i)) - }); + for (int i = size - 1; i >= 0; i--) { + source.addData(new String[] { "", wf.format(wqday.getW(i)), qf.format(wqday.getQ(i)), "", "", "", df.format(wqday.getDay(i)) }); } - } - else { - for (int i = 0; i < size; i ++) { - source.addData(new String[] { - "", - wf.format(wqday.getW(i)), - qf.format(wqday.getQ(i)), - "", "", "", - df.format(wqday.getDay(i)) - }); + } else { + for (int i = 0; i < size; i++) { + source.addData(new String[] { "", wf.format(wqday.getW(i)), qf.format(wqday.getQ(i)), "", "", "", df.format(wqday.getDay(i)) }); } } } diff -r 7c7f73e5e01e -r 740d65e4aa14 artifacts/src/main/java/org/dive4elements/river/exports/DurationCurveGenerator.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/DurationCurveGenerator.java Thu Jul 26 11:16:06 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/DurationCurveGenerator.java Thu Jul 26 15:54:20 2018 +0200 @@ -8,6 +8,10 @@ package org.dive4elements.river.exports; +import java.awt.Font; +import java.awt.geom.Point2D; + +import org.apache.log4j.Logger; import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; import org.dive4elements.artifacts.CallContext; import org.dive4elements.river.artifacts.model.FacetTypes; @@ -16,77 +20,59 @@ import org.dive4elements.river.jfree.RiverAnnotation; import org.dive4elements.river.jfree.StyledXYSeries; import org.dive4elements.river.themes.ThemeDocument; - -import java.awt.Font; -import java.awt.geom.Point2D; - -import org.apache.log4j.Logger; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.plot.XYPlot; import org.jfree.data.Range; import org.jfree.data.xy.XYSeries; - /** * An OutGenerator that generates duration curves. * * @author Ingo Weinzierl */ -public class DurationCurveGenerator -extends XYChartGenerator -implements FacetTypes -{ +public class DurationCurveGenerator extends XYChartGenerator implements FacetTypes { public static enum YAXIS { - W(0), - Q(1); + W(0), Q(1); public int idx; - private YAXIS(int c) { - idx = c; + + private YAXIS(final int c) { + this.idx = c; } } /** Local log. */ - private static Logger log = - Logger.getLogger(DurationCurveGenerator.class); - - public static final String I18N_CHART_TITLE = - "chart.duration.curve.title"; - - public static final String I18N_CHART_SUBTITLE = - "chart.duration.curve.subtitle"; - - public static final String I18N_XAXIS_LABEL = - "chart.duration.curve.xaxis.label"; + private static Logger log = Logger.getLogger(DurationCurveGenerator.class); - public static final String I18N_YAXIS_LABEL_W = - "chart.duration.curve.yaxis.label.w"; - - public static final String I18N_YAXIS_LABEL_Q = - "chart.duration.curve.yaxis.label.q"; + public static final String I18N_CHART_TITLE = "chart.duration.curve.title"; - public static final String I18N_CHART_TITLE_DEFAULT = - "Dauerlinie"; + public static final String I18N_CHART_SUBTITLE = "chart.duration.curve.subtitle"; - public static final String I18N_XAXIS_LABEL_DEFAULT = - "Unterschreitungsdauer [Tage]"; + public static final String I18N_XAXIS_LABEL = "chart.duration.curve.xaxis.label"; + public static final String I18N_YAXIS_LABEL_W = "chart.duration.curve.yaxis.label.w"; + + public static final String I18N_YAXIS_LABEL_Q = "common.export.csv.header.q"; + + public static final String I18N_CHART_TITLE_DEFAULT = "Dauerlinie"; + + public static final String I18N_XAXIS_LABEL_DEFAULT = "Unterschreitungsdauer [Tage]"; public DurationCurveGenerator() { super(); } - /** * Create Axis for given index. + * * @return axis with according internationalized label. */ @Override - protected NumberAxis createYAxis(int index) { - Font labelFont = new Font("Tahoma", Font.BOLD, 14); - String label = getYAxisLabel(index); + protected NumberAxis createYAxis(final int index) { + final Font labelFont = new Font("Tahoma", Font.BOLD, 14); + final String label = getYAxisLabel(index); - NumberAxis axis = createNumberAxis(index, label); + final NumberAxis axis = createNumberAxis(index, label); if (index == YAXIS.W.idx) { axis.setAutoRangeIncludesZero(false); } @@ -94,54 +80,40 @@ return axis; } - @Override protected String getDefaultChartTitle(final CallContext context) { return msg(I18N_CHART_TITLE, I18N_CHART_TITLE_DEFAULT); } - @Override protected String getDefaultChartSubtitle(final CallContext context) { - double[] dist = getRange(); + final double[] dist = getRange(); - Object[] args = new Object[] { - getRiverName(), - dist[0] - }; + final Object[] args = new Object[] { getRiverName(), dist[0] }; return msg(I18N_CHART_SUBTITLE, "", args); } - @Override protected String getDefaultXAxisLabel(final CallContext context) { return msg(I18N_XAXIS_LABEL, I18N_XAXIS_LABEL_DEFAULT); } - @Override - protected String getDefaultYAxisLabel(int index) { + protected String getDefaultYAxisLabel(final int index) { String label = "default"; if (index == YAXIS.W.idx) { label = msg(I18N_YAXIS_LABEL_W, I18N_YAXIS_LABEL_W, new Object[] { getRiverUnit() }); - } - else if (index == YAXIS.Q.idx) { + } else if (index == YAXIS.Q.idx) { label = msg(I18N_YAXIS_LABEL_Q); } return label; } - @Override - protected boolean zoomX( - XYPlot plot, - ValueAxis axis, - Bounds bounds, - Range x - ) { - boolean zoomin = super.zoom(plot, axis, bounds, x); + protected boolean zoomX(final XYPlot plot, final ValueAxis axis, final Bounds bounds, final Range x) { + final boolean zoomin = super.zoom(plot, axis, bounds, x); if (!zoomin) { axis.setLowerBound(0d); @@ -152,23 +124,17 @@ return zoomin; } - /** * This method overrides the method in the parent class to set the lower * bounds of the Q axis to 0. This axis should never display negative * values on its own. */ @Override - protected boolean zoomY( - XYPlot plot, - ValueAxis axis, - Bounds bounds, - Range x - ) { - boolean zoomin = super.zoom(plot, axis, bounds, x); + protected boolean zoomY(final XYPlot plot, final ValueAxis axis, final Bounds bounds, final Range x) { + final boolean zoomin = super.zoom(plot, axis, bounds, x); if (!zoomin && axis instanceof IdentifiableNumberAxis) { - String id = ((IdentifiableNumberAxis) axis).getId(); + final String id = ((IdentifiableNumberAxis) axis).getId(); if (YAXIS.Q.toString().equals(id)) { axis.setLowerBound(0d); @@ -178,14 +144,9 @@ return zoomin; } - @Override - public void doOut( - ArtifactAndFacet artifactFacet, - ThemeDocument attr, - boolean visible - ) { - String name = artifactFacet.getFacetName(); + public void doOut(final ArtifactAndFacet artifactFacet, final ThemeDocument attr, final boolean visible) { + final String name = artifactFacet.getFacetName(); log.debug("DurationCurveGenerator.doOut: " + name); @@ -193,69 +154,41 @@ log.error("No facet given. Cannot create dataset."); return; } - + final CallContext context = getContext(); if (name.equals(DURATION_W)) { - doWOut( - (WQDay) artifactFacet.getData(context), - artifactFacet, - attr, - visible); - } - else if (name.equals(DURATION_Q)) { - doQOut( - (WQDay) artifactFacet.getData(context), - artifactFacet, - attr, - visible); - } - else if (name.equals(MAINVALUES_Q) || name.equals(MAINVALUES_W)) { - doAnnotations( - (RiverAnnotation) artifactFacet.getData(context), - artifactFacet, - attr, - visible); - } - else if (name.equals(RELATIVE_POINT)) { - doPointOut((Point2D) artifactFacet.getData(context), - artifactFacet, - attr, - visible); - } - else if (FacetTypes.IS.MANUALPOINTS(name)) { - doPoints( - artifactFacet.getData(context), - artifactFacet, - attr, visible, YAXIS.W.idx); - } - else { + doWOut((WQDay) artifactFacet.getData(context), artifactFacet, attr, visible); + } else if (name.equals(DURATION_Q)) { + doQOut((WQDay) artifactFacet.getData(context), artifactFacet, attr, visible); + } else if (name.equals(MAINVALUES_Q) || name.equals(MAINVALUES_W)) { + doAnnotations((RiverAnnotation) artifactFacet.getData(context), artifactFacet, attr, visible); + } else if (name.equals(RELATIVE_POINT)) { + doPointOut((Point2D) artifactFacet.getData(context), artifactFacet, attr, visible); + } else if (FacetTypes.IS.MANUALPOINTS(name)) { + doPoints(artifactFacet.getData(context), artifactFacet, attr, visible, YAXIS.W.idx); + } else { log.warn("Unknown facet name: " + name); return; } } - /** * Creates the series for a duration curve's W facet. * - * @param wqdays The WQDay store that contains the Ws. + * @param wqdays + * The WQDay store that contains the Ws. * @param theme */ - protected void doWOut( - WQDay wqdays, - ArtifactAndFacet aaf, - ThemeDocument theme, - boolean visible - ) { + protected void doWOut(final WQDay wqdays, final ArtifactAndFacet aaf, final ThemeDocument theme, final boolean visible) { log.debug("DurationCurveGenerator.doWOut"); - XYSeries series = new StyledXYSeries(aaf.getFacetDescription(), theme); + final XYSeries series = new StyledXYSeries(aaf.getFacetDescription(), theme); - int size = wqdays.size(); + final int size = wqdays.size(); for (int i = 0; i < size; i++) { - int day = wqdays.getDay(i); - double w = wqdays.getW(i); + final int day = wqdays.getDay(i); + final double w = wqdays.getW(i); series.add(day, w); } @@ -263,43 +196,32 @@ addAxisSeries(series, YAXIS.W.idx, visible); } - protected void doPointOut( - Point2D point, - ArtifactAndFacet aandf, - ThemeDocument theme, - boolean visible - ){ + protected void doPointOut(final Point2D point, final ArtifactAndFacet aandf, final ThemeDocument theme, final boolean visible) { log.debug("DurationCurveGenerator.doPointOut"); - XYSeries series = - new StyledXYSeries(aandf.getFacetDescription(), theme); + final XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), theme); series.add(point.getX(), point.getY()); addAxisSeries(series, YAXIS.W.idx, visible); } - /** * Creates the series for a duration curve's Q facet. * - * @param wqdays The WQDay store that contains the Qs. + * @param wqdays + * The WQDay store that contains the Qs. * @param theme */ - protected void doQOut( - WQDay wqdays, - ArtifactAndFacet aaf, - ThemeDocument theme, - boolean visible - ) { + protected void doQOut(final WQDay wqdays, final ArtifactAndFacet aaf, final ThemeDocument theme, final boolean visible) { log.debug("DurationCurveGenerator.doQOut"); - XYSeries series = new StyledXYSeries(aaf.getFacetDescription(), theme); + final XYSeries series = new StyledXYSeries(aaf.getFacetDescription(), theme); - int size = wqdays.size(); + final int size = wqdays.size(); for (int i = 0; i < size; i++) { - int day = wqdays.getDay(i); - double q = wqdays.getQ(i); + final int day = wqdays.getDay(i); + final double q = wqdays.getQ(i); series.add(day, q); } @@ -307,7 +229,6 @@ addAxisSeries(series, YAXIS.Q.idx, visible); } - @Override protected YAxisWalker getYAxisWalker() { return new YAxisWalker() { @@ -317,8 +238,8 @@ } @Override - public String getId(int idx) { - YAXIS[] yaxes = YAXIS.values(); + public String getId(final int idx) { + final YAXIS[] yaxes = YAXIS.values(); return yaxes[idx].toString(); } }; diff -r 7c7f73e5e01e -r 740d65e4aa14 artifacts/src/main/java/org/dive4elements/river/exports/FlowVelocityExporter.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/FlowVelocityExporter.java Thu Jul 26 11:16:06 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/FlowVelocityExporter.java Thu Jul 26 15:54:20 2018 +0200 @@ -14,48 +14,37 @@ import java.util.List; import org.apache.log4j.Logger; - -import au.com.bytecode.opencsv.CSVWriter; - import org.dive4elements.river.artifacts.D4EArtifact; import org.dive4elements.river.artifacts.model.CalculationResult; import org.dive4elements.river.artifacts.model.FlowVelocityData; +import org.dive4elements.river.utils.Formatter; import org.dive4elements.river.utils.RiverUtils; -import org.dive4elements.river.utils.Formatter; +import au.com.bytecode.opencsv.CSVWriter; /** * @author Ingo Weinzierl */ public class FlowVelocityExporter extends AbstractExporter { - private static final Logger log = - Logger.getLogger(FlowVelocityExporter.class); - - - public static final String CSV_KM = - "export.flow_velocity.csv.header.km"; - - public static final String CSV_V_TOTAL = - "export.flow_velocity.csv.header.v_total"; + private static final Logger log = Logger.getLogger(FlowVelocityExporter.class); - public static final String CSV_V_MAIN = - "export.flow_velocity.csv.header.v_main"; - - public static final String CSV_TAU_MAIN = - "export.flow_velocity.csv.header.tau_main"; + public static final String CSV_KM = "export.flow_velocity.csv.header.km"; - public static final String CSV_Q = - "export.flow_velocity.csv.header.q"; + public static final String CSV_V_TOTAL = "export.flow_velocity.csv.header.v_total"; - public static final String CSV_LOCATIONS = - "export.flow_velocity.csv.header.locations"; + public static final String CSV_V_MAIN = "export.flow_velocity.csv.header.v_main"; + public static final String CSV_TAU_MAIN = "export.flow_velocity.csv.header.tau_main"; + + public static final String CSV_Q = "common.export.csv.header.q"; + + public static final String CSV_LOCATIONS = "export.flow_velocity.csv.header.locations"; protected List data; public FlowVelocityExporter() { - data = new ArrayList(); + this.data = new ArrayList<>(); } @Override @@ -65,76 +54,56 @@ if (d instanceof FlowVelocityData[]) { log.debug("Add new data of type FlowVelocityData"); - data.add((FlowVelocityData[]) d); + this.data.add((FlowVelocityData[]) d); } } } - @Override - protected void writeCSVData(CSVWriter writer) { + protected void writeCSVData(final CSVWriter writer) { log.info("FlowVelocityExporter.writeCSVData"); - log.debug("CSV gets " + data.size() + " FlowVelocityData objects."); + log.debug("CSV gets " + this.data.size() + " FlowVelocityData objects."); writeCSVHeader(writer); - for (FlowVelocityData[] d: data) { + for (final FlowVelocityData[] d : this.data) { data2CSV(writer, d); } } - - protected void writeCSVHeader(CSVWriter writer) { - writer.writeNext(new String[] { - msg(CSV_KM, CSV_KM), - msg(CSV_V_MAIN, CSV_V_MAIN), - msg(CSV_V_TOTAL, CSV_V_TOTAL), - msg(CSV_TAU_MAIN, CSV_TAU_MAIN), - msg(CSV_Q, CSV_Q), - msg(CSV_LOCATIONS, CSV_LOCATIONS) - }); + protected void writeCSVHeader(final CSVWriter writer) { + writer.writeNext(new String[] { msg(CSV_KM, CSV_KM), msg(CSV_V_MAIN, CSV_V_MAIN), msg(CSV_V_TOTAL, CSV_V_TOTAL), msg(CSV_TAU_MAIN, CSV_TAU_MAIN), + msg(CSV_Q, CSV_Q), msg(CSV_LOCATIONS, CSV_LOCATIONS) }); } - - protected void data2CSV(CSVWriter writer, FlowVelocityData[] fData) { + protected void data2CSV(final CSVWriter writer, final FlowVelocityData[] fData) { log.debug("Add next FlowVelocityData to CSV"); - D4EArtifact flys = (D4EArtifact) master; + final D4EArtifact flys = (D4EArtifact) this.master; - for (FlowVelocityData data: fData) { + for (final FlowVelocityData data : fData) { for (int i = 0, n = data.size(); i < n; i++) { - NumberFormat kmF = Formatter.getFlowVelocityKM(context); - NumberFormat valF = Formatter.getFlowVelocityValues(context); - NumberFormat qF = Formatter.getFlowVelocityQ(context); + final NumberFormat kmF = Formatter.getFlowVelocityKM(this.context); + final NumberFormat valF = Formatter.getFlowVelocityValues(this.context); + final NumberFormat qF = Formatter.getFlowVelocityQ(this.context); String vMain = ""; String vTotal = ""; - if (data.getType().equals("main") - || data.getType().equals("main_total") - ) { + if (data.getType().equals("main") || data.getType().equals("main_total")) { vMain = valF.format(data.getVMain(i)); } - if (data.getType().equals("total") - || data.getType().equals("main_total") - ) { + if (data.getType().equals("total") || data.getType().equals("main_total")) { vTotal = valF.format(data.getVTotal(i)); } - writer.writeNext(new String[] { - kmF.format(data.getKM(i)), - vMain, - vTotal, - valF.format(data.getTauMain(i)), - qF.format(data.getQ(i)) + "=" + data.getZone(), - RiverUtils.getLocationDescription(flys, data.getKM(i)), - }); + writer.writeNext(new String[] { kmF.format(data.getKM(i)), vMain, vTotal, valF.format(data.getTauMain(i)), + qF.format(data.getQ(i)) + "=" + data.getZone(), RiverUtils.getLocationDescription(flys, data.getKM(i)), }); } } } - @Override - protected void writePDF(OutputStream out) { + protected void writePDF(final OutputStream out) { log.error("TODO: Implement FlowVelocityExporter.writePDF"); } } diff -r 7c7f73e5e01e -r 740d65e4aa14 artifacts/src/main/java/org/dive4elements/river/exports/HistoricalDischargeCurveGenerator.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/HistoricalDischargeCurveGenerator.java Thu Jul 26 11:16:06 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/HistoricalDischargeCurveGenerator.java Thu Jul 26 15:54:20 2018 +0200 @@ -11,64 +11,48 @@ import java.util.Date; import org.apache.log4j.Logger; - import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; import org.dive4elements.artifacts.CallContext; import org.dive4elements.river.artifacts.D4EArtifact; - import org.dive4elements.river.artifacts.access.HistoricalDischargeAccess; - import org.dive4elements.river.artifacts.model.FacetTypes; import org.dive4elements.river.artifacts.model.HistoricalWQTimerange; import org.dive4elements.river.artifacts.model.Timerange; import org.dive4elements.river.artifacts.model.WQTimerange; - import org.dive4elements.river.jfree.StyledTimeSeries; - import org.dive4elements.river.themes.ThemeDocument; import org.dive4elements.river.utils.RiverUtils; - import org.jfree.chart.plot.XYPlot; - import org.jfree.data.general.SeriesException; - import org.jfree.data.time.FixedMillisecond; import org.jfree.data.time.RegularTimePeriod; import org.jfree.data.time.TimeSeries; import org.jfree.data.time.TimeSeriesCollection; - /** * @author Ingo Weinzierl */ -public class HistoricalDischargeCurveGenerator extends TimeseriesChartGenerator - implements FacetTypes { - - private static Logger log = Logger - .getLogger(HistoricalDischargeCurveGenerator.class); - - public static final String I18N_CHART_TITLE = - "chart.historical.discharge.title"; +public class HistoricalDischargeCurveGenerator extends TimeseriesChartGenerator implements FacetTypes { - public static final String I18N_CHART_SUBTITLE = - "chart.historical.discharge.subtitle"; + private static Logger log = Logger.getLogger(HistoricalDischargeCurveGenerator.class); - public static final String I18N_XAXIS_LABEL = - "chart.historical.discharge.xaxis.label"; + public static final String I18N_CHART_TITLE = "chart.historical.discharge.title"; - public static final String I18N_YAXIS_LABEL = - "chart.historical.discharge.yaxis.label"; + public static final String I18N_CHART_SUBTITLE = "chart.historical.discharge.subtitle"; - public static final String I18N_YAXIS_SECOND_LABEL = - "chart.historical.discharge.yaxis.second.label"; + public static final String I18N_XAXIS_LABEL = "chart.historical.discharge.xaxis.label"; + + public static final String I18N_YAXIS_LABEL = "chart.historical.discharge.yaxis.label"; + + public static final String I18N_YAXIS_SECOND_LABEL = "common.export.csv.header.q"; public static enum YAXIS { W(0), Q(1); protected int idx; - private YAXIS(int c) { - idx = c; + private YAXIS(final int c) { + this.idx = c; } } @@ -82,8 +66,8 @@ } @Override - public String getId(int idx) { - YAXIS[] yaxes = YAXIS.values(); + public String getId(final int idx) { + final YAXIS[] yaxes = YAXIS.values(); return yaxes[idx].toString(); } }; @@ -96,12 +80,10 @@ @Override protected String getDefaultChartSubtitle(final CallContext context) { - D4EArtifact flys = getArtifact(); - Timerange evalTime = new HistoricalDischargeAccess(flys) - .getEvaluationTimerange(); + final D4EArtifact flys = getArtifact(); + final Timerange evalTime = new HistoricalDischargeAccess(flys).getEvaluationTimerange(); - Object[] args = new Object[] { RiverUtils.getReferenceGaugeName(flys), - evalTime.getStart(), evalTime.getEnd() }; + final Object[] args = new Object[] { RiverUtils.getReferenceGaugeName(flys), evalTime.getStart(), evalTime.getEnd() }; return msg(I18N_CHART_SUBTITLE, "", args); } @@ -112,119 +94,93 @@ } @Override - protected String getDefaultYAxisLabel(int pos) { + protected String getDefaultYAxisLabel(final int pos) { if (pos == 0) { return msg(I18N_YAXIS_LABEL, I18N_YAXIS_LABEL); - } - else if (pos == 1) { + } else if (pos == 1) { return msg(I18N_YAXIS_SECOND_LABEL, I18N_YAXIS_SECOND_LABEL); - } - else { + } else { return "NO TITLE FOR Y AXIS: " + pos; } } @Override - protected void adjustPlot(XYPlot plot) { + protected void adjustPlot(final XYPlot plot) { super.adjustPlot(plot); plot.setRangeZeroBaselineVisible(true); } @Override - public void doOut(ArtifactAndFacet artifactFacet, ThemeDocument theme, - boolean visible) { - String name = artifactFacet.getFacetName(); + public void doOut(final ArtifactAndFacet artifactFacet, final ThemeDocument theme, final boolean visible) { + final String name = artifactFacet.getFacetName(); log.debug("HistoricalDischargeCurveGenerator.doOut: " + name); - log.debug("Theme description is: " - + artifactFacet.getFacetDescription()); + log.debug("Theme description is: " + artifactFacet.getFacetDescription()); final CallContext context = getContext(); - + if (name.equals(HISTORICAL_DISCHARGE_Q)) { - doHistoricalDischargeOutQ( - (D4EArtifact) artifactFacet.getArtifact(), - artifactFacet.getData(context), - artifactFacet.getFacetDescription(), theme, visible); - } - else if (name.equals(HISTORICAL_DISCHARGE_W)) { - doHistoricalDischargeOutW( - (D4EArtifact) artifactFacet.getArtifact(), - artifactFacet.getData(context), - artifactFacet.getFacetDescription(), theme, visible); - } - else if (name.equals(HISTORICAL_DISCHARGE_Q_DIFF)) { - doHistoricalDischargeDifferenceOutQ( - (D4EArtifact) artifactFacet.getArtifact(), - artifactFacet.getData(context), - artifactFacet.getFacetDescription(), theme, visible); - } - else if (name.equals(HISTORICAL_DISCHARGE_W_DIFF)) { - doHistoricalDischargeDifferenceOutW( - (D4EArtifact) artifactFacet.getArtifact(), - artifactFacet.getData(context), - artifactFacet.getFacetDescription(), theme, visible); - } - else if (FacetTypes.IS.MANUALPOINTS(name)) { - HistoricalDischargeAccess.EvaluationMode mode = - new HistoricalDischargeAccess( - (D4EArtifact)getMaster()).getEvaluationMode(); - int axis = mode == HistoricalDischargeAccess.EvaluationMode.W - ? YAXIS.Q.idx - : YAXIS.W.idx; + doHistoricalDischargeOutQ((D4EArtifact) artifactFacet.getArtifact(), artifactFacet.getData(context), artifactFacet.getFacetDescription(), theme, + visible); + } else if (name.equals(HISTORICAL_DISCHARGE_W)) { + doHistoricalDischargeOutW((D4EArtifact) artifactFacet.getArtifact(), artifactFacet.getData(context), artifactFacet.getFacetDescription(), theme, + visible); + } else if (name.equals(HISTORICAL_DISCHARGE_Q_DIFF)) { + doHistoricalDischargeDifferenceOutQ((D4EArtifact) artifactFacet.getArtifact(), artifactFacet.getData(context), artifactFacet.getFacetDescription(), + theme, visible); + } else if (name.equals(HISTORICAL_DISCHARGE_W_DIFF)) { + doHistoricalDischargeDifferenceOutW((D4EArtifact) artifactFacet.getArtifact(), artifactFacet.getData(context), artifactFacet.getFacetDescription(), + theme, visible); + } else if (FacetTypes.IS.MANUALPOINTS(name)) { + final HistoricalDischargeAccess.EvaluationMode mode = new HistoricalDischargeAccess((D4EArtifact) getMaster()).getEvaluationMode(); + final int axis = mode == HistoricalDischargeAccess.EvaluationMode.W ? YAXIS.Q.idx : YAXIS.W.idx; - doPoints(artifactFacet.getData(context), artifactFacet, theme, - visible, axis); - } - else { + doPoints(artifactFacet.getData(context), artifactFacet, theme, visible, axis); + } else { log.warn("doOut(): unknown facet name: " + name); return; } } - protected void doHistoricalDischargeOutQ(D4EArtifact artifact, - Object data, String desc, ThemeDocument theme, boolean visible) { + protected void doHistoricalDischargeOutQ(final D4EArtifact artifact, final Object data, final String desc, final ThemeDocument theme, + final boolean visible) { log.debug("doHistoricalDischargeOut(): description = " + desc); - WQTimerange wqt = (WQTimerange) data; + final WQTimerange wqt = (WQTimerange) data; - TimeSeriesCollection tsc = newTimeSeriesCollection(wqt.getTimeranges(), - wqt.getQs(), theme, desc); + final TimeSeriesCollection tsc = newTimeSeriesCollection(wqt.getTimeranges(), wqt.getQs(), theme, desc); addAxisDataset(tsc, YAXIS.Q.idx, visible); } - protected void doHistoricalDischargeOutW(D4EArtifact artifact, - Object data, String desc, ThemeDocument theme, boolean visible) { + protected void doHistoricalDischargeOutW(final D4EArtifact artifact, final Object data, final String desc, final ThemeDocument theme, + final boolean visible) { log.debug("doHistoricalDischargeOut(): description = " + desc); - WQTimerange wqt = (WQTimerange) data; + final WQTimerange wqt = (WQTimerange) data; - TimeSeriesCollection tsc = newTimeSeriesCollection(wqt.getTimeranges(), - wqt.getWs(), theme, desc); + final TimeSeriesCollection tsc = newTimeSeriesCollection(wqt.getTimeranges(), wqt.getWs(), theme, desc); addAxisDataset(tsc, YAXIS.W.idx, visible); } - protected void doHistoricalDischargeDifferenceOutQ(D4EArtifact artifact, - Object data, String desc, ThemeDocument theme, boolean visible) { + protected void doHistoricalDischargeDifferenceOutQ(final D4EArtifact artifact, final Object data, final String desc, final ThemeDocument theme, + final boolean visible) { log.debug("doHistoricalDischargeDifferenceOut: desc = " + desc); - HistoricalWQTimerange wqt = (HistoricalWQTimerange) data; + final HistoricalWQTimerange wqt = (HistoricalWQTimerange) data; - TimeSeriesCollection tsc = newTimeSeriesCollection(wqt.getTimeranges(), - wqt.getDiffs(), theme, desc); + final TimeSeriesCollection tsc = newTimeSeriesCollection(wqt.getTimeranges(), wqt.getDiffs(), theme, desc); addAxisDataset(tsc, YAXIS.Q.idx, visible); } - protected void doHistoricalDischargeDifferenceOutW(D4EArtifact artifact, - Object data, String desc, ThemeDocument theme, boolean visible) { + protected void doHistoricalDischargeDifferenceOutW(final D4EArtifact artifact, final Object data, final String desc, final ThemeDocument theme, + final boolean visible) { log.debug("doHistoricalDischargeDifferenceOut: desc = " + desc); - HistoricalWQTimerange wqt = (HistoricalWQTimerange) data; + final HistoricalWQTimerange wqt = (HistoricalWQTimerange) data; - TimeSeriesCollection tsc = newTimeSeriesCollection(wqt.getTimeranges(), - wqt.getDiffs(), theme, desc); + final TimeSeriesCollection tsc = newTimeSeriesCollection(wqt.getTimeranges(), wqt.getDiffs(), theme, desc); addAxisDataset(tsc, YAXIS.W.idx, visible); } @@ -235,19 +191,14 @@ * provided by wqt. This has the effect, that the line in the chart * looks like a "step chart". */ - protected TimeSeriesCollection newTimeSeriesCollection( - Timerange[] timeranges, - double[] values, - ThemeDocument theme, - String desc - ) { + protected TimeSeriesCollection newTimeSeriesCollection(final Timerange[] timeranges, final double[] values, final ThemeDocument theme, final String desc) { log.debug("Create new TimeSeriesCollection for: " + desc); - TimeSeriesCollection tsc = new TimeSeriesCollection(); - TimeSeries series = new StyledTimeSeries(desc, theme); + final TimeSeriesCollection tsc = new TimeSeriesCollection(); + final TimeSeries series = new StyledTimeSeries(desc, theme); for (int i = 0, n = timeranges.length; i < n; i++) { - RegularTimePeriod[] rtp = newRegularTimePeriod(timeranges[i]); + final RegularTimePeriod[] rtp = newRegularTimePeriod(timeranges[i]); try { if (Double.isNaN(values[i])) { @@ -264,7 +215,7 @@ log.debug(" Value: " + values[i]); } } - catch (SeriesException se) { + catch (final SeriesException se) { log.warn("Error while adding TimePeriod: " + se); } } @@ -283,13 +234,11 @@ * * @return an array with two FixedMillisecond periods [start, end]. */ - protected RegularTimePeriod[] newRegularTimePeriod(Timerange timerange) { - Date start = new Date(timerange.getStart()); - Date end = new Date(timerange.getEnd() - 1000 * 60 * 60 * 24); + protected RegularTimePeriod[] newRegularTimePeriod(final Timerange timerange) { + final Date start = new Date(timerange.getStart()); + final Date end = new Date(timerange.getEnd() - 1000 * 60 * 60 * 24); - return new RegularTimePeriod[] { - new FixedMillisecond(start), - new FixedMillisecond(end) }; + return new RegularTimePeriod[] { new FixedMillisecond(start), new FixedMillisecond(end) }; } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : diff -r 7c7f73e5e01e -r 740d65e4aa14 artifacts/src/main/java/org/dive4elements/river/exports/LongitudinalSectionGenerator.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/LongitudinalSectionGenerator.java Thu Jul 26 11:16:06 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/LongitudinalSectionGenerator.java Thu Jul 26 15:54:20 2018 +0200 @@ -8,6 +8,7 @@ package org.dive4elements.river.exports; +import org.apache.log4j.Logger; import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; import org.dive4elements.artifactdatabase.state.Facet; import org.dive4elements.artifacts.CallContext; @@ -17,90 +18,72 @@ import org.dive4elements.river.artifacts.model.FacetTypes; import org.dive4elements.river.artifacts.model.WKms; import org.dive4elements.river.artifacts.model.WQKms; - -import org.dive4elements.river.exports.process.Processor; +import org.dive4elements.river.exports.process.AnnotationProcessor; import org.dive4elements.river.exports.process.BedDiffHeightYearProcessor; import org.dive4elements.river.exports.process.BedDiffYearProcessor; +import org.dive4elements.river.exports.process.Processor; import org.dive4elements.river.exports.process.QOutProcessor; import org.dive4elements.river.exports.process.WOutProcessor; -import org.dive4elements.river.exports.process.AnnotationProcessor; - import org.dive4elements.river.jfree.StyledAreaSeriesCollection; import org.dive4elements.river.jfree.StyledXYSeries; import org.dive4elements.river.themes.ThemeDocument; import org.dive4elements.river.utils.RiverUtils; -import org.apache.log4j.Logger; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.plot.XYPlot; import org.jfree.data.xy.XYSeries; - /** * An OutGenerator that generates longitudinal section curves. * * @author Ingo Weinzierl */ -public class LongitudinalSectionGenerator -extends XYChartGenerator -implements FacetTypes -{ +public class LongitudinalSectionGenerator extends XYChartGenerator implements FacetTypes { public enum YAXIS { - W(0), - D(1), - Q(2); + W(0), D(1), Q(2); protected int idx; - private YAXIS(int c) { - idx = c; + + private YAXIS(final int c) { + this.idx = c; } } /** The log that is used in this generator. */ - private static Logger log = - Logger.getLogger(LongitudinalSectionGenerator.class); + private static Logger log = Logger.getLogger(LongitudinalSectionGenerator.class); /** Key to look up internationalized String for annotations label. */ - public static final String I18N_ANNOTATIONS_LABEL = - "chart.longitudinal.annotations.label"; + public static final String I18N_ANNOTATIONS_LABEL = "chart.longitudinal.annotations.label"; /** * Key to look up internationalized String for LongitudinalSection diagrams * titles. */ - public static final String I18N_CHART_TITLE = - "chart.longitudinal.section.title"; + public static final String I18N_CHART_TITLE = "chart.longitudinal.section.title"; /** * Key to look up internationalized String for LongitudinalSection diagrams * subtitles. */ - public static final String I18N_CHART_SUBTITLE = - "chart.longitudinal.section.subtitle"; + public static final String I18N_CHART_SUBTITLE = "chart.longitudinal.section.subtitle"; /** * Key to look up internationalized String for LongitudinalSection diagrams * short subtitles. */ - public static final String I18N_CHART_SHORT_SUBTITLE = - "chart.longitudinal.section.shortsubtitle"; - - public static final String I18N_XAXIS_LABEL = - "chart.longitudinal.section.xaxis.label"; + public static final String I18N_CHART_SHORT_SUBTITLE = "chart.longitudinal.section.shortsubtitle"; - public static final String I18N_YAXIS_LABEL = - "chart.longitudinal.section.yaxis.label"; + public static final String I18N_XAXIS_LABEL = "chart.longitudinal.section.xaxis.label"; - public static final String I18N_2YAXIS_LABEL = - "chart.longitudinal.section.yaxis.second.label"; + public static final String I18N_YAXIS_LABEL = "chart.longitudinal.section.yaxis.label"; - public static final String I18N_CHART_TITLE_DEFAULT = - "W-L\u00e4ngsschnitt"; - public static final String I18N_XAXIS_LABEL_DEFAULT = "km"; - public static final String I18N_YAXIS_LABEL_DEFAULT = "W [NN + m]"; + public static final String I18N_2YAXIS_LABEL = "common.export.csv.header.q"; + + public static final String I18N_CHART_TITLE_DEFAULT = "W-L\u00e4ngsschnitt"; + public static final String I18N_XAXIS_LABEL_DEFAULT = "km"; + public static final String I18N_YAXIS_LABEL_DEFAULT = "W [NN + m]"; public static final String I18N_2YAXIS_LABEL_DEFAULT = "Q [m\u00b3/s]"; - public final static String I18N_WDIFF_YAXIS_LABEL = - "chart.w_differences.yaxis.label"; + public final static String I18N_WDIFF_YAXIS_LABEL = "chart.w_differences.yaxis.label"; public final static String I18N_WDIFF_YAXIS_LABEL_DEFAULT = "m"; @@ -108,7 +91,6 @@ super(); } - @Override protected YAxisWalker getYAxisWalker() { return new YAxisWalker() { @@ -118,14 +100,13 @@ } @Override - public String getId(int idx) { - YAXIS[] yaxes = YAXIS.values(); + public String getId(final int idx) { + final YAXIS[] yaxes = YAXIS.values(); return yaxes[idx].toString(); } }; } - /** * Return left most data points x value (on first axis). * Overridden because axis could be inverted. @@ -133,12 +114,11 @@ @Override protected double getLeftX() { if (isInverted()) { - return (Double)getXBounds(0).getUpper(); + return (Double) getXBounds(0).getUpper(); } - return (Double)getXBounds(0).getLower(); + return (Double) getXBounds(0).getLower(); } - /** * Return right most data points x value (on first axis). * Overridden because axis could be inverted. @@ -146,12 +126,11 @@ @Override protected double getRightX() { if (isInverted()) { - return (Double)getXBounds(0).getLower(); + return (Double) getXBounds(0).getLower(); } - return (Double)getXBounds(0).getUpper(); + return (Double) getXBounds(0).getUpper(); } - /** * Returns the default title for this chart. * @@ -169,109 +148,91 @@ */ @Override protected String getDefaultChartSubtitle(final CallContext context) { - double[] dist = getRange(); + final double[] dist = getRange(); Object[] args = null; if (dist == null) { - args = new Object[] {getRiverName()}; + args = new Object[] { getRiverName() }; return msg(getChartShortSubtitleKey(), "", args); } - args = new Object[] { - getRiverName(), - dist[0], - dist[1] - }; + args = new Object[] { getRiverName(), dist[0], dist[1] }; return msg(getChartSubtitleKey(), "", args); } - /** * Gets key to look up internationalized String for the charts subtitle. + * * @return key to look up translated subtitle. */ protected String getChartSubtitleKey() { return I18N_CHART_SUBTITLE; } - /** * Gets key to look up internationalized String for the charts short * subtitle. + * * @return key to look up translated subtitle. */ protected String getChartShortSubtitleKey() { return I18N_CHART_SHORT_SUBTITLE; } - /** * Get internationalized label for the x axis. */ @Override - protected String getDefaultXAxisLabel(CallContext context) { - D4EArtifact flys = getArtifact(); + protected String getDefaultXAxisLabel(final CallContext context) { + final D4EArtifact flys = getArtifact(); - return msg( - I18N_XAXIS_LABEL, - I18N_XAXIS_LABEL_DEFAULT, - new Object[] { RiverUtils.getRiver(flys).getName() }); + return msg(I18N_XAXIS_LABEL, I18N_XAXIS_LABEL_DEFAULT, new Object[] { RiverUtils.getRiver(flys).getName() }); } - @Override - protected String getDefaultYAxisLabel(int index) { + protected String getDefaultYAxisLabel(final int index) { String label = "default"; if (index == YAXIS.W.idx) { label = getWAxisLabel(); - } - else if (index == YAXIS.Q.idx) { + } else if (index == YAXIS.Q.idx) { label = msg(getQAxisLabelKey(), getQAxisDefaultLabel()); - } - else if (index == YAXIS.D.idx) { - label = msg( - I18N_WDIFF_YAXIS_LABEL, I18N_WDIFF_YAXIS_LABEL_DEFAULT); + } else if (index == YAXIS.D.idx) { + label = msg(I18N_WDIFF_YAXIS_LABEL, I18N_WDIFF_YAXIS_LABEL_DEFAULT); } return label; } - /** * Get internationalized label for the y axis. */ protected String getWAxisLabel() { - D4EArtifact flys = getArtifact(); - - String unit = RiverUtils.getRiver(flys).getWstUnit().getName(); + final D4EArtifact flys = getArtifact(); - return msg( - I18N_YAXIS_LABEL, - I18N_YAXIS_LABEL_DEFAULT, - new Object[] { unit }); + final String unit = RiverUtils.getRiver(flys).getWstUnit().getName(); + + return msg(I18N_YAXIS_LABEL, I18N_YAXIS_LABEL_DEFAULT, new Object[] { unit }); } - /** * Create Axis for given index. + * * @return axis with according internationalized label. */ @Override - protected NumberAxis createYAxis(int index) { - NumberAxis axis = super.createYAxis(index); + protected NumberAxis createYAxis(final int index) { + final NumberAxis axis = super.createYAxis(index); // "Q" Axis shall include 0. if (index == YAXIS.Q.idx) { axis.setAutoRangeIncludesZero(true); - } - else { + } else { axis.setAutoRangeIncludesZero(false); } return axis; } - /** * Get default value for the second Y-Axis' label (if no translation was * found). @@ -280,7 +241,6 @@ return I18N_2YAXIS_LABEL_DEFAULT; } - /** * Get key for internationalization of the second Y-Axis' label. */ @@ -288,44 +248,41 @@ return I18N_2YAXIS_LABEL; } - /** * Trigger inversion. */ @Override - protected void adjustAxes(XYPlot plot) { + protected void adjustAxes(final XYPlot plot) { super.adjustAxes(plot); invertXAxis(plot.getDomainAxis()); } - /** * This method inverts the x-axis based on the kilometer information of the * selected river. If the head of the river is at kilometer 0, the axis is * not inverted, otherwise it is. * - * @param xaxis The domain axis. + * @param xaxis + * The domain axis. */ - protected void invertXAxis(ValueAxis xaxis) { + protected void invertXAxis(final ValueAxis xaxis) { if (isInverted()) { log.debug("X-Axis.setInverted(true)"); xaxis.setInverted(true); } } - /** * Produce output. - * @param artifactAndFacet current facet and artifact. - * @param attr theme for facet + * + * @param artifactAndFacet + * current facet and artifact. + * @param attr + * theme for facet */ @Override - public void doOut( - ArtifactAndFacet artifactAndFacet, - ThemeDocument attr, - boolean visible - ) { - String name = artifactAndFacet.getFacetName(); + public void doOut(final ArtifactAndFacet artifactAndFacet, final ThemeDocument attr, final boolean visible) { + final String name = artifactAndFacet.getFacetName(); log.debug("LongitudinalSectionGenerator.doOut: " + name); @@ -334,63 +291,38 @@ return; } - Facet facet = artifactAndFacet.getFacet(); + final Facet facet = artifactAndFacet.getFacet(); if (facet == null) { return; } - CallContext context = getContext(); - - Processor wProcessor = new WOutProcessor(); - Processor qProcessor = new QOutProcessor(); - Processor bdyProcessor = new BedDiffYearProcessor(); - Processor bdhyProcessor = new BedDiffHeightYearProcessor(); - Processor annotationProcessor = new AnnotationProcessor(); + final CallContext context = getContext(); + + final Processor wProcessor = new WOutProcessor(); + final Processor qProcessor = new QOutProcessor(); + final Processor bdyProcessor = new BedDiffYearProcessor(); + final Processor bdhyProcessor = new BedDiffHeightYearProcessor(); + final Processor annotationProcessor = new AnnotationProcessor(); if (wProcessor.canHandle(name)) { - wProcessor.doOut( - this, artifactAndFacet, attr, visible, YAXIS.W.idx); + wProcessor.doOut(this, artifactAndFacet, attr, visible, YAXIS.W.idx); } if (qProcessor.canHandle(name)) { - qProcessor.doOut( - this, artifactAndFacet, attr, visible, YAXIS.Q.idx); - } - else if (bdyProcessor.canHandle(name)) { - bdyProcessor.doOut( - this, artifactAndFacet, attr, visible, YAXIS.W.idx); - } - else if (bdhyProcessor.canHandle(name)) { - bdhyProcessor.doOut( - this, artifactAndFacet, attr, visible, YAXIS.W.idx); - } - else if (annotationProcessor.canHandle(name)) { - annotationProcessor.doOut( - this, artifactAndFacet, attr, visible, 0); - } - else if (name.equals(W_DIFFERENCES)) { - doWDifferencesOut( - (WKms) artifactAndFacet.getData(context), - artifactAndFacet, - attr, - visible); - } - else if (FacetTypes.IS.AREA(name)) { - doArea( - artifactAndFacet.getData(context), - artifactAndFacet, - attr, - visible); - } - else if (FacetTypes.IS.MANUALPOINTS(name)) { - doPoints( - artifactAndFacet.getData(context), - artifactAndFacet, - attr, - visible, - YAXIS.W.idx); - } - else { + qProcessor.doOut(this, artifactAndFacet, attr, visible, YAXIS.Q.idx); + } else if (bdyProcessor.canHandle(name)) { + bdyProcessor.doOut(this, artifactAndFacet, attr, visible, YAXIS.W.idx); + } else if (bdhyProcessor.canHandle(name)) { + bdhyProcessor.doOut(this, artifactAndFacet, attr, visible, YAXIS.W.idx); + } else if (annotationProcessor.canHandle(name)) { + annotationProcessor.doOut(this, artifactAndFacet, attr, visible, 0); + } else if (name.equals(W_DIFFERENCES)) { + doWDifferencesOut((WKms) artifactAndFacet.getData(context), artifactAndFacet, attr, visible); + } else if (FacetTypes.IS.AREA(name)) { + doArea(artifactAndFacet.getData(context), artifactAndFacet, attr, visible); + } else if (FacetTypes.IS.MANUALPOINTS(name)) { + doPoints(artifactAndFacet.getData(context), artifactAndFacet, attr, visible, YAXIS.W.idx); + } else { log.warn("Unknown facet name: " + name); return; } @@ -399,20 +331,14 @@ /** * Add items to dataseries which describes the differences. */ - protected void doWDifferencesOut( - WKms wkms, - ArtifactAndFacet aandf, - ThemeDocument theme, - boolean visible - ) { + protected void doWDifferencesOut(final WKms wkms, final ArtifactAndFacet aandf, final ThemeDocument theme, final boolean visible) { log.debug("WDifferencesCurveGenerator.doWDifferencesOut"); if (wkms == null) { log.warn("No data to add to WDifferencesChart."); return; - } + } - XYSeries series = - new StyledXYSeries(aandf.getFacetDescription(), theme); + final XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), theme); if (log.isDebugEnabled()) { if (wkms.size() > 0) { @@ -428,83 +354,65 @@ addAxisSeries(series, YAXIS.D.idx, visible); } - /** * Get name of series (displayed in legend). + * * @return name of the series. */ - protected String getSeriesName(WQKms wqkms, String mode) { - String name = wqkms.getName(); - String prefix = name != null && name.indexOf(mode) >= 0 ? null : mode; + protected String getSeriesName(final WQKms wqkms, final String mode) { + final String name = wqkms.getName(); + final String prefix = name != null && name.indexOf(mode) >= 0 ? null : mode; - return prefix != null && prefix.length() > 0 - ? prefix + "(" + name +")" - : name; + return prefix != null && prefix.length() > 0 ? prefix + "(" + name + ")" : name; } - /** Look up the axis identifier for a given facet type. */ - public int axisIdxForFacet(String facetName) { + public int axisIdxForFacet(final String facetName) { if (FacetTypes.IS.W(facetName)) { return YAXIS.W.idx; - } - else if (FacetTypes.IS.Q(facetName)) { + } else if (FacetTypes.IS.Q(facetName)) { return YAXIS.Q.idx; - } - else { + } else { log.warn("Could not find axis for facet " + facetName); return YAXIS.W.idx; } } - /** * Do Area out. - * @param theme styling information. - * @param visible whether or not visible. + * + * @param theme + * styling information. + * @param visible + * whether or not visible. */ - protected void doArea( - Object o, - ArtifactAndFacet aandf, - ThemeDocument theme, - boolean visible - ) { + protected void doArea(final Object o, final ArtifactAndFacet aandf, final ThemeDocument theme, final boolean visible) { log.debug("LongitudinalSectionGenerator.doArea"); - StyledAreaSeriesCollection area = new StyledAreaSeriesCollection(theme); + final StyledAreaSeriesCollection area = new StyledAreaSeriesCollection(theme); - String seriesName = aandf.getFacetDescription(); + final String seriesName = aandf.getFacetDescription(); - AreaFacet.Data data = (AreaFacet.Data) o; + final AreaFacet.Data data = (AreaFacet.Data) o; - XYSeries up = null; + XYSeries up = null; XYSeries down = null; if (data.getUpperData() != null) { up = new StyledXYSeries(seriesName, false, theme); if (data.getUpperData() instanceof WQKms) { if (FacetTypes.IS.Q(data.getUpperFacetName())) { - StyledSeriesBuilder.addPointsKmQ( - up, (WQKms)data.getUpperData()); - } - else { - StyledSeriesBuilder.addPoints( - up, (WKms) data.getUpperData()); + StyledSeriesBuilder.addPointsKmQ(up, (WQKms) data.getUpperData()); + } else { + StyledSeriesBuilder.addPoints(up, (WKms) data.getUpperData()); } - } - else if (data.getUpperData() instanceof double[][]) { - StyledSeriesBuilder.addPoints( - up, (double [][]) data.getUpperData(), false); - } - else if (data.getUpperData() instanceof WKms) { + } else if (data.getUpperData() instanceof double[][]) { + StyledSeriesBuilder.addPoints(up, (double[][]) data.getUpperData(), false); + } else if (data.getUpperData() instanceof WKms) { StyledSeriesBuilder.addPoints(up, (WKms) data.getUpperData()); - } - else if (data.getUpperData() instanceof Lines.LineData) { - StyledSeriesBuilder.addPoints( - up, ((Lines.LineData) data.getUpperData()).points, false); - } - else { - log.error("Do not know how to deal with (up) area info from: " - + data.getUpperData()); + } else if (data.getUpperData() instanceof Lines.LineData) { + StyledSeriesBuilder.addPoints(up, ((Lines.LineData) data.getUpperData()).points, false); + } else { + log.error("Do not know how to deal with (up) area info from: " + data.getUpperData()); } } @@ -517,32 +425,18 @@ down = new StyledXYSeries(seriesName + " ", false, theme); if (data.getLowerData() instanceof WQKms) { if (FacetTypes.IS.Q(data.getLowerFacetName())) { - StyledSeriesBuilder.addPointsKmQ( - down, (WQKms) data.getLowerData()); - } - else { - StyledSeriesBuilder.addPoints( - down, (WQKms) data.getLowerData()); + StyledSeriesBuilder.addPointsKmQ(down, (WQKms) data.getLowerData()); + } else { + StyledSeriesBuilder.addPoints(down, (WQKms) data.getLowerData()); } - } - else if (data.getLowerData() instanceof double[][]) { - StyledSeriesBuilder.addPoints( - down, (double[][]) data.getLowerData(), false); - } - else if (data.getLowerData() instanceof WKms) { - StyledSeriesBuilder.addPoints( - down, (WKms) data.getLowerData()); - } - else if (data.getLowerData() instanceof Lines.LineData) { - StyledSeriesBuilder.addPoints( - down, - ((Lines.LineData) data.getLowerData()).points, - false); - } - else { - log.error( - "Do not know how to deal with (down) area info from: " - + data.getLowerData()); + } else if (data.getLowerData() instanceof double[][]) { + StyledSeriesBuilder.addPoints(down, (double[][]) data.getLowerData(), false); + } else if (data.getLowerData() instanceof WKms) { + StyledSeriesBuilder.addPoints(down, (WKms) data.getLowerData()); + } else if (data.getLowerData() instanceof Lines.LineData) { + StyledSeriesBuilder.addPoints(down, ((Lines.LineData) data.getLowerData()).points, false); + } else { + log.error("Do not know how to deal with (down) area info from: " + data.getLowerData()); } } @@ -551,26 +445,21 @@ down.setKey(seriesName); area.addSeries(down); area.addSeries(StyledSeriesBuilder.createGroundAtInfinity(down)); - } - else if (up != null && down == null) { + } else if (up != null && down == null) { area.setMode(StyledAreaSeriesCollection.FILL_MODE.UNDER); area.addSeries(up); area.addSeries(StyledSeriesBuilder.createGroundAtInfinity(up)); - } - else if (up != null && down != null) { + } else if (up != null && down != null) { if (data.doPaintBetween()) { area.setMode(StyledAreaSeriesCollection.FILL_MODE.BETWEEN); - } - else { + } else { area.setMode(StyledAreaSeriesCollection.FILL_MODE.ABOVE); } area.addSeries(up); area.addSeries(down); } // Add area to the respective axis. - String facetAxisName = data.getUpperFacetName() == null - ? data.getLowerFacetName() - : data.getUpperFacetName(); + final String facetAxisName = data.getUpperFacetName() == null ? data.getLowerFacetName() : data.getUpperFacetName(); addAreaSeries(area, axisIdxForFacet(facetAxisName), visible); } } diff -r 7c7f73e5e01e -r 740d65e4aa14 artifacts/src/main/java/org/dive4elements/river/exports/WaterlevelExporter.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/WaterlevelExporter.java Thu Jul 26 11:16:06 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/WaterlevelExporter.java Thu Jul 26 15:54:20 2018 +0200 @@ -73,7 +73,7 @@ public static final String CSV_W_HEADER = "export.waterlevel.csv.header.w"; - public static final String CSV_Q_HEADER = "export.waterlevel.csv.header.q"; + public static final String CSV_Q_HEADER = "common.export.csv.header.q"; /** * @deprecated Use {@link WaterlevelDescriptionBuilder} instead. diff -r 7c7f73e5e01e -r 740d65e4aa14 artifacts/src/main/java/org/dive4elements/river/exports/process/QOutProcessor.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/process/QOutProcessor.java Thu Jul 26 11:16:06 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/QOutProcessor.java Thu Jul 26 15:54:20 2018 +0200 @@ -9,20 +9,18 @@ package org.dive4elements.river.exports.process; import org.apache.log4j.Logger; -import org.jfree.data.xy.XYSeries; - import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; import org.dive4elements.artifacts.CallContext; import org.dive4elements.river.artifacts.model.FacetTypes; -import org.dive4elements.river.artifacts.model.WQKms; import org.dive4elements.river.artifacts.model.FlowVelocityData; -import org.dive4elements.river.model.FlowVelocityMeasurementValue.FastFlowVelocityMeasurementValue; - +import org.dive4elements.river.artifacts.model.WQKms; +import org.dive4elements.river.exports.DiagramGenerator; import org.dive4elements.river.exports.StyledSeriesBuilder; import org.dive4elements.river.exports.XYChartGenerator; -import org.dive4elements.river.exports.DiagramGenerator; import org.dive4elements.river.jfree.StyledXYSeries; +import org.dive4elements.river.model.FlowVelocityMeasurementValue.FastFlowVelocityMeasurementValue; import org.dive4elements.river.themes.ThemeDocument; +import org.jfree.data.xy.XYSeries; /** * Add data to chart/generator. @@ -31,89 +29,68 @@ */ public class QOutProcessor extends DefaultProcessor { - public static final String I18N_LONGITUDINAL_LABEL = - "chart.longitudinal.section.yaxis.second.label"; + public static final String I18N_LONGITUDINAL_LABEL = "common.export.csv.header.q"; - public static final String - I18N_LONGITUDINAL_LABEL_DEFAULT = "Q [m\u00b3/s]"; + public static final String I18N_LONGITUDINAL_LABEL_DEFAULT = "Q [m\u00b3/s]"; /** Private log. */ - private static final Logger log = - Logger.getLogger(QOutProcessor.class); + private static final Logger log = Logger.getLogger(QOutProcessor.class); @Override - public void doOut( - DiagramGenerator generator, - ArtifactAndFacet bundle, - ThemeDocument theme, - boolean visible) { - CallContext context = generator.getContext(); - Object data = bundle.getData(context); - XYSeries series = new StyledXYSeries( - bundle.getFacetDescription(), theme); - String facetName = bundle.getFacetName(); + public void doOut(final DiagramGenerator generator, final ArtifactAndFacet bundle, final ThemeDocument theme, final boolean visible) { + final CallContext context = generator.getContext(); + final Object data = bundle.getData(context); + final XYSeries series = new StyledXYSeries(bundle.getFacetDescription(), theme); + final String facetName = bundle.getFacetName(); if (facetName.equals(FacetTypes.FLOW_VELOCITY_DISCHARGE)) { if (data instanceof FlowVelocityData) { - FlowVelocityData fData = (FlowVelocityData) data; + final FlowVelocityData fData = (FlowVelocityData) data; StyledSeriesBuilder.addPoints(series, fData.getQPoints(), true); - } - else { - FastFlowVelocityMeasurementValue fData = - (FastFlowVelocityMeasurementValue) data; - double[][] points = new double[][] { - {fData.getStation()},{fData.getQ()}}; + } else { + final FastFlowVelocityMeasurementValue fData = (FastFlowVelocityMeasurementValue) data; + final double[][] points = new double[][] { { fData.getStation() }, { fData.getQ() } }; StyledSeriesBuilder.addPoints(series, points, true); } } else { - WQKms wqkms = (WQKms) data; + final WQKms wqkms = (WQKms) data; StyledSeriesBuilder.addStepPointsKmQ(series, wqkms); } - generator.addAxisSeries(series, axisName, visible); + generator.addAxisSeries(series, this.axisName, visible); } @Override - public void doOut( - XYChartGenerator generator, - ArtifactAndFacet bundle, - ThemeDocument theme, - boolean visible, - int index) - { - CallContext context = generator.getContext(); - WQKms wqkms = (WQKms) bundle.getData(context); + public void doOut(final XYChartGenerator generator, final ArtifactAndFacet bundle, final ThemeDocument theme, final boolean visible, final int index) { + final CallContext context = generator.getContext(); + final WQKms wqkms = (WQKms) bundle.getData(context); - XYSeries series = new StyledXYSeries( - bundle.getFacetDescription(), theme); + final XYSeries series = new StyledXYSeries(bundle.getFacetDescription(), theme); StyledSeriesBuilder.addStepPointsKmQ(series, wqkms); generator.addAxisSeries(series, index, visible); - /* Check if the diagram should be inverted*/ + /* Check if the diagram should be inverted */ generator.setInverted(wqkms.guessRTLData()); } @Override - public String getAxisLabel(DiagramGenerator generator) { - return generator.msg(I18N_LONGITUDINAL_LABEL, - I18N_LONGITUDINAL_LABEL_DEFAULT); + public String getAxisLabel(final DiagramGenerator generator) { + return generator.msg(I18N_LONGITUDINAL_LABEL, I18N_LONGITUDINAL_LABEL_DEFAULT); } /** * Returns true if facettype is q-type. */ @Override - public boolean canHandle(String facetType) { + public boolean canHandle(final String facetType) { if (facetType == null) { return false; } - if (facetType.equals(FacetTypes.STATIC_WQKMS_Q) - || facetType.equals(FacetTypes.LONGITUDINAL_Q) - || facetType.startsWith(FacetTypes.DISCHARGE_LONGITUDINAL_Q) - || facetType.startsWith(FacetTypes.FLOW_VELOCITY_DISCHARGE)) { + if (facetType.equals(FacetTypes.STATIC_WQKMS_Q) || facetType.equals(FacetTypes.LONGITUDINAL_Q) + || facetType.startsWith(FacetTypes.DISCHARGE_LONGITUDINAL_Q) || facetType.startsWith(FacetTypes.FLOW_VELOCITY_DISCHARGE)) { return true; } return false; diff -r 7c7f73e5e01e -r 740d65e4aa14 artifacts/src/main/java/org/dive4elements/river/exports/sq/SQRelationExporter.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/sq/SQRelationExporter.java Thu Jul 26 11:16:06 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/sq/SQRelationExporter.java Thu Jul 26 15:54:20 2018 +0200 @@ -9,47 +9,39 @@ package org.dive4elements.river.exports.sq; import java.io.OutputStream; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.HashMap; -import java.util.Date; -import java.util.Locale; import java.text.DateFormat; import java.text.NumberFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import org.apache.log4j.Logger; +import org.dive4elements.artifacts.CallMeta; +import org.dive4elements.artifacts.common.utils.Config; +import org.dive4elements.river.artifacts.D4EArtifact; +import org.dive4elements.river.artifacts.access.SQRelationAccess; +import org.dive4elements.river.artifacts.model.CalculationResult; +import org.dive4elements.river.artifacts.model.DateRange; +import org.dive4elements.river.artifacts.model.Parameters; +import org.dive4elements.river.artifacts.model.sq.SQ; +import org.dive4elements.river.artifacts.model.sq.SQFractionResult; +import org.dive4elements.river.artifacts.model.sq.SQMeasurementsJRDataSource; +import org.dive4elements.river.artifacts.model.sq.SQRelationJRDataSource; +import org.dive4elements.river.artifacts.model.sq.SQResult; +import org.dive4elements.river.artifacts.resources.Resources; +import org.dive4elements.river.exports.AbstractExporter; +import org.dive4elements.river.utils.Formatter; +import org.dive4elements.river.utils.RiverUtils; + +import au.com.bytecode.opencsv.CSVWriter; +import net.sf.jasperreports.engine.JRException; +import net.sf.jasperreports.engine.JRPrintPage; import net.sf.jasperreports.engine.JasperExportManager; import net.sf.jasperreports.engine.JasperFillManager; import net.sf.jasperreports.engine.JasperPrint; -import net.sf.jasperreports.engine.JRPrintPage; -import net.sf.jasperreports.engine.JRException; - -import au.com.bytecode.opencsv.CSVWriter; - -import org.dive4elements.artifacts.CallMeta; - -import org.dive4elements.river.artifacts.model.CalculationResult; -import org.dive4elements.river.artifacts.model.sq.SQFractionResult; -import org.dive4elements.river.artifacts.model.sq.SQResult; -import org.dive4elements.river.artifacts.model.sq.SQ; -import org.dive4elements.river.artifacts.model.sq.SQRelationJRDataSource; -import org.dive4elements.river.artifacts.model.sq.SQMeasurementsJRDataSource; -import org.dive4elements.river.artifacts.model.Parameters; -import org.dive4elements.river.artifacts.model.DateRange; -import org.dive4elements.river.artifacts.access.SQRelationAccess; - -import org.dive4elements.river.artifacts.resources.Resources; - -import org.dive4elements.river.artifacts.D4EArtifact; - -import org.dive4elements.river.exports.AbstractExporter; - -import org.dive4elements.river.utils.RiverUtils; -import org.dive4elements.river.utils.Formatter; - -import org.dive4elements.artifacts.common.utils.Config; - -import org.apache.log4j.Logger; /** * @author Ingo Weinzierl @@ -57,273 +49,182 @@ public class SQRelationExporter extends AbstractExporter { /** Private log. */ - private static final Logger log = - Logger.getLogger(SQRelationExporter.class); - - public static final String INFO_COEFF_A = - "export.sqrelation.csv.info.coeff.a"; - - public static final String INFO_COEFF_B = - "export.sqrelation.csv.info.coeff.b"; - - public static final String INFO_QMAX = - "export.sqrelation.csv.info.qmax"; - - public static final String INFO_STDERR = - "export.sqrelation.csv.info.stderr"; - - public static final String INFO_R2 = - "export.sqrelation.csv.info.r2"; - - public static final String INFO_NTOT = - "export.sqrelation.csv.info.ntot"; - - public static final String INFO_NOUTL = - "export.sqrelation.csv.info.noutl"; - - public static final String INFO_CFERGUSON = - "export.sqrelation.csv.info.cferguson"; - - public static final String INFO_CDUAN = - "export.sqrelation.csv.info.cduan"; - - public static final String INFO_PARAM_A = - "export.sqrelation.csv.info.param.a"; - - public static final String INFO_PARAM_B = - "export.sqrelation.csv.info.param.b"; - - public static final String INFO_PARAM_C = - "export.sqrelation.csv.info.param.c"; - - public static final String INFO_PARAM_D = - "export.sqrelation.csv.info.param.d"; - - public static final String INFO_PARAM_E = - "export.sqrelation.csv.info.param.e"; - - public static final String INFO_PARAM_F = - "export.sqrelation.csv.info.param.f"; - - public static final String INFO_Q = - "export.sqrelation.csv.info.q"; - - public static final String INFO_S_KG = - "export.sqrelation.csv.info.s_kg"; - - public static final String INFO_DATE = - "export.sqrelation.csv.info.date"; - - public static final String CSV_PARAMETER = - "export.sqrelation.csv.header.parameter"; + private static final Logger log = Logger.getLogger(SQRelationExporter.class); - public static final String CSV_STATION = - "export.sqrelation.csv.header.station"; - - public static final String CSV_KM = - "export.sqrelation.csv.header.km"; - - public static final String CSV_FUNCTION = - "export.sqrelation.csv.header.function"; - - public static final String CSV_GAUGE = - "export.sqrelation.csv.header.gauge"; - - public static final String CSV_COEFF_A = - "export.sqrelation.csv.header.coeff.a"; - - public static final String CSV_COEFF_B = - "export.sqrelation.csv.header.coeff.b"; - - public static final String CSV_COEFF_Q = - "export.sqrelation.csv.header.coeff.q"; - - public static final String CSV_COEFF_R = - "export.sqrelation.csv.header.coeff.r"; - - public static final String CSV_N_TOTAL = - "export.sqrelation.csv.header.n.total"; - - public static final String CSV_N_OUTLIERS = - "export.sqrelation.csv.header.n.outliers"; + public static final String INFO_COEFF_A = "export.sqrelation.csv.info.coeff.a"; - public static final String CSV_C_DUAN = - "export.sqrelation.csv.header.c.duan"; - - public static final String CSV_C_FERGUSON = - "export.sqrelation.csv.header.c.ferguson"; - - public static final String CSV_QMAX = - "export.sqrelation.csv.header.qmax"; - - public static final String CSV_SD = - "export.sqrelation.csv.header.sd"; - - public static final String CSV_S_KG = - "export.sqrelation.csv.header.s_kg"; + public static final String INFO_COEFF_B = "export.sqrelation.csv.info.coeff.b"; - public static final String CSV_Q = - "export.sqrelation.csv.header.q"; - - public static final String CSV_DATE = - "export.sqrelation.csv.header.date"; - - public static final String PDF_TITLE= - "export.sqrelation.pdf.title"; + public static final String INFO_QMAX = "export.sqrelation.csv.info.qmax"; - public static final String PDF_HEADER_MODE = - "export.sqrelation.pdf.mode"; + public static final String INFO_STDERR = "export.sqrelation.csv.info.stderr"; - public static final String JASPER_FILE = - "export.sqrelation.pdf.file"; + public static final String INFO_R2 = "export.sqrelation.csv.info.r2"; - public static final String JASPER_MEASUREMENTS_FILE = - "export.sqrelation.measurements.pdf.file"; + public static final String INFO_NTOT = "export.sqrelation.csv.info.ntot"; - protected List data; + public static final String INFO_NOUTL = "export.sqrelation.csv.info.noutl"; + + public static final String INFO_CFERGUSON = "export.sqrelation.csv.info.cferguson"; + + public static final String INFO_CDUAN = "export.sqrelation.csv.info.cduan"; + + public static final String INFO_PARAM_A = "export.sqrelation.csv.info.param.a"; + + public static final String INFO_PARAM_B = "export.sqrelation.csv.info.param.b"; + + public static final String INFO_PARAM_C = "export.sqrelation.csv.info.param.c"; + + public static final String INFO_PARAM_D = "export.sqrelation.csv.info.param.d"; + + public static final String INFO_PARAM_E = "export.sqrelation.csv.info.param.e"; + + public static final String INFO_PARAM_F = "export.sqrelation.csv.info.param.f"; + + public static final String INFO_Q = "export.sqrelation.csv.info.q"; + + public static final String INFO_S_KG = "export.sqrelation.csv.info.s_kg"; + + public static final String INFO_DATE = "export.sqrelation.csv.info.date"; + + public static final String CSV_PARAMETER = "export.sqrelation.csv.header.parameter"; + + public static final String CSV_STATION = "export.sqrelation.csv.header.station"; + + public static final String CSV_KM = "export.sqrelation.csv.header.km"; + + public static final String CSV_FUNCTION = "export.sqrelation.csv.header.function"; + + public static final String CSV_GAUGE = "export.sqrelation.csv.header.gauge"; + + public static final String CSV_COEFF_A = "export.sqrelation.csv.header.coeff.a"; + + public static final String CSV_COEFF_B = "export.sqrelation.csv.header.coeff.b"; + + public static final String CSV_COEFF_Q = "export.sqrelation.csv.header.coeff.q"; + + public static final String CSV_COEFF_R = "export.sqrelation.csv.header.coeff.r"; + + public static final String CSV_N_TOTAL = "export.sqrelation.csv.header.n.total"; + + public static final String CSV_N_OUTLIERS = "export.sqrelation.csv.header.n.outliers"; + + public static final String CSV_C_DUAN = "export.sqrelation.csv.header.c.duan"; + + public static final String CSV_C_FERGUSON = "export.sqrelation.csv.header.c.ferguson"; + + public static final String CSV_QMAX = "export.sqrelation.csv.header.qmax"; + + public static final String CSV_SD = "export.sqrelation.csv.header.sd"; + + public static final String CSV_S_KG = "export.sqrelation.csv.header.s_kg"; + + public static final String CSV_Q = "common.export.csv.header.q"; + + public static final String CSV_DATE = "export.sqrelation.csv.header.date"; + + public static final String PDF_TITLE = "export.sqrelation.pdf.title"; + + public static final String PDF_HEADER_MODE = "export.sqrelation.pdf.mode"; + + public static final String JASPER_FILE = "export.sqrelation.pdf.file"; + + public static final String JASPER_MEASUREMENTS_FILE = "export.sqrelation.measurements.pdf.file"; + + protected List data; public SQRelationExporter() { - data = new ArrayList(); + this.data = new ArrayList<>(); } @Override protected void addData(Object d) { if (d instanceof CalculationResult) { - d = ((CalculationResult)d).getData(); - if (d instanceof SQResult []) { - data.add((SQResult [])d); + d = ((CalculationResult) d).getData(); + if (d instanceof SQResult[]) { + this.data.add((SQResult[]) d); } } } - protected void writeCSVHeader(CSVWriter writer) { - writer.writeNext(new String[] { - msg(CSV_KM), - msg(CSV_PARAMETER), - msg(CSV_COEFF_A), - msg(CSV_COEFF_B), - msg(CSV_SD), - msg(CSV_QMAX), - msg(CSV_COEFF_R), - msg(CSV_N_TOTAL), - msg(CSV_N_OUTLIERS), - msg(CSV_C_DUAN), - msg(CSV_C_FERGUSON), - msg(CSV_S_KG), - msg(CSV_Q), - msg(CSV_DATE) - }); + protected void writeCSVHeader(final CSVWriter writer) { + writer.writeNext(new String[] { msg(CSV_KM), msg(CSV_PARAMETER), msg(CSV_COEFF_A), msg(CSV_COEFF_B), msg(CSV_SD), msg(CSV_QMAX), msg(CSV_COEFF_R), + msg(CSV_N_TOTAL), msg(CSV_N_OUTLIERS), msg(CSV_C_DUAN), msg(CSV_C_FERGUSON), msg(CSV_S_KG), msg(CSV_Q), msg(CSV_DATE) }); } @Override - protected void writeCSVData(CSVWriter writer) { + protected void writeCSVData(final CSVWriter writer) { log.debug("writeCSVData"); - writeCSVInfo(writer, new String[] { - msg(INFO_PARAM_A), - msg(INFO_PARAM_B), - msg(INFO_PARAM_C), - msg(INFO_PARAM_D), - msg(INFO_PARAM_E), - msg(INFO_PARAM_F), - msg(INFO_COEFF_A), - msg(INFO_COEFF_B), - msg(INFO_QMAX), - msg(INFO_STDERR), - msg(INFO_R2), - msg(INFO_NTOT), - msg(INFO_NOUTL), - msg(INFO_CFERGUSON), - msg(INFO_CDUAN), - msg(INFO_S_KG), - msg(INFO_Q), - msg(INFO_DATE) - }); + writeCSVInfo(writer, + new String[] { msg(INFO_PARAM_A), msg(INFO_PARAM_B), msg(INFO_PARAM_C), msg(INFO_PARAM_D), msg(INFO_PARAM_E), msg(INFO_PARAM_F), + msg(INFO_COEFF_A), msg(INFO_COEFF_B), msg(INFO_QMAX), msg(INFO_STDERR), msg(INFO_R2), msg(INFO_NTOT), msg(INFO_NOUTL), + msg(INFO_CFERGUSON), msg(INFO_CDUAN), msg(INFO_S_KG), msg(INFO_Q), msg(INFO_DATE) }); writeCSVHeader(writer); - for (SQResult [] results: data) { - for (SQResult result: results) { + for (final SQResult[] results : this.data) { + for (final SQResult result : results) { writer.writeAll(data2StringArrays(result, true)); } } } - protected List data2StringArrays( - SQResult result, - boolean includeMeasurements - ) { - String km = Formatter.getSQRelationKM(context - ).format(result.getKm()); - List retval = new ArrayList(); + protected List data2StringArrays(final SQResult result, final boolean includeMeasurements) { + final String km = Formatter.getSQRelationKM(this.context).format(result.getKm()); + final List retval = new ArrayList<>(); - NumberFormat sqAFormatter = Formatter.getSQRelationA(context); - NumberFormat sqBFormatter = Formatter.getSQRelationB(context); - NumberFormat fThreeFormatter = Formatter.getFormatter(context, 3, 3); - NumberFormat fTwoFormatter = Formatter.getFormatter(context, 2, 2); - NumberFormat fZeroFormatter = Formatter.getFormatter(context, 0, 0); - DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, - Resources.getLocale(context.getMeta())); + final NumberFormat sqAFormatter = Formatter.getSQRelationA(this.context); + final NumberFormat sqBFormatter = Formatter.getSQRelationB(this.context); + final NumberFormat fThreeFormatter = Formatter.getFormatter(this.context, 3, 3); + final NumberFormat fTwoFormatter = Formatter.getFormatter(this.context, 2, 2); + final NumberFormat fZeroFormatter = Formatter.getFormatter(this.context, 0, 0); + final DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, Resources.getLocale(this.context.getMeta())); for (int i = 0; i < SQResult.NUMBER_FRACTIONS; ++i) { - SQFractionResult fraction = result.getFraction(i); + final SQFractionResult fraction = result.getFraction(i); - String name = result.getFractionName(i); + final String name = result.getFractionName(i); - Parameters parameters = fraction.getParameters(); + final Parameters parameters = fraction.getParameters(); if (parameters == null) { continue; } String a, b, sd, o, t, max_q, c_ferguson, c_duan, r2; - a = sqAFormatter.format(parameters.getValue(0, "a")); - b = sqBFormatter.format(parameters.getValue(0, "b")); + a = sqAFormatter.format(parameters.getValue(0, "a")); + b = sqBFormatter.format(parameters.getValue(0, "b")); /* The std_dev parameter contains the standard error actually */ sd = fThreeFormatter.format(parameters.getValue(0, "std_dev")); max_q = fZeroFormatter.format(parameters.getValue(0, "max_q")); - c_ferguson = fTwoFormatter.format( - parameters.getValue(0, "c_ferguson")); + c_ferguson = fTwoFormatter.format(parameters.getValue(0, "c_ferguson")); c_duan = fTwoFormatter.format(parameters.getValue(0, "c_duan")); r2 = fTwoFormatter.format(parameters.getValue(0, "r2")); - - o = String.valueOf(fraction.totalNumOutliers()); - t = String.valueOf(fraction.numMeasurements()); + o = String.valueOf(fraction.totalNumOutliers()); + t = String.valueOf(fraction.numMeasurements()); if (includeMeasurements) { - for (SQ sq: fraction.getMeasurements()) { - retval.add(new String[] { - km, - name, - a, - b, - sd, // 4 + for (final SQ sq : fraction.getMeasurements()) { + retval.add(new String[] { km, name, a, b, sd, // 4 + max_q, // 5 + r2, // 6 + t, // 7 + o, // 8 + c_duan, // 9 + c_ferguson, // 10 + fThreeFormatter.format(sq.getS()), fZeroFormatter.format(sq.getQ()), df.format(sq.getDate()) }); + } + } else { + retval.add(new String[] { km, name, a, b, sd, // 4 max_q, // 5 r2, // 6 t, // 7 o, // 8 c_duan, // 9 - c_ferguson, // 10 - fThreeFormatter.format(sq.getS()), - fZeroFormatter.format(sq.getQ()), - df.format(sq.getDate()) - }); - } - } else { - retval.add(new String[] { - km, - name, - a, - b, - sd, // 4 - max_q, // 5 - r2, // 6 - t, // 7 - o, // 8 - c_duan, // 9 - c_ferguson // 10 + c_ferguson // 10 }); } @@ -331,14 +232,13 @@ return retval; } - protected SQRelationJRDataSource createJRData() { - SQRelationJRDataSource source = new SQRelationJRDataSource(); + final SQRelationJRDataSource source = new SQRelationJRDataSource(); addMetaData(source); - for (SQResult [] results: data) { - for (SQResult result: results) { - for (String[] res: data2StringArrays(result, false)) { + for (final SQResult[] results : this.data) { + for (final SQResult result : results) { + for (final String[] res : data2StringArrays(result, false)) { source.addData(res); } } @@ -347,35 +247,24 @@ } protected SQMeasurementsJRDataSource createMeasurementJRData() { - SQMeasurementsJRDataSource source = new SQMeasurementsJRDataSource(); - NumberFormat fZeroFormatter = Formatter.getFormatter(context, 0, 0); - NumberFormat fThreeFormatter = Formatter.getFormatter(context, 3, 3); - DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, - Resources.getLocale(context.getMeta())); + final SQMeasurementsJRDataSource source = new SQMeasurementsJRDataSource(); + final NumberFormat fZeroFormatter = Formatter.getFormatter(this.context, 0, 0); + final NumberFormat fThreeFormatter = Formatter.getFormatter(this.context, 3, 3); + final DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, Resources.getLocale(this.context.getMeta())); - for (SQResult [] results: data) { - for (SQResult result: results) { + for (final SQResult[] results : this.data) { + for (final SQResult result : results) { for (int i = 0; i < SQResult.NUMBER_FRACTIONS; ++i) { - String name = result.getFractionName(i); - SQFractionResult fraction = result.getFraction(i); - for (SQ sq: fraction.getMeasurements()) { - source.addData(new String[] { - name, - fThreeFormatter.format(sq.getS()), - fZeroFormatter.format(sq.getQ()), - df.format(sq.getDate()), - null - }); + final String name = result.getFractionName(i); + final SQFractionResult fraction = result.getFraction(i); + for (final SQ sq : fraction.getMeasurements()) { + source.addData( + new String[] { name, fThreeFormatter.format(sq.getS()), fZeroFormatter.format(sq.getQ()), df.format(sq.getDate()), null }); } for (int j = 0; j < fraction.numIterations(); j++) { - for (SQ sq: fraction.getOutliers(j)) { - source.addData(new String[] { - name, - fThreeFormatter.format(sq.getS()), - fZeroFormatter.format(sq.getQ()), - df.format(sq.getDate()), - Integer.toString(j + 1) - }); + for (final SQ sq : fraction.getOutliers(j)) { + source.addData(new String[] { name, fThreeFormatter.format(sq.getS()), fZeroFormatter.format(sq.getQ()), df.format(sq.getDate()), + Integer.toString(j + 1) }); } } } @@ -384,39 +273,30 @@ return source; } - protected void addMetaData(SQRelationJRDataSource source) { - CallMeta meta = context.getMeta(); + protected void addMetaData(final SQRelationJRDataSource source) { + final CallMeta meta = this.context.getMeta(); - D4EArtifact arti = (D4EArtifact) master; + final D4EArtifact arti = (D4EArtifact) this.master; - source.addMetaData ("river", RiverUtils.getRivername(arti)); + source.addMetaData("river", RiverUtils.getRivername(arti)); - Locale locale = Resources.getLocale(meta); - DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, locale); + final Locale locale = Resources.getLocale(meta); + final DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, locale); source.addMetaData("date", df.format(new Date())); - SQRelationAccess access = new SQRelationAccess(arti); - source.addMetaData( - "location", "KM " + getKmFormatter().format(access.getLocation())); - - DateRange period = access.getPeriod(); - source.addMetaData("periods", df.format(period.getFrom()) + " - " + - df.format(period.getTo())); + final SQRelationAccess access = new SQRelationAccess(arti); + source.addMetaData("location", "KM " + getKmFormatter().format(access.getLocation())); - source.addMetaData("outliertest", Resources.getMsg(meta, - access.getOutlierMethod(), - access.getOutlierMethod())); - source.addMetaData( - "outliers", Formatter.getRawFormatter(context).format( - access.getOutliers())); + final DateRange period = access.getPeriod(); + source.addMetaData("periods", df.format(period.getFrom()) + " - " + df.format(period.getTo())); - source.addMetaData("calculation", Resources.getMsg( - locale, - PDF_HEADER_MODE, - "SQRelation")); + source.addMetaData("outliertest", Resources.getMsg(meta, access.getOutlierMethod(), access.getOutlierMethod())); + source.addMetaData("outliers", Formatter.getRawFormatter(this.context).format(access.getOutliers())); - String measurementStationName = access.getMeasurementStationName(); + source.addMetaData("calculation", Resources.getMsg(locale, PDF_HEADER_MODE, "SQRelation")); + + final String measurementStationName = access.getMeasurementStationName(); if (measurementStationName != null) { source.addMetaData("msName", measurementStationName); @@ -424,8 +304,7 @@ source.addMetaData("msName", ""); } - String measurementStationGaugeName = access - .getMeasurementStationGaugeName(); + final String measurementStationGaugeName = access.getMeasurementStationGaugeName(); if (measurementStationGaugeName != null) { source.addMetaData("msGauge", measurementStationGaugeName); @@ -436,44 +315,32 @@ } @Override - protected void writePDF(OutputStream out) { + protected void writePDF(final OutputStream out) { log.debug("write PDF"); - SQRelationJRDataSource source = createJRData(); - SQMeasurementsJRDataSource measureSource = createMeasurementJRData(); - - String jasperFile = Resources.getMsg( - context.getMeta(), - JASPER_FILE, - "/jasper/sqrelation_en.jasper"); - String jasperMeasurementsFile = Resources.getMsg( - context.getMeta(), - JASPER_MEASUREMENTS_FILE, - "/jasper/sqmeasurements_en.jasper"); - String confPath = Config.getConfigDirectory().toString(); - + final SQRelationJRDataSource source = createJRData(); + final SQMeasurementsJRDataSource measureSource = createMeasurementJRData(); - Map parameters = new HashMap(); - parameters.put("ReportTitle", Resources.getMsg( - context.getMeta(), PDF_TITLE, "Exported Data")); + final String jasperFile = Resources.getMsg(this.context.getMeta(), JASPER_FILE, "/jasper/sqrelation_en.jasper"); + final String jasperMeasurementsFile = Resources.getMsg(this.context.getMeta(), JASPER_MEASUREMENTS_FILE, "/jasper/sqmeasurements_en.jasper"); + final String confPath = Config.getConfigDirectory().toString(); + + final Map parameters = new HashMap(); + parameters.put("ReportTitle", Resources.getMsg(this.context.getMeta(), PDF_TITLE, "Exported Data")); try { - /* Page numbers start have a built in offset of 1 so this - * is fine. */ - JasperPrint p2 = JasperFillManager.fillReport( - confPath + jasperMeasurementsFile, - parameters, - measureSource); + /* + * Page numbers start have a built in offset of 1 so this + * is fine. + */ + final JasperPrint p2 = JasperFillManager.fillReport(confPath + jasperMeasurementsFile, parameters, measureSource); parameters.put("MEASUREMENT_PAGE_NUM", p2.getPages().size()); - JasperPrint p1 = JasperFillManager.fillReport( - confPath + jasperFile, - parameters, - source); - for (Object page: p2.getPages()) { - JRPrintPage object = (JRPrintPage)page; + final JasperPrint p1 = JasperFillManager.fillReport(confPath + jasperFile, parameters, source); + for (final Object page : p2.getPages()) { + final JRPrintPage object = (JRPrintPage) page; p1.addPage(object); } JasperExportManager.exportReportToPdfStream(p1, out); } - catch(JRException je) { + catch (final JRException je) { log.warn("Error generating PDF Report!", je); } } diff -r 7c7f73e5e01e -r 740d65e4aa14 artifacts/src/main/resources/messages.properties --- a/artifacts/src/main/resources/messages.properties Thu Jul 26 11:16:06 2018 +0200 +++ b/artifacts/src/main/resources/messages.properties Thu Jul 26 15:54:20 2018 +0200 @@ -191,10 +191,8 @@ chart.longitudinal.section.locsubtitle = {0} km {1,number,#.###} chart.longitudinal.section.xaxis.label = {0}-km chart.longitudinal.section.yaxis.label = W [{0}] -chart.longitudinal.section.yaxis.second.label = Q [m\u00b3/s] chart.longitudinal.annotations.label = {0}.km chart.discharge.curve.title = Discharge Curve -chart.discharge.curve.xaxis.label = Q [m\u00b3/s] chart.discharge.curve.yaxis.label = W [{0}] chart.discharge.curve.yaxis.cm.label = W [cm] chart.discharge.curve.curve.valid.from = {0} (valid from {1,date,short}) @@ -209,16 +207,13 @@ chart.duration.curve.subtitle = {0}-km: {1,number,#.###} chart.duration.curve.xaxis.label = Duration of Non-Exceedence [Days] chart.duration.curve.yaxis.label.w = W [{0}] -chart.duration.curve.yaxis.label.q = Q [m\u00b3/s] chart.duration.curve.curve.w = Waterlevel duration curve for {0} (km: {1}) chart.duration.curve.curve.q = Discharge duration curve for {0} (km: {1}) chart.historical.discharge.title = Historical Discharge Curves for Gauge {0} chart.historical.discharge.subtitle = Gauge {0} {1,date,medium} - {2,date,medium} -chart.historical.discharge.xaxis.label = Time -chart.historical.discharge.yaxis.second.label = Q [m\u00b3/s] +chart.historical.discharge.xaxis.label = Time chart.historical.discharge.yaxis.label = W [cm] chart.historical.discharge.wq.title = Discharge Curves -chart.historical.discharge.wq.xaxis.label = Q [m\u00b3/s] chart.historical.discharge.wq.yaxis.label = W [cm] chart.reference.curve.title = Reference Curve @@ -402,7 +397,7 @@ export.waterlevel.csv.header.km = River-Km export.waterlevel.csv.header.w = W [{0}] -export.waterlevel.csv.header.q = Q [m\u00b3/s] +common.export.csv.header.q = Q [m\u00b3/s] export.waterlevel.csv.header.q.desc = Description export.waterlevel.csv.header.location = Location export.waterlevel.csv.header.gauge = Reference Gauge @@ -416,14 +411,11 @@ export.waterlevel.csv.meta.w = # W (NN + m): {0} - {1} export.waterlevel.csv.not.in.gauge.range = Outside selected gauge export.computed.discharge.curve.csv.header.w = W [{0}] -export.computed.discharge.curve.csv.header.q = Q [m\u00b3/s] export.duration.curve.csv.header.duration = D [Days] export.duration.curve.csv.header.w = W [{0}] -export.duration.curve.csv.header.q = Q [m\u00b3/s] export.discharge.longitudinal.section.csv.header.km = River-Km export.discharge.longitudinal.section.csv.header.w = W [NN + m] export.discharge.longitudinal.section.csv.header.cw = W corr. [NN + m] -export.discharge.longitudinal.section.csv.header.q = Q [m\u00b3/s] export.discharge.curve.at.gauge.header = Dischargetable for {1}/{0} since {2} datum[{4}] = {3} export.discharge.curve.at.header = Computed discharge curve for {0} {0}-km: {1} export.historical.discharge.csv.header.timerange = Timerange @@ -457,7 +449,6 @@ export.flow_velocity.csv.header.v_total = v Total Channel export.flow_velocity.csv.header.v_main = v Main Channel export.flow_velocity.csv.header.tau_main = Bottom shear stress Main Channel -export.flow_velocity.csv.header.q = Q [m\u00b3/s] export.flow_velocity.csv.header.locations = Location export.bedheight_middle.csv.header.km = River km export.bedheight_middle.csv.header.sounding = Sounding / Epoch @@ -511,7 +502,6 @@ export.sqrelation.csv.header.sd = Standard error export.sqrelation.csv.header.qmax = Q max, measured [m\u00b3/s] export.sqrelation.csv.header.s_kg = S [kg/s] -export.sqrelation.csv.header.q = Q [m\u00b3/s] export.sqrelation.csv.header.date = Measurement date export.sqrelation.pdf.file = /jasper/sqrelation_en.jasper export.sqrelation.measurements.pdf.file = /jasper/sqmeasurements_en.jasper @@ -736,7 +726,6 @@ fix.km.chart.q.sector.border2=HQ5 fix.km.chart.label.date=yyyy/MM/dd fix.km.chart.title=Fixings {0} km {1,number,#.###} -fix.km.chart.q.axis=Q [m\u00b3/s] fix.km.chart.w.axis=W [NN + m] fix.km.chart.measured=measured fix.km.chart.interpolated=interpolated @@ -765,7 +754,6 @@ area.label.template = Area = %s m\u00b2 gauge.discharge.service.chart.title = Discharge Tables at Gauge {0} -gauge.discharge.service.chart.x.title = Q [m\u00b3/s] gauge.discharge.service.chart.y.title = W [cm] gauge.discharge.service.chart.series.title = Discharge Curve {0,date,short} - {1,date,short} gauge.discharge.service.chart.series.title.master = Current Discharge Curve since {0,date,short} @@ -895,17 +883,17 @@ sinfo.export.flow_depth.csv.meta.creation.label = Time of creation sinfo.export.flow_depth.csv.meta.river = # {0}: {1} sinfo.export.flow_depth.csv.meta.river.label = Gew\u00e4sser -sinfo.export.flow_depth.csv.meta.header.sounding = ##METADATEN PEILUNG -sinfo.export.flow_depth.csv.meta.header.sounding.year = # Jahr der Peilung: {0} -sinfo.export.flow_depth.csv.meta.header.sounding.type = # Aufnahmeart: {0} -sinfo.export.flow_depth.csv.meta.header.sounding.evaluator = # Auswerter: {0} -sinfo.export.flow_depth.csv.meta.header.sounding.prj = # Lagesystem: {0} -sinfo.export.flow_depth.csv.meta.header.sounding.elevationmodel = # H\u00f6hensystem: {0} -sinfo.export.flow_depth.csv.meta.header.sounding.elevationmodel.original = # urspr\u00fcngliches H\u00f6hensystem: {0} -sinfo.export.flow_depth.csv.meta.header.waterlevel = ##METADATEN WASSERSPIEGELLAGE -sinfo.export.flow_depth.csv.meta.header.waterlevel.name = # Bezeichnung der Wasserspiegellage: {0} -sinfo.export.flow_depth.csv.meta.header.waterlevel.gauge = # Bezugspegel: {0} -sinfo.export.flow_depth.csv.meta.header.waterlevel.year = # Jahr/Zeitraum der Wasserspiegellage: {0} +common.export.flow_depth.csv.meta.header.sounding = ##METADATEN PEILUNG +common.export.csv.meta.header.sounding.year = # Jahr der Peilung: {0} +common.export.csv.meta.header.sounding.type = # Aufnahmeart: {0} +common.export.csv.meta.header.sounding.evaluator = # Auswerter: {0} +common.export.csv.meta.header.sounding.prj = # Lagesystem: {0} +common.export.csv.meta.header.sounding.elevationmodel = # H\u00f6hensystem: {0} +common.export.csv.meta.header.sounding.elevationmodel.original = # urspr\u00fcngliches H\u00f6hensystem: {0} +common.export.csv.meta.header.waterlevel = ##METADATEN WASSERSPIEGELLAGE +common.export.csv.meta.header.waterlevel.name = # Bezeichnung der Wasserspiegellage: {0} +common.export.csv.meta.header.waterlevel.gauge = # Bezugspegel: {0} +common.export.csv.meta.header.waterlevel.year = # Jahr/Zeitraum der Wasserspiegellage: {0} sinfo.export.flow_depth.csv.meta.range = # {0}: {1} - {2} sinfo.export.flow_depth.csv.meta.range.label = Range (km) sinfo.export.flow_depth.pdf.meta.calculation.label = Angewandte Gleichung @@ -924,7 +912,7 @@ sinfo.export.flow_depth.csv.header.mean_bed_height = Mittlere Sohlh\u00f6he sinfo.export.flow_depth.csv.header.mean_bed_height.short = Mittlere Sohl- sinfo.export.flow_depth.csv.header.sounding = Peilung/Epoche -sinfo.export.flow_depth.csv.header.location = Lage +common.export.csv.header.location = Lage sinfo.export.flood_duration.csv.header.riverside = Uferseite sinfo.export.flood_duration.csv.header.infrastructure.height = H\u00f6he der Infrastruktur @@ -1228,6 +1216,8 @@ state.bundu.wst.load.function = Ausgleichsfunktion state.bundu.wst.function = Auswahl der Ausgleichsfunktion +bundu.wst.export.csv.meta.header.bezugswst = Bezugswasserstand + common.client.ui.selection = Selection common.client.ui.from = from common.client.ui.to = to diff -r 7c7f73e5e01e -r 740d65e4aa14 artifacts/src/main/resources/messages_de.properties --- a/artifacts/src/main/resources/messages_de.properties Thu Jul 26 11:16:06 2018 +0200 +++ b/artifacts/src/main/resources/messages_de.properties Thu Jul 26 15:54:20 2018 +0200 @@ -191,10 +191,8 @@ chart.longitudinal.section.locsubtitle = {0} km {1,number,#.###} chart.longitudinal.section.xaxis.label = {0}-km chart.longitudinal.section.yaxis.label = W [{0}] -chart.longitudinal.section.yaxis.second.label = Q [m\u00b3/s] chart.longitudinal.annotations.label = {0}.km chart.discharge.curve.title = Abflusskurve -chart.discharge.curve.xaxis.label = Q [m\u00b3/s] chart.discharge.curve.yaxis.label = W [{0}] chart.discharge.curve.yaxis.cm.label = W [cm] chart.discharge.curve.curve.valid.from = {0} (g\u00fcltig ab {1,date,medium}) @@ -209,16 +207,13 @@ chart.duration.curve.subtitle = {0}-km: {1,number,#.###} chart.duration.curve.xaxis.label = Unterschreitungsdauer [Tage] chart.duration.curve.yaxis.label.w = W [{0}] -chart.duration.curve.yaxis.label.q = Q [m\u00b3/s] chart.duration.curve.curve.w = Wasserstandsdauerline f\u00fcr {0} (km:{1}) chart.duration.curve.curve.q = Abflussdauerline f\u00fcr {0} (km:{1}) chart.historical.discharge.title = Historische Abflusskurven chart.historical.discharge.subtitle = Pegel {0} {1,date,medium} - {2,date,medium} chart.historical.discharge.xaxis.label = Zeit -chart.historical.discharge.yaxis.second.label = Q [m\u00b3/s] chart.historical.discharge.yaxis.label = W [cm] chart.historical.discharge.wq.title = Abflusskurven -chart.historical.discharge.wq.xaxis.label = Q [m\u00b3/s] chart.historical.discharge.wq.yaxis.label = W [cm] chart.reference.curve.title = Bezugslinie @@ -402,7 +397,7 @@ export.waterlevel.csv.header.km = Fluss-Km export.waterlevel.csv.header.w = W [{0}] -export.waterlevel.csv.header.q = Q [m\u00b3/s] +common.export.csv.header.q = Q [m\u00b3/s] export.waterlevel.csv.header.q.desc = Bezeichnung export.waterlevel.csv.header.location = Lage export.waterlevel.csv.header.gauge = Bezugspegel @@ -416,14 +411,11 @@ export.waterlevel.csv.meta.w = # W (NN + m): {0} - {1} export.waterlevel.csv.not.in.gauge.range = au\u00dferh. d. Bez.pegels export.computed.discharge.curve.csv.header.w = W [{0}] -export.computed.discharge.curve.csv.header.q = Q [m\u00b3/s] export.duration.curve.csv.header.duration = D [Tage] export.duration.curve.csv.header.w = W [{0}] -export.duration.curve.csv.header.q = Q [m\u00b3/s] export.discharge.longitudinal.section.csv.header.km = Fluss-Km export.discharge.longitudinal.section.csv.header.w = W [NN + m] export.discharge.longitudinal.section.csv.header.cw = W korr. [NN + m] -export.discharge.longitudinal.section.csv.header.q = Q [m\u00b3/s] export.discharge.curve.at.gauge.header = Abflusstafel f\u00fcr {1}/{0} ab {2} PNP[{4}] = {3} export.discharge.curve.at.header = Berechnete Abflusstafel f\u00fcr {0}, km {1} export.historical.discharge.csv.header.timerange = Zeitraum @@ -457,7 +449,6 @@ export.flow_velocity.csv.header.v_total = v Gesamtgerinne [m/s] export.flow_velocity.csv.header.v_main = v Hauptgerinne [m/s] export.flow_velocity.csv.header.tau_main = Sohlschubspannung Hauptgerinne [N/m\u00b2] -export.flow_velocity.csv.header.q = Q [m\u00b3/s] export.flow_velocity.csv.header.locations = Streckendaten export.bedheight_middle.csv.header.km = Fluss-km export.bedheight_middle.csv.header.sounding = Peilung / Epoche @@ -511,7 +502,6 @@ export.sqrelation.csv.header.sd = Standardfehler export.sqrelation.csv.header.qmax = Q max, gemessen [m\u00b3/s] export.sqrelation.csv.header.s_kg = S [kg/s] -export.sqrelation.csv.header.q = Q [m\u00b3/s] export.sqrelation.csv.header.date = Messdatum export.sqrelation.pdf.file = /jasper/sqrelation.jasper export.sqrelation.measurements.pdf.file = /jasper/sqmeasurements.jasper @@ -736,7 +726,6 @@ fix.km.chart.q.sector.border2=HQ5 fix.km.chart.label.date=dd.MM.yyyy fix.km.chart.title=Fixierungen {0} km {1,number,#.###} -fix.km.chart.q.axis=Q [m\u00b3/s] fix.km.chart.w.axis=W [NN + m] fix.km.chart.measured=gemessen fix.km.chart.interpolated=interpoliert @@ -765,7 +754,6 @@ area.label.template = Fl\u00e4che = %s m\u00b2 gauge.discharge.service.chart.title = Abflusskurven am Pegel {0} -gauge.discharge.service.chart.x.title = Q [m\u00b3/s] gauge.discharge.service.chart.y.title = W [cm] gauge.discharge.service.chart.series.title = Abflusskurve {0,date,short} - {1,date,short} gauge.discharge.service.chart.series.title.master = Aktuelle Abflusskurve ab {0,date,short} @@ -895,17 +883,17 @@ sinfo.export.flow_depth.csv.meta.creation.label = Datum der Erstellung sinfo.export.flow_depth.csv.meta.river = # {0}: {1} sinfo.export.flow_depth.csv.meta.river.label = Gew\u00e4sser -sinfo.export.flow_depth.csv.meta.header.sounding = ##METADATEN PEILUNG -sinfo.export.flow_depth.csv.meta.header.sounding.year = # Jahr der Peilung: {0} -sinfo.export.flow_depth.csv.meta.header.sounding.type = # Aufnahmeart: {0} -sinfo.export.flow_depth.csv.meta.header.sounding.evaluator = # Auswerter: {0} -sinfo.export.flow_depth.csv.meta.header.sounding.prj = # Lagesystem: {0} -sinfo.export.flow_depth.csv.meta.header.sounding.elevationmodel = # H\u00f6hensystem: {0} -sinfo.export.flow_depth.csv.meta.header.sounding.elevationmodel.original = # urspr\u00fcngliches H\u00f6hensystem: {0} -sinfo.export.flow_depth.csv.meta.header.waterlevel = ##METADATEN WASSERSPIEGELLAGE -sinfo.export.flow_depth.csv.meta.header.waterlevel.name = # Bezeichnung der Wasserspiegellage: {0} -sinfo.export.flow_depth.csv.meta.header.waterlevel.gauge = # Bezugspegel: {0} -sinfo.export.flow_depth.csv.meta.header.waterlevel.year = # Jahr/Zeitraum der Wasserspiegellage: {0} +common.export.flow_depth.csv.meta.header.sounding = ##METADATEN PEILUNG +common.export.csv.meta.header.sounding.year = # Jahr der Peilung: {0} +common.export.csv.meta.header.sounding.type = # Aufnahmeart: {0} +common.export.csv.meta.header.sounding.evaluator = # Auswerter: {0} +common.export.csv.meta.header.sounding.prj = # Lagesystem: {0} +common.export.csv.meta.header.sounding.elevationmodel = # H\u00f6hensystem: {0} +common.export.csv.meta.header.sounding.elevationmodel.original = # urspr\u00fcngliches H\u00f6hensystem: {0} +common.export.csv.meta.header.waterlevel = ##METADATEN WASSERSPIEGELLAGE +common.export.csv.meta.header.waterlevel.name = # Bezeichnung der Wasserspiegellage: {0} +common.export.csv.meta.header.waterlevel.gauge = # Bezugspegel: {0} +common.export.csv.meta.header.waterlevel.year = # Jahr/Zeitraum der Wasserspiegellage: {0} sinfo.export.flow_depth.csv.meta.range = # {0}: {1} - {2} sinfo.export.flow_depth.csv.meta.range.label = Bereich (km) sinfo.export.flow_depth.pdf.meta.calculation.label = Angewandte Gleichung @@ -924,7 +912,7 @@ sinfo.export.flow_depth.csv.header.mean_bed_height = Mittlere Sohlh\u00f6he sinfo.export.flow_depth.csv.header.mean_bed_height.short = Mittlere Sohl- sinfo.export.flow_depth.csv.header.sounding = Peilung/Epoche -sinfo.export.flow_depth.csv.header.location = Lage +common.export.csv.header.location = Lage sinfo.export.flood_duration.csv.header.riverside = Uferseite sinfo.export.flood_duration.csv.header.infrastructure.height = H\u00f6he der Infrastruktur @@ -1227,7 +1215,9 @@ state.bundu.wst.missing_volume = Ermittlung von Fehlvolumina? state.bundu.wst.load.function = Ausgleichsfunktion state.bundu.wst.function = Auswahl der Ausgleichsfunktion - + +bundu.wst.export.csv.meta.header.bezugswst = Bezugswasserstand + common.client.ui.selection = Auswahl common.client.ui.from = von common.client.ui.to = bis