[bugfix] fixed minor initialization bug

This commit is contained in:
Daniel_M_Williams 2015-11-25 19:27:34 -05:00
parent 12cda5b722
commit a32b303069
5 changed files with 30 additions and 27 deletions

View File

@ -2,13 +2,13 @@ package net.sf.openrocket.aerodynamics;
import java.util.Map; import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import net.sf.openrocket.rocketcomponent.FlightConfiguration; import net.sf.openrocket.rocketcomponent.FlightConfiguration;
import net.sf.openrocket.rocketcomponent.RocketComponent; import net.sf.openrocket.rocketcomponent.RocketComponent;
import net.sf.openrocket.util.Coordinate; import net.sf.openrocket.util.Coordinate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* An abstract aerodynamic calculator implementation, that offers basic implementation * An abstract aerodynamic calculator implementation, that offers basic implementation
@ -93,9 +93,18 @@ public abstract class AbstractAerodynamicCalculator implements AerodynamicCalcul
protected final void checkCache(FlightConfiguration configuration) { protected final void checkCache(FlightConfiguration configuration) {
if (rocketAeroModID != configuration.getRocket().getAerodynamicModID() || if (rocketAeroModID != configuration.getRocket().getAerodynamicModID() ||
rocketTreeModID != configuration.getRocket().getTreeModID()) { rocketTreeModID != configuration.getRocket().getTreeModID()) {
// // vvvv DEVEL vvvv
// log.debug("Voiding the aerodynamic cache");
// System.err.println(" >> Voiding Aero Cache... because modIDs changed...");
// StackTraceElement[] els = Thread.currentThread().getStackTrace();
// final int depth=12;
// for(int i=1; i< depth; i++){
// System.err.println(" "+els[i]);
// }
// // ^^^^ DEVEL ^^^^
rocketAeroModID = configuration.getRocket().getAerodynamicModID(); rocketAeroModID = configuration.getRocket().getAerodynamicModID();
rocketTreeModID = configuration.getRocket().getTreeModID(); rocketTreeModID = configuration.getRocket().getTreeModID();
log.debug("Voiding the aerodynamic cache");
voidAerodynamicCache(); voidAerodynamicCache();
} }
} }

View File

@ -718,8 +718,6 @@ public class BarrowmanCalculator extends AbstractAerodynamicCalculator {
protected void voidAerodynamicCache() { protected void voidAerodynamicCache() {
super.voidAerodynamicCache(); super.voidAerodynamicCache();
// System.err.println("> Voiding Calc Map.");
calcMap = null; calcMap = null;
cacheDiameter = -1; cacheDiameter = -1;
cacheLength = -1; cacheLength = -1;

View File

@ -24,7 +24,7 @@ public class ComponentChangeEvent extends EventObject {
this.value = _val; this.value = _val;
} }
public boolean has( final int testValue ){ public boolean matches( final int testValue ){
return (0 != (this.value & testValue )); return (0 != (this.value & testValue ));
} }
@ -37,7 +37,8 @@ public class ComponentChangeEvent extends EventObject {
/** A change that affects the aerodynamic properties of the rocket */ /** A change that affects the aerodynamic properties of the rocket */
public static final int AERODYNAMIC_CHANGE = TYPE.AERODYNAMIC.value; public static final int AERODYNAMIC_CHANGE = TYPE.AERODYNAMIC.value;
/** A change that affects the mass and aerodynamic properties of the rocket */ /** A change that affects the mass and aerodynamic properties of the rocket */
public static final int BOTH_CHANGE = TYPE.AERO_MASS.value; // Mass & Aerodynamic public static final int AEROMASS_CHANGE = TYPE.AERO_MASS.value; // Mass & Aerodynamic
public static final int BOTH_CHANGE = AEROMASS_CHANGE; // syntactic sugar / backward compatibility
/** A change that affects the rocket tree structure */ /** A change that affects the rocket tree structure */
public static final int TREE_CHANGE = TYPE.TREE.value; public static final int TREE_CHANGE = TYPE.TREE.value;
@ -60,9 +61,6 @@ public class ComponentChangeEvent extends EventObject {
public ComponentChangeEvent(RocketComponent component, final int type) { public ComponentChangeEvent(RocketComponent component, final int type) {
super(component); super(component);
if (0 > type ) {
throw new IllegalArgumentException("bad event type provided");
}
this.type = type; this.type = type;
} }
@ -85,37 +83,37 @@ public class ComponentChangeEvent extends EventObject {
} }
public boolean isAerodynamicChange() { public boolean isAerodynamicChange() {
return TYPE.AERODYNAMIC.has( this.type); return TYPE.AERODYNAMIC.matches( this.type);
} }
public boolean isEventChange() { public boolean isEventChange() {
return TYPE.EVENT.has( this.type); return TYPE.EVENT.matches( this.type);
} }
public boolean isFunctionalChange() { public boolean isFunctionalChange() {
return ! (TYPE.NON_FUNCTIONAL.has( this.type)); return ! (TYPE.NON_FUNCTIONAL.matches( this.type));
} }
public boolean isMassChange() { public boolean isMassChange() {
return TYPE.MASS.has(this.type); return TYPE.MASS.matches(this.type);
} }
public boolean isTextureChange() { public boolean isTextureChange() {
return TYPE.TEXTURE.has(this.type); return TYPE.TEXTURE.matches(this.type);
} }
public boolean isTreeChange() { public boolean isTreeChange() {
return TYPE.TREE.has(this.type); return TYPE.TREE.matches(this.type);
} }
public boolean isUndoChange() { public boolean isUndoChange() {
return TYPE.UNDO.has(this.type); return TYPE.UNDO.matches(this.type);
} }
public boolean isMotorChange() { public boolean isMotorChange() {
return TYPE.MASS.has(this.type); return TYPE.MASS.matches(this.type);
} }
public int getType() { public int getType() {

View File

@ -1,13 +1,11 @@
package net.sf.openrocket.rocketcomponent; package net.sf.openrocket.rocketcomponent;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator;
import java.util.EventObject; import java.util.EventObject;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Vector;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;

View File

@ -68,12 +68,12 @@ public class RailButton extends ExternalComponent implements LineInstanceable {
this.setTotalHeight( ht); this.setTotalHeight( ht);
} }
public RailButton( final double od, final double id, final double ht, final double _thickness, final double _standoff ) { public RailButton( final double od, final double id, final double ht, final double flangeThickness, final double _standoff ) {
super(Position.MIDDLE); super(Position.MIDDLE);
this.outerDiameter_m = od; this.outerDiameter_m = od;
this.totalHeight_m = ht; this.totalHeight_m = ht;
this.innerDiameter_m = id; this.innerDiameter_m = id;
this.flangeHeight_m = _thickness; this.flangeHeight_m = flangeThickness;
this.setStandoff( _standoff); this.setStandoff( _standoff);
this.setInstanceSeparation( od*2); this.setInstanceSeparation( od*2);
} }
@ -186,14 +186,14 @@ public class RailButton extends ExternalComponent implements LineInstanceable {
if (MathUtil.equals(this.angle_rad, clamped_rad)) if (MathUtil.equals(this.angle_rad, clamped_rad))
return; return;
this.angle_rad = clamped_rad; this.angle_rad = clamped_rad;
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE); fireComponentChangeEvent(ComponentChangeEvent.AERODYNAMIC_CHANGE);
} }
@Override @Override
public void setRelativePosition(RocketComponent.Position position) { public void setRelativePosition(RocketComponent.Position position) {
super.setRelativePosition(position); super.setRelativePosition(position);
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE); fireComponentChangeEvent(ComponentChangeEvent.AERODYNAMIC_CHANGE);
} }
@ -221,7 +221,7 @@ public class RailButton extends ExternalComponent implements LineInstanceable {
@Override @Override
public Type getPresetType() { public Type getPresetType() {
return ComponentPreset.Type.LAUNCH_LUG; return ComponentPreset.Type.RAIL_BUTTON;
} }
@Override @Override
@ -258,7 +258,7 @@ public class RailButton extends ExternalComponent implements LineInstanceable {
@Override @Override
public void setInstanceSeparation(final double _separation){ public void setInstanceSeparation(final double _separation){
this.instanceSeparation = _separation; this.instanceSeparation = _separation;
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE); fireComponentChangeEvent(ComponentChangeEvent.AERODYNAMIC_CHANGE);
} }
@Override @Override