Search in sources :

Example 76 with Element

use of org.eclipse.xtext.parsetree.impl.bug305397.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 77 with Element

use of org.eclipse.xtext.parsetree.impl.bug305397.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 78 with Element

use of org.eclipse.xtext.parsetree.impl.bug305397.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 79 with Element

use of org.eclipse.xtext.parsetree.impl.bug305397.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)

Example 80 with Element

use of org.eclipse.xtext.parsetree.impl.bug305397.Element in project JMRI by JMRI.

the class PositionablePolygonXml method store.

/**
     * Default implementation for storing the contents of a PositionableShape
     *
     * @param o Object to store, of type PositionableShape
     * @return Element containing the complete info
     */
@Override
public Element store(Object o) {
    PositionablePolygon p = (PositionablePolygon) o;
    if (!p.isActive()) {
        // if flagged as inactive, don't store
        return null;
    }
    Element element = new Element("positionablePolygon");
    storeCommonAttributes(p, element);
    element.addContent(storePath(p));
    element.setAttribute("class", "jmri.jmrit.display.controlPanelEditor.shape.configurexml.PositionablePolygonXml");
    return element;
}
Also used : Element(org.jdom2.Element) PositionablePolygon(jmri.jmrit.display.controlPanelEditor.shape.PositionablePolygon)

Aggregations

Element (org.jdom2.Element)829 Attribute (org.jdom2.Attribute)76 Document (org.jdom2.Document)75 Test (org.junit.Test)70 File (java.io.File)53 ArrayList (java.util.ArrayList)45 JDOMException (org.jdom2.JDOMException)37 IOException (java.io.IOException)34 HashMap (java.util.HashMap)28 NamedIcon (jmri.jmrit.catalog.NamedIcon)27 List (java.util.List)26 XmlFile (jmri.jmrit.XmlFile)24 SAXBuilder (org.jdom2.input.SAXBuilder)21 Turnout (jmri.Turnout)20 DataConversionException (org.jdom2.DataConversionException)20 DocType (org.jdom2.DocType)19 Editor (jmri.jmrit.display.Editor)18 XMLOutputter (org.jdom2.output.XMLOutputter)18 Namespace (org.jdom2.Namespace)17 Point (java.awt.Point)15