Skip to content

Commit

Permalink
Travis-ci fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
geowar1 committed Apr 13, 2020
1 parent 4323a6e commit 50cc542
Show file tree
Hide file tree
Showing 11 changed files with 349 additions and 285 deletions.
23 changes: 17 additions & 6 deletions java/src/jmri/jmrit/display/layoutEditor/ConnectivityUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public List<LayoutTrackExpectedState<LayoutTurnout>> getTurnoutList(
trackSegment = null;
prevConnectTrack = xt;
switch (lc.getXoverBoundaryType()) {
case LayoutConnectivity.XOVER_BOUNDARY_AB:
case LayoutConnectivity.XOVER_BOUNDARY_AB: {
setting = Turnout.CLOSED;
if (((TrackSegment) xt.getConnectA() != null) && (currLayoutBlock == ((TrackSegment) xt.getConnectA()).getLayoutBlock())) {
// block exits Xover at A
Expand All @@ -179,7 +179,8 @@ public List<LayoutTrackExpectedState<LayoutTurnout>> getTurnoutList(
prevConnectType = LayoutEditor.HitPointTypes.TURNOUT_B;
}
break;
case LayoutConnectivity.XOVER_BOUNDARY_CD:
}
case LayoutConnectivity.XOVER_BOUNDARY_CD: {
setting = Turnout.CLOSED;
if (((TrackSegment) xt.getConnectC() != null) && (currLayoutBlock == ((TrackSegment) xt.getConnectC()).getLayoutBlock())) {
// block exits Xover at C
Expand All @@ -191,7 +192,8 @@ public List<LayoutTrackExpectedState<LayoutTurnout>> getTurnoutList(
prevConnectType = LayoutEditor.HitPointTypes.TURNOUT_D;
}
break;
case LayoutConnectivity.XOVER_BOUNDARY_AC:
}
case LayoutConnectivity.XOVER_BOUNDARY_AC: {
if (((TrackSegment) xt.getConnectA() != null) && (currLayoutBlock == ((TrackSegment) xt.getConnectA()).getLayoutBlock())) {
// block exits Xover at A
trackSegment = (TrackSegment) xt.getConnectA();
Expand All @@ -202,7 +204,8 @@ public List<LayoutTrackExpectedState<LayoutTurnout>> getTurnoutList(
prevConnectType = LayoutEditor.HitPointTypes.TURNOUT_C;
}
break;
case LayoutConnectivity.XOVER_BOUNDARY_BD:
}
case LayoutConnectivity.XOVER_BOUNDARY_BD: {
if (((TrackSegment) xt.getConnectB() != null) && (currLayoutBlock == ((TrackSegment) xt.getConnectB()).getLayoutBlock())) {
// block exits Xover at B
trackSegment = (TrackSegment) xt.getConnectB();
Expand All @@ -213,8 +216,11 @@ public List<LayoutTrackExpectedState<LayoutTurnout>> getTurnoutList(
prevConnectType = LayoutEditor.HitPointTypes.TURNOUT_D;
}
break;
default:
}
default: {
log.error("Unhandled crossover boundary type: {}", lc.getXoverBoundaryType());
break;
}
}
result.add(new LayoutTrackExpectedState<>(xt, setting));
notFound = false;
Expand Down Expand Up @@ -329,6 +335,10 @@ else if (LayoutEditor.HitPointTypes.isTurnoutHitType(cType)) {
}
break;
}
default: {
log.warn("Unhandled Level Crossing type: {}", cType);
break;
}
}
} else if (LayoutEditor.HitPointTypes.isTurnoutHitType(cType)) {
// reached a turnout
Expand Down Expand Up @@ -479,9 +489,10 @@ else if (LayoutEditor.HitPointTypes.isTurnoutHitType(cType)) {
trackSegment = null;
}
break;
default:
default: {
log.warn("Unhandled crossover type: {}", cType);
break;
}
}
} else if ((tType == LayoutTurnout.TurnoutType.RH_TURNOUT) || (tType == LayoutTurnout.TurnoutType.LH_TURNOUT)
|| (tType == LayoutTurnout.TurnoutType.WYE_TURNOUT)) {
Expand Down
111 changes: 42 additions & 69 deletions java/src/jmri/jmrit/display/layoutEditor/LayoutEditor.java

Large diffs are not rendered by default.

136 changes: 92 additions & 44 deletions java/src/jmri/jmrit/display/layoutEditor/LayoutTurnout.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,31 +142,104 @@ public enum TurnoutType {
}

/**
* Returns true if this is a turnout or wye, i.e. has a single-track
* entrance end.
* Returns true if this is a turnout (not a crossover or slip)
*
* @param type the turnout type
* @return boolean true if this is a turnout
*/
public static boolean hasEnteringSingleTrack(TurnoutType type) {
public static boolean isTurnoutTypeTurnout(TurnoutType type) {
return (type == TurnoutType.RH_TURNOUT
|| type == TurnoutType.LH_TURNOUT
|| type == TurnoutType.WYE_TURNOUT);
}

public boolean hasEnteringSingleTrack() {
return hasEnteringSingleTrack(getTurnoutType());
/**
* Returns true if this is a turnout (not a crossover or slip)
*
* @param type the turnout type
* @return boolean true if this is a turnout
*/
public boolean isTurnoutTypeTurnout() {
return isTurnoutTypeTurnout(getTurnoutType());
}

/**
* Returns true if this is a slip or crossover, i.e. has double track on the
* entrance end
* Returns true if this is a crossover
*
* @param type the turnout type
* @return boolean true if this is a crossover
*/
public static boolean hasEnteringDoubleTrack(TurnoutType type) {
public static boolean isTurnoutTypeXover(TurnoutType type) {
return (type == TurnoutType.DOUBLE_XOVER
|| type == TurnoutType.RH_XOVER
|| type == TurnoutType.LH_XOVER
|| type == TurnoutType.SINGLE_SLIP
|| type == TurnoutType.LH_XOVER);
}

/**
* Returns true if this is a crossover
*
* @return boolean true if this is a crossover
*/
public boolean isTurnoutTypeXover() {
return hasEnteringDoubleTrack(getTurnoutType());
}

/**
* Returns true if this is a slip
*
* @param type the turnout type
* @return boolean true if this is a slip
*/
public static boolean isTurnoutTypeSlip(TurnoutType type) {
return (type == TurnoutType.SINGLE_SLIP
|| type == TurnoutType.DOUBLE_SLIP);
}

/**
* Returns true if this is a slip
*
* @return boolean true if this is a slip
*/
public boolean isTurnoutTypeSlip() {
return isTurnoutTypeSlip(getTurnoutType());
}

/**
* Returns true if this has a single-track entrance end. (turnout or wye)
*
* @param type the turnout type
* @return boolean true if single track entrance
*/
public static boolean hasEnteringSingleTrack(TurnoutType type) {
return isTurnoutTypeTurnout(type);
}

/**
* Returns true if this has a single-track entrance end. (turnout or wye)
*
* @return boolean true if single track entrance
*/
public boolean hasEnteringSingleTrack() {
return hasEnteringSingleTrack(getTurnoutType());
}

/**
* Returns true if this has double track on the entrance end (crossover or
* slip)
*
* @param type the turnout type
* @return boolean true if double track entrance
*/
public static boolean hasEnteringDoubleTrack(TurnoutType type) {
return isTurnoutTypeXover(type) || isTurnoutTypeSlip(type);
}

/**
* Returns true if this has double track on the entrance end (crossover or
* slip)
*
* @return boolean true if double track entrance
*/
public boolean hasEnteringDoubleTrack() {
return hasEnteringDoubleTrack(getTurnoutType());
}
Expand Down Expand Up @@ -1126,14 +1199,6 @@ public TurnoutType getTurnoutType() {
return type;
}

public boolean isTurnoutTypeXover() {
return ((type == TurnoutType.DOUBLE_XOVER) || (type == TurnoutType.RH_XOVER) || (type == TurnoutType.LH_XOVER));
}

public boolean isTurnoutTypeSlip() {
return ((type == TurnoutType.SINGLE_SLIP) || (type == TurnoutType.DOUBLE_SLIP));
}

public LayoutTrack getConnectA() {
return connectA;
}
Expand Down Expand Up @@ -1236,9 +1301,7 @@ public void setSecondTurnout(@CheckForNull String tName) {
secondNamedTurnout = null;
}
activateTurnout(); // Even if secondary is null, the primary Turnout may still need to be re-activated
if ((getTurnoutType() == TurnoutType.RH_TURNOUT)
|| (getTurnoutType() == TurnoutType.LH_TURNOUT)
|| (getTurnoutType() == TurnoutType.WYE_TURNOUT)) {
if (isTurnoutTypeTurnout()) {
LayoutEditorFindItems lf = layoutEditor.getFinder();
if (oldSecondTurnoutName != null && !oldSecondTurnoutName.isEmpty()) {
Turnout oldTurnout = InstanceManager.turnoutManagerInstance().getTurnout(oldSecondTurnoutName);
Expand Down Expand Up @@ -1414,9 +1477,7 @@ public LayoutBlock getLayoutBlockD() {
}

public Point2D getCoordsA() {
if ((getTurnoutType() == TurnoutType.DOUBLE_XOVER)
|| (getTurnoutType() == TurnoutType.LH_XOVER)
|| (getTurnoutType() == TurnoutType.RH_XOVER)) {
if (isTurnoutTypeXover()) {
if (version == 2) {
return pointA;
}
Expand All @@ -1429,27 +1490,21 @@ public Point2D getCoordsA() {
}

public Point2D getCoordsB() {
if ((version == 2) && ((getTurnoutType() == TurnoutType.DOUBLE_XOVER)
|| (getTurnoutType() == TurnoutType.LH_XOVER)
|| (getTurnoutType() == TurnoutType.RH_XOVER))) {
if ((version == 2) && isTurnoutTypeXover()) {
return pointB;
}
return MathUtil.add(center, dispB);
}

public Point2D getCoordsC() {
if ((version == 2) && ((getTurnoutType() == TurnoutType.DOUBLE_XOVER)
|| (getTurnoutType() == TurnoutType.LH_XOVER)
|| (getTurnoutType() == TurnoutType.RH_XOVER))) {
if ((version == 2) && isTurnoutTypeXover()) {
return pointC;
}
return MathUtil.add(center, dispA);
}

public Point2D getCoordsD() {
if ((version == 2) && ((getTurnoutType() == TurnoutType.DOUBLE_XOVER)
|| (getTurnoutType() == TurnoutType.LH_XOVER)
|| (getTurnoutType() == TurnoutType.RH_XOVER))) {
if ((version == 2) && isTurnoutTypeXover()) {
return pointD;
}
// only allowed for single and double crossovers
Expand Down Expand Up @@ -2533,15 +2588,12 @@ public int getState() {
* @return true if occupied
*/
private boolean isOccupied() {
if ((getTurnoutType() == TurnoutType.RH_TURNOUT)
|| (getTurnoutType() == TurnoutType.LH_TURNOUT)
|| (getTurnoutType() == TurnoutType.WYE_TURNOUT)) {
if (isTurnoutTypeTurnout()) {
if (getLayoutBlock().getOccupancy() == LayoutBlock.OCCUPIED) {
log.debug("Block {} is Occupied", getBlockName());
return true;
}
}
if (isTurnoutTypeXover()) {
} else if (isTurnoutTypeXover()) {
//If the turnout is set for straight over, we need to deal with the straight over connecting blocks
if (getTurnout().getKnownState() == Turnout.CLOSED) {
if ((getLayoutBlock().getOccupancy() == LayoutBlock.OCCUPIED)
Expand Down Expand Up @@ -3025,9 +3077,7 @@ public void actionPerformed(ActionEvent e) {

public String[] getBlockBoundaries() {
final String[] boundaryBetween = new String[4];
if ((getTurnoutType() == TurnoutType.WYE_TURNOUT)
|| (getTurnoutType() == TurnoutType.RH_TURNOUT)
|| (getTurnoutType() == TurnoutType.LH_TURNOUT)) {
if (isTurnoutTypeTurnout()) {
//This should only be needed where we are looking at a single turnout.
if (getLayoutBlock() != null) {
LayoutBlock aLBlock = null;
Expand Down Expand Up @@ -4629,9 +4679,7 @@ protected int getConnectivityStateForLayoutBlocks(
@Override
public void reCheckBlockBoundary() {
if (connectA == null && connectB == null && connectC == null) {
if ((getTurnoutType() == TurnoutType.RH_TURNOUT)
|| (getTurnoutType() == TurnoutType.LH_TURNOUT)
|| (getTurnoutType() == TurnoutType.WYE_TURNOUT)) {
if (isTurnoutTypeTurnout()) {
if (signalAMastNamed != null) {
removeSML(getSignalAMast());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,8 @@ public void load(Element element, Object o) {
type1 = LayoutEditor.HitPointTypes.valueOf(attribute.getValue());
} catch (IllegalArgumentException e) {
try {
int t1 = attribute.getIntValue();
type1 = LayoutEditor.HitPointTypes.getValue(t1);
} catch (DataConversionException e1) {
type1 = LayoutEditor.HitPointTypes.getValue(attribute.getIntValue());
} catch (DataConversionException | NullPointerException e1) {
log.error("failed to convert tracksegment type1 attribute");
}
}
Expand All @@ -259,9 +258,8 @@ public void load(Element element, Object o) {
type2 = LayoutEditor.HitPointTypes.valueOf(attribute.getValue());
} catch (IllegalArgumentException e) {
try {
int t2 = attribute.getIntValue();
type2 = LayoutEditor.HitPointTypes.getValue(t2);
} catch (DataConversionException e1) {
type2 = LayoutEditor.HitPointTypes.getValue(attribute.getIntValue());
} catch (DataConversionException | NullPointerException e1) {
log.error("failed to convert tracksegment type2 attribute");
}
}
Expand Down
Loading

0 comments on commit 50cc542

Please sign in to comment.