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
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
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
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
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
@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
\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
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