diff --git a/core/src/net/sf/openrocket/gui/print/PrintableCenteringRing.java b/core/src/net/sf/openrocket/gui/print/PrintableCenteringRing.java index 502e045ab..00c4e89c0 100644 --- a/core/src/net/sf/openrocket/gui/print/PrintableCenteringRing.java +++ b/core/src/net/sf/openrocket/gui/print/PrintableCenteringRing.java @@ -37,7 +37,8 @@ public class PrintableCenteringRing extends AbstractPrintable { private Set innerCenterPoints = new HashSet(); /** - * Construct a simple, non-clustered, printable centering ring. + * Construct a simple, non-clustered, printable centering ring, or if the motor mount represents a clustered + * configuration then get the cluster points to create the centering ring. * * @param theRing the component to print * @param theMotorMount the motor mount if clustered, else null @@ -46,17 +47,24 @@ public class PrintableCenteringRing extends AbstractPrintable { super(false, theRing); if (theMotorMount == null || theMotorMount.getClusterConfiguration().equals(ClusterConfiguration.SINGLE)) { //Single motor. - innerCenterPoints.add(new CenteringRingStrategy.Dimension((float) PrintUnit.METERS.toPoints(target.getOuterRadius()), - (float) PrintUnit.METERS.toPoints(target.getOuterRadius()))); + final float v = (float) PrintUnit.METERS.toPoints(target.getOuterRadius()); + innerCenterPoints.add( + new CenteringRingStrategy.Dimension(v, v, + (float) PrintUnit.METERS.toPoints((target.getInnerRadius())))); } else { List coords = theMotorMount.getClusterPoints(); - populateCenterPoints(coords); + List points = new ArrayList(); + for (Coordinate coordinate : coords) { + points.add(coordinate.setX(theMotorMount.getOuterRadius())); + } + populateCenterPoints(points); } } /** - * Constructor for a clustered centering ring. + * Constructor for a clustered centering ring. This version is for a "split cluster", where each motor mount tube + * is a distinct entity. * * @param theRing the centering ring component * @param theMotorMounts a list of the motor mount tubes that are physically supported by the centering ring @@ -66,10 +74,18 @@ public class PrintableCenteringRing extends AbstractPrintable { List points = new ArrayList(); //Transform the radial positions of the tubes. for (InnerTube it : theMotorMounts) { - double y = it.getRadialShiftY(); - double z = it.getRadialShiftZ(); - Coordinate coordinate = new Coordinate(0, y, z); - points.add(coordinate); + if (it.getClusterCount() > 1) { + List c = it.getClusterPoints(); + for (Coordinate coordinate : c) { + points.add(coordinate.setX(it.getOuterRadius())); + } + } + else { + double y = it.getRadialShiftY(); + double z = it.getRadialShiftZ(); + Coordinate coordinate = new Coordinate(it.getOuterRadius(), y, z); + points.add(coordinate); + } } populateCenterPoints(points); } @@ -101,9 +117,10 @@ public class PrintableCenteringRing extends AbstractPrintable { private void populateCenterPoints(final List theCoords) { float radius = (float) PrintUnit.METERS.toPoints(target.getOuterRadius()); for (Coordinate coordinate : theCoords) { - innerCenterPoints.add(new CenteringRingStrategy.Dimension((float) PrintUnit.METERS.toPoints - (coordinate.y) + radius, - (float) PrintUnit.METERS.toPoints(coordinate.z) + radius)); + innerCenterPoints.add(new CenteringRingStrategy.Dimension( + (float) PrintUnit.METERS.toPoints(coordinate.y) + radius, //center point x + (float) PrintUnit.METERS.toPoints(coordinate.z) + radius, //center point y + (float) PrintUnit.METERS.toPoints(coordinate.x))); //radius of motor mount } } @@ -137,7 +154,7 @@ public class PrintableCenteringRing extends AbstractPrintable { g2.draw(outerCircle); for (CenteringRingStrategy.Dimension next : innerCenterPoints) { - drawInnerCircle(g2, next.getWidth(), next.getHeight()); + drawInnerCircle(g2, next.getWidth(), next.getHeight(), next.getBreadth()); } g2.setColor(original); } @@ -149,8 +166,8 @@ public class PrintableCenteringRing extends AbstractPrintable { * @param theCenterX the center x in points * @param theCenterY the center y in points */ - private void drawInnerCircle(final Graphics2D g2, final double theCenterX, final double theCenterY) { - double innerRadius = PrintUnit.METERS.toPoints(target.getInnerRadius()); + private void drawInnerCircle(final Graphics2D g2, final double theCenterX, final double theCenterY, + final double innerRadius) { Shape innerCircle = new Ellipse2D.Double(theCenterX - innerRadius, theCenterY - innerRadius, innerRadius * 2, innerRadius * 2); g2.setColor(Color.white); g2.fill(innerCircle); diff --git a/core/src/net/sf/openrocket/gui/print/visitor/CenteringRingStrategy.java b/core/src/net/sf/openrocket/gui/print/visitor/CenteringRingStrategy.java index a3315aedd..1df756997 100644 --- a/core/src/net/sf/openrocket/gui/print/visitor/CenteringRingStrategy.java +++ b/core/src/net/sf/openrocket/gui/print/visitor/CenteringRingStrategy.java @@ -107,10 +107,8 @@ public class CenteringRingStrategy { if (rocketComponents != rc) { if (rocketComponents instanceof InnerTube) { InnerTube it = (InnerTube) rocketComponents; - if (it.isMotorMount()) { - if (overlaps(rc, it)) { - mounts.add(it); - } + if (overlaps(rc, it)) { + mounts.add(it); } } } @@ -213,6 +211,10 @@ public class CenteringRingStrategy { * Height, in points. */ public float height; + /** + * Breadth, in points. + */ + public float breadth = 0f; /** * Constructor. @@ -225,6 +227,19 @@ public class CenteringRingStrategy { height = h; } + /** + * Constructor. + * + * @param w width + * @param h height + * @param b breadth; optionally used to represent radius + */ + public Dimension(float w, float h, float b) { + width = w; + height = h; + breadth = b; + } + /** * Get the width. * @@ -242,5 +257,14 @@ public class CenteringRingStrategy { public float getHeight() { return height; } + + /** + * Get the breadth. + * + * @return the breadth + */ + public float getBreadth() { + return breadth; + } } }