DGP - 1st printing
[debian/openrocket] / src / net / sf / openrocket / rocketcomponent / Transition.java
index 7155a7988311fc941186aa8dee88718d4e3b889c..f26666ae9079415722dedf1420f9419bd2b2fde6 100644 (file)
@@ -1,15 +1,17 @@
 package net.sf.openrocket.rocketcomponent;
 
+import net.sf.openrocket.util.Coordinate;
+import net.sf.openrocket.util.MathUtil;
+
+import java.util.Collection;
+
 import static java.lang.Math.sin;
 import static java.lang.Math.sqrt;
+import static net.sf.openrocket.util.Chars.FRAC12;
+import static net.sf.openrocket.util.Chars.FRAC34;
 import static net.sf.openrocket.util.MathUtil.pow2;
 import static net.sf.openrocket.util.MathUtil.pow3;
 
-import java.util.Collection;
-
-import net.sf.openrocket.util.Coordinate;
-import net.sf.openrocket.util.MathUtil;
-
 
 public class Transition extends SymmetricComponent {
        private static final double CLIP_PRECISION = 0.0001;
@@ -172,6 +174,9 @@ public class Transition extends SymmetricComponent {
        }
        
        public void setType(Shape type) {
+               if (type == null) {
+                       throw new IllegalArgumentException("BUG:  setType called with null argument");
+               }
                if (this.type == type)
                        return;
                this.type = type;
@@ -352,7 +357,7 @@ public class Transition extends SymmetricComponent {
        /**
         * Numerically solve clipLength from the equation
         *     r1 == type.getRadius(clipLength,r2,clipLength+length)
-        * using a binary search.  It assumes getRadius() to be monotonically increasing.
+        * using a binary search.  It assumes getOuterRadius() to be monotonically increasing.
         */
        private void calculateClip(double r1, double r2) {
                double min=0, max=length;
@@ -495,6 +500,15 @@ public class Transition extends SymmetricComponent {
                clipLength = -1;
        }
        
+    /**
+     * Accept a visitor to this Transition in the component hierarchy.
+     * 
+     * @param theVisitor  the visitor that will be called back with a reference to this Transition
+     */
+    @Override 
+    public void accept (final ComponentVisitor theVisitor) {
+        theVisitor.visit(this);
+    }
        
        
        /**
@@ -594,14 +608,14 @@ public class Transition extends SymmetricComponent {
                                "<i>Radius</i>&nbsp;&times;&nbsp;(<i>x</i>&nbsp;/&nbsp;<i>Length</i>)" +
                                "<sup><i>k</i></sup> "+
                                "where <i>k</i> is the shape parameter.  For <i>k</i>=0.5 this is a "+
-                               "<b>½-power</b> or <b>parabolic</b> nose cone, for <i>k</i>=0.75 a "+
-                               "<b>¾-power</b>, and for <i>k</i>=1 a <b>conical</b> nose cone.",
+                               "<b>" + FRAC12 +"-power</b> or <b>parabolic</b> nose cone, for <i>k</i>=0.75 a "+
+                               "<b>" + FRAC34 +"-power</b>, and for <i>k</i>=1 a <b>conical</b> nose cone.",
                                "A power series transition has a profile of "+
                                "<i>Radius</i>&nbsp;&times;&nbsp;(<i>x</i>&nbsp;/&nbsp;<i>Length</i>)" +
                                "<sup><i>k</i></sup> "+
                                "where <i>k</i> is the shape parameter.  For <i>k</i>=0.5 the transition is "+
-                               "<b>½-power</b> or <b>parabolic</b>, for <i>k</i>=0.75 a <b>¾-power</b>, and for " +
-                               "<i>k</i>=1 <b>conical</b>.",true) {
+                               "<b>" + FRAC12 + "-power</b> or <b>parabolic</b>, for <i>k</i>=0.75 a " +
+                               "<b>" + FRAC34 + "-power</b>, and for <i>k</i>=1 <b>conical</b>.",true) {
                        @Override
                        public boolean usesParameter() {  // Range 0...1
                                return true;