diff --git a/swing/src/net/sf/openrocket/gui/rocketfigure/ComponentAssemblyShapes.java b/swing/src/net/sf/openrocket/gui/rocketfigure/ComponentAssemblyShapes.java index da8250474..5dd94d4d0 100644 --- a/swing/src/net/sf/openrocket/gui/rocketfigure/ComponentAssemblyShapes.java +++ b/swing/src/net/sf/openrocket/gui/rocketfigure/ComponentAssemblyShapes.java @@ -1,9 +1,11 @@ package net.sf.openrocket.gui.rocketfigure; import net.sf.openrocket.rocketcomponent.AxialStage; +import net.sf.openrocket.rocketcomponent.ComponentAssembly; import net.sf.openrocket.rocketcomponent.ParallelStage; import net.sf.openrocket.rocketcomponent.PodSet; import net.sf.openrocket.rocketcomponent.RocketComponent; +import net.sf.openrocket.rocketcomponent.position.AxialMethod; import net.sf.openrocket.util.Color; import net.sf.openrocket.util.Transformation; @@ -17,9 +19,22 @@ public class ComponentAssemblyShapes extends RocketComponentShape { return null; } - double radius = getDisplayRadius(component); + ComponentAssembly assembly = (ComponentAssembly) component; - Shape[] s = EmptyShapes.getShapesSideWithSelectionSquare(transformation, radius); + // Update the marker location based on the axial method. The axial method changes the "reference point" of the component. + Transformation correctedTransform = transformation; + if (assembly.getAxialMethod() == AxialMethod.BOTTOM) { + correctedTransform = transformation.applyTransformation(new Transformation(assembly.getLength(), 0, 0)); + } else if (assembly.getAxialMethod() == AxialMethod.MIDDLE) { + correctedTransform = transformation.applyTransformation(new Transformation(assembly.getLength() / 2, 0, 0)); + } + + // Correct the radius to be at the "reference point" dictated by the component's radius offset. + double boundingRadius = assembly.getBoundingRadius(); + correctedTransform = correctedTransform.applyTransformation(new Transformation(0, -boundingRadius, 0)); + + double markerRadius = getDisplayRadius(component); + Shape[] s = EmptyShapes.getShapesSideWithSelectionSquare(correctedTransform, markerRadius); RocketComponentShape[] shapes = RocketComponentShape.toArray(s, component); // Set the color of the shapes @@ -36,9 +51,15 @@ public class ComponentAssemblyShapes extends RocketComponentShape { if (component instanceof AxialStage && !(component instanceof ParallelStage)) { return null; } - double radius = getDisplayRadius(component); - Shape[] s = EmptyShapes.getShapesBackWithSelectionSquare(transformation, radius); + ComponentAssembly assembly = (ComponentAssembly) component; + + // Correct the radius to be at the "reference point" dictated by the component's radius offset. + double boundingRadius = assembly.getBoundingRadius(); + Transformation correctedTransform = transformation.applyTransformation(new Transformation(0, -boundingRadius, 0)); + + double markerRadius = getDisplayRadius(component); + Shape[] s = EmptyShapes.getShapesBackWithSelectionSquare(correctedTransform, markerRadius); RocketComponentShape[] shapes = RocketComponentShape.toArray(s, component); // Set the color of the shapes @@ -50,6 +71,11 @@ public class ComponentAssemblyShapes extends RocketComponentShape { return shapes; } + /** + * Returns the radius of the marker (i.e. the marker size), based on the rocket size. + * @param component this component + * @return the radius to draw the marker with + */ private static double getDisplayRadius(RocketComponent component) { return component.getRocket().getBoundingRadius() * 0.03; }