use of org.openmuc.jasn1.compiler.pkix1explicit88.Attribute in project JMRI by JMRI.
the class JsonServerPreferences method load.
public void load(Element child) {
Attribute a;
a = child.getAttribute(HEARTBEAT_INTERVAL);
if (a != null) {
try {
this.setHeartbeatInterval(a.getIntValue());
this.asLoadedHeartbeatInterval = this.getHeartbeatInterval();
} catch (DataConversionException e) {
this.setHeartbeatInterval(15000);
log.error("Unable to read heartbeat interval. Setting to default value.", e);
}
}
a = child.getAttribute(PORT);
if (a != null) {
try {
this.setPort(a.getIntValue());
this.asLoadedPort = this.getPort();
} catch (DataConversionException e) {
this.setPort(2056);
log.error("Unable to read port. Setting to default value.", e);
}
}
}
use of org.openmuc.jasn1.compiler.pkix1explicit88.Attribute in project JMRI by JMRI.
the class DefaultCatalogTreeManagerXml method loadCatalogTrees.
/**
* Utility method to load the individual CatalogTree objects.
*
* @param catalogTrees element containing trees
*/
public void loadCatalogTrees(Element catalogTrees) {
List<Element> catList = catalogTrees.getChildren("catalogTree");
if (log.isDebugEnabled()) {
log.debug("loadCatalogTrees: found " + catList.size() + " CatalogTree objects");
}
CatalogTreeManager mgr = InstanceManager.getDefault(jmri.CatalogTreeManager.class);
for (int i = 0; i < catList.size(); i++) {
Element elem = catList.get(i);
Attribute attr = elem.getAttribute("systemName");
if (attr == null) {
log.warn("unexpected null systemName. elem= " + elem + ", attrs= " + elem.getAttributes());
continue;
}
String sysName = attr.getValue();
String userName;
attr = elem.getAttribute("userName");
if (attr == null) {
log.warn("unexpected null userName. attrs= " + elem.getAttributes());
continue;
} else {
userName = attr.getValue();
}
DefaultTreeModel ct = (DefaultTreeModel) mgr.getBySystemName(sysName);
if (ct != null) {
// tree already registered
continue;
}
ct = (DefaultTreeModel) mgr.newCatalogTree(sysName, userName);
if (log.isDebugEnabled()) {
log.debug("CatalogTree: sysName= " + sysName + ", userName= " + userName);
}
CatalogTreeNode root = (CatalogTreeNode) ct.getRoot();
elem = elem.getChild("node");
loadNode(elem, root, ct);
}
}
use of org.openmuc.jasn1.compiler.pkix1explicit88.Attribute in project JMRI by JMRI.
the class SignalHeadIconXml method load.
/**
* Create a PositionableLabel, then add to a target JLayeredPane
*
* @param element Top level Element to unpack.
* @param o an Editor as an Object
*/
@Override
public void load(Element element, Object o) {
// create the objects
Editor ed = (Editor) o;
SignalHeadIcon l = new SignalHeadIcon(ed);
String name;
Attribute attr = element.getAttribute("signalhead");
if (attr == null) {
log.error("incorrect information for signal head; must use signalhead name");
ed.loadFailed();
return;
} else {
name = attr.getValue();
}
SignalHead sh = jmri.InstanceManager.getDefault(jmri.SignalHeadManager.class).getSignalHead(name);
if (sh != null) {
l.setSignalHead(name);
} else {
log.error("SignalHead named '" + attr.getValue() + "' not found.");
// ed.loadFailed();
return;
}
int rotation = 0;
try {
attr = element.getAttribute("rotate");
rotation = attr.getIntValue();
} catch (org.jdom2.DataConversionException e) {
} catch (NullPointerException e) {
// considered normal if the attributes are not present
}
List<Element> aspects = element.getChildren();
if (aspects.size() > 0) {
Element icons = element.getChild("icons");
Element elem = element;
if (icons != null) {
List<Element> c = icons.getChildren();
aspects = c;
elem = icons;
}
for (int i = 0; i < aspects.size(); i++) {
String aspect = aspects.get(i).getName();
NamedIcon icon = loadIcon(l, aspect, elem, "SignalHead \"" + name + "\": icon \"" + aspect + "\" ", ed);
if (icon != null) {
l.setIcon(_nameMap.get(aspect), icon);
} else {
log.info("SignalHead \"" + name + "\": icon \"" + aspect + "\" removed");
}
}
log.debug(aspects.size() + " icons loaded for " + l.getNameString());
} else {
// old style as attributes - somewhere around pre 2.5.4
NamedIcon icon = loadSignalIcon("red", rotation, l, element, name, ed);
if (icon != null) {
l.setIcon(rbean.getString("SignalHeadStateRed"), icon);
}
icon = loadSignalIcon("yellow", rotation, l, element, name, ed);
if (icon != null) {
l.setIcon(rbean.getString("SignalHeadStateYellow"), icon);
}
icon = loadSignalIcon("green", rotation, l, element, name, ed);
if (icon != null) {
l.setIcon(rbean.getString("SignalHeadStateGreen"), icon);
}
icon = loadSignalIcon("lunar", rotation, l, element, name, ed);
if (icon != null) {
l.setIcon(rbean.getString("SignalHeadStateLunar"), icon);
}
icon = loadSignalIcon("held", rotation, l, element, name, ed);
if (icon != null) {
l.setIcon(rbean.getString("SignalHeadStateHeld"), icon);
}
icon = loadSignalIcon("dark", rotation, l, element, name, ed);
if (icon != null) {
l.setIcon(rbean.getString("SignalHeadStateDark"), icon);
}
icon = loadSignalIcon("flashred", rotation, l, element, name, ed);
if (icon != null) {
l.setIcon(rbean.getString("SignalHeadStateFlashingRed"), icon);
}
icon = loadSignalIcon("flashyellow", rotation, l, element, name, ed);
if (icon != null) {
l.setIcon(rbean.getString("SignalHeadStateFlashingYellow"), icon);
}
icon = loadSignalIcon("flashgreen", rotation, l, element, name, ed);
if (icon != null) {
l.setIcon(rbean.getString("SignalHeadStateFlashingGreen"), icon);
}
icon = loadSignalIcon("flashlunar", rotation, l, element, name, ed);
if (icon != null) {
l.setIcon(rbean.getString("SignalHeadStateFlashingLunar"), icon);
}
}
Element elem = element.getChild("iconmaps");
if (elem != null) {
attr = elem.getAttribute("family");
if (attr != null) {
l.setFamily(attr.getValue());
}
}
try {
attr = element.getAttribute("clickmode");
if (attr != null) {
l.setClickMode(attr.getIntValue());
}
} catch (org.jdom2.DataConversionException e) {
log.error("Failed on clickmode attribute: " + e);
}
try {
attr = element.getAttribute("litmode");
if (attr != null) {
l.setLitMode(attr.getBooleanValue());
}
} catch (org.jdom2.DataConversionException e) {
log.error("Failed on litmode attribute: " + e);
}
ed.putItem(l);
// load individual item's option settings after editor has set its global settings
loadCommonAttributes(l, Editor.SIGNALS, element);
}
use of org.openmuc.jasn1.compiler.pkix1explicit88.Attribute in project JMRI by JMRI.
the class SignalMastIconXml method load.
/**
* Create a SignalMastIcon, then add
*
* @param element Top level Element to unpack.
* @param o an Editor as an Object
*/
@Override
public void load(Element element, Object o) {
// create the objects
Editor ed = (Editor) o;
SignalMastIcon l = new SignalMastIcon(ed);
String name;
Attribute attr;
/*
* We need to set the rotation and scaling first, prior to setting the
* signalmast, otherwise we end up in a situation where by the icons do
* not get rotated or scaled correctly.
**/
try {
int rotation = 0;
double scale = 1.0;
// former attribute name.
attr = element.getAttribute("rotation");
if (attr != null) {
rotation = attr.getIntValue();
}
attr = element.getAttribute("degrees");
if (attr != null) {
rotation = attr.getIntValue();
}
l.rotate(rotation);
attr = element.getAttribute("scale");
String text = "Error attr null";
if (attr != null) {
scale = attr.getDoubleValue();
text = attr.getValue();
}
l.setScale(scale);
if (log.isDebugEnabled()) {
log.debug("Load SignalMast rotation= " + rotation + " scale= " + scale + " attr text= " + text);
}
} catch (org.jdom2.DataConversionException e) {
log.error("failed to convert rotation or scale attribute");
}
attr = element.getAttribute("signalmast");
if (attr == null) {
log.error("incorrect information for signal mast; must use signalmast name");
ed.loadFailed();
return;
} else {
name = attr.getValue();
if (log.isDebugEnabled()) {
log.debug("Load SignalMast " + name);
}
}
SignalMast sh = jmri.InstanceManager.getDefault(jmri.SignalMastManager.class).getSignalMast(name);
if (sh != null) {
l.setSignalMast(name);
} else {
log.error("SignalMast named '" + attr.getValue() + "' not found.");
ed.loadFailed();
// return;
}
attr = element.getAttribute("imageset");
if (attr != null) {
l.useIconSet(attr.getValue());
}
attr = element.getAttribute("imageset");
if (attr != null) {
l.useIconSet(attr.getValue());
}
try {
attr = element.getAttribute("clickmode");
if (attr != null) {
l.setClickMode(attr.getIntValue());
}
} catch (org.jdom2.DataConversionException e) {
log.error("Failed on clickmode attribute: " + e);
}
try {
attr = element.getAttribute("litmode");
if (attr != null) {
l.setLitMode(attr.getBooleanValue());
}
} catch (org.jdom2.DataConversionException e) {
log.error("Failed on litmode attribute: " + e);
}
ed.putItem(l);
// load individual item's option settings after editor has set its global settings
loadCommonAttributes(l, Editor.SIGNALS, element);
}
use of org.openmuc.jasn1.compiler.pkix1explicit88.Attribute in project JMRI by JMRI.
the class LayoutSlipXml method load.
/**
* Load, starting with the LayoutSlip element, then all the other data
*
* @param element Top level Element to unpack.
* @param o LayoutEditor as an Object
*/
@Override
public void load(Element element, Object o) {
// create the objects
LayoutEditor p = (LayoutEditor) o;
// get center point
String name = element.getAttribute("ident").getValue();
double x = 0.0;
double y = 0.0;
try {
x = element.getAttribute("xcen").getFloatValue();
y = element.getAttribute("ycen").getFloatValue();
} catch (org.jdom2.DataConversionException e) {
log.error("failed to convert layoutslip center attribute");
}
int type = LayoutSlip.SINGLE_SLIP;
try {
type = element.getAttribute("slipType").getIntValue();
} catch (org.jdom2.DataConversionException e) {
log.error("failed to convert layoutslip type attribute");
}
// create the new LayoutSlip
LayoutSlip l = new LayoutSlip(name, new Point2D.Double(x, y), 0.0, p, type);
// get remaining attributes
Attribute a = element.getAttribute("blockname");
if (a != null) {
l.tBlockName = a.getValue();
}
a = element.getAttribute("connectaname");
if (a != null) {
l.connectAName = a.getValue();
}
a = element.getAttribute("connectbname");
if (a != null) {
l.connectBName = a.getValue();
}
a = element.getAttribute("connectcname");
if (a != null) {
l.connectCName = a.getValue();
}
a = element.getAttribute("connectdname");
if (a != null) {
l.connectDName = a.getValue();
}
l.setSignalA1Name(getElement(element, "signala1name"));
l.setSignalB1Name(getElement(element, "signalb1name"));
l.setSignalC1Name(getElement(element, "signalc1name"));
l.setSignalD1Name(getElement(element, "signald1name"));
l.setSignalA2Name(getElement(element, "signala2name"));
l.setSignalB2Name(getElement(element, "signalb2name"));
l.setSignalC2Name(getElement(element, "signalc2name"));
l.setSignalD2Name(getElement(element, "signald2name"));
try {
x = element.getAttribute("xa").getFloatValue();
y = element.getAttribute("ya").getFloatValue();
} catch (org.jdom2.DataConversionException e) {
log.error("failed to convert LayoutSlip a coords attribute");
}
l.setCoordsA(new Point2D.Double(x, y));
try {
x = element.getAttribute("xb").getFloatValue();
y = element.getAttribute("yb").getFloatValue();
} catch (org.jdom2.DataConversionException e) {
log.error("failed to convert LayoutSlip b coords attribute");
}
l.setCoordsB(new Point2D.Double(x, y));
l.setSignalAMast(getElement(element, "signalAMast"));
l.setSignalBMast(getElement(element, "signalBMast"));
l.setSignalCMast(getElement(element, "signalCMast"));
l.setSignalDMast(getElement(element, "signalDMast"));
l.setSensorA(getElement(element, "sensorA"));
l.setSensorB(getElement(element, "sensorB"));
l.setSensorC(getElement(element, "sensorC"));
l.setSensorD(getElement(element, "sensorD"));
l.setTurnout(getElement(element, "turnout"));
l.setTurnoutB(getElement(element, "turnoutB"));
if (element.getChild("states") != null) {
Element state = element.getChild("states");
if (state.getChild("A-C") != null) {
Element ac = state.getChild("A-C");
l.setTurnoutStates(LayoutSlip.STATE_AC, ac.getChild("turnout").getText(), ac.getChild("turnoutB").getText());
}
if (state.getChild("A-D") != null) {
Element ad = state.getChild("A-D");
l.setTurnoutStates(LayoutSlip.STATE_AD, ad.getChild("turnout").getText(), ad.getChild("turnoutB").getText());
}
if (state.getChild("B-D") != null) {
Element bd = state.getChild("B-D");
l.setTurnoutStates(LayoutSlip.STATE_BD, bd.getChild("turnout").getText(), bd.getChild("turnoutB").getText());
}
if (state.getChild("B-C") != null) {
Element bc = state.getChild("B-C");
l.setTurnoutStates(LayoutSlip.STATE_BC, bc.getChild("turnout").getText(), bc.getChild("turnoutB").getText());
}
}
p.slipList.add(l);
}
Aggregations