Mercurial > dive4elements > river
changeset 8372:cac60032aa7d
merged.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Thu, 02 Oct 2014 14:02:57 +0200 (2014-10-02) |
parents | 676687c3d8f0 (current diff) 6e9c01a6e90e (diff) |
children | 55b5d6d98d15 |
files | artifacts/doc/conf/generators/discharge-diagrams.xml artifacts/src/main/java/org/dive4elements/river/exports/process/FixWQProcessor.java |
diffstat | 12 files changed, 55 insertions(+), 102 deletions(-) [+] |
line wrap: on
line diff
--- a/artifacts/doc/conf/generators/discharge-diagrams.xml Thu Oct 02 14:01:13 2014 +0200 +++ b/artifacts/doc/conf/generators/discharge-diagrams.xml Thu Oct 02 14:02:57 2014 +0200 @@ -62,7 +62,7 @@ <output-generator names="sq_relation_a,sq_relation_a_chartinfo" class="org.dive4elements.river.exports.DischargeGenerator" - injectors="org.dive4elements.river.exports.injector.PNPInjector" + injectors="org.dive4elements.river.exports.injector.KmFromLocationInjector,org.dive4elements.river.exports.injector.PNPInjector" converter="org.dive4elements.river.exports.DiagramAttributes"> <title key="chart.sq_relation_a.title" default=""/> &sqrelation-defaults; @@ -70,7 +70,7 @@ <output-generator names="sq_relation_b,sq_relation_b_chartinfo" class="org.dive4elements.river.exports.DischargeGenerator" - injectors="org.dive4elements.river.exports.injector.PNPInjector" + injectors="org.dive4elements.river.exports.injector.KmFromLocationInjector,org.dive4elements.river.exports.injector.PNPInjector" converter="org.dive4elements.river.exports.DiagramAttributes"> <title key="chart.sq_relation_b.title" default=""/> &sqrelation-defaults; @@ -78,7 +78,7 @@ <output-generator names="sq_relation_c,sq_relation_c_chartinfo" class="org.dive4elements.river.exports.DischargeGenerator" - injectors="org.dive4elements.river.exports.injector.PNPInjector" + injectors="org.dive4elements.river.exports.injector.KmFromLocationInjector,org.dive4elements.river.exports.injector.PNPInjector" converter="org.dive4elements.river.exports.DiagramAttributes"> <title key="chart.sq_relation_c.title" default=""/> &sqrelation-defaults; @@ -86,7 +86,7 @@ <output-generator names="sq_relation_d,sq_relation_d_chartinfo" class="org.dive4elements.river.exports.DischargeGenerator" - injectors="org.dive4elements.river.exports.injector.PNPInjector" + injectors="org.dive4elements.river.exports.injector.KmFromLocationInjector,org.dive4elements.river.exports.injector.PNPInjector" converter="org.dive4elements.river.exports.DiagramAttributes"> <title key="chart.sq_relation_d.title" default=""/> &sqrelation-defaults; @@ -94,7 +94,7 @@ <output-generator names="sq_relation_e,sq_relation_e_chartinfo" class="org.dive4elements.river.exports.DischargeGenerator" - injectors="org.dive4elements.river.exports.injector.PNPInjector" + injectors="org.dive4elements.river.exports.injector.KmFromLocationInjector,org.dive4elements.river.exports.injector.PNPInjector" converter="org.dive4elements.river.exports.DiagramAttributes"> <title key="chart.sq_relation_e.title" default=""/> &sqrelation-defaults; @@ -102,21 +102,21 @@ <output-generator names="sq_relation_f,sq_relation_f_chartinfo" class="org.dive4elements.river.exports.DischargeGenerator" - injectors="org.dive4elements.river.exports.injector.PNPInjector" + injectors="org.dive4elements.river.exports.injector.KmFromLocationInjector,org.dive4elements.river.exports.injector.PNPInjector" converter="org.dive4elements.river.exports.DiagramAttributes"> <title key="chart.sq_relation_f.title" default=""/> &sqrelation-defaults; </output-generator> <output-generator names="sq_relation_g,sq_relation_g_chartinfo" class="org.dive4elements.river.exports.DischargeGenerator" - injectors="org.dive4elements.river.exports.injector.PNPInjector" + injectors="org.dive4elements.river.exports.injector.KmFromLocationInjector,org.dive4elements.river.exports.injector.PNPInjector" converter="org.dive4elements.river.exports.DiagramAttributes"> <title key="chart.sq_relation_f.title" default=""/> &sqrelation-defaults; </output-generator> <output-generator names="sq_overview,sq_overview_chartinfo" class="org.dive4elements.river.exports.DischargeGenerator" - injectors="org.dive4elements.river.exports.injector.PNPInjector" + injectors="org.dive4elements.river.exports.injector.KmFromLocationInjector,org.dive4elements.river.exports.injector.PNPInjector" converter="org.dive4elements.river.exports.DiagramAttributes"> <title key="chart.sq_relation_f.title" default=""/> &sqrelation-defaults;
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/D4EArtifact.java Thu Oct 02 14:01:13 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/D4EArtifact.java Thu Oct 02 14:02:57 2014 +0200 @@ -1235,7 +1235,6 @@ */ public List<Output> getOutputs(Object context) { if (log.isDebugEnabled()) { - log.debug("##### Get Outputs for: " + identifier() + " #####"); dumpArtifact(); }
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/SedimentLoadSQTiSelect.java Thu Oct 02 14:01:13 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/SedimentLoadSQTiSelect.java Thu Oct 02 14:02:57 2014 +0200 @@ -8,18 +8,12 @@ package org.dive4elements.river.artifacts.states.minfo; -import org.apache.log4j.Logger; - import org.dive4elements.river.artifacts.states.DefaultState; public class SedimentLoadSQTiSelect extends DefaultState { - /** The logger used in this class. */ - private static Logger logger = Logger.getLogger(SedimentLoadSQTiSelect.class); - - /** * The default constructor that initializes an empty State object. */
--- a/artifacts/src/main/java/org/dive4elements/river/exports/injector/KmFromGaugeNameInjector.java Thu Oct 02 14:01:13 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/injector/KmFromGaugeNameInjector.java Thu Oct 02 14:02:57 2014 +0200 @@ -25,6 +25,10 @@ @Override public void injectContext(CallContext ctx, Artifact artifact, Document doc) { + if (ctx.getContextValue(CURRENT_KM) instanceof Number) { + return; + } + D4EArtifact d4e = (D4EArtifact)artifact; RangeAccess access = new RangeAccess(d4e); String name = d4e.getDataAsString("gauge_name");
--- a/artifacts/src/main/java/org/dive4elements/river/exports/injector/KmFromGaugeNumberInjector.java Thu Oct 02 14:01:13 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/injector/KmFromGaugeNumberInjector.java Thu Oct 02 14:02:57 2014 +0200 @@ -29,6 +29,10 @@ Artifact artifact, Document request ) { + if (ctx.getContextValue(CURRENT_KM) instanceof Number) { + return; + } + HistoricalDischargeAccess access = new HistoricalDischargeAccess((D4EArtifact)artifact); Long gaugeNumber = access.getOfficialGaugeNumber();
--- a/artifacts/src/main/java/org/dive4elements/river/exports/injector/KmFromLocationInjector.java Thu Oct 02 14:01:13 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/injector/KmFromLocationInjector.java Thu Oct 02 14:02:57 2014 +0200 @@ -27,6 +27,10 @@ Artifact artifact, Document doc ) { + if (ctx.getContextValue(CURRENT_KM) instanceof Number) { + return; + } + RangeAccess access = new RangeAccess((D4EArtifact)artifact); if (access.getLocations() != null && access.getLocations().length > 0) {
--- a/artifacts/src/main/java/org/dive4elements/river/exports/injector/KmFromRequestInjector.java Thu Oct 02 14:01:13 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/injector/KmFromRequestInjector.java Thu Oct 02 14:02:57 2014 +0200 @@ -19,7 +19,6 @@ { private static final Logger log = Logger.getLogger(KmFromRequestInjector.class); - public static final Double INVALID_KM = Double.valueOf(-1d); public static final String XPATH_CHART_CURRENTKM = "/art:action/art:attributes/art:currentKm/@art:km"; @Override @@ -31,7 +30,12 @@ public void injectContext( CallContext ctx, Artifact artifact, - Document request) { + Document request + ) { + if (ctx.getContextValue(CURRENT_KM) instanceof Number) { + return; + } + Double km = getCurrentKmFromRequest(request); if (Double.isNaN(km)) { RangeAccess access = new RangeAccess((D4EArtifact)artifact);
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/FixWQProcessor.java Thu Oct 02 14:01:13 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/FixWQProcessor.java Thu Oct 02 14:02:57 2014 +0200 @@ -22,7 +22,6 @@ import org.dive4elements.river.artifacts.resources.Resources; import org.dive4elements.river.exports.DiagramGenerator; import org.dive4elements.river.exports.StyledSeriesBuilder; -import org.dive4elements.river.exports.fixings.FixChartGenerator; import org.dive4elements.river.exports.fixings.FixWQCurveGenerator; import org.dive4elements.river.java2d.ShapeUtils; import org.dive4elements.river.jfree.CollisionFreeXYTextAnnotation; @@ -39,13 +38,14 @@ import org.jfree.ui.RectangleInsets; import org.jfree.ui.TextAnchor; +import static org.dive4elements.river.exports.injector.InjectorConstants.CURRENT_KM; public class FixWQProcessor extends DefaultProcessor implements FacetTypes { - private static Logger logger = Logger.getLogger(FixWQProcessor.class); + private static Logger log = Logger.getLogger(FixWQProcessor.class); private String I18N_AXIS_LABEL = "chart.discharge.curve.yaxis.label"; @@ -62,10 +62,10 @@ ThemeDocument theme, boolean visible ) { - // TODO: Simplyfy this processor and move general facets/data to + // TODO: Simplify this processor and move general facets/data to // MiscDischargeProcessor or something... String facetType = bundle.getFacetName(); - logger.debug("facet: " + facetType + " name: " + bundle.getFacetDescription()); + log.debug("facet: " + facetType + " name: " + bundle.getFacetDescription()); if(facetType.startsWith(FIX_SECTOR_AVERAGE_WQ)) { doSectorAverageOut(generator, bundle, theme, visible); } @@ -106,7 +106,7 @@ ThemeDocument theme, boolean visible ) { - logger.debug("doSectorAverageOut"); + log.debug("doSectorAverageOut"); QWDDateRange qwdd = (QWDDateRange)bundle.getData(generator.getCallContext()); QWD qwd = qwdd != null ? qwdd.getQWD() : null; @@ -118,7 +118,6 @@ DateFormat dateFormat = DateFormat.getDateInstance( DateFormat.SHORT); - //TODO: W in cm at Gauge!!! series.add(qwd.getQ(), qwd.getW(), false); XYTextAnnotation anno = new CollisionFreeXYTextAnnotation( @@ -137,7 +136,7 @@ } } else { - logger.debug("doSectorAverageOut: qwd == null"); + log.debug("doSectorAverageOut: qwd == null"); } } @@ -149,21 +148,14 @@ ThemeDocument theme, boolean visible ) { - logger.debug("doAnalysisEventsOut"); + log.debug("doAnalysisEventsOut"); QWD qwd = (QWD)bundle.getData(generator.getCallContext()); if (qwd == null) { - logger.debug("doAnalysisEventsOut: qwd == null"); + log.debug("doAnalysisEventsOut: qwd == null"); return; } -// TODO: W in cm at Gauge!!! - //double gaugeDatum = getCurrentGaugeDatum(); - //boolean atGauge = gaugeDatum != 0d; - - //double factor = atGauge ? 100d : 1d; - - //double w = factor*(qwd.getW()-gaugeDatum); // Force empty symbol. if (qwd.getInterpolated()) { @@ -206,11 +198,11 @@ ArtifactAndFacet bundle, ThemeDocument theme, boolean visible) { - logger.debug("doReferenceEventsOut"); + log.debug("doReferenceEventsOut"); QWI qwd = (QWI)bundle.getData(generator.getCallContext()); if (qwd == null) { - logger.debug("doReferenceEventsOut: qwds == null in " + bundle.getFacetDescription()); + log.debug("doReferenceEventsOut: qwds == null in " + bundle.getFacetDescription()); return; } @@ -227,13 +219,6 @@ ? ShapeUtils.INTERPOLATED_SHAPE : ShapeUtils.MEASURED_SHAPE); -// TODO: W in cm at gauge!!! - //double gaugeDatum = getCurrentGaugeDatum(); - //boolean atGauge = gaugeDatum != 0d; - - //double factor = atGauge ? 100d : 1d; - //double w = factor*(qwd.getW()-gaugeDatum); - series.add(qwd.getQ(), qwd.getW(), false); if (visible && theme.parseShowPointLabel()) { @@ -261,14 +246,14 @@ ThemeDocument theme, boolean visible ) { - logger.debug("doWQCurveOut"); + log.debug("doWQCurveOut"); FixWQCurveFacet facet = (FixWQCurveFacet)bundle.getFacet(); FixFunction func = (FixFunction)facet.getData( bundle.getArtifact(), generator.getCallContext()); if (func == null) { - logger.warn("doWQCurveOut: Facet does not contain FixFunction"); + log.warn("doWQCurveOut: Facet does not contain FixFunction"); return; } @@ -282,32 +267,9 @@ 500, // number of samples 0.0 , // start maxQ); // end - - //TODO: W in cm at gauge!!! -// double gaugeDatum = getCurrentGaugeDatum(); - -// if (gaugeDatum == 0d) { - generator.addAxisSeries(series, axisName, visible); -// } -/* else { - StyledXYSeries series2 = JFreeUtil.sampleFunction2D( - func.getFunction(), - doc, - aaf.getFacetDescription(), - 500, // number of samples - 0.0 , // start - maxQ); // end - addAxisSeries(series2, YAXIS.W.idx, false); - // Use second axis at cm if at gauge. - for (int i = 0, N = series.getItemCount(); i < N; i++) { - series.updateByIndex( - i, new Double(100d*(series.getY(i).doubleValue()-gaugeDatum))); - } - addAxisSeries(series, YAXIS.WCm.idx, visible); - }*/ } else { - logger.warn("doWQCurveOut: maxQ <= 0"); + log.warn("doWQCurveOut: maxQ <= 0"); } } @@ -317,7 +279,7 @@ ThemeDocument theme, boolean visible ) { - logger.debug("doOutlierOut"); + log.debug("doOutlierOut"); QWI[] qws = (QWI[])bundle.getData(generator.getCallContext()); if(qws != null) { @@ -329,7 +291,7 @@ DateFormat.SHORT); List<XYTextAnnotation> annos = new ArrayList<XYTextAnnotation>(); - //TODO: W in cm at Gauge!!! + for (QWI qw: qws) { series.add(qw.getQ(), qw.getW(), false); @@ -349,7 +311,7 @@ } } else { - logger.debug("doOutlierOut: qwd == null"); + log.debug("doOutlierOut: qwd == null"); } } @@ -360,20 +322,20 @@ ThemeDocument theme, boolean visible ) { - logger.debug("doQSectorOut"); + log.debug("doQSectorOut"); if (!visible) { return; } Object qsectorsObj = bundle.getData(generator.getCallContext()); if (qsectorsObj == null || !(qsectorsObj instanceof List)) { - logger.warn("No QSectors coming from data."); + log.warn("No QSectors coming from data."); return; } List<?> qsectorsList = (List<?>) qsectorsObj; if (qsectorsList.size() == 0 || !(qsectorsList.get(0) instanceof NamedDouble)) { - logger.warn("No QSectors coming from data."); + log.warn("No QSectors coming from data."); return; } @@ -433,7 +395,7 @@ Object data = bundle.getData(generator.getCallContext()); List<StickyAxisAnnotation> xy = new ArrayList<StickyAxisAnnotation>(); if (data instanceof double[][]) { - logger.debug("Got double[][]"); + log.debug("Got double[][]"); double [][] values = (double [][]) data; for (int i = 0; i< values[0].length; i++) { xy.add(new StickyAxisAnnotation(bundle.getFacetDescription(), @@ -448,7 +410,7 @@ } else { // Assume its WKms. - logger.debug("Got WKms"); + log.debug("Got WKms"); /* TODO WKms wkms = (WKms) data; @@ -476,24 +438,21 @@ ThemeDocument theme, boolean visible ) { - logger.debug("FixWQCurveGenerator: doWQOut"); Object data = bundle.getData(generator.getCallContext()); if (data instanceof WQKms) { WQKms wqkms = (WQKms)data; // TODO As in doEventsOut, the value-searching should - // be delivered by the facet already (instead of in the Generator). - logger.debug("FixWQCurveGenerator: doWQOut: WQKms"); + // be delivered by the facet already XYSeries series = new StyledXYSeries(bundle.getFacetDescription(), theme); - // TODO: Remove dependency to FixChartGenerator. - Double ckm = (Double) generator.getCallContext().getContextValue(FixChartGenerator.CURRENT_KM); + Double ckm = (Double) generator.getCallContext() + .getContextValue(CURRENT_KM); + if (wqkms == null || wqkms.getKms().length == 0 || ckm == null) { - logger.info("addPointFromWQKms: No event data to show."); + log.info("addPointFromWQKms: No event data to show."); return; } + double[] kms = wqkms.getKms(); - // TODO W in cm at gauge!!! - //double gaugeDatum = getCurrentGaugeDatum(); - //double factor = (gaugeDatum == 0d) ? 1d : 100d; for (int i = 0 ; i< kms.length; i++) { // TODO: Remove dependency to FixWQCurveGenerator. if (Math.abs(kms[i] - ckm) <= FixWQCurveGenerator.EPSILON) { @@ -515,7 +474,7 @@ } } else { - logger.debug("FixWQCurveGenerator: doWQOut: double[][]"); + log.debug("FixWQCurveGenerator: doWQOut: double[][]"); double [][] values = (double [][]) data; XYSeries series = new StyledXYSeries(bundle.getFacetDescription(), false, true, theme);
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/SedimentLoadLSM3AProcessor.java Thu Oct 02 14:01:13 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/SedimentLoadLSM3AProcessor.java Thu Oct 02 14:02:57 2014 +0200 @@ -7,15 +7,10 @@ */ package org.dive4elements.river.exports.process; -import org.apache.log4j.Logger; - import org.dive4elements.river.exports.DiagramGenerator; public class SedimentLoadLSM3AProcessor extends SedimentLoadLSProcessor { - private final static Logger logger = - Logger.getLogger(SedimentLoadM3AProcessor.class); - public static final String I18N_YAXIS_LABEL = "chart.sedimentload.ls.yaxis.label.m3pera"; public static final String I18N_YAXIS_LABEL_DEFAULT = "[m\u00b3/a]";
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/SedimentLoadLSTAProcessor.java Thu Oct 02 14:01:13 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/SedimentLoadLSTAProcessor.java Thu Oct 02 14:02:57 2014 +0200 @@ -8,15 +8,10 @@ package org.dive4elements.river.exports.process; -import org.apache.log4j.Logger; - import org.dive4elements.river.exports.DiagramGenerator; public class SedimentLoadLSTAProcessor extends SedimentLoadLSProcessor{ - private final static Logger logger = - Logger.getLogger(SedimentLoadTAProcessor.class); - public static final String I18N_YAXIS_LABEL = "chart.sedimentload.ls.yaxis.label.tpera"; public static final String I18N_YAXIS_LABEL_DEFAULT = "[t/a]";
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/SedimentLoadM3AProcessor.java Thu Oct 02 14:01:13 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/SedimentLoadM3AProcessor.java Thu Oct 02 14:02:57 2014 +0200 @@ -7,15 +7,10 @@ */ package org.dive4elements.river.exports.process; -import org.apache.log4j.Logger; - import org.dive4elements.river.exports.DiagramGenerator; public class SedimentLoadM3AProcessor extends SedimentLoadProcessor { - private final static Logger log = - Logger.getLogger(SedimentLoadM3AProcessor.class); - public static final String I18N_YAXIS_LABEL = "chart.sedimentload.ls.yaxis.label.m3pera"; public static final String I18N_YAXIS_LABEL_DEFAULT = "[m\u00b3/a]";
--- a/artifacts/src/main/java/org/dive4elements/river/jfree/AnnotationHelper.java Thu Oct 02 14:01:13 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/jfree/AnnotationHelper.java Thu Oct 02 14:02:57 2014 +0200 @@ -187,7 +187,7 @@ int axisIndex = annotation.getAxisSymbol(); XYItemRenderer renderer = null; - if (dataset.getDatasets().length > 0) { + if (dataset != null && dataset.getDatasets().length > 0) { renderer = plot.getRendererForDataset(dataset.getDatasets()[0]); } else {