[Bugfix] Added unit tests for Transition Shapes

- and refactored member names a bit
This commit is contained in:
Daniel_M_Williams 2016-01-24 21:37:13 -05:00
parent cd829ff3fd
commit 4e64d817d1
4 changed files with 29 additions and 27 deletions

View File

@ -34,6 +34,8 @@ public class NoseCone extends Transition {
super.setLength(length); super.setLength(length);
super.setClipped(false); super.setClipped(false);
super.setAftRadiusAutomatic(false);
super.setAftRadius(radius);
} }

View File

@ -424,7 +424,7 @@ public class Rocket extends RocketComponent {
checkState(); checkState();
{ // vvvv DEVEL vvvv { // vvvv DEVEL vvvv
System.err.println("fireEvent@rocket."); //System.err.println("fireEvent@rocket.");
} // ^^^^ DEVEL ^^^^ } // ^^^^ DEVEL ^^^^
// Update modification ID's only for normal (not undo/redo) events // Update modification ID's only for normal (not undo/redo) events

View File

@ -23,8 +23,8 @@ public class Transition extends SymmetricComponent {
private double shapeParameter; private double shapeParameter;
private boolean clipped; // Not to be read - use isClipped(), which may be overriden private boolean clipped; // Not to be read - use isClipped(), which may be overriden
private double radius1, radius2; private double foreRadius, aftRadius;
private boolean autoRadius1, autoRadius2; // Whether the start radius is automatic private boolean autoForeRadius, autoAftRadius2; // Whether the start radius is automatic
private double foreShoulderRadius; private double foreShoulderRadius;
@ -43,11 +43,11 @@ public class Transition extends SymmetricComponent {
public Transition() { public Transition() {
super(); super();
this.radius1 = DEFAULT_RADIUS; this.foreRadius = DEFAULT_RADIUS;
this.radius2 = DEFAULT_RADIUS; this.aftRadius = DEFAULT_RADIUS;
this.length = DEFAULT_RADIUS * 3; this.length = DEFAULT_RADIUS * 3;
this.autoRadius1 = true; this.autoForeRadius = true;
this.autoRadius2 = true; this.autoAftRadius2 = true;
this.type = Shape.CONICAL; this.type = Shape.CONICAL;
this.shapeParameter = 0; this.shapeParameter = 0;
@ -82,18 +82,18 @@ public class Transition extends SymmetricComponent {
r = DEFAULT_RADIUS; r = DEFAULT_RADIUS;
return r; return r;
} }
return radius1; return foreRadius;
} }
public void setForeRadius(double radius) { public void setForeRadius(double radius) {
if ((this.radius1 == radius) && (autoRadius1 == false)) if ((this.foreRadius == radius) && (autoForeRadius == false))
return; return;
this.autoRadius1 = false; this.autoForeRadius = false;
this.radius1 = Math.max(radius, 0); this.foreRadius = Math.max(radius, 0);
if (this.thickness > this.radius1 && this.thickness > this.radius2) if (this.thickness > this.foreRadius && this.thickness > this.aftRadius)
this.thickness = Math.max(this.radius1, this.radius2); this.thickness = Math.max(this.foreRadius, this.aftRadius);
clearPreset(); clearPreset();
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE); fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
@ -101,14 +101,14 @@ public class Transition extends SymmetricComponent {
@Override @Override
public boolean isForeRadiusAutomatic() { public boolean isForeRadiusAutomatic() {
return autoRadius1; return autoForeRadius;
} }
public void setForeRadiusAutomatic(boolean auto) { public void setForeRadiusAutomatic(boolean auto) {
if (autoRadius1 == auto) if (autoForeRadius == auto)
return; return;
autoRadius1 = auto; autoForeRadius = auto;
clearPreset(); clearPreset();
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE); fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
@ -130,20 +130,20 @@ public class Transition extends SymmetricComponent {
r = DEFAULT_RADIUS; r = DEFAULT_RADIUS;
return r; return r;
} }
return radius2; return aftRadius;
} }
public void setAftRadius(double radius) { public void setAftRadius(double radius) {
if ((this.radius2 == radius) && (autoRadius2 == false)) if ((this.aftRadius == radius) && (autoAftRadius2 == false))
return; return;
this.autoRadius2 = false; this.autoAftRadius2 = false;
this.radius2 = Math.max(radius, 0); this.aftRadius = Math.max(radius, 0);
if (this.thickness > this.radius1 && this.thickness > this.radius2) if (this.thickness > this.foreRadius && this.thickness > this.aftRadius)
this.thickness = Math.max(this.radius1, this.radius2); this.thickness = Math.max(this.foreRadius, this.aftRadius);
clearPreset(); clearPreset();
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE); fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
@ -151,14 +151,14 @@ public class Transition extends SymmetricComponent {
@Override @Override
public boolean isAftRadiusAutomatic() { public boolean isAftRadiusAutomatic() {
return autoRadius2; return autoAftRadius2;
} }
public void setAftRadiusAutomatic(boolean auto) { public void setAftRadiusAutomatic(boolean auto) {
if (autoRadius2 == auto) if (autoAftRadius2 == auto)
return; return;
autoRadius2 = auto; autoAftRadius2 = auto;
clearPreset(); clearPreset();
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE); fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);

View File

@ -404,8 +404,8 @@ public class TestRockets {
double noseconeLength = 0.07; double noseconeLength = 0.07;
double noseconeRadius = 0.012; double noseconeRadius = 0.012;
NoseCone nosecone = new NoseCone(Transition.Shape.OGIVE, noseconeLength, noseconeRadius); NoseCone nosecone = new NoseCone(Transition.Shape.OGIVE, noseconeLength, noseconeRadius);
nosecone.setAftShoulderLength(0.025); nosecone.setAftShoulderLength(0.02);
nosecone.setAftShoulderRadius(0.012); nosecone.setAftShoulderRadius(0.011);
nosecone.setName("Nose Cone"); nosecone.setName("Nose Cone");
stage.addChild(nosecone); stage.addChild(nosecone);