/** * Load, starting with the layoutblock element, then all the value-icon pairs * * @param element Top level Element to unpack. * @param o LayoutEditor as an Object */ public void load(Element element, Object o) { // create the objects LayoutEditor p = (LayoutEditor) o; // get attributes String name = element.getAttribute("ident").getValue(); int type = PositionablePoint.ANCHOR; double x = 0.0; double y = 0.0; try { x = element.getAttribute("x").getFloatValue(); y = element.getAttribute("y").getFloatValue(); type = element.getAttribute("type").getIntValue(); } catch (org.jdom2.DataConversionException e) { log.error("failed to convert positionablepoint attribute"); } // create the new PositionablePoint PositionablePoint l = new PositionablePoint(name, type, new Point2D.Double(x, y), p); // get remaining attributes Attribute a = element.getAttribute("connect1name"); if (a != null) { l.trackSegment1Name = a.getValue(); } a = element.getAttribute("connect2name"); if (a != null) { l.trackSegment2Name = a.getValue(); } a = element.getAttribute("eastboundsignal"); if (a != null) { l.setEastBoundSignal(a.getValue()); } a = element.getAttribute("westboundsignal"); if (a != null) { l.setWestBoundSignal(a.getValue()); } a = element.getAttribute("eastboundsignalmast"); if (a != null) { l.setEastBoundSignalMast(a.getValue()); } a = element.getAttribute("westboundsignalmast"); if (a != null) { l.setWestBoundSignalMast(a.getValue()); } a = element.getAttribute("eastboundsensor"); if (a != null) { l.setEastBoundSensor(a.getValue()); } a = element.getAttribute("westboundsensor"); if (a != null) { l.setWestBoundSensor(a.getValue()); } if (type == PositionablePoint.EDGE_CONNECTOR && element.getAttribute("linkedpanel") != null && element.getAttribute("linkpointid") != null) { String linkedEditorName = element.getAttribute("linkedpanel").getValue(); LayoutEditor linkedEditor = (LayoutEditor) jmri.jmrit.display.PanelMenu.instance().getEditorByName(linkedEditorName); if (linkedEditor != null) { String linkedPoint = element.getAttribute("linkpointid").getValue(); for (PositionablePoint point : linkedEditor.pointList) { if (point.getType() == PositionablePoint.EDGE_CONNECTOR && point.getID().equals(linkedPoint)) { point.setLinkedPoint(l); l.setLinkedPoint(point); break; } } } } p.pointList.add(l); }