use of org.openmuc.jasn1.compiler.pkix1explicit88.Attribute in project JMRI by JMRI.
the class DefaultCatalogTreeManagerXml method addLeaves.
private void addLeaves(Element element, CatalogTreeNode node) {
List<Element> leafList = element.getChildren("leaf");
for (int i = 0; i < leafList.size(); i++) {
Element elem = leafList.get(i);
Attribute attr = elem.getAttribute("name");
if (attr == null) {
log.error("unexpected null leaf name. elem= " + elem + ", attrs= " + elem.getAttributes());
continue;
}
String name = attr.getValue();
attr = elem.getAttribute("path");
if (attr == null) {
log.error("unexpected null leaf path. elem= " + elem + ", attrs= " + elem.getAttributes());
continue;
}
String path = attr.getValue();
// use the method that maintains the same order
node.addLeaf(new CatalogTreeLeaf(name, path, 0));
}
}
use of org.openmuc.jasn1.compiler.pkix1explicit88.Attribute in project JMRI by JMRI.
the class PositionableLabelXml method loadCommonAttributes.
public void loadCommonAttributes(Positionable l, int defaultLevel, Element element) {
Attribute a = element.getAttribute("forcecontroloff");
if ((a != null) && a.getValue().equals("true")) {
l.setControlling(false);
} else {
l.setControlling(true);
}
// find coordinates
int x = 0;
int y = 0;
try {
x = element.getAttribute("x").getIntValue();
y = element.getAttribute("y").getIntValue();
} catch (org.jdom2.DataConversionException e) {
log.error("failed to convert positional attribute");
}
l.setLocation(x, y);
// find display level
int level = defaultLevel;
try {
level = element.getAttribute("level").getIntValue();
} catch (org.jdom2.DataConversionException e) {
log.warn("Could not parse level attribute!");
} catch (NullPointerException e) {
// considered normal if the attribute not present
}
l.setDisplayLevel(level);
a = element.getAttribute("hidden");
if ((a != null) && a.getValue().equals("yes")) {
l.setHidden(true);
l.setVisible(false);
}
a = element.getAttribute("positionable");
if ((a != null) && a.getValue().equals("true")) {
l.setPositionable(true);
} else {
l.setPositionable(false);
}
a = element.getAttribute("showtooltip");
if ((a != null) && a.getValue().equals("true")) {
l.setShowTooltip(true);
} else {
l.setShowTooltip(false);
}
a = element.getAttribute("editable");
if ((a != null) && a.getValue().equals("true")) {
l.setEditable(true);
} else {
l.setEditable(false);
}
a = element.getAttribute("degrees");
if (a != null && l instanceof PositionableLabel) {
try {
int deg = a.getIntValue();
((PositionableLabel) l).setDegrees(deg);
} catch (org.jdom2.DataConversionException dce) {
}
}
Element elem = element.getChild("tooltip");
if (elem == null) {
// pre JMRI 3.5.2
elem = element.getChild("toolTip");
}
if (elem != null) {
ToolTip tip = l.getTooltip();
if (tip != null) {
tip.setText(elem.getText());
}
}
}
use of org.openmuc.jasn1.compiler.pkix1explicit88.Attribute in project JMRI by JMRI.
the class MultiSensorIconXml method load.
/**
* Create a PositionableLabel, then add to a target JLayeredPane
*
* @param element Top level Element to unpack.
* @param o an Editor an Object
*/
@Override
public void load(Element element, Object o) {
Editor pe = (Editor) o;
MultiSensorIcon l = new MultiSensorIcon(pe);
// create the objects
int rotation = 0;
try {
rotation = element.getAttribute("rotate").getIntValue();
} catch (org.jdom2.DataConversionException e) {
} catch (NullPointerException e) {
// considered normal if the attributes are not present
}
NamedIcon icon = loadSensorIcon("inactive", rotation, l, element, pe);
if (icon != null) {
l.setInactiveIcon(icon);
} else {
return;
}
icon = loadSensorIcon("unknown", rotation, l, element, pe);
if (icon != null) {
l.setUnknownIcon(icon);
} else {
return;
}
icon = loadSensorIcon("inconsistent", rotation, l, element, pe);
if (icon != null) {
l.setInconsistentIcon(icon);
} else {
return;
}
Attribute a = element.getAttribute("updown");
if ((a != null) && a.getValue().equals("true")) {
l.setUpDown(true);
} else {
l.setUpDown(false);
}
// get the icon pairs & load
List<Element> items = element.getChildren();
for (int i = 0; i < items.size(); i++) {
// get the class, hence the adapter object to do loading
Element item = items.get(i);
if (item.getAttribute("sensor") != null) {
String sensor = item.getAttribute("sensor").getValue();
if (item.getAttribute("url") != null) {
String name = item.getAttribute("url").getValue();
icon = NamedIcon.getIconByName(name);
if (icon == null) {
icon = pe.loadFailed("MultiSensor \"" + l.getNameString() + "\" ", name);
if (icon == null) {
log.error("MultiSensor \"" + l.getNameString() + "\" removed for url= " + name);
return;
}
}
try {
int deg = 0;
a = item.getAttribute("degrees");
if (a != null) {
deg = a.getIntValue();
double scale = 1.0;
a = item.getAttribute("scale");
if (a != null) {
scale = item.getAttribute("scale").getDoubleValue();
}
icon.setLoad(deg, scale, l);
}
if (deg == 0) {
a = item.getAttribute("rotate");
if (a != null) {
rotation = a.getIntValue();
icon.setRotation(rotation, l);
}
}
} catch (org.jdom2.DataConversionException dce) {
}
} else {
String name = item.getAttribute("icon").getValue();
icon = NamedIcon.getIconByName(name);
if (icon == null) {
icon = pe.loadFailed("MultiSensor \"" + l.getNameString(), name);
if (icon == null) {
log.info("MultiSensor \"" + l.getNameString() + " removed for url= " + name);
return;
}
}
if (rotation != 0) {
icon.setRotation(rotation, l);
}
}
l.addEntry(sensor, icon);
}
}
pe.putItem(l);
// load individual item's option settings after editor has set its global settings
loadCommonAttributes(l, Editor.SENSORS, element);
}
use of org.openmuc.jasn1.compiler.pkix1explicit88.Attribute in project JMRI by JMRI.
the class PositionableLabelXml method loadIcon.
public NamedIcon loadIcon(PositionableLabel l, String attrName, Element element, String name, Editor ed) {
NamedIcon icon = getNamedIcon(attrName, element, name, ed);
if (icon != null) {
try {
int deg = 0;
double scale = 1.0;
Element elem = element.getChild(attrName);
if (elem != null) {
Attribute a = elem.getAttribute("degrees");
if (a != null) {
deg = a.getIntValue();
}
a = elem.getAttribute("scale");
if (a != null) {
scale = elem.getAttribute("scale").getDoubleValue();
}
icon.setLoad(deg, scale, l);
if (deg == 0) {
// "rotate" attribute is JMRI 2.9.3 and before
a = elem.getAttribute("rotate");
if (a != null) {
int rotation = a.getIntValue();
// 2.9.3 and before, only unscaled icons rotate
if (scale == 1.0) {
icon.setRotation(rotation, l);
}
}
// "rotation" element is JMRI 2.9.4 and after
Element e = elem.getChild("rotation");
if (e != null) {
// ver 2.9.4 allows orthogonal rotations of scaled icons
int rotation = Integer.parseInt(e.getText());
icon.setRotation(rotation, l);
}
}
}
} catch (org.jdom2.DataConversionException dce) {
}
}
return icon;
}
use of org.openmuc.jasn1.compiler.pkix1explicit88.Attribute in project JMRI by JMRI.
the class SensorIconXml 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) {
Editor ed = (Editor) o;
SensorIcon l;
String name;
Attribute attr = element.getAttribute("sensor");
if (attr == null) {
log.error("incorrect information for sensor; must use sensor name");
ed.loadFailed();
return;
} else {
name = attr.getValue();
}
_icon = true;
if (element.getAttribute("icon") != null) {
String yesno = element.getAttribute("icon").getValue();
if ((yesno != null) && (!yesno.equals(""))) {
if (yesno.equals("yes")) {
_icon = true;
} else if (yesno.equals("no")) {
_icon = false;
}
}
}
if (_icon) {
l = new SensorIcon(new NamedIcon("resources/icons/smallschematics/tracksegments/circuit-error.gif", "resources/icons/smallschematics/tracksegments/circuit-error.gif"), ed);
} else {
l = new SensorIcon(" ", ed);
}
int rotation = 0;
try {
rotation = element.getAttribute("rotate").getIntValue();
} catch (org.jdom2.DataConversionException e) {
} catch (NullPointerException e) {
// considered normal if the attributes are not present
}
if (loadSensorIcon("active", rotation, l, element, name, ed) == null) {
return;
}
if (loadSensorIcon("inactive", rotation, l, element, name, ed) == null) {
return;
}
if (loadSensorIcon("unknown", rotation, l, element, name, ed) == null) {
return;
}
if (loadSensorIcon("inconsistent", rotation, l, element, name, ed) == null) {
return;
}
Element elem = element.getChild("iconmaps");
if (elem != null) {
attr = elem.getAttribute("family");
if (attr != null) {
l.setFamily(attr.getValue());
}
}
Attribute a = element.getAttribute("momentary");
if ((a != null) && a.getValue().equals("true")) {
l.setMomentary(true);
} else {
l.setMomentary(false);
}
loadTextInfo(l, element);
l.setSensor(name);
ed.putItem(l);
// load individual item's option settings after editor has set its global settings
loadCommonAttributes(l, Editor.SENSORS, element);
if (l.isIcon() && l.getText() != null) {
l.setOpaque(false);
}
}
Aggregations