diff --git a/core/src/net/sf/openrocket/rocketcomponent/FinSet.java b/core/src/net/sf/openrocket/rocketcomponent/FinSet.java index 686449c2f..b7a5ffa05 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/FinSet.java +++ b/core/src/net/sf/openrocket/rocketcomponent/FinSet.java @@ -977,6 +977,13 @@ public abstract class FinSet extends ExternalComponent implements AxialPositiona 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. * 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[] points = new Coordinate[pointCount]; + Coordinate[] tabPoints = new Coordinate[4]; final Coordinate finFront = this.getFinFront(); final SymmetricComponent body = (SymmetricComponent)this.getParent(); @@ -1022,16 +1028,13 @@ public abstract class FinSet extends ExternalComponent implements AxialPositiona yTabBottom = MathUtil.min(yTabFront, yTabTrail) - tabHeight; } - points[0] = new Coordinate(xTabFront, yTabFront); - points[1] = new Coordinate(xTabFront, yTabBottom ); - points[2] = new Coordinate(xTabTrail, yTabBottom ); - points[3] = new Coordinate(xTabTrail, yTabTrail); - for (int i = 0; i < rootPoints.size(); i++) { - points[i + 4] = rootPoints.get(rootPoints.size() - 1 - i); - } - points[pointCount - 1] = new Coordinate(xTabFront, yTabFront); + tabPoints[0] = new Coordinate(xTabFront, yTabFront); + tabPoints[1] = new Coordinate(xTabFront, yTabBottom ); + tabPoints[2] = new Coordinate(xTabTrail, yTabBottom ); + tabPoints[3] = new Coordinate(xTabTrail, yTabTrail); + rootPoints.add(0, new Coordinate(xTabFront, yTabFront)); - return points; + return combineCurves(tabPoints, rootPoints.toArray(new Coordinate[0])); } /* diff --git a/swing/src/net/sf/openrocket/gui/print/PrintableFinSet.java b/swing/src/net/sf/openrocket/gui/print/PrintableFinSet.java index 59719b504..af385c3ff 100644 --- a/swing/src/net/sf/openrocket/gui/print/PrintableFinSet.java +++ b/swing/src/net/sf/openrocket/gui/print/PrintableFinSet.java @@ -19,7 +19,11 @@ public class PrintableFinSet extends AbstractPrintable { /** * 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. @@ -46,15 +50,17 @@ public class PrintableFinSet extends AbstractPrintable { */ 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); - polygon.moveTo(0, 0); + finPolygon = new GeneralPath(GeneralPath.WIND_NON_ZERO, points.length); + finTabPolygon = new GeneralPath(GeneralPath.WIND_NON_ZERO, tabPoints.length); + finPolygon.moveTo(0, 0); - minX = 0; - minY = 0; - int maxX = 0; - int maxY = 0; + minX = Integer.MAX_VALUE; + minY = Integer.MAX_VALUE;; + int maxX = Integer.MIN_VALUE;; + int maxY = Integer.MIN_VALUE; for (Coordinate point : points) { final float x = (float) PrintUnit.METERS.toPoints(point.x); @@ -63,9 +69,24 @@ public class PrintableFinSet extends AbstractPrintable { minY = (int) Math.min(y, minY); maxX = (int) Math.max(x, maxX); 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); } @@ -94,9 +115,11 @@ public class PrintableFinSet extends AbstractPrintable { // Reset the origin. g2d.translate(x, y); g2d.setPaint(TemplateProperties.getFillColor()); - g2d.fill(polygon); + g2d.fill(finPolygon); + g2d.fill(finTabPolygon); g2d.setPaint(TemplateProperties.getLineColor()); - g2d.draw(polygon); + g2d.draw(finPolygon); + g2d.draw(finTabPolygon); } /**