use of com.zhan_dui.utils.m3u8.Element in project JMRI by JMRI.
the class QuadOutputSignalHeadXml method store.
/**
* Default implementation for storing the contents of a QuadOutputSignalHead
*
* @param o Object to store, of type TripleTurnoutSignalHead
* @return Element containing the complete info
*/
@Override
public Element store(Object o) {
QuadOutputSignalHead p = (QuadOutputSignalHead) o;
Element element = new Element("signalhead");
element.setAttribute("class", this.getClass().getName());
element.addContent(new Element("systemName").addContent(p.getSystemName()));
storeCommon(p, element);
element.addContent(addTurnoutElement(p.getGreen(), "green"));
element.addContent(addTurnoutElement(p.getYellow(), "yellow"));
element.addContent(addTurnoutElement(p.getRed(), "red"));
element.addContent(addTurnoutElement(p.getLunar(), "lunar"));
return element;
}
use of com.zhan_dui.utils.m3u8.Element in project JMRI by JMRI.
the class DoubleTurnoutSignalHeadXml method store.
/**
* Default implementation for storing the contents of a
* DoubleTurnoutSignalHead
*
* @param o Object to store, of type TripleTurnoutSignalHead
* @return Element containing the complete info
*/
@Override
public Element store(Object o) {
DoubleTurnoutSignalHead p = (DoubleTurnoutSignalHead) o;
Element element = new Element("signalhead");
element.setAttribute("class", this.getClass().getName());
element.addContent(new Element("systemName").addContent(p.getSystemName()));
storeCommon(p, element);
element.addContent(addTurnoutElement(p.getGreen(), "green"));
element.addContent(addTurnoutElement(p.getRed(), "red"));
return element;
}
use of com.zhan_dui.utils.m3u8.Element in project JMRI by JMRI.
the class DccSignalMastXml method loadCommonDCCMast.
protected boolean loadCommonDCCMast(DccSignalMast m, Element element) {
loadCommon(m, element);
if (element.getChild("unlit") != null) {
Element unlit = element.getChild("unlit");
if (unlit.getAttribute("allowed") != null) {
if (unlit.getAttribute("allowed").getValue().equals("no")) {
m.setAllowUnLit(false);
} else {
m.setAllowUnLit(true);
m.setUnlitId(Integer.parseInt(unlit.getChild("aspect").getValue()));
}
}
}
List<Element> list = element.getChildren("aspect");
for (int i = 0; i < list.size(); i++) {
Element e = list.get(i);
String aspect = e.getAttribute("defines").getValue();
int number = -1;
try {
String value = e.getChild("number").getValue();
number = Integer.parseInt(value);
} catch (Exception ex) {
log.error("failed to convert DCC number");
}
m.setOutputForAppearance(aspect, number);
}
Element e = element.getChild("disabledAspects");
if (e != null) {
list = e.getChildren("disabledAspect");
for (Element aspect : list) {
m.setAspectDisabled(aspect.getText());
}
}
InstanceManager.getDefault(jmri.SignalMastManager.class).register(m);
return true;
}
use of com.zhan_dui.utils.m3u8.Element in project JMRI by JMRI.
the class VirtualSignalMastXml method load.
@Override
public boolean load(Element shared, Element perNode) {
VirtualSignalMast m;
String sys = getSystemName(shared);
m = new jmri.implementation.VirtualSignalMast(sys);
if (getUserName(shared) != null) {
m.setUserName(getUserName(shared));
}
loadCommon(m, shared);
if (shared.getChild("unlit") != null) {
Element unlit = shared.getChild("unlit");
if (unlit.getAttribute("allowed") != null) {
if (unlit.getAttribute("allowed").getValue().equals("no")) {
m.setAllowUnLit(false);
} else {
m.setAllowUnLit(true);
}
}
}
Element e = shared.getChild("disabledAspects");
if (e != null) {
List<Element> list = e.getChildren("disabledAspect");
for (Element aspect : list) {
m.setAspectDisabled(aspect.getText());
}
}
InstanceManager.getDefault(jmri.SignalMastManager.class).register(m);
return true;
}
use of com.zhan_dui.utils.m3u8.Element in project JMRI by JMRI.
the class DefaultCatalogTreeManagerXml method loadNode.
/**
* Recursively load a CatalogTree.
*
* @param element element containing the node to load
* @param parent the parent node of the node in element
* @param model the tree model containing the tree to add the node to
*/
public void loadNode(Element element, CatalogTreeNode parent, DefaultTreeModel model) {
List<Element> nodeList = element.getChildren("node");
if (log.isDebugEnabled()) {
log.debug("Found " + nodeList.size() + " CatalogTreeNode objects");
}
for (int i = 0; i < nodeList.size(); i++) {
Element elem = nodeList.get(i);
Attribute attr = elem.getAttribute("nodeName");
if (attr == null) {
log.warn("unexpected null nodeName. elem= " + elem + ", attrs= " + elem.getAttributes());
continue;
}
String nodeName = attr.getValue();
CatalogTreeNode n = new CatalogTreeNode(nodeName);
addLeaves(elem, n);
model.insertNodeInto(n, parent, parent.getChildCount());
loadNode(elem, n, model);
}
}
Aggregations