# HG changeset patch # User Ingo Weinzierl # Date 1324020497 0 # Node ID e1c9f28e2675147feb2234975d31d9492a0039e9 # Parent 0bd7c3cf0af167a166a1fa220c78882e3a2da768 Added more attributes to ChartSettings AxisSection. flys-artifacts/trunk@3428 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 0bd7c3cf0af1 -r e1c9f28e2675 flys-artifacts/ChangeLog --- 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 + + * 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 * src/main/java/de/intevation/flys/exports/AxisSection.java: Added methods diff -r 0bd7c3cf0af1 -r e1c9f28e2675 flys-artifacts/src/main/java/de/intevation/flys/exports/AxisSection.java --- 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(); diff -r 0bd7c3cf0af1 -r e1c9f28e2675 flys-artifacts/src/main/java/de/intevation/flys/exports/DoubleAttribute.java --- /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 Ingo Weinzierl + */ +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 + * type with value double. + * + * @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 : diff -r 0bd7c3cf0af1 -r e1c9f28e2675 flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java --- 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); }