Mercurial > dive4elements > river
diff artifacts/src/main/java/org/dive4elements/river/exports/process/FixWQProcessor.java @ 8372:cac60032aa7d
merged.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Thu, 02 Oct 2014 14:02:57 +0200 |
parents | e1ff1263d79a 061e85212d25 |
children | 0faa82973f60 |
line wrap: on
line diff
--- 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);