changeset 1992:e1c9f28e2675

Added more attributes to ChartSettings AxisSection. flys-artifacts/trunk@3428 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 16 Dec 2011 07:28:17 +0000
parents 0bd7c3cf0af1
children 85132c9edd64
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/exports/AxisSection.java flys-artifacts/src/main/java/de/intevation/flys/exports/DoubleAttribute.java flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java
diffstat 4 files changed, 112 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Thu Dec 15 17:10:42 2011 +0000
+++ b/flys-artifacts/ChangeLog	Fri Dec 16 07:28:17 2011 +0000
@@ -1,3 +1,14 @@
+2011-12-16  Ingo Weinzierl <ingo@intevation.de>
+
+	* src/main/java/de/intevation/flys/exports/DoubleAttribute.java: New. An
+	  Attribute that stores double values.
+
+	* src/main/java/de/intevation/flys/exports/AxisSection.java: Added methods
+	  to set values for 'fixation', 'font-size', 'lower' and 'upper'.
+
+	* src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java:
+	  Set new attributes mentioned above for each axis' AxisSection.
+
 2011-12-15  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/flys/exports/AxisSection.java: Added methods
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/AxisSection.java	Thu Dec 15 17:10:42 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/AxisSection.java	Fri Dec 16 07:28:17 2011 +0000
@@ -16,6 +16,10 @@
 
     public static final String IDENTIFIER_ATTR = "id";
     public static final String LABEL_ATTR      = "label";
+    public static final String FONTSIZE_ATTR   = "font-size";
+    public static final String FIXATION_ATTR   = "fixation";
+    public static final String UPPERRANGE_ATTR = "upper";
+    public static final String LOWERRANGE_ATTR = "lower";
 
 
     public AxisSection() {
@@ -55,6 +59,58 @@
     }
 
 
+    public void setFontSize(int fontSize) {
+        if (fontSize <= 0) {
+            return;
+        }
+
+        Attribute attr = getAttribute(FONTSIZE_ATTR);
+        if (attr == null) {
+            attr = new IntegerAttribute(FONTSIZE_ATTR, fontSize, true);
+            addAttribute(FONTSIZE_ATTR, attr);
+        }
+        else {
+            attr.setValue(fontSize);
+        }
+    }
+
+
+    public void setFixed(boolean fixed) {
+        Attribute attr = getAttribute(FIXATION_ATTR);
+        if (attr == null) {
+            attr = new BooleanAttribute(FIXATION_ATTR, fixed, true);
+            addAttribute(FIXATION_ATTR, attr);
+        }
+        else {
+            attr.setValue(fixed);
+        }
+    }
+
+
+    public void setUpperRange(double upperRange) {
+        Attribute attr = getAttribute(UPPERRANGE_ATTR);
+        if (attr == null) {
+            attr = new DoubleAttribute(UPPERRANGE_ATTR, upperRange, true);
+            addAttribute(UPPERRANGE_ATTR, attr);
+        }
+        else {
+            attr.setValue(upperRange);
+        }
+    }
+
+
+    public void setLowerRange(double lowerRange) {
+        Attribute attr = getAttribute(LOWERRANGE_ATTR);
+        if (attr == null) {
+            attr = new DoubleAttribute(LOWERRANGE_ATTR, lowerRange, true);
+            addAttribute(LOWERRANGE_ATTR, attr);
+        }
+        else {
+            attr.setValue(lowerRange);
+        }
+    }
+
+
     @Override
     public void toXML(Node parent) {
         Document owner = parent.getOwnerDocument();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/DoubleAttribute.java	Fri Dec 16 07:28:17 2011 +0000
@@ -0,0 +1,37 @@
+package de.intevation.flys.exports;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+
+/**
+ * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
+ */
+public class DoubleAttribute extends VisibleAttribute {
+
+
+    public DoubleAttribute(String name, double value, boolean visible) {
+        super(name, value, visible);
+    }
+
+
+    /**
+     * Calls VisibleAttribute.toXML() and appends afterwards an attribute
+     * <i>type</i> with value <i>double</i>.
+     *
+     * @param parent The parent Node.
+     *
+     * @return the new Node that represents this Attribute.
+     */
+    @Override
+    public Node toXML(Node parent) {
+        Document owner = parent.getOwnerDocument();
+
+        Element ele = (Element) super.toXML(parent);
+        ele.setAttribute("type", "double");
+
+        return ele;
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java	Thu Dec 15 17:10:42 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java	Fri Dec 16 07:28:17 2011 +0000
@@ -475,11 +475,15 @@
             AxisSection axisSection = new AxisSection();
             axisSection.setIdentifier(identifier);
             axisSection.setLabel(getYAxisLabel(axis.idx));
+            axisSection.setFontSize(14);
+            axisSection.setFixed(false);
 
-            // TODO font-size
-            // TODO fixation
-            // TODO lower
-            // TODO upper
+            // XXX We are able to find better default ranges that [0,0], the
+            // only problem is, that we do NOT have a better range than [0,0]
+            // for each axis, because the initial chart will not have a dataset
+            // for each axis set!
+            axisSection.setUpperRange(0d);
+            axisSection.setLowerRange(0d);
 
             axisSections.add(axisSection);
         }

http://dive4elements.wald.intevation.org