Search in sources :

Example 81 with Element

use of org.neo4j.ogm.domain.gh806.Element in project JMRI by JMRI.

the class RpsPositionIconXml method store.

/**
     * Default implementation for storing the contents of a RpsPositionIcon
     *
     * @param o Object to store, of type RpsPositionIcon
     * @return Element containing the complete info
     */
@Override
public Element store(Object o) {
    RpsPositionIcon p = (RpsPositionIcon) o;
    if (!p.isActive()) {
        // if flagged as inactive, don't store
        return null;
    }
    Element element = new Element("sensoricon");
    storeCommonAttributes(p, element);
    // include contents
    element.setAttribute("active", p.getActiveIcon().getURL());
    element.setAttribute("error", p.getErrorIcon().getURL());
    element.setAttribute("rotate", String.valueOf(p.getActiveIcon().getRotation()));
    element.setAttribute("momentary", p.getMomentary() ? "true" : "false");
    element.setAttribute("sxscale", "" + p.getXScale());
    element.setAttribute("syscale", "" + p.getYScale());
    element.setAttribute("sxorigin", "" + p.getXOrigin());
    element.setAttribute("syorigin", "" + p.getYOrigin());
    element.setAttribute("showid", p.isShowID() ? "true" : "false");
    if (p.getFilter() != null) {
        element.setAttribute("filter", "" + p.getFilter());
    }
    element.addContent(storeIcon("active", p.getActiveIcon()));
    element.addContent(storeIcon("error", p.getErrorIcon()));
    element.setAttribute("class", "jmri.jmrit.display.configurexml.RpsPositionIconXml");
    return element;
}
Also used : Element(org.jdom2.Element) RpsPositionIcon(jmri.jmrit.display.RpsPositionIcon)

Example 82 with Element

use of org.neo4j.ogm.domain.gh806.Element in project JMRI by JMRI.

the class SignalHeadIconXml method store.

/**
     * Default implementation for storing the contents of a SignalHeadIcon
     *
     * @param o Object to store, of type SignalHeadIcon
     * @return Element containing the complete info
     */
@Override
public Element store(Object o) {
    SignalHeadIcon p = (SignalHeadIcon) o;
    if (!p.isActive()) {
        // if flagged as inactive, don't store
        return null;
    }
    Element element = new Element("signalheadicon");
    element.setAttribute("signalhead", "" + p.getNamedSignalHead().getName());
    storeCommonAttributes(p, element);
    element.setAttribute("clickmode", "" + p.getClickMode());
    element.setAttribute("litmode", "" + p.getLitMode());
    Element elem = new Element("icons");
    NamedIcon icon = p.getIcon(rbean.getString("SignalHeadStateHeld"));
    if (icon != null) {
        elem.addContent(storeIcon("held", icon));
    }
    icon = p.getIcon(rbean.getString("SignalHeadStateDark"));
    if (icon != null) {
        elem.addContent(storeIcon("dark", icon));
    }
    icon = p.getIcon(rbean.getString("SignalHeadStateRed"));
    if (icon != null) {
        elem.addContent(storeIcon("red", icon));
    }
    icon = p.getIcon(rbean.getString("SignalHeadStateYellow"));
    if (icon != null) {
        elem.addContent(storeIcon("yellow", icon));
    }
    icon = p.getIcon(rbean.getString("SignalHeadStateGreen"));
    if (icon != null) {
        elem.addContent(storeIcon("green", icon));
    }
    icon = p.getIcon(rbean.getString("SignalHeadStateLunar"));
    if (icon != null) {
        elem.addContent(storeIcon("lunar", icon));
    }
    icon = p.getIcon(rbean.getString("SignalHeadStateFlashingRed"));
    if (icon != null) {
        elem.addContent(storeIcon("flashred", icon));
    }
    icon = p.getIcon(rbean.getString("SignalHeadStateFlashingYellow"));
    if (icon != null) {
        elem.addContent(storeIcon("flashyellow", icon));
    }
    icon = p.getIcon(rbean.getString("SignalHeadStateFlashingGreen"));
    if (icon != null) {
        elem.addContent(storeIcon("flashgreen", icon));
    }
    icon = p.getIcon(rbean.getString("SignalHeadStateFlashingLunar"));
    if (icon != null) {
        elem.addContent(storeIcon("flashlunar", icon));
    }
    element.addContent(elem);
    elem = new Element("iconmaps");
    String family = p.getFamily();
    if (family != null) {
        elem.setAttribute("family", family);
    }
    element.addContent(elem);
    element.setAttribute("class", "jmri.jmrit.display.configurexml.SignalHeadIconXml");
    return element;
}
Also used : NamedIcon(jmri.jmrit.catalog.NamedIcon) Element(org.jdom2.Element) SignalHeadIcon(jmri.jmrit.display.SignalHeadIcon)

Example 83 with Element

use of org.neo4j.ogm.domain.gh806.Element in project JMRI by JMRI.

the class PositionableRectangleXml method load.

/**
     * Create a PositionableShape, then add to a target JLayeredPane
     *
     * @param element Top level Element to unpack.
     * @param o       Editor as an Object
     */
@Override
public void load(Element element, Object o) {
    // create the objects
    Editor ed = (Editor) o;
    PositionableRectangle ps = new PositionableRectangle(ed);
    Element elem = element.getChild("size");
    ps.setWidth(getInt(elem, "width"));
    ps.setHeight(getInt(elem, "height"));
    ed.putItem(ps);
    // load individual item's option settings after editor has set its global settings
    loadCommonAttributes(ps, Editor.MARKERS, element);
}
Also used : PositionableRectangle(jmri.jmrit.display.controlPanelEditor.shape.PositionableRectangle) Element(org.jdom2.Element) Editor(jmri.jmrit.display.Editor)

Example 84 with Element

use of org.neo4j.ogm.domain.gh806.Element in project JMRI by JMRI.

the class PositionableShapeXml method storeColor.

public Element storeColor(String name, Color c) {
    if (c == null) {
        return null;
    }
    Element elem = new Element(name);
    elem.setAttribute("red", "" + c.getRed());
    elem.setAttribute("green", "" + c.getGreen());
    elem.setAttribute("blue", "" + c.getBlue());
    elem.setAttribute("alpha", "" + c.getAlpha());
    return elem;
}
Also used : Element(org.jdom2.Element)

Example 85 with Element

use of org.neo4j.ogm.domain.gh806.Element in project JMRI by JMRI.

the class PositionableShapeXml method storeCommonAttributes.

/**
     * Default implementation for storing the common contents
     *
     * @param element Element in which contents are stored
     */
public void storeCommonAttributes(PositionableShape p, Element element) {
    element.setAttribute("x", "" + p.getX());
    element.setAttribute("y", "" + p.getY());
    element.setAttribute("level", String.valueOf(p.getDisplayLevel()));
    element.setAttribute("forcecontroloff", !p.isControlling() ? "true" : "false");
    element.setAttribute("hidden", p.isHidden() ? "yes" : "no");
    element.setAttribute("positionable", p.isPositionable() ? "true" : "false");
    element.setAttribute("showtooltip", p.showTooltip() ? "true" : "false");
    element.setAttribute("editable", p.isEditable() ? "true" : "false");
    ToolTip tip = p.getTooltip();
    String txt = tip.getText();
    if (txt != null) {
        Element elem = new Element("toolTip").addContent(txt);
        element.addContent(elem);
    }
    if (p.getDegrees() != 0) {
        element.setAttribute("degrees", "" + p.getDegrees());
    }
    Element elem = storeColor("lineColor", p.getLineColor());
    if (elem != null) {
        element.addContent(elem);
    }
    elem = storeColor("fillColor", p.getFillColor());
    if (elem != null) {
        element.addContent(elem);
    }
    element.setAttribute("lineWidth", "" + p.getLineWidth());
    NamedBeanHandle<Sensor> handle = p.getControlSensorHandle();
    if (handle != null) {
        element.setAttribute("controlSensor", handle.getName());
    }
    element.setAttribute("hideOnSensor", p.isHideOnSensor() ? "true" : "false");
    element.setAttribute("changeLevelOnSensor", String.valueOf(p.getChangeLevel()));
}
Also used : ToolTip(jmri.jmrit.display.ToolTip) Element(org.jdom2.Element) Sensor(jmri.Sensor)

Aggregations

Element (org.jdom2.Element)3327 Document (org.jdom2.Document)502 Test (org.junit.Test)457 ArrayList (java.util.ArrayList)327 IOException (java.io.IOException)268 Attribute (org.jdom2.Attribute)207 JDOMException (org.jdom2.JDOMException)202 Element (org.osate.aadl2.Element)143 Namespace (org.jdom2.Namespace)136 Test (org.junit.jupiter.api.Test)131 List (java.util.List)130 SAXBuilder (org.jdom2.input.SAXBuilder)125 File (java.io.File)124 HashMap (java.util.HashMap)117 XMLOutputter (org.jdom2.output.XMLOutputter)103 XConfiguration (org.apache.oozie.util.XConfiguration)98 Configuration (org.apache.hadoop.conf.Configuration)96 NamedElement (org.osate.aadl2.NamedElement)77 StringReader (java.io.StringReader)67 Iterator (java.util.Iterator)63