bug fixes
[debian/openrocket] / src / net / sf / openrocket / rocketcomponent / BodyComponent.java
index 2bc112fbb11624924fcd699307157bde8764c3b1..a102e87f720871ae46f1341a3f3f05280bb6c858 100644 (file)
@@ -1,6 +1,7 @@
 package net.sf.openrocket.rocketcomponent;
 
 
+
 /**
  * Class to represent a body object.  The object can be described as a function of
  * the cylindrical coordinates x and angle theta as  r = f(x,theta).  The component
@@ -13,7 +14,7 @@ package net.sf.openrocket.rocketcomponent;
  */
 
 public abstract class BodyComponent extends ExternalComponent {
-
+       
        /**
         * Default constructor.  Sets the relative position to POSITION_RELATIVE_AFTER,
         * i.e. body components come after one another.
@@ -21,8 +22,8 @@ public abstract class BodyComponent extends ExternalComponent {
        public BodyComponent() {
                super(RocketComponent.Position.AFTER);
        }
-
-
+       
+       
        /**
         * Get the outer radius of the component at cylindrical coordinate (x,theta).
         *
@@ -33,8 +34,8 @@ public abstract class BodyComponent extends ExternalComponent {
         * @return  Distance to the outer edge of the object
         */
        public abstract double getRadius(double x, double theta);
-
-
+       
+       
        /**
         * Get the inner radius of the component at cylindrical coordinate (x,theta).
         *
@@ -45,11 +46,23 @@ public abstract class BodyComponent extends ExternalComponent {
         * @return  Distance to the inner edge of the object
         */
        public abstract double getInnerRadius(double x, double theta);
-
-
+       
+       
+       @Override
+       protected void loadFromPreset(RocketComponent preset) {
+               BodyComponent c = (BodyComponent) preset;
+               this.setLength(c.getLength());
+               
+               super.loadFromPreset(preset);
+       }
+       
+       
 
        /**
         * Sets the length of the body component.
+        * <p>
+        * Note: This should be overridden by the subcomponents which need to call
+        * clearPreset().  (BodyTube allows changing length without resetting the preset.)
         */
        public void setLength(double length) {
                if (this.length == length)
@@ -57,10 +70,10 @@ public abstract class BodyComponent extends ExternalComponent {
                this.length = Math.max(length, 0);
                fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
        }
-
+       
        @Override
        public boolean allowsChildren() {
                return true;
        }
-
+       
 }