[PATCH] Simplified code

Wald Commits scm-commit at wald.intevation.org
Wed Nov 6 19:41:16 CET 2013


# HG changeset patch
# User Sascha L. Teichmann <teichmann at intevation.de>
# Date 1383763272 -3600
# Node ID 0ee545a02204b3c39e735ac40abe029bd432634e
# Parent  a836adfaccc646621b3a20d21d64757415df7ad7
Simplified code.

diff -r a836adfaccc6 -r 0ee545a02204 artifacts/src/main/java/org/dive4elements/river/exports/fixings/FixWQCurveGenerator.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/fixings/FixWQCurveGenerator.java	Wed Nov 06 19:18:50 2013 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/fixings/FixWQCurveGenerator.java	Wed Nov 06 19:41:12 2013 +0100
@@ -275,41 +275,47 @@
     }
 
     /** Add analysis event points to chart. */
-    protected void doAnalysisEventsOut(ArtifactAndFacet aaf, ThemeDocument doc, boolean visible) {
+    protected void doAnalysisEventsOut(
+        ArtifactAndFacet aaf,
+        ThemeDocument    doc,
+        boolean          visible
+    ) {
         logger.debug("doAnalysisEventsOut");
 
         QWD qwd = (QWD)aaf.getData(context);
-        if(qwd != null) {
-            XYSeries series = new StyledXYSeries(aaf.getFacetDescription(), doc);
-            List<XYTextAnnotation> textAnnos = new ArrayList<XYTextAnnotation>();
 
-            DateFormat dateFormat = DateFormat.getDateInstance(
-                    DateFormat.SHORT);
+        if (qwd == null) {
+            logger.debug("doAnalysisEventsOut: qwd == null");
+            return;
+        }
 
-            double gaugeDatum = getCurrentGaugeDatum();
-            double factor = (gaugeDatum == 0d) ? 1d : 100d;
+        XYSeries series = new StyledXYSeries(aaf.getFacetDescription(), doc);
+        List<XYTextAnnotation> textAnnos = new ArrayList<XYTextAnnotation>();
 
-            series.add(qwd.getQ(), factor*(qwd.getW()-gaugeDatum));
-            XYTextAnnotation anno = new CollisionFreeXYTextAnnotation(
-                    dateFormat.format(qwd.getDate()),
-                    qwd.getQ(),
-                    factor*(qwd.getW()-gaugeDatum));
-            textAnnos.add(anno);
+        DateFormat dateFormat = DateFormat.getDateInstance(
+            DateFormat.SHORT);
 
-            if (gaugeDatum == 0d) {
-                addAxisSeries(series, YAXIS.W.idx, visible);
-            }
-            else {
-                addAxisSeries(series, YAXIS.WCm.idx, visible);
-            }
-            if(visible && doc.parseShowPointLabel()) {
-                RiverAnnotation flysAnno = new RiverAnnotation(null, null, null, doc);
-                flysAnno.setTextAnnotations(textAnnos);
-                addAnnotations(flysAnno);
-            }
-        }
-        else {
-            logger.debug("doAnalysisEventsOut: qwds == null");
+        double gaugeDatum = getCurrentGaugeDatum();
+        boolean atGauge = gaugeDatum != 0d;
+
+        double factor = atGauge ? 100d : 1d;
+
+        double w = factor*(qwd.getW()-gaugeDatum);
+
+        series.add(qwd.getQ(), w);
+
+        XYTextAnnotation anno = new CollisionFreeXYTextAnnotation(
+            dateFormat.format(qwd.getDate()),
+            qwd.getQ(),
+            w);
+        textAnnos.add(anno);
+
+        addAxisSeries(series, atGauge ? YAXIS.WCm.idx : YAXIS.W.idx, visible);
+
+        if (visible && doc.parseShowPointLabel()) {
+            RiverAnnotation flysAnno = new RiverAnnotation(null, null, null, doc);
+            flysAnno.setTextAnnotations(textAnnos);
+            addAnnotations(flysAnno);
         }
     }
 


More information about the Dive4elements-commits mailing list