diff --git a/swing/src/net/sf/openrocket/gui/rocketfigure/ComponentAssemblyShapes.java b/swing/src/net/sf/openrocket/gui/rocketfigure/ComponentAssemblyShapes.java new file mode 100644 index 000000000..c4b2cb960 --- /dev/null +++ b/swing/src/net/sf/openrocket/gui/rocketfigure/ComponentAssemblyShapes.java @@ -0,0 +1,56 @@ +package net.sf.openrocket.gui.rocketfigure; + +import net.sf.openrocket.rocketcomponent.ParallelStage; +import net.sf.openrocket.rocketcomponent.PodSet; +import net.sf.openrocket.rocketcomponent.RocketComponent; +import net.sf.openrocket.util.Color; +import net.sf.openrocket.util.Transformation; + +import java.awt.Shape; + +public class ComponentAssemblyShapes extends RocketComponentShape { + + public static RocketComponentShape[] getShapesSide(final RocketComponent component, final Transformation transformation) { + double radius = getDisplayRadius(component); + + Shape[] s = EmptyShapes.getShapesSideWithSelectionSquare(transformation, radius); + RocketComponentShape[] shapes = RocketComponentShape.toArray(s, component); + + // Set the color of the shapes + Color color = getColor(component); + for (int i = 0; i < shapes.length - 1; i++) { + shapes[i].setColor(color); + } + + return shapes; + } + + public static RocketComponentShape[] getShapesBack(final RocketComponent component, final Transformation transformation) { + double radius = getDisplayRadius(component); + + Shape[] s = EmptyShapes.getShapesBackWithSelectionSquare(transformation, radius); + RocketComponentShape[] shapes = RocketComponentShape.toArray(s, component); + + // Set the color of the shapes + Color color = getColor(component); + for (int i = 0; i < shapes.length - 1; i++) { + shapes[i].setColor(color); + } + + return shapes; + } + + private static double getDisplayRadius(RocketComponent component) { + return component.getRocket().getBoundingRadius() * 0.03; + } + + private static Color getColor(RocketComponent component) { + if (component instanceof PodSet) { + return new Color(160,160,215); + } else if (component instanceof ParallelStage) { + return new Color(198,163,184); + } else { + return new Color(160, 160, 160); + } + } +} diff --git a/swing/src/net/sf/openrocket/gui/rocketfigure/ParallelStageShapes.java b/swing/src/net/sf/openrocket/gui/rocketfigure/ParallelStageShapes.java index 565a23591..18f27ab4a 100644 --- a/swing/src/net/sf/openrocket/gui/rocketfigure/ParallelStageShapes.java +++ b/swing/src/net/sf/openrocket/gui/rocketfigure/ParallelStageShapes.java @@ -1,48 +1,5 @@ package net.sf.openrocket.gui.rocketfigure; -import net.sf.openrocket.rocketcomponent.ParallelStage; -import net.sf.openrocket.rocketcomponent.RocketComponent; -import net.sf.openrocket.util.Color; -import net.sf.openrocket.util.Transformation; - -import java.awt.Shape; - -public class ParallelStageShapes extends RocketComponentShape { - public static final Color boosterColor = new Color(198,163,184); - - public static RocketComponentShape[] getShapesSide(final RocketComponent component, final Transformation transformation) { - ParallelStage booster = (ParallelStage)component; - double radius = getDisplayRadius(booster); - - Shape[] s = EmptyShapes.getShapesSideWithSelectionSquare(transformation, radius); - RocketComponentShape[] shapes = RocketComponentShape.toArray(s, component); - - // Set the color of the shapes - for (int i = 0; i < shapes.length - 1; i++) { - shapes[i].setColor(boosterColor); - } - shapes[shapes.length - 1].setColor(Color.INVISIBLE); - - return shapes; - } - - public static RocketComponentShape[] getShapesBack(final RocketComponent component, final Transformation transformation) { - ParallelStage booster = (ParallelStage)component; - double radius = getDisplayRadius(booster); - - Shape[] s = EmptyShapes.getShapesBackWithSelectionSquare(transformation, radius); - RocketComponentShape[] shapes = RocketComponentShape.toArray(s, component); - - // Set the color of the shapes - for (int i = 0; i < shapes.length - 1; i++) { - shapes[i].setColor(boosterColor); - } - shapes[shapes.length - 1].setColor(Color.INVISIBLE); - - return shapes; - } - - private static double getDisplayRadius(ParallelStage booster) { - return booster.getRocket().getBoundingRadius() * 0.03; - } +public class ParallelStageShapes extends ComponentAssemblyShapes { + // Everything is implemented in ComponentAssemblyShapes.java } diff --git a/swing/src/net/sf/openrocket/gui/rocketfigure/PodSetShapes.java b/swing/src/net/sf/openrocket/gui/rocketfigure/PodSetShapes.java index 7ef928f2d..1d2ba4144 100644 --- a/swing/src/net/sf/openrocket/gui/rocketfigure/PodSetShapes.java +++ b/swing/src/net/sf/openrocket/gui/rocketfigure/PodSetShapes.java @@ -1,48 +1,5 @@ package net.sf.openrocket.gui.rocketfigure; -import net.sf.openrocket.rocketcomponent.PodSet; -import net.sf.openrocket.rocketcomponent.RocketComponent; -import net.sf.openrocket.util.Color; -import net.sf.openrocket.util.Transformation; - -import java.awt.Shape; - -public class PodSetShapes extends RocketComponentShape { - public static final Color podsetColor = new Color(160,160,215); - - public static RocketComponentShape[] getShapesSide(final RocketComponent component, final Transformation transformation) { - PodSet podset = (PodSet)component; - double radius = getDisplayRadius(podset); - - Shape[] s = EmptyShapes.getShapesSideWithSelectionSquare(transformation, radius); - RocketComponentShape[] shapes = RocketComponentShape.toArray(s, component); - - // Set the color of the shapes - for (int i = 0; i < shapes.length - 1; i++) { - shapes[i].setColor(podsetColor); - } - shapes[shapes.length - 1].setColor(Color.INVISIBLE); - - return shapes; - } - - public static RocketComponentShape[] getShapesBack(final RocketComponent component, final Transformation transformation) { - PodSet podset = (PodSet)component; - double radius = getDisplayRadius(podset); - - Shape[] s = EmptyShapes.getShapesBackWithSelectionSquare(transformation, radius); - RocketComponentShape[] shapes = RocketComponentShape.toArray(s, component); - - // Set the color of the shapes - for (int i = 0; i < shapes.length - 1; i++) { - shapes[i].setColor(podsetColor); - } - shapes[shapes.length - 1].setColor(Color.INVISIBLE); - - return shapes; - } - - private static double getDisplayRadius(PodSet podset) { - return podset.getRocket().getBoundingRadius() * 0.03; - } +public class PodSetShapes extends ComponentAssemblyShapes { + // Everything is implemented in ComponentAssemblyShapes.java } diff --git a/swing/src/net/sf/openrocket/gui/scalefigure/RocketFigure.java b/swing/src/net/sf/openrocket/gui/scalefigure/RocketFigure.java index 0f62a28f7..fa195b4c0 100644 --- a/swing/src/net/sf/openrocket/gui/scalefigure/RocketFigure.java +++ b/swing/src/net/sf/openrocket/gui/scalefigure/RocketFigure.java @@ -387,8 +387,8 @@ public class RocketFigure extends AbstractScaleFigure { for (Entry> entry : config.getActiveInstances().entrySet()) { final RocketComponent comp = entry.getKey(); - // Only draw podsets when they are selected - if ((comp instanceof PodSet || comp instanceof ParallelStage) && preferences.isShowMarkers()) { + // Only draw pod sets and boosters when they are selected + if (preferences.isShowMarkers() && (comp instanceof PodSet || comp instanceof ParallelStage)) { boolean selected = false; // Check if component is in the selection