Fix fin set template print for curved parent
This commit is contained in:
parent
f907ff186b
commit
5f3cb5a494
@ -977,6 +977,13 @@ public abstract class FinSet extends ExternalComponent implements AxialPositiona
|
|||||||
return getMountPoints( finLead.x, xFinEnd, -finLead.x, -finLead.y);
|
return getMountPoints( finLead.x, xFinEnd, -finLead.x, -finLead.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a list of coordinates defining the geometry of a single fin, including the parent's body points .
|
||||||
|
*/
|
||||||
|
public Coordinate[] getFinPointsWithRoot() {
|
||||||
|
return combineCurves(getFinPoints(), getRootPoints());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a list of X,Y coordinates defining the geometry of a single fin tab.
|
* Return a list of X,Y coordinates defining the geometry of a single fin tab.
|
||||||
* The origin is the leading root edge, and the tab height (or 'depth') is
|
* The origin is the leading root edge, and the tab height (or 'depth') is
|
||||||
@ -1006,8 +1013,7 @@ public abstract class FinSet extends ExternalComponent implements AxialPositiona
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final int pointCount = 5 + rootPoints.size();
|
Coordinate[] tabPoints = new Coordinate[4];
|
||||||
Coordinate[] points = new Coordinate[pointCount];
|
|
||||||
final Coordinate finFront = this.getFinFront();
|
final Coordinate finFront = this.getFinFront();
|
||||||
|
|
||||||
final SymmetricComponent body = (SymmetricComponent)this.getParent();
|
final SymmetricComponent body = (SymmetricComponent)this.getParent();
|
||||||
@ -1022,16 +1028,13 @@ public abstract class FinSet extends ExternalComponent implements AxialPositiona
|
|||||||
yTabBottom = MathUtil.min(yTabFront, yTabTrail) - tabHeight;
|
yTabBottom = MathUtil.min(yTabFront, yTabTrail) - tabHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
points[0] = new Coordinate(xTabFront, yTabFront);
|
tabPoints[0] = new Coordinate(xTabFront, yTabFront);
|
||||||
points[1] = new Coordinate(xTabFront, yTabBottom );
|
tabPoints[1] = new Coordinate(xTabFront, yTabBottom );
|
||||||
points[2] = new Coordinate(xTabTrail, yTabBottom );
|
tabPoints[2] = new Coordinate(xTabTrail, yTabBottom );
|
||||||
points[3] = new Coordinate(xTabTrail, yTabTrail);
|
tabPoints[3] = new Coordinate(xTabTrail, yTabTrail);
|
||||||
for (int i = 0; i < rootPoints.size(); i++) {
|
rootPoints.add(0, new Coordinate(xTabFront, yTabFront));
|
||||||
points[i + 4] = rootPoints.get(rootPoints.size() - 1 - i);
|
|
||||||
}
|
|
||||||
points[pointCount - 1] = new Coordinate(xTabFront, yTabFront);
|
|
||||||
|
|
||||||
return points;
|
return combineCurves(tabPoints, rootPoints.toArray(new Coordinate[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -19,7 +19,11 @@ public class PrintableFinSet extends AbstractPrintable<FinSet> {
|
|||||||
/**
|
/**
|
||||||
* The object that represents the shape (outline) of the fin. This gets drawn onto the Swing component.
|
* The object that represents the shape (outline) of the fin. This gets drawn onto the Swing component.
|
||||||
*/
|
*/
|
||||||
protected GeneralPath polygon;
|
protected GeneralPath finPolygon;
|
||||||
|
/**
|
||||||
|
* The object that represents the tab (outline) of the fin. This gets drawn onto the Swing component.
|
||||||
|
*/
|
||||||
|
protected GeneralPath finTabPolygon;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The minimum X coordinate.
|
* The minimum X coordinate.
|
||||||
@ -46,15 +50,17 @@ public class PrintableFinSet extends AbstractPrintable<FinSet> {
|
|||||||
*/
|
*/
|
||||||
protected void init (FinSet component) {
|
protected void init (FinSet component) {
|
||||||
|
|
||||||
Coordinate[] points = component.getFinPointsWithTab();
|
Coordinate[] points = component.getFinPointsWithRoot();
|
||||||
|
Coordinate[] tabPoints = component.getTabPoints();
|
||||||
|
|
||||||
polygon = new GeneralPath(GeneralPath.WIND_NON_ZERO, points.length);
|
finPolygon = new GeneralPath(GeneralPath.WIND_NON_ZERO, points.length);
|
||||||
polygon.moveTo(0, 0);
|
finTabPolygon = new GeneralPath(GeneralPath.WIND_NON_ZERO, tabPoints.length);
|
||||||
|
finPolygon.moveTo(0, 0);
|
||||||
|
|
||||||
minX = 0;
|
minX = Integer.MAX_VALUE;
|
||||||
minY = 0;
|
minY = Integer.MAX_VALUE;;
|
||||||
int maxX = 0;
|
int maxX = Integer.MIN_VALUE;;
|
||||||
int maxY = 0;
|
int maxY = Integer.MIN_VALUE;
|
||||||
|
|
||||||
for (Coordinate point : points) {
|
for (Coordinate point : points) {
|
||||||
final float x = (float) PrintUnit.METERS.toPoints(point.x);
|
final float x = (float) PrintUnit.METERS.toPoints(point.x);
|
||||||
@ -63,9 +69,24 @@ public class PrintableFinSet extends AbstractPrintable<FinSet> {
|
|||||||
minY = (int) Math.min(y, minY);
|
minY = (int) Math.min(y, minY);
|
||||||
maxX = (int) Math.max(x, maxX);
|
maxX = (int) Math.max(x, maxX);
|
||||||
maxY = (int) Math.max(y, maxY);
|
maxY = (int) Math.max(y, maxY);
|
||||||
polygon.lineTo(x, y);
|
finPolygon.lineTo(x, y);
|
||||||
}
|
}
|
||||||
polygon.closePath();
|
finPolygon.closePath();
|
||||||
|
|
||||||
|
for (int i = 0; i < tabPoints.length; i++) {
|
||||||
|
final float x = (float) PrintUnit.METERS.toPoints(tabPoints[i].x);
|
||||||
|
final float y = (float) PrintUnit.METERS.toPoints(tabPoints[i].y);
|
||||||
|
minX = (int) Math.min(x, minX);
|
||||||
|
minY = (int) Math.min(y, minY);
|
||||||
|
maxX = (int) Math.max(x, maxX);
|
||||||
|
maxY = (int) Math.max(y, maxY);
|
||||||
|
if (i == 0) {
|
||||||
|
finTabPolygon.moveTo(x, y);
|
||||||
|
} else {
|
||||||
|
finTabPolygon.lineTo(x, y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finTabPolygon.closePath();
|
||||||
|
|
||||||
setSize(maxX - minX + 1, maxY - minY + 1);
|
setSize(maxX - minX + 1, maxY - minY + 1);
|
||||||
}
|
}
|
||||||
@ -94,9 +115,11 @@ public class PrintableFinSet extends AbstractPrintable<FinSet> {
|
|||||||
// Reset the origin.
|
// Reset the origin.
|
||||||
g2d.translate(x, y);
|
g2d.translate(x, y);
|
||||||
g2d.setPaint(TemplateProperties.getFillColor());
|
g2d.setPaint(TemplateProperties.getFillColor());
|
||||||
g2d.fill(polygon);
|
g2d.fill(finPolygon);
|
||||||
|
g2d.fill(finTabPolygon);
|
||||||
g2d.setPaint(TemplateProperties.getLineColor());
|
g2d.setPaint(TemplateProperties.getLineColor());
|
||||||
g2d.draw(polygon);
|
g2d.draw(finPolygon);
|
||||||
|
g2d.draw(finTabPolygon);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user