]> git.gag.com Git - sw/motorsim/blob - src/com/billkuker/rocketry/motorsim/grain/Moonburner.java
Organized grain package
[sw/motorsim] / src / com / billkuker / rocketry / motorsim / grain / Moonburner.java
1 package com.billkuker.rocketry.motorsim.grain;\r
2 \r
3 import java.awt.Shape;\r
4 import java.awt.geom.Ellipse2D;\r
5 import java.beans.PropertyVetoException;\r
6 \r
7 import javax.measure.quantity.Length;\r
8 import javax.measure.unit.SI;\r
9 \r
10 import org.jscience.physics.amount.Amount;\r
11 \r
12 import com.billkuker.rocketry.motorsim.grain.util.BurningShape;\r
13 import com.billkuker.rocketry.motorsim.grain.util.ExtrudedShapeGrain;\r
14 import com.billkuker.rocketry.motorsim.visual.Editor;\r
15 import com.billkuker.rocketry.motorsim.visual.GrainPanel;\r
16 \r
17 public class Moonburner extends ExtrudedShapeGrain {\r
18 \r
19         private Amount<Length> oD = Amount.valueOf(30, SI.MILLIMETER);\r
20         private Amount<Length> iD = Amount.valueOf(10, SI.MILLIMETER);\r
21         private Amount<Length> coreOffset = Amount.valueOf(0, SI.MILLIMETER);\r
22         \r
23         public Moonburner(){\r
24                 try {\r
25                         setLength(Amount.valueOf(70, SI.MILLIMETER));\r
26                 } catch (PropertyVetoException e) {\r
27                         e.printStackTrace();\r
28                 }\r
29                 generateGeometry();\r
30         }\r
31 \r
32         public Amount<Length> getOD() {\r
33                 return oD;\r
34         }\r
35 \r
36         public void setOD(Amount<Length> od) throws PropertyVetoException {\r
37                 if (od.equals(this.oD))\r
38                         return;\r
39                 fireVetoableChange("od", this.oD, od);\r
40                 Amount<Length> old = this.oD;\r
41                 this.oD = od;\r
42                 generateGeometry();\r
43                 firePropertyChange("OD", old, oD);\r
44         }\r
45 \r
46         public Amount<Length> getID() {\r
47                 return iD;\r
48         }\r
49 \r
50         public void setID(Amount<Length> id) throws PropertyVetoException {\r
51                 if (id.equals(this.iD))\r
52                         return;\r
53                 fireVetoableChange("id", this.iD, id);\r
54                 Amount<Length> old = this.iD;\r
55                 iD = id;\r
56                 generateGeometry();\r
57                 firePropertyChange("ID", old, iD);\r
58         }\r
59 \r
60         public Amount<Length> getCoreOffset() {\r
61                 return coreOffset;\r
62         }\r
63 \r
64         public void setCoreOffset(Amount<Length> coreOffset)\r
65                         throws PropertyVetoException {\r
66                 if (coreOffset.equals(this.coreOffset))\r
67                         return;\r
68                 fireVetoableChange("coreOffset", this.coreOffset, coreOffset);\r
69                 Amount<Length> old = this.coreOffset;\r
70                 this.coreOffset = coreOffset;\r
71                 generateGeometry();\r
72                 firePropertyChange("coreOffset", old, this.coreOffset);\r
73         }\r
74 \r
75         private void generateGeometry() {\r
76                 double odmm = oD.doubleValue(SI.MILLIMETER);\r
77                 double idmm = iD.doubleValue(SI.MILLIMETER);\r
78                 double offmm = coreOffset.doubleValue(SI.MILLIMETER);\r
79                 xsection = new BurningShape();\r
80                 Shape outside = new Ellipse2D.Double(0, 0, odmm, odmm);\r
81                 xsection.add(outside);\r
82                 xsection.inhibit(outside);\r
83 \r
84                 xsection.subtract(new Ellipse2D.Double(odmm/2 - idmm/2 + offmm, odmm/2 - idmm/2 + offmm, idmm, idmm));\r
85                 webThickness = null;\r
86         }\r
87         \r
88         public static void main(String args[]) throws Exception {\r
89                 Moonburner e = new Moonburner();\r
90                 new Editor(e).showAsWindow();\r
91                 new GrainPanel(e).showAsWindow();\r
92         }\r
93 \r
94 }\r