Skip to content

Commit

Permalink
keep TODO in Git
Browse files Browse the repository at this point in the history
  • Loading branch information
bobjacobsen committed Apr 30, 2020
1 parent 629e1fb commit 488e918
Showing 1 changed file with 228 additions and 0 deletions.
228 changes: 228 additions & 0 deletions java/src/jmri/jmrit/display/layoutEditor/TODO_migration.md
@@ -0,0 +1,228 @@
This is a fast-evolving list of items for the restructuring of the display.layoutEditor package.
It's in no particular order, items are removed as done, so please don't consider it documentation.

----

## MVC work
- make a diagram for documentation

- *View, LayoutEditorDialogs/*Editor need a complete set of clases
Still to do (mark off when present)
View: LayoutTrack.java LayoutTurntable.java LevelXing.java LayoutTurnout.java LayoutWye.java
LayoutLHTurnout.java LayoutRHTurnout.java
LayoutSlip.java LayoutSingleSlip.java LayoutDoubleSlip.java
LayoutXOver.java LayoutDoubleXOver.java LayoutLHXOver.java LayoutRHXOver.java

Editor: LayoutTurntable.java LevelXing.java LayoutTurnout.java LayoutWye.java
LayoutLHTurnout.java LayoutRHTurnout.java
LayoutSlip.java LayoutSingleSlip.java LayoutDoubleSlip.java
LayoutXOver.java LayoutDoubleXOver.java LayoutLHXOver.java LayoutRHXOver.java
(The e)

MVC: LayoutEditorComponent is the JComponent
gets data from LE with
layoutEditor.getLayoutTracks()
List<LayoutTrack> getLayoutTracks()

layoutEditor.getPositionablePoints()
List<PositionablePoint> getPositionablePoints()

layoutEditor.getLayoutShapes()
(future problem)


## Code Pushes

- Operational code in the LayoutTrack tree needs to be pushed up and down.

isDisconnected in LayoutTrack (base) and PositionablePoint (subclass) seem very different;
do they actually do the same thing? Want to make one final implementation if possible.


- setConnection is similar in
LayoutTurnout, LayoutSlip, LevelXing

- Why is this considered common code by CI?
import static java.lang.Float.POSITIVE_INFINITY;


## Minor Cleanups

- Add a NUM_ARROW_TYPES constant for use in TrackSegment.java, PositionablePoint.java

- LayoutTurnoutTest was taken whole into the test subtypes, should be sorted out to have type-specific tests in subclasses (to reduce duplication)



==================

TrackSegment HIDECON as an EnumSet
https://docs.oracle.com/javase/7/docs/api/java/util/EnumSet.html

public enum Style {
BOLD, ITALIC, UNDERLINE, STRIKETHROUGH
}

public static void main(String[] args) {
final EnumSet<Style> styles = EnumSet.noneOf(Style.class);
styles.addAll(EnumSet.range(Style.BOLD, Style.STRIKETHROUGH)); // enable all constants
styles.removeAll(EnumSet.of(Style.UNDERLINE, Style.STRIKETHROUGH)); // disable a couple
assert EnumSet.of(Style.BOLD, Style.ITALIC).equals(styles); // check set contents are correct
System.out.println(styles);
}
--
public enum Flag {
UPPERCASE, REVERSE, FULL_STOP, EMPHASISE;

public static final EnumSet<Flag> ALL_OPTS = EnumSet.allOf(Flag.class);
}


if (flags.contains(Flag.UPPERCASE)) value = value.toUpperCase();

EnumSet.of(Flag.UPPERCASE))
EnumSet.of(Flag.FULL_STOP, Flag.EMPHASISE)

============
% grep "nothing to see" *.java (Multiple copies removed below)
LayoutEditorChecks.java: //nothing to see here... move along...
LayoutTurntable.java: // nothing to see here, move along...
LevelXing.java: // nothing to see here... move along...
PositionablePoint.java: //nothing to see here... move along...
TrackSegment.java: //nothing to see here, move along
TrackSegment.java: //nothing to see here, move along


=============
The LayoutTrack classes ($LETRK) use these from LayoutEditor
layoutEditor.setDirty();
layoutEditor.redrawPanel(); {just calls repaint?} see .paintTargetPanel abstract in ../Editor; LayoutEditor extends PanelEditor
layoutEditor.repaint()
layoutEditor.getLETools(). {lots of stuff}
layoutEditor.getLEAuxTools(). {lots of stuff}
layoutEditor.getFinder().{lots of stuff}
layoutEditor.getLayoutEditorToolBarPanel()

layoutEditor.setShowAlignmentMenu(popup)
layoutEditor.isEditable()
layoutEditor.getZoom()
layoutEditor.getTargetPanel()

layoutEditor.circleDiameter
layoutEditor.circleRadius

layoutEditor.isTurnoutDrawUnselectedLeg

layoutEditor.getXOverLong()
layoutEditor.getXOverHWid()
layoutEditor.getXOverShort()
layoutEditor.setXOverLong
layoutEditor.setXOverHWid
layoutEditor.setXOverShort

layoutEditor.isTurnoutFillControlCircles
LayoutEditor.SIZE * layoutEditor.getTurnoutCircleSize();

layoutEditor.layoutEditorControlRectAt(getCoordsA())
layoutEditor. setSelectionRect

layoutEditor.getXScale()
layoutEditor.getYScale()

layoutEditor.setTurnoutBX
layoutEditor.setTurnoutCX
layoutEditor.setTurnoutWid

layoutEditor.getFinder()

layoutEditor.removeLayoutSlip
layoutEditor.removeLayoutTurnout
if (canRemove() && layoutEditor.removeLevelXing(LevelXing.this))

layoutEditor.setLink
layoutEditor.addAnchor

layoutEditor.getLayoutTrackDrawingOptions()

layoutEditor.getLayoutTrackEditors()
layoutEditor.getLayoutTracks()

layoutEditor.selectedObject
layoutEditor.prevSelectedObject

To understand the above, probably have to move the listener definitions out.

% grep Listener $LETRK | awk '{print $1}' | uniq -c
8 LayoutTurntable.java:
1 LevelXing.java:
1 PositionablePoint.java:import
21 PositionablePoint.java:
49 TrackSegment.java:
13 LayoutTurnout.java:
11 LayoutSlip.java:

Mostly addActionListener via ()->, some named listeners, some addPropertyChangeListener

=============

Example from LayoutEditor

if ((lt.getConnectD() == null) && (lt.isTurnoutTypeXover() || lt.isTurnoutTypeSlip())) {
if (lt instanceof LayoutSlip) {
beginHitPointType = HitPointType.SLIP_D;
} else {
beginHitPointType = HitPointType.TURNOUT_D;
}
dLoc = lt.getCoordsD();
hitPointCheckLayoutTurnoutSubs(dLoc);
}

Should that be a "getBeginHitPoint"?

(Scan for instanceOf)

---------

Example from LayoutEditor (What's that stuff at the top selecting?)

case TURNOUT_A:
case TURNOUT_B:
case TURNOUT_C:
case TURNOUT_D:
case SLIP_A:
case SLIP_B:
case SLIP_C:
case SLIP_D: {
LayoutTurnout ft = (LayoutTurnout) foundTrack;
addTrackSegment();

if ((ft.getTurnoutType() == LayoutTurnout.TurnoutType.RH_TURNOUT) || (ft.getTurnoutType() == LayoutTurnout.TurnoutType.LH_TURNOUT)) {
rotateTurnout(ft);
}

// Assign a block to the new zero length track segment.
ft.setTrackSegmentBlock(foundHitPointType, true);
break;
}

What are we _not_ rotating the other types? Is this a conditional thing somehow?
(check rotateTurnout method a few lines down which does a similar check and returns, but might be called from elsewhere)

---------

Figure this one out! At least part of the comments is wrong...
TrackSegment 436
/**
* {@inheritDoc}
* <p>
* This implementation returns null because {@link #getConnect1} and
* {@link #getConnect2} should be used instead.
*/
//only implemented here to suppress "does not override abstract method " error in compiler
@Override
public LayoutTrack getConnection(HitPointType connectionType) throws jmri.JmriException {
//nothing to see here, move along
throw new jmri.JmriException("Use getConnect1() or getConnect2() instead.");
}

(Searching for "nothing to see here" is interesting)

0 comments on commit 488e918

Please sign in to comment.