Merge commit '42b2e5ca519766e37ce6941ba4faecc9691cc403' into upstream
[debian/openrocket] / core / src / net / sf / openrocket / rocketcomponent / RadiusRingComponent.java
index 46a35143900afddd218c2cda1d29facf7139f4c7..6d0ccb657e96e1ec754e21b70049485f0013abb8 100644 (file)
@@ -1,5 +1,6 @@
 package net.sf.openrocket.rocketcomponent;
 
+import net.sf.openrocket.preset.ComponentPreset;
 import net.sf.openrocket.util.Coordinate;
 import net.sf.openrocket.util.MathUtil;
 
@@ -16,6 +17,22 @@ public abstract class RadiusRingComponent extends RingComponent implements Coaxi
        protected double outerRadius = 0;
        protected double innerRadius = 0;
 
+       @Override
+       protected void loadFromPreset(ComponentPreset preset) {
+               super.loadFromPreset(preset);
+               if ( preset.has(ComponentPreset.OUTER_DIAMETER)) {
+                       this.outerRadius = preset.get(ComponentPreset.OUTER_DIAMETER) / 2.0;
+                       this.outerRadiusAutomatic = false;
+               }
+               this.innerRadiusAutomatic = false;
+               if ( preset.has(ComponentPreset.INNER_DIAMETER)) {
+                       this.innerRadius = preset.get(ComponentPreset.INNER_DIAMETER) / 2.0;
+               }
+
+               fireComponentChangeEvent(ComponentChangeEvent.MASS_CHANGE);
+
+       }
+
        @Override
        public double getOuterRadius() {
                if (outerRadiusAutomatic && getParent() instanceof RadialParent) {
@@ -44,6 +61,7 @@ public abstract class RadiusRingComponent extends RingComponent implements Coaxi
                        innerRadiusAutomatic = false;
                }
 
+               clearPreset();
                fireComponentChangeEvent(ComponentChangeEvent.MASS_CHANGE);
        }
 
@@ -65,6 +83,7 @@ public abstract class RadiusRingComponent extends RingComponent implements Coaxi
                        outerRadiusAutomatic = false;
                }
 
+               clearPreset();
                fireComponentChangeEvent(ComponentChangeEvent.MASS_CHANGE);
        }