diff --git a/swing/src/net/sf/openrocket/gui/dialogs/ScaleDialog.java b/swing/src/net/sf/openrocket/gui/dialogs/ScaleDialog.java index 10526ec3e..ce2fe5c16 100644 --- a/swing/src/net/sf/openrocket/gui/dialogs/ScaleDialog.java +++ b/swing/src/net/sf/openrocket/gui/dialogs/ScaleDialog.java @@ -122,7 +122,7 @@ public class ScaleDialog extends JDialog { addScaler(EllipticalFinSet.class, "Height", SCALERS_NO_OFFSET); // FreeformFinSet - list = new ArrayList(1); + list = new ArrayList<>(1); list.add(new FreeformFinSetScaler()); SCALERS_NO_OFFSET.put(FreeformFinSet.class, list); @@ -135,7 +135,7 @@ public class ScaleDialog extends JDialog { addScaler(MassObject.class, "RadialPosition", SCALERS_OFFSET); // MassComponent - list = new ArrayList(1); + list = new ArrayList<>(1); list.add(new MassComponentScaler()); SCALERS_NO_OFFSET.put(MassComponent.class, list); @@ -162,8 +162,9 @@ public class ScaleDialog extends JDialog { addScaler(InnerTube.class, "MotorOverhang", SCALERS_NO_OFFSET); // RadiusRingComponent - addScaler(RadiusRingComponent.class, "OuterRadius", "isOuterRadiusAutomatic", SCALERS_NO_OFFSET); - addScaler(RadiusRingComponent.class, "InnerRadius", "isInnerRadiusAutomatic", SCALERS_NO_OFFSET); + list = new ArrayList<>(1); + list.add(new RadiusRingComponentScaler()); + SCALERS_NO_OFFSET.put(RadiusRingComponent.class, list); } private static void addScaler(Class componentClass, String methodName, @@ -745,5 +746,29 @@ public class ScaleDialog extends JDialog { } } + + private static class RadiusRingComponentScaler implements Scaler { + + @Override + public void scale(RocketComponent component, double multiplier, boolean scaleMass) { + final Map, List> scalers = new HashMap<>(); + RadiusRingComponent ring = (RadiusRingComponent) component; + // We need to specify this particular order, otherwise scale the inner/outer radius may clip the dimensions of the other outer/inner radius + if (multiplier >= 1) { + addScaler(RadiusRingComponent.class, "OuterRadius", "isOuterRadiusAutomatic", scalers); + addScaler(RadiusRingComponent.class, "InnerRadius", "isInnerRadiusAutomatic", scalers); + } else { + addScaler(RadiusRingComponent.class, "InnerRadius", "isInnerRadiusAutomatic", scalers); + addScaler(RadiusRingComponent.class, "OuterRadius", "isOuterRadiusAutomatic", scalers); + } + + for (List foo : scalers.values()) { + for (Scaler s : foo) { + s.scale(component, multiplier, scaleMass); + } + } + } + + } }