Search in sources :

Example 1 with PositionableRoundRect

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

the class PositionableRoundRectXml 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;
    PositionableRoundRect ps = new PositionableRoundRect(ed);
    Element elem = element.getChild("size");
    ps.setWidth(getInt(elem, "width"));
    ps.setHeight(getInt(elem, "height"));
    ps.setCornerRadius(getInt(elem, "cornerRadius"));
    ed.putItem(ps);
    // load individual item's option settings after editor has set its global settings
    loadCommonAttributes(ps, Editor.MARKERS, element);
}
Also used : Element(org.jdom2.Element) PositionableRoundRect(jmri.jmrit.display.controlPanelEditor.shape.PositionableRoundRect) Editor(jmri.jmrit.display.Editor)

Example 2 with PositionableRoundRect

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

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

Aggregations

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