1 package com.billkuker.rocketry.motorsim.grain;
3 import java.awt.geom.Rectangle2D;
4 import java.beans.PropertyChangeEvent;
5 import java.beans.PropertyChangeListener;
7 import javax.measure.quantity.Length;
8 import javax.measure.unit.SI;
10 import org.jscience.physics.amount.Amount;
12 import com.billkuker.rocketry.motorsim.Validating;
13 import com.billkuker.rocketry.motorsim.Validating.ValidationException;
14 import com.billkuker.rocketry.motorsim.grain.util.BurningShape;
15 import com.billkuker.rocketry.motorsim.grain.util.RotatedShapeGrain;
17 public class EndBurner extends RotatedShapeGrain implements Validating {
19 private Amount<Length> length = Amount.valueOf(70, SI.MILLIMETER);
20 private Amount<Length> oD = Amount.valueOf(30, SI.MILLIMETER);
21 private Amount<Length> puntDiameter = Amount.valueOf(10, SI.MILLIMETER);
22 private Amount<Length> puntDepth = Amount.valueOf(10, SI.MILLIMETER);
24 private void generateGeometry(){
25 double len = length.doubleValue(SI.MILLIMETER);
26 double od = oD.doubleValue(SI.MILLIMETER);
27 double pdi = puntDiameter.doubleValue(SI.MILLIMETER);
28 double plen = puntDepth.doubleValue(SI.MILLIMETER);
30 Rectangle2D.Double grain, punt, end;
31 grain = new Rectangle2D.Double(0,0,od/2.0,len);
32 punt = new Rectangle2D.Double(0,len-plen, pdi/2.0, plen);
33 end = new Rectangle2D.Double(0,len,od,0);
35 shape = new BurningShape();
45 this.addPropertyChangeListener(new PropertyChangeListener(){
47 public void propertyChange(PropertyChangeEvent evt) {
54 public void validate() throws ValidationException {
55 if ( oD.equals(Amount.ZERO) )
56 throw new ValidationException(this, "Invalid oD");
57 if ( getLength().equals(Amount.ZERO) )
58 throw new ValidationException(this, "Invalid Length");
59 if ( puntDiameter.isGreaterThan(oD) )
60 throw new ValidationException(this, "puntDiameter > oD");
61 if ( puntDepth.isGreaterThan(length) )
62 throw new ValidationException(this, "puntDepth > length");
65 public Amount<Length> getLength() {
69 public void setLength(Amount<Length> length) {
73 public Amount<Length> getOD() {
77 public void setOD(Amount<Length> oD) {
81 public Amount<Length> getPuntDiameter() {
85 public void setPuntDiameter(Amount<Length> puntDiameter) {
86 this.puntDiameter = puntDiameter;
89 public Amount<Length> getPuntDepth() {
93 public void setPuntDepth(Amount<Length> puntDepth) {
94 this.puntDepth = puntDepth;