[fix] fixed stack overflow in RocketFigure

This commit is contained in:
Daniel_M_Williams 2020-07-03 10:40:35 -04:00
parent 04476ecc98
commit 7c20b64135

View File

@ -407,33 +407,36 @@ public class RocketFigure extends AbstractScaleFigure {
} }
/** /**
* Gets the bounds of the drawn subject in Model-Space * Gets the bounds of the drawn subject in Model-Space
* *
* i.e. the maximum extents in the selected dimensions. * i.e. the maximum extents in the selected dimensions.
* The bounds are stored in the variables minX, maxX and maxR. * The bounds are stored in the variables minX, maxX and maxR.
* *
* @return * @return
*/ */
@Override @Override
protected void updateSubjectDimensions() { protected void updateSubjectDimensions() {
// calculate bounds, and store in class variables // calculate bounds, and store in class variables
final BoundingBox bounds = rocket.getSelectedConfiguration().getBoundingBox(); BoundingBox newBounds = rocket.getSelectedConfiguration().getBoundingBox();
final double maxR = Math.max(Math.hypot(bounds.min.y, bounds.min.z), if(newBounds.isEmpty())
Math.hypot(bounds.max.y, bounds.max.z)); newBounds = new BoundingBox(Coordinate.ZERO,Coordinate.X_UNIT);
switch (currentViewType) { final double maxR = Math.max(Math.hypot(newBounds.min.y, newBounds.min.z),
case SideView: Math.hypot(newBounds.max.y, newBounds.max.z));
subjectBounds_m = new Rectangle2D.Double(bounds.min.x, -maxR, bounds.span().x, 2 * maxR);
break; switch (currentViewType) {
case BackView: case SideView:
subjectBounds_m = new Rectangle2D.Double(-maxR, -maxR, 2 * maxR, 2 * maxR); subjectBounds_m = new Rectangle2D.Double(newBounds.min.x, -maxR, newBounds.span().x, 2 * maxR);
break; break;
default: case BackView:
throw new BugException("Illegal figure type = " + currentViewType); subjectBounds_m = new Rectangle2D.Double(-maxR, -maxR, 2 * maxR, 2 * maxR);
} break;
} default:
throw new BugException("Illegal figure type = " + currentViewType);
}
}
/** /**
* Calculates the necessary size of the figure and set the PreferredSize * Calculates the necessary size of the figure and set the PreferredSize
* property accordingly. * property accordingly.