[fix][refactor] Fixes and simplifies the bounds calculations in FinPointFigure
This commit is contained in:
parent
69a338f440
commit
04476ecc98
@ -54,10 +54,10 @@ public class FinPointFigure extends AbstractScaleFigure {
|
|||||||
private final FreeformFinSet finset;
|
private final FreeformFinSet finset;
|
||||||
private int modID = -1;
|
private int modID = -1;
|
||||||
|
|
||||||
protected Rectangle2D finBounds_m = null;
|
protected BoundingBox finBounds_m = null;
|
||||||
protected Rectangle2D mountBounds_m = null;
|
protected BoundingBox mountBounds_m = null;
|
||||||
|
|
||||||
protected final List<StateChangeListener> listeners = new LinkedList<StateChangeListener>();
|
protected final List<StateChangeListener> listeners = new LinkedList<>();
|
||||||
|
|
||||||
private Rectangle2D.Double[] finPointHandles = null;
|
private Rectangle2D.Double[] finPointHandles = null;
|
||||||
private int selectedIndex = -1;
|
private int selectedIndex = -1;
|
||||||
@ -199,11 +199,11 @@ public class FinPointFigure extends AbstractScaleFigure {
|
|||||||
|
|
||||||
private void paintBodyTube( Graphics2D g2){
|
private void paintBodyTube( Graphics2D g2){
|
||||||
// in-figure left extent
|
// in-figure left extent
|
||||||
final double xFore = mountBounds_m.getMinX();
|
final double xFore = mountBounds_m.min.x;
|
||||||
// in-figure right extent
|
// in-figure right extent
|
||||||
final double xAft = mountBounds_m.getMaxX();
|
final double xAft = mountBounds_m.max.x;
|
||||||
// in-figure right extent
|
// in-figure right extent
|
||||||
final double yCenter = mountBounds_m.getMinY();
|
final double yCenter = mountBounds_m.min.y;
|
||||||
|
|
||||||
Path2D.Double shape = new Path2D.Double();
|
Path2D.Double shape = new Path2D.Double();
|
||||||
shape.moveTo( xFore, yCenter );
|
shape.moveTo( xFore, yCenter );
|
||||||
@ -357,29 +357,29 @@ public class FinPointFigure extends AbstractScaleFigure {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void updateSubjectDimensions(){
|
protected void updateSubjectDimensions(){
|
||||||
|
|
||||||
// update subject (i.e. Fin) bounds
|
// update subject (i.e. Fin) bounds
|
||||||
finBounds_m = new BoundingBox().update(finset.getFinPoints()).toRectangle();
|
finBounds_m = new BoundingBox().update(finset.getFinPoints());
|
||||||
|
|
||||||
// update to bound the parent body:
|
// update to bound the parent body:
|
||||||
SymmetricComponent parent = (SymmetricComponent)this.finset.getParent();
|
SymmetricComponent parent = (SymmetricComponent)this.finset.getParent();
|
||||||
final double xFinFront = finset.getAxialOffset(AxialMethod.TOP);
|
final double xFinFront = finset.getAxialOffset(AxialMethod.TOP);
|
||||||
final double xParent = -xFinFront;
|
final double xParent = -xFinFront;
|
||||||
final double yParent = -parent.getRadius(xParent); // from parent centerline to fin front.
|
final double yParent = -parent.getRadius(xParent); // from fin-front to parent centerline
|
||||||
final double rParent = Math.max(parent.getForeRadius(), parent.getAftRadius());
|
final double rParent = Math.max(parent.getForeRadius(), parent.getAftRadius());
|
||||||
mountBounds_m = new Rectangle2D.Double( xParent, yParent, parent.getLength(), rParent);
|
|
||||||
|
|
||||||
final double xMinBounds = Math.min(xParent, finBounds_m.getMinX());
|
mountBounds_m = new BoundingBox()
|
||||||
final double yMinBounds = Math.min(xParent, finBounds_m.getMinY());
|
.update(new Coordinate(xParent, yParent, 0))
|
||||||
final double subjectWidth = Math.max( xFinFront + finBounds_m.getWidth(), parent.getLength());
|
.update(new Coordinate(xParent + parent.getLength(), yParent + rParent));
|
||||||
final double subjectHeight = Math.max( 2*rParent, rParent + finBounds_m.getHeight());
|
|
||||||
subjectBounds_m = new Rectangle2D.Double( xMinBounds, yMinBounds, subjectWidth, subjectHeight);
|
final BoundingBox combinedBounds = new BoundingBox().update(finBounds_m).update(mountBounds_m);
|
||||||
|
|
||||||
|
subjectBounds_m = combinedBounds.toRectangle();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void updateCanvasOrigin() {
|
protected void updateCanvasOrigin() {
|
||||||
final int finHeight = (int)(finBounds_m.getHeight()*scale);
|
final int finHeight = (int)(finBounds_m.span().y*scale);
|
||||||
final int mountHeight = (int)(mountBounds_m.getHeight()*scale);
|
final int mountHeight = (int)(mountBounds_m.span().y*scale);
|
||||||
final int finFrontX = (int)(subjectBounds_m.getX()*scale);
|
final int finFrontX = (int)(subjectBounds_m.getX()*scale);
|
||||||
final int subjectHeight = (int)(subjectBounds_m.getHeight()*scale);
|
final int subjectHeight = (int)(subjectBounds_m.getHeight()*scale);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user