use of org.eclipse.xtext.parsetree.reconstr.bug302128.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;
}
use of org.eclipse.xtext.parsetree.reconstr.bug302128.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);
}
use of org.eclipse.xtext.parsetree.reconstr.bug302128.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;
}
use of org.eclipse.xtext.parsetree.reconstr.bug302128.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()));
}
use of org.eclipse.xtext.parsetree.reconstr.bug302128.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;
}
Aggregations