@DefaultAnnotation({})

Package jmri.jmrit.display.layoutEditor

Layout Editor currently represents both structure and graphical display through a single set of objects. Work is proceeding to separate those out and provide clean interfaces for other packages to access the structural information.

Example

A small example layout:
Simple layout example

Connectivity

This is coded and stored as the following: (Some graphical attributes removed, reordered)
    <layoutturnout ident="TO1" type="RH_TURNOUT" continuing="2" ver="1" connectaname="T3" connectbname="T2" connectcname="T1" class="jmri.jmrit.display.layoutEditor.configurexml.LayoutTurnoutXml" />
    <layoutturnout ident="TO2" type="LH_TURNOUT" continuing="2" ver="1" connectaname="T4" connectbname="T2" connectcname="T1" class="jmri.jmrit.display.layoutEditor.configurexml.LayoutTurnoutXml" />
    <tracksegment ident="T1" connect1name="TO1" type1="TURNOUT_C" connect2name="TO2" type2="TURNOUT_C" class="jmri.jmrit.display.layoutEditor.configurexml.TrackSegmentXml" />
    <tracksegment ident="T2" connect1name="TO1" type1="TURNOUT_B" connect2name="TO2" type2="TURNOUT_B" class="jmri.jmrit.display.layoutEditor.configurexml.TrackSegmentXml" />
    <tracksegment ident="T3" connect1name="EB1" type1="POS_POINT" connect2name="TO1" type2="TURNOUT_A" class="jmri.jmrit.display.layoutEditor.configurexml.TrackSegmentXml" />
    <tracksegment ident="T4" connect1name="TO2" type1="TURNOUT_A" connect2name="EC1" type2="POS_POINT" class="jmri.jmrit.display.layoutEditor.configurexml.TrackSegmentXml" />
    <positionablepoint ident="EB1" type="END_BUMPER" connect1name="T3" class="jmri.jmrit.display.layoutEditor.configurexml.PositionablePointXml" />
    <positionablepoint ident="EC1" type="EDGE_CONNECTOR" connect1name="T4" linkedpanel="" linkpointid="" class="jmri.jmrit.display.layoutEditor.configurexml.PositionablePointXml" />

Example interconnections

For TrackSegment objects, a connection is represented by the name of the other end, and the type (in type2 or type2) of the connection at the other end. For example, a connection in object T1 to a turnout might give the turnouts TO1 name, and that the connection is to the TURNOUT_C leg of that turnout.

Connections to END BUMPERs and EDGE CONNECTORs don't quite fit that. The far end sees the connection to the EB and EC as to a POS_POINT, not specifically a END BUMPER or EDGE CONNECTOR. There's no type1 value representing the far end of the connection from the EB and EC either. But the EB and EC PositionablePoint knows what itself is through its type variable, and that can be queried by following the link as there's only one connection to a PositionablePoint.

Turnouts also have a type variable to represent their geometry, i.e. RH, LH, Wye, etc.

Internals

Class Hierarchy

Class Relationships

The LayoutBlock class is at the heart of the navigation web for layout-representing objects.
UML class diagram for track objects

GUI

The Layout Editor window consists of a menu bar and an upper tool-bar that are all made with (basically) standard Swing components. Below that is a JPane containing the layout drawing itself.

The LayoutTrackView tree defines draw1 and draw2 methods that draw two different representations of the track elements. These are only invoked from {}@link jmri.jmrit.display.layoutEditor.LayoutEditorComponent}. LayoutEditorComponent is a JComponent with a LayoutEditorComponent.paint(java.awt.Graphics) public method that invokes a series of internal private methods to display the layers of the layout drawing. That in turn is invoked via the usual repaint() mechanism, although it's often kicked off by a call to LayoutEditor.redrawPanel(). Each of those layer private methods sets up graphics and method options, then calls LayoutEditorComponent.draw1(java.awt.Graphics2D, boolean, boolean, boolean) or LayoutEditorComponent.draw2(java.awt.Graphics2D, boolean, float). Those in turn loop through a list from LayoutEditor.getLayoutTracks() calling their individual LayoutTrackView.draw1(java.awt.Graphics2D, boolean, boolean) and LayoutTrackView.draw1(java.awt.Graphics2D, boolean, boolean) methods.


MVC object diagram
The goal is a MVC-like structure, with modifications to account for the mix of swing components and AWT-style paint operations.

Persistance

The classes that have ConfigureXML partner classes are: Only LayoutBlockManager and LayoutEditor are registered with the ConfigureManager.

LayoutBlockManager is stored and loaded in the usual manager way, including the LayoutBlock objects. They are stored with the configuration information because they can be used on multiple LayoutPanels.

LayoutEditorXml handles the storing and loading of all the track and icon objects. It is stored at the user level ("Store Panels...")

A BlockValueFile stores and loads the value (internal temporary contents) of Block objects from the BlockManager. It doesn't reference LayoutBlock objects.

More Info

User-level documentation is available here.

(If these Javadoc were created with UML, the full-scale package diagram is also available.)

Link to UML diagram

See Also:
jmri.jmrit.entryexit, Section