]> git.gag.com Git - sw/motorsim/commitdiff
Added end surface inhibit option
authorBill Kuker <bkuker@billkuker.com>
Sun, 12 Apr 2009 17:37:52 +0000 (17:37 +0000)
committerBill Kuker <bkuker@billkuker.com>
Sun, 12 Apr 2009 17:37:52 +0000 (17:37 +0000)
src/com/billkuker/rocketry/motorsim/grain/ExtrudedGrain.java

index 18d856af54770d9a596303a0a80d94a03c0f37b1..266c52e3935b5090064d6533cce4e329658085f6 100644 (file)
@@ -7,6 +7,7 @@ import java.awt.geom.Ellipse2D;
 import java.awt.geom.GeneralPath;\r
 import java.awt.geom.PathIterator;\r
 import java.awt.geom.Rectangle2D;\r
+import java.beans.PropertyVetoException;\r
 import java.util.HashSet;\r
 import java.util.Set;\r
 \r
@@ -18,9 +19,11 @@ import javax.measure.unit.SI;
 import org.jscience.physics.amount.Amount;\r
 \r
 import com.billkuker.rocketry.motorsim.Grain;\r
+import com.billkuker.rocketry.motorsim.MotorPart;\r
+import com.billkuker.rocketry.motorsim.visual.Editor;\r
 import com.billkuker.rocketry.motorsim.visual.GrainPanel;\r
 \r
-public class ExtrudedGrain implements Grain {\r
+public class ExtrudedGrain extends MotorPart implements Grain {\r
 \r
        Set<Shape> plus = new HashSet<Shape>();\r
 \r
@@ -29,6 +32,8 @@ public class ExtrudedGrain implements Grain {
        Set<Shape> inhibited = new HashSet<Shape>();\r
 \r
        Amount<Length> length = Amount.valueOf(25, SI.MILLIMETER);\r
+       \r
+       boolean endSurfaceInhibited = false;\r
 \r
        Amount<Length> rStep;\r
 \r
@@ -68,7 +73,10 @@ public class ExtrudedGrain implements Grain {
                if (regression.isGreaterThan(webThickness))\r
                        return zero;\r
                \r
-               Amount<Length> rLen = length.minus(regression.times(2));\r
+               Amount<Length> rLen = length;\r
+               if ( !endSurfaceInhibited ) //Regress length if uninhibited\r
+                       rLen = length.minus(regression.times(2));\r
+               \r
                if (rLen.isLessThan(Amount.valueOf(0, SI.MILLIMETER)))\r
                        return zero;\r
 \r
@@ -90,7 +98,10 @@ public class ExtrudedGrain implements Grain {
        public Amount<Volume> volume(Amount<Length> regression) {\r
                Amount<Volume> zero = Amount.valueOf(0, Volume.UNIT);\r
                \r
-               Amount<Length> rLen = length.minus(regression.times(2));\r
+               Amount<Length> rLen = length;\r
+               if ( !endSurfaceInhibited ) //Regress length if uninhibited\r
+                       rLen = length.minus(regression.times(2));\r
+               \r
                if (rLen.isLessThan(Amount.valueOf(0, SI.MILLIMETER)))\r
                        return zero;\r
                \r
@@ -196,7 +207,12 @@ public class ExtrudedGrain implements Grain {
        @Override\r
        public java.awt.geom.Area getSideView(Amount<Length> regression) {\r
                java.awt.geom.Area res = new java.awt.geom.Area();\r
-               double rLenmm = length.minus(regression.times(2)).doubleValue(SI.MILLIMETER);\r
+               \r
+               Amount<Length> rLen = length;\r
+               if ( !endSurfaceInhibited ) //Regress length if uninhibited\r
+                       rLen = length.minus(regression.times(2));\r
+               \r
+               double rLenmm = rLen.doubleValue(SI.MILLIMETER);\r
                \r
                for( java.awt.geom.Area a : separate(getCrossSection(regression))){\r
                        Rectangle2D bounds = a.getBounds2D();\r
@@ -281,6 +297,7 @@ public class ExtrudedGrain implements Grain {
 \r
        public static void main(String args[]) throws Exception {\r
                ExtrudedGrain e = new ExtrudedGrain();\r
+               new Editor(e).show();\r
                new GrainPanel(e).show();\r
        }\r
 \r
@@ -393,4 +410,26 @@ public class ExtrudedGrain implements Grain {
                return Amount.valueOf(area, SI.MILLIMETER.pow(2)).to(Area.UNIT);\r
        }\r
 \r
+       public Amount<Length> getLength() {\r
+               return length;\r
+       }\r
+\r
+       public void setLength(Amount<Length> length) throws PropertyVetoException {\r
+               fireVetoableChange("length", this.length, length);\r
+               Amount<Length> old = this.length;\r
+               this.length = length;\r
+               firePropertyChange("length", old, length);\r
+       }\r
+\r
+       public boolean isEndSurfaceInhibited() {\r
+               return endSurfaceInhibited;\r
+       }\r
+\r
+       public void setEndSurfaceInhibited(boolean endSurfaceInhibited) throws PropertyVetoException {\r
+               fireVetoableChange("endSurfaceInhibited", this.endSurfaceInhibited, endSurfaceInhibited);\r
+               boolean old = this.endSurfaceInhibited;\r
+               this.endSurfaceInhibited = endSurfaceInhibited;\r
+               firePropertyChange("endSurfaceInhibited", old, endSurfaceInhibited);\r
+       }\r
+\r
 }\r