teichmann@5863: /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde teichmann@5863: * Software engineering by Intevation GmbH teichmann@5863: * teichmann@5994: * This file is Free Software under the GNU AGPL (>=v3) teichmann@5863: * and comes with ABSOLUTELY NO WARRANTY! Check out the teichmann@5994: * documentation coming with Dive4Elements River for details. teichmann@5863: */ teichmann@5863: teichmann@5831: package org.dive4elements.river.exports; ingo@1986: ingo@1986: ingo@1986: import org.w3c.dom.Document; ingo@1986: import org.w3c.dom.Element; ingo@1986: import org.w3c.dom.Node; ingo@1986: teichmann@5831: import org.dive4elements.artifactdatabase.state.Attribute; ingo@1986: ingo@1986: ingo@1986: /** ingo@1986: * @author Ingo Weinzierl ingo@1986: */ ingo@2058: public class AxisSection extends TypeSection { ingo@1986: aheinecke@7597: public static final String IDENTIFIER_ATTR = "id"; aheinecke@7597: public static final String LABEL_ATTR = "label"; aheinecke@7597: public static final String SUGGESTED_LABEL_ATTR = "suggested-label"; aheinecke@7597: public static final String FONTSIZE_ATTR = "font-size"; aheinecke@7597: public static final String FIXATION_ATTR = "fixation"; aheinecke@7597: public static final String UPPERRANGE_ATTR = "upper"; aheinecke@7597: public static final String LOWERRANGE_ATTR = "lower"; andre@8455: public static final String UPPERRANGE_TIME_ATTR = "upper-time"; andre@8455: public static final String LOWERRANGE_TIME_ATTR = "lower-time"; ingo@1991: ingo@1991: ingo@1991: public AxisSection() { ingo@1991: super("axis"); ingo@1991: } ingo@1991: ingo@1991: ingo@1991: public void setIdentifier(String identifier) { ingo@2058: setStringValue(IDENTIFIER_ATTR, identifier); ingo@1991: } ingo@1991: ingo@1991: ingo@2050: public String getIdentifier() { ingo@2058: return getStringValue(IDENTIFIER_ATTR); ingo@2050: } ingo@2050: ingo@2050: ingo@1991: public void setLabel(String label) { ingo@2058: setStringValue(LABEL_ATTR, label); ingo@1986: } ingo@1986: ingo@1986: ingo@2051: public String getLabel() { ingo@2058: return getStringValue(LABEL_ATTR); ingo@2051: } ingo@2051: ingo@2051: aheinecke@7597: public void setSuggestedLabel(String label) { aheinecke@7597: setStringValue(SUGGESTED_LABEL_ATTR, label); aheinecke@7597: } aheinecke@7597: aheinecke@7597: aheinecke@7597: public String getSuggestedLabel() { aheinecke@7597: return getStringValue(SUGGESTED_LABEL_ATTR); aheinecke@7597: } aheinecke@7597: ingo@1992: public void setFontSize(int fontSize) { ingo@1992: if (fontSize <= 0) { ingo@1992: return; ingo@1992: } ingo@1992: ingo@2058: setIntegerValue(FONTSIZE_ATTR, fontSize); ingo@1992: } ingo@1992: ingo@1992: ingo@2053: public Integer getFontSize() { ingo@2058: return getIntegerValue(FONTSIZE_ATTR); ingo@2053: } ingo@2053: ingo@2053: ingo@1992: public void setFixed(boolean fixed) { ingo@2058: setBooleanValue(FIXATION_ATTR, fixed); ingo@1992: } ingo@1992: ingo@1992: gernotbelger@9123: public boolean isFixed() { gernotbelger@9123: return getBooleanValue(FIXATION_ATTR, false); ingo@2050: } ingo@2050: ingo@2050: ingo@1992: public void setUpperRange(double upperRange) { ingo@2058: setDoubleValue(UPPERRANGE_ATTR, upperRange); ingo@1992: } ingo@1992: ingo@1992: ingo@2050: public Double getUpperRange() { ingo@2058: return getDoubleValue(UPPERRANGE_ATTR); ingo@2050: } ingo@2050: ingo@2050: ingo@1992: public void setLowerRange(double lowerRange) { ingo@2058: setDoubleValue(LOWERRANGE_ATTR, lowerRange); ingo@1992: } ingo@1992: ingo@1992: ingo@2050: public Double getLowerRange() { ingo@2058: return getDoubleValue(LOWERRANGE_ATTR); ingo@2050: } ingo@2050: andre@8455: public void setUpperTimeRange(long upperRange) { andre@8455: setStringValue(UPPERRANGE_TIME_ATTR, Long.toString(upperRange)); andre@8455: } andre@8455: andre@8455: /* return the upper time rang limit as a long value that can be converted andre@8455: * to a date. If none is set null is returned. */ andre@8455: public Long getUpperTimeRange() { andre@8455: try { andre@8455: return Long.valueOf(getStringValue(UPPERRANGE_TIME_ATTR)); andre@8455: } catch (NumberFormatException e) { andre@8455: return null; andre@8455: } andre@8455: } andre@8455: andre@8455: public void setLowerTimeRange(long lowerRange) { andre@8455: setStringValue(LOWERRANGE_TIME_ATTR, Long.toString(lowerRange)); andre@8455: } andre@8455: andre@8455: /* See getUpperTimeRange */ andre@8455: public Long getLowerTimeRange() { andre@8455: try { andre@8455: return Long.valueOf(getStringValue(LOWERRANGE_TIME_ATTR)); andre@8455: } catch (NumberFormatException e) { andre@8455: return null; andre@8455: } andre@8455: } andre@8455: andre@8455: ingo@2050: ingo@1986: @Override ingo@1986: public void toXML(Node parent) { ingo@1986: Document owner = parent.getOwnerDocument(); ingo@1986: Element axis = owner.createElement("axis"); ingo@1986: ingo@1986: parent.appendChild(axis); ingo@1986: ingo@1986: for (String key: getKeys()) { ingo@1986: Attribute attr = getAttribute(key); ingo@1986: attr.toXML(axis); ingo@1986: } ingo@1986: } ingo@1986: } ingo@1986: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :