[PATCH 5 of 5] issue1370: Translate main values if needed

Wald Commits scm-commit at wald.intevation.org
Tue Jul 2 08:13:15 CEST 2013


# HG changeset patch
# User Felix Wolfsteller <felix.wolfsteller at intevation.de>
# Date 1372746070 -7200
# Node ID e1e04db79e3c57f56c83acc994317310480abe7b
# Parent  abb7a2d4c6328214082912e6e48122ad3b30ad0f
issue1370: Translate main values if needed.

diff -r abb7a2d4c632 -r e1e04db79e3c artifacts/src/main/java/org/dive4elements/river/exports/fixings/FixWQCurveGenerator.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/fixings/FixWQCurveGenerator.java	Tue Jul 02 07:12:50 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/fixings/FixWQCurveGenerator.java	Tue Jul 02 08:21:10 2013 +0200
@@ -162,6 +162,23 @@
         else return 0d;
     }
 
+    /** Translate River annotations if not at gauge. */
+    public void translateRiverAnnotation(RiverAnnotation riverAnnotation) {
+        if (getCurrentGaugeDatum() == 0d) {
+            return;
+        }
+        logger.debug("Translate some river annotation.");
+        double translate = getCurrentGaugeDatum();
+        double factor    = 100d;
+        for (StickyAxisAnnotation annotation: riverAnnotation.getAxisTextAnnotations()){
+            if (!annotation.atX()) {
+                annotation.setPos((annotation.getPos() - translate)*factor);
+            }
+        }
+        for (XYTextAnnotation annotation: riverAnnotation.getTextAnnotations()) {
+            annotation.setY((annotation.getY() - translate)*factor);
+        }
+    }
 
     @Override
     public void doOut(ArtifactAndFacet aaf, Document doc, boolean visible) {
@@ -226,8 +243,10 @@
                     visible);
         }
         else if (name.equals(MAINVALUES_W) || name.equals(MAINVALUES_Q)) {
+            RiverAnnotation mainValues = (RiverAnnotation) aaf.getData(context);
+            translateRiverAnnotation(mainValues);
             doAnnotations(
-                ((RiverAnnotation) aaf.getData(context)),
+                mainValues,
                 aaf,
                 doc,
                 visible);


More information about the Dive4elements-commits mailing list