Search in sources :

Example 1 with PositionableRectangle

use of jmri.jmrit.display.controlPanelEditor.shape.PositionableRectangle 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 2 with PositionableRectangle

use of jmri.jmrit.display.controlPanelEditor.shape.PositionableRectangle in project JMRI by JMRI.

the class PositionableRectangleXml 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) {
    PositionableRectangle p = (PositionableRectangle) o;
    if (!p.isActive()) {
        // if flagged as inactive, don't store
        return null;
    }
    Element element = new Element("positionableRectangle");
    storeCommonAttributes(p, element);
    Element elem = new Element("size");
    elem.setAttribute("width", "" + p.getWidth());
    elem.setAttribute("height", "" + p.getHeight());
    element.addContent(elem);
    element.setAttribute("class", "jmri.jmrit.display.controlPanelEditor.shape.configurexml.PositionableRectangleXml");
    return element;
}
Also used : PositionableRectangle(jmri.jmrit.display.controlPanelEditor.shape.PositionableRectangle) Element(org.jdom2.Element)

Aggregations

PositionableRectangle (jmri.jmrit.display.controlPanelEditor.shape.PositionableRectangle)2 Element (org.jdom2.Element)2 Editor (jmri.jmrit.display.Editor)1