view flys-artifacts/src/main/java/de/intevation/flys/exports/AxisSection.java @ 2019:aa3e7ed1fa46

Added theme defaults for areas, added facets to compatibility matrices. flys-artifacts/trunk@3474 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Tue, 20 Dec 2011 06:39:20 +0000
parents e1c9f28e2675
children c4e0e433f825
line wrap: on
line source
package de.intevation.flys.exports;


import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;

import de.intevation.artifactdatabase.state.Attribute;
import de.intevation.artifactdatabase.state.DefaultSection;


/**
 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
 */
public class AxisSection extends DefaultSection {

    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() {
        super("axis");
    }


    public void setIdentifier(String identifier) {
        if (identifier == null || identifier.length() == 0) {
            return;
        }

        Attribute attr = getAttribute(IDENTIFIER_ATTR);
        if (attr == null) {
            attr = new StringAttribute(IDENTIFIER_ATTR, identifier, false);
            addAttribute(IDENTIFIER_ATTR, attr);
        }
        else {
            attr.setValue(identifier);
        }
    }


    public void setLabel(String label) {
        if (label == null) {
            return;
        }

        Attribute attr = getAttribute(LABEL_ATTR);
        if (attr == null) {
            attr = new StringAttribute(LABEL_ATTR, label, true);
            addAttribute(LABEL_ATTR, attr);
        }
        else {
            attr.setValue(label);
        }
    }


    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();
        Element   axis = owner.createElement("axis");

        parent.appendChild(axis);

        for (String key: getKeys()) {
            Attribute attr = getAttribute(key);
            attr.toXML(axis);
        }
    }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org