Skip to content

Commit

Permalink
Remove redundant isValid logic
Browse files Browse the repository at this point in the history
  • Loading branch information
geowar1 committed May 25, 2020
1 parent 43d8639 commit 6a660b5
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions java/src/jmri/jmrit/display/layoutEditor/TrackSegment.java
Expand Up @@ -750,23 +750,11 @@ public Rectangle2D getBounds() {
boolean isValid = (getConnect1() != null) && (getConnect2() != null);

if (isValid && isCircle()) {
//if these have been defined...
if (isValid) {
calculateTrackSegmentAngle();
Arc2D arc = new Arc2D.Double(getCX(), getCY(), getCW(), getCH(), getStartAdj(), getTmpAngle(), Arc2D.OPEN);
result = arc.getBounds2D();
}
calculateTrackSegmentAngle();
Arc2D arc = new Arc2D.Double(getCX(), getCY(), getCW(), getCH(), getStartAdj(), getTmpAngle(), Arc2D.OPEN);
result = arc.getBounds2D();
} else if (isValid && isBezier()) {
//if these have been defined...
if (isValid) {
result = MathUtil.getBezierBounds(getBezierPoints());
} else {
//otherwise fake it with just the control points
result = MathUtil.setOrigin(result, bezierControlPoints.get(0));
for (int idx = 1; idx < bezierControlPoints.size(); idx++) {
result.add(bezierControlPoints.get(idx));
}
}
result = MathUtil.getBezierBounds(getBezierPoints());
} else {
if (getConnect1() != null) {
result.add(LayoutEditor.getCoords(getConnect1(), getType1()));
Expand Down

0 comments on commit 6a660b5

Please sign in to comment.