Merge pull request #268 from teyrana/configfix
Multiple Configuration Fixes
This commit is contained in:
commit
1a3b5efb74
@ -25,5 +25,7 @@
|
|||||||
<classpathentry kind="lib" path="/OpenRocket Test Libraries/junit-dep-4.8.2.jar"/>
|
<classpathentry kind="lib" path="/OpenRocket Test Libraries/junit-dep-4.8.2.jar"/>
|
||||||
<classpathentry kind="lib" path="/OpenRocket Test Libraries/test-plugin.jar"/>
|
<classpathentry kind="lib" path="/OpenRocket Test Libraries/test-plugin.jar"/>
|
||||||
<classpathentry kind="lib" path="/OpenRocket Test Libraries/uispec4j-2.3-jdk16.jar"/>
|
<classpathentry kind="lib" path="/OpenRocket Test Libraries/uispec4j-2.3-jdk16.jar"/>
|
||||||
|
<classpathentry kind="lib" path="/OpenRocket Swing/lib/logback-classic-1.0.12.jar"/>
|
||||||
|
<classpathentry kind="lib" path="/OpenRocket Swing/lib/logback-core-1.0.12.jar"/>
|
||||||
<classpathentry kind="output" path="bin"/>
|
<classpathentry kind="output" path="bin"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
@ -164,7 +164,7 @@ public class OpenRocketDocument implements ComponentChangeListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public FlightConfiguration getDefaultConfiguration() {
|
public FlightConfiguration getSelectedConfiguration() {
|
||||||
return rocket.getSelectedConfiguration();
|
return rocket.getSelectedConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -286,7 +286,7 @@ public class OpenRocketDocument implements ComponentChangeListener {
|
|||||||
removeSimulation(s);
|
removeSimulation(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rocket.removeFlightConfigurationID(configId);
|
rocket.removeFlightConfiguration(configId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -62,9 +62,7 @@ class MotorConfigurationHandler extends AbstractElementHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ("true".equals(attributes.remove("default"))) {
|
if ("true".equals(attributes.remove("default"))) {
|
||||||
// also associate this configuration with the default.
|
rocket.setSelectedConfiguration( fcid);
|
||||||
FlightConfiguration fc = rocket.getFlightConfiguration(fcid);
|
|
||||||
rocket.setSelectedConfiguration( fc);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
super.closeElement(element, attributes, content, warnings);
|
super.closeElement(element, attributes, content, warnings);
|
||||||
|
@ -53,7 +53,7 @@ public class OpenRocketLoader extends AbstractRocketLoader {
|
|||||||
throw new RocketLoadException("Malformed XML in input.", e);
|
throw new RocketLoadException("Malformed XML in input.", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
doc.getDefaultConfiguration().setAllStages();
|
doc.getSelectedConfiguration().setAllStages();
|
||||||
|
|
||||||
// Deduce suitable time skip
|
// Deduce suitable time skip
|
||||||
double timeSkip = StorageOptions.SIMULATION_DATA_NONE;
|
double timeSkip = StorageOptions.SIMULATION_DATA_NONE;
|
||||||
|
@ -16,19 +16,18 @@ public class MotorConfiguration implements FlightConfigurableParameter<MotorConf
|
|||||||
|
|
||||||
public static final String EMPTY_DESCRIPTION = "Empty Motor Configuration".intern();
|
public static final String EMPTY_DESCRIPTION = "Empty Motor Configuration".intern();
|
||||||
|
|
||||||
protected final MotorMount mount;
|
private final MotorMount mount;
|
||||||
protected final FlightConfigurationId fcid;
|
private final FlightConfigurationId fcid;
|
||||||
protected final MotorConfigurationId id;
|
private final MotorConfigurationId mid;
|
||||||
|
|
||||||
protected String name = "";
|
private Motor motor = null;
|
||||||
protected Motor motor = null;
|
private double ejectionDelay = 0.0;
|
||||||
protected double ejectionDelay = 0.0;
|
|
||||||
|
|
||||||
protected boolean ignitionOveride = false;
|
private boolean ignitionOveride = false;
|
||||||
protected double ignitionDelay = 0.0;
|
private double ignitionDelay = 0.0;
|
||||||
protected IgnitionEvent ignitionEvent = IgnitionEvent.AUTOMATIC;
|
private IgnitionEvent ignitionEvent = IgnitionEvent.AUTOMATIC;
|
||||||
|
|
||||||
protected int modID = 0;
|
private int modID = 0;
|
||||||
|
|
||||||
public MotorConfiguration( final MotorMount _mount, final FlightConfigurationId _fcid ) {
|
public MotorConfiguration( final MotorMount _mount, final FlightConfigurationId _fcid ) {
|
||||||
if (null == _mount ) {
|
if (null == _mount ) {
|
||||||
@ -40,7 +39,7 @@ public class MotorConfiguration implements FlightConfigurableParameter<MotorConf
|
|||||||
|
|
||||||
this.mount = _mount;
|
this.mount = _mount;
|
||||||
this.fcid = _fcid;
|
this.fcid = _fcid;
|
||||||
this.id = new MotorConfigurationId( _mount, _fcid );
|
this.mid = new MotorConfigurationId( _mount, _fcid );
|
||||||
|
|
||||||
modID++;
|
modID++;
|
||||||
}
|
}
|
||||||
@ -68,7 +67,15 @@ public class MotorConfiguration implements FlightConfigurableParameter<MotorConf
|
|||||||
}
|
}
|
||||||
|
|
||||||
public MotorConfigurationId getID() {
|
public MotorConfigurationId getID() {
|
||||||
return this.id;
|
return this.mid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FlightConfigurationId getFCID() {
|
||||||
|
return fcid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MotorConfigurationId getMID() {
|
||||||
|
return mid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMotor(Motor motor){
|
public void setMotor(Motor motor){
|
||||||
@ -175,7 +182,7 @@ public class MotorConfiguration implements FlightConfigurableParameter<MotorConf
|
|||||||
return false;
|
return false;
|
||||||
}else if( other instanceof MotorConfiguration ){
|
}else if( other instanceof MotorConfiguration ){
|
||||||
MotorConfiguration omi = (MotorConfiguration)other;
|
MotorConfiguration omi = (MotorConfiguration)other;
|
||||||
if( this.id.equals( omi.id)){
|
if( this.mid.equals( omi.mid)){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -184,7 +191,7 @@ public class MotorConfiguration implements FlightConfigurableParameter<MotorConf
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return this.id.hashCode();
|
return this.mid.hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -202,6 +209,19 @@ public class MotorConfiguration implements FlightConfigurableParameter<MotorConf
|
|||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MotorConfiguration copy( final FlightConfigurationId copyId){
|
||||||
|
MotorConfiguration clone = new MotorConfiguration( this.mount, copyId);
|
||||||
|
clone.motor = this.motor;
|
||||||
|
clone.ejectionDelay = this.ejectionDelay;
|
||||||
|
clone.ignitionOveride = this.ignitionOveride;
|
||||||
|
clone.ignitionDelay = this.ignitionDelay;
|
||||||
|
clone.ignitionEvent = this.ignitionEvent;
|
||||||
|
return clone;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public int getModID() {
|
public int getModID() {
|
||||||
return modID;
|
return modID;
|
||||||
}
|
}
|
||||||
@ -223,9 +243,10 @@ public class MotorConfiguration implements FlightConfigurableParameter<MotorConf
|
|||||||
public String toDebugDetail( ) {
|
public String toDebugDetail( ) {
|
||||||
StringBuilder buf = new StringBuilder();
|
StringBuilder buf = new StringBuilder();
|
||||||
|
|
||||||
buf.append(String.format(">> in: %28s::%10s %8s ign@: %12s ",
|
buf.append(String.format("[in: %28s][fcid %10s][mid %10s][ %8s ign@: %12s]",
|
||||||
mount.getDebugName(),
|
mount.getDebugName(),
|
||||||
fcid.toShortKey(),
|
fcid.toShortKey(),
|
||||||
|
mid.toDebug(),
|
||||||
toMotorDescription(),
|
toMotorDescription(),
|
||||||
toIgnitionDescription() ));
|
toIgnitionDescription() ));
|
||||||
|
|
||||||
|
@ -18,17 +18,12 @@ public final class MotorConfigurationId {
|
|||||||
|
|
||||||
private final static String ERROR_ID_TEXT = "MotorInstance Error Id".intern();
|
private final static String ERROR_ID_TEXT = "MotorInstance Error Id".intern();
|
||||||
private final static UUID ERROR_KEY = new UUID( 62274413, 56768908);
|
private final static UUID ERROR_KEY = new UUID( 62274413, 56768908);
|
||||||
public final static MotorConfigurationId ERROR_ID = new MotorConfigurationId();
|
|
||||||
|
|
||||||
private MotorConfigurationId( ) {
|
|
||||||
this.key = MotorConfigurationId.ERROR_KEY;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sole constructor.
|
* Sole constructor.
|
||||||
*
|
*
|
||||||
* @param componentName the component ID, must not be null
|
* @param _mount the component ID, must not be null
|
||||||
* @param number a positive motor number
|
* @param _fcid the key for a
|
||||||
*/
|
*/
|
||||||
public MotorConfigurationId(final MotorMount _mount, final FlightConfigurationId _fcid) {
|
public MotorConfigurationId(final MotorMount _mount, final FlightConfigurationId _fcid) {
|
||||||
if (null == _mount ) {
|
if (null == _mount ) {
|
||||||
@ -38,13 +33,11 @@ public final class MotorConfigurationId {
|
|||||||
throw new NullPointerException("Provided FlightConfigurationId was null");
|
throw new NullPointerException("Provided FlightConfigurationId was null");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use intern so comparison can be done using == instead of equals()
|
final long mountHash= ((long)_mount.getID().hashCode()) << 32;
|
||||||
final long upper = ((long)_mount.getID().hashCode()) << 32;
|
final long fcidLower = _fcid.key.getMostSignificantBits();
|
||||||
final long lower = _fcid.key.getLeastSignificantBits();
|
this.key = new UUID( mountHash, fcidLower);
|
||||||
this.key = new UUID( upper, lower);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object other) {
|
public boolean equals(Object other) {
|
||||||
if (this == other)
|
if (this == other)
|
||||||
@ -62,6 +55,10 @@ public final class MotorConfigurationId {
|
|||||||
return key.hashCode();
|
return key.hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String toDebug(){
|
||||||
|
return toShortKey();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString(){
|
public String toString(){
|
||||||
if( this.key == MotorConfigurationId.ERROR_KEY){
|
if( this.key == MotorConfigurationId.ERROR_KEY){
|
||||||
@ -70,4 +67,13 @@ public final class MotorConfigurationId {
|
|||||||
return key.toString();
|
return key.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String toShortKey() {
|
||||||
|
final String keyString = key.toString();
|
||||||
|
final int lastIndex = -1 + keyString.length();
|
||||||
|
final int chunkLen = 4;
|
||||||
|
|
||||||
|
// return the head + tail of the full 64-character id
|
||||||
|
return (keyString.substring(0,chunkLen)+"/"+keyString.substring(lastIndex - chunkLen,lastIndex));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ import net.sf.openrocket.rocketcomponent.ComponentChangeEvent;
|
|||||||
import net.sf.openrocket.rocketcomponent.FlightConfigurableParameterSet;
|
import net.sf.openrocket.rocketcomponent.FlightConfigurableParameterSet;
|
||||||
import net.sf.openrocket.rocketcomponent.FlightConfigurationId;
|
import net.sf.openrocket.rocketcomponent.FlightConfigurationId;
|
||||||
import net.sf.openrocket.rocketcomponent.MotorMount;
|
import net.sf.openrocket.rocketcomponent.MotorMount;
|
||||||
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FlightConfigurationSet for motors.
|
* FlightConfigurationSet for motors.
|
||||||
@ -24,8 +23,15 @@ public class MotorConfigurationSet extends FlightConfigurableParameterSet<MotorC
|
|||||||
* @param component the rocket component on which events are fired when the parameter values are changed
|
* @param component the rocket component on which events are fired when the parameter values are changed
|
||||||
* @param eventType the event type that will be fired on changes
|
* @param eventType the event type that will be fired on changes
|
||||||
*/
|
*/
|
||||||
public MotorConfigurationSet(FlightConfigurableParameterSet<MotorConfiguration> configSet, RocketComponent component) {
|
public MotorConfigurationSet(FlightConfigurableParameterSet<MotorConfiguration> sourceSet, final MotorMount newMount) {
|
||||||
super(configSet);
|
// creates a new empty config w/ default value
|
||||||
|
super( new MotorConfiguration( newMount, FlightConfigurationId.DEFAULT_VALUE_FCID ));
|
||||||
|
|
||||||
|
for( MotorConfiguration sourceConfig : sourceSet ){
|
||||||
|
FlightConfigurationId nextFCID = sourceConfig.getFCID();
|
||||||
|
MotorConfiguration nextValue = new MotorConfiguration( newMount, nextFCID, sourceConfig);
|
||||||
|
set( nextFCID, nextValue );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -37,15 +43,24 @@ public class MotorConfigurationSet extends FlightConfigurableParameterSet<MotorC
|
|||||||
public String toDebug(){
|
public String toDebug(){
|
||||||
StringBuilder buffer = new StringBuilder();
|
StringBuilder buffer = new StringBuilder();
|
||||||
final MotorMount mnt = this.getDefault().getMount();
|
final MotorMount mnt = this.getDefault().getMount();
|
||||||
buffer.append("====== Dumping MotorConfigurationSet: "+this.size()+ " motors in "+mnt.getDebugName()+" \n");
|
buffer.append(String.format(" ====== Dumping MotorConfigurationSet: %d motors in %s ====== ",
|
||||||
|
this.size(), mnt.getDebugName() ));
|
||||||
|
|
||||||
for( FlightConfigurationId loopFCID : this.map.keySet()){
|
for( FlightConfigurationId loopFCID : this.map.keySet()){
|
||||||
MotorConfiguration curConfig = this.map.get(loopFCID);
|
MotorConfiguration curConfig = this.map.get(loopFCID);
|
||||||
if( this.isDefault(loopFCID)){
|
if( this.isDefault(loopFCID)){
|
||||||
buffer.append( " [DEFAULT] "+curConfig.toDebugDetail()+"\n");
|
buffer.append( " [DEF]");
|
||||||
}else{
|
}else{
|
||||||
buffer.append( " "+curConfig.toDebugDetail() +"\n");
|
buffer.append( " ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
buffer.append(String.format("@%10s=[fcid//%8s][mid//%8s][ %8s ign@: %12s]\n",
|
||||||
|
loopFCID.toShortKey(),
|
||||||
|
curConfig.getFCID().toShortKey(),
|
||||||
|
curConfig.getMID().toShortKey(),
|
||||||
|
curConfig.toMotorDescription(),
|
||||||
|
curConfig.toIgnitionDescription() ));
|
||||||
|
|
||||||
}
|
}
|
||||||
return buffer.toString();
|
return buffer.toString();
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,11 @@ public class AxialStage extends ComponentAssembly implements FlightConfigurableC
|
|||||||
return separations;
|
return separations;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reset( final FlightConfigurationId fcid){
|
||||||
|
separations.reset(fcid);
|
||||||
|
}
|
||||||
|
|
||||||
// not strictly accurate, but this should provide an acceptable estimate for total vehicle size
|
// not strictly accurate, but this should provide an acceptable estimate for total vehicle size
|
||||||
@Override
|
@Override
|
||||||
public Collection<Coordinate> getComponentBounds() {
|
public Collection<Coordinate> getComponentBounds() {
|
||||||
@ -72,8 +77,8 @@ public class AxialStage extends ComponentAssembly implements FlightConfigurableC
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void cloneFlightConfiguration(FlightConfigurationId oldConfigId, FlightConfigurationId newConfigId) {
|
public void copyFlightConfiguration(FlightConfigurationId oldConfigId, FlightConfigurationId newConfigId) {
|
||||||
separations.cloneFlightConfiguration(oldConfigId, newConfigId);
|
separations.copyFlightConfiguration(oldConfigId, newConfigId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -92,7 +92,6 @@ public class BodyTube extends SymmetricComponent implements MotorMount, Coaxial
|
|||||||
return outerRadius;
|
return outerRadius;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the outer radius of the body tube. If the radius is less than the wall thickness,
|
* Set the outer radius of the body tube. If the radius is less than the wall thickness,
|
||||||
* the wall thickness is decreased accordingly of the value of the radius.
|
* the wall thickness is decreased accordingly of the value of the radius.
|
||||||
@ -397,8 +396,13 @@ public class BodyTube extends SymmetricComponent implements MotorMount, Coaxial
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void cloneFlightConfiguration(FlightConfigurationId oldConfigId, FlightConfigurationId newConfigId) {
|
public void reset( final FlightConfigurationId fcid){
|
||||||
motors.cloneFlightConfiguration(oldConfigId, newConfigId);
|
this.motors.reset(fcid);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void copyFlightConfiguration(FlightConfigurationId oldConfigId, FlightConfigurationId newConfigId) {
|
||||||
|
motors.copyFlightConfiguration(oldConfigId, newConfigId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -141,6 +141,9 @@ public class DeploymentConfiguration implements FlightConfigurableParameter<Depl
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DeploymentConfiguration clone() {
|
public DeploymentConfiguration clone() {
|
||||||
|
return copy(null);
|
||||||
|
}
|
||||||
|
public DeploymentConfiguration copy( final FlightConfigurationId copyId) {
|
||||||
DeploymentConfiguration that = new DeploymentConfiguration();
|
DeploymentConfiguration that = new DeploymentConfiguration();
|
||||||
that.deployAltitude = this.deployAltitude;
|
that.deployAltitude = this.deployAltitude;
|
||||||
that.deployDelay = this.deployDelay;
|
that.deployDelay = this.deployDelay;
|
||||||
|
@ -14,6 +14,13 @@ public interface FlightConfigurableComponent {
|
|||||||
* @param oldConfigId the old configuration ID
|
* @param oldConfigId the old configuration ID
|
||||||
* @param newConfigId the new configuration ID
|
* @param newConfigId the new configuration ID
|
||||||
*/
|
*/
|
||||||
public void cloneFlightConfiguration(FlightConfigurationId oldConfigId, FlightConfigurationId newConfigId);
|
void copyFlightConfiguration(FlightConfigurationId oldConfigId, FlightConfigurationId newConfigId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reset a specific flight configuration ID to use the default parameter value.
|
||||||
|
*
|
||||||
|
* @param fcid the flight configuration ID
|
||||||
|
*/
|
||||||
|
void reset( final FlightConfigurationId fcid);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -10,11 +10,18 @@ package net.sf.openrocket.rocketcomponent;
|
|||||||
public interface FlightConfigurableParameter<E> {
|
public interface FlightConfigurableParameter<E> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a copy of this object. The listeners must not be copied
|
* return an exact copy of this object
|
||||||
* to the new object.
|
|
||||||
*/
|
*/
|
||||||
public E clone();
|
E clone();
|
||||||
|
|
||||||
public void update();
|
/**
|
||||||
|
* return a copy of this object, corresponding to the specified Id
|
||||||
|
*
|
||||||
|
* @param fcid id to attach the new object to
|
||||||
|
* @return the desired copy
|
||||||
|
*/
|
||||||
|
E copy( final FlightConfigurationId fcid );
|
||||||
|
|
||||||
|
void update();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -22,23 +22,20 @@ public class FlightConfigurableParameterSet<E extends FlightConfigurableParamete
|
|||||||
|
|
||||||
//private static final Logger log = LoggerFactory.getLogger(ParameterSet.class);
|
//private static final Logger log = LoggerFactory.getLogger(ParameterSet.class);
|
||||||
protected final HashMap<FlightConfigurationId, E> map = new HashMap<FlightConfigurationId, E>();
|
protected final HashMap<FlightConfigurationId, E> map = new HashMap<FlightConfigurationId, E>();
|
||||||
protected static final FlightConfigurationId defaultValueId = FlightConfigurationId.DEFAULT_VALUE_FCID;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a FlightConfiguration that has no overrides.
|
* Construct a FlightConfiguration that has no overrides.
|
||||||
*
|
*
|
||||||
* @param component the rocket component on which events are fired when the parameter values are changed
|
* @param _defaultValue the first default value
|
||||||
* @param eventType the event type that will be fired on changes
|
|
||||||
*/
|
*/
|
||||||
public FlightConfigurableParameterSet(E _defaultValue) {
|
public FlightConfigurableParameterSet(E _defaultValue) {
|
||||||
this.map.put( defaultValueId, _defaultValue);
|
this.map.put( FlightConfigurationId.DEFAULT_VALUE_FCID, _defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a copy of an existing FlightConfigurationImpl.
|
* Construct a copy of an existing FlightConfigurationImpl.
|
||||||
*
|
*
|
||||||
* @param component the rocket component on which events are fired when the parameter values are changed
|
* @param configSet the FlightConfigurableParameterSet to copy
|
||||||
* @param eventType the event type that will be fired on changes
|
|
||||||
*/
|
*/
|
||||||
public FlightConfigurableParameterSet(FlightConfigurableParameterSet<E> configSet ){
|
public FlightConfigurableParameterSet(FlightConfigurableParameterSet<E> configSet ){
|
||||||
for (FlightConfigurationId key : configSet.map.keySet()) {
|
for (FlightConfigurationId key : configSet.map.keySet()) {
|
||||||
@ -55,7 +52,7 @@ public class FlightConfigurableParameterSet<E extends FlightConfigurableParamete
|
|||||||
* @return the default parameter value (never null)
|
* @return the default parameter value (never null)
|
||||||
*/
|
*/
|
||||||
public E getDefault(){
|
public E getDefault(){
|
||||||
return this.map.get( defaultValueId);
|
return this.map.get( FlightConfigurationId.DEFAULT_VALUE_FCID );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -63,7 +60,7 @@ public class FlightConfigurableParameterSet<E extends FlightConfigurableParamete
|
|||||||
*This is used in case a per-flight configuration override
|
*This is used in case a per-flight configuration override
|
||||||
* has not been defined.
|
* has not been defined.
|
||||||
*
|
*
|
||||||
* @param value the parameter value (null not allowed)
|
* @param nextDefaultValue the parameter value (null not allowed)
|
||||||
*/
|
*/
|
||||||
public void setDefault(E nextDefaultValue) {
|
public void setDefault(E nextDefaultValue) {
|
||||||
if (nextDefaultValue == null) {
|
if (nextDefaultValue == null) {
|
||||||
@ -72,9 +69,14 @@ public class FlightConfigurableParameterSet<E extends FlightConfigurableParamete
|
|||||||
if( this.isDefault(nextDefaultValue)){
|
if( this.isDefault(nextDefaultValue)){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.map.put( defaultValueId, nextDefaultValue);
|
this.map.put( FlightConfigurationId.DEFAULT_VALUE_FCID, nextDefaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean containsId( final FlightConfigurationId fcid){
|
||||||
|
return this.map.containsKey(fcid);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterator<E> iterator() {
|
public Iterator<E> iterator() {
|
||||||
return map.values().iterator();
|
return map.values().iterator();
|
||||||
@ -93,7 +95,7 @@ public class FlightConfigurableParameterSet<E extends FlightConfigurableParamete
|
|||||||
* This returns either the value specified for this flight config ID,
|
* This returns either the value specified for this flight config ID,
|
||||||
* or the default value.
|
* or the default value.
|
||||||
*
|
*
|
||||||
* @param value the parameter to find
|
* @param testValue the parameter to find
|
||||||
* @return the flight configuration ID
|
* @return the flight configuration ID
|
||||||
*/
|
*/
|
||||||
public FlightConfigurationId getId(E testValue) {
|
public FlightConfigurationId getId(E testValue) {
|
||||||
@ -121,7 +123,7 @@ public class FlightConfigurableParameterSet<E extends FlightConfigurableParamete
|
|||||||
+" than the stored values: "+index+"/"+this.map.size());
|
+" than the stored values: "+index+"/"+this.map.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
List<FlightConfigurationId> ids = this.getSortedConfigurationIDs();
|
List<FlightConfigurationId> ids = this.getIds();
|
||||||
FlightConfigurationId selectedId = ids.get(index);
|
FlightConfigurationId selectedId = ids.get(index);
|
||||||
return this.map.get(selectedId);
|
return this.map.get(selectedId);
|
||||||
}
|
}
|
||||||
@ -135,9 +137,6 @@ public class FlightConfigurableParameterSet<E extends FlightConfigurableParamete
|
|||||||
* @return the parameter to use (never null)
|
* @return the parameter to use (never null)
|
||||||
*/
|
*/
|
||||||
public E get(FlightConfigurationId id) {
|
public E get(FlightConfigurationId id) {
|
||||||
if( id.hasError() ){
|
|
||||||
throw new NullPointerException("Attempted to retrieve a parameter with an error key!");
|
|
||||||
}
|
|
||||||
E toReturn;
|
E toReturn;
|
||||||
if (map.containsKey(id)) {
|
if (map.containsKey(id)) {
|
||||||
toReturn = map.get(id);
|
toReturn = map.get(id);
|
||||||
@ -147,14 +146,15 @@ public class FlightConfigurableParameterSet<E extends FlightConfigurableParamete
|
|||||||
return toReturn;
|
return toReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return a sorted list of all the contained FlightConfigurationIDs
|
* @return a sorted list of all the contained FlightConfigurationIDs
|
||||||
*/
|
*/
|
||||||
public List<FlightConfigurationId> getSortedConfigurationIDs(){
|
public List<FlightConfigurationId> getIds(){
|
||||||
ArrayList<FlightConfigurationId> toReturn = new ArrayList<FlightConfigurationId>();
|
ArrayList<FlightConfigurationId> toReturn = new ArrayList<FlightConfigurationId>();
|
||||||
|
|
||||||
toReturn.addAll( this.map.keySet() );
|
toReturn.addAll( this.map.keySet() );
|
||||||
toReturn.remove( defaultValueId );
|
toReturn.remove( FlightConfigurationId.DEFAULT_VALUE_FCID );
|
||||||
// Java 1.8:
|
// Java 1.8:
|
||||||
//toReturn.sort( null );
|
//toReturn.sort( null );
|
||||||
|
|
||||||
@ -164,21 +164,20 @@ public class FlightConfigurableParameterSet<E extends FlightConfigurableParamete
|
|||||||
return toReturn;
|
return toReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<FlightConfigurationId> getIds(){
|
|
||||||
return this.getSortedConfigurationIDs();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the parameter value for the provided flight configuration ID.
|
* Set the parameter value for the provided flight configuration ID.
|
||||||
* This sets the override for this flight configuration ID.
|
* This sets the override for this flight configuration ID.
|
||||||
*
|
*
|
||||||
* @param id the flight configuration ID
|
* @param fcid the flight configuration ID
|
||||||
* @param value the parameter value (null not allowed)
|
* @param nextValue the parameter value (null not allowed)
|
||||||
*/
|
*/
|
||||||
public void set(FlightConfigurationId fcid, E nextValue) {
|
public void set( final FlightConfigurationId fcid, E nextValue) {
|
||||||
if ( nextValue == null) {
|
if ( nextValue == null) {
|
||||||
// null value means to delete this fcid
|
// null value means to delete this fcid
|
||||||
this.map.remove(fcid);
|
this.map.remove(fcid);
|
||||||
|
}else if( FlightConfigurationId.DEFAULT_VALUE_FCID == fcid ){
|
||||||
|
// if a user wants to set the default value, make them do it explicitly with .setDefaultValue(...)
|
||||||
|
return;
|
||||||
}else{
|
}else{
|
||||||
this.map.put(fcid, nextValue);
|
this.map.put(fcid, nextValue);
|
||||||
}
|
}
|
||||||
@ -187,7 +186,7 @@ public class FlightConfigurableParameterSet<E extends FlightConfigurableParamete
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean isDefault(E testVal) {
|
public boolean isDefault( final E testVal) {
|
||||||
return (Utils.equals( this.getDefault(), testVal));
|
return (Utils.equals( this.getDefault(), testVal));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,19 +194,19 @@ public class FlightConfigurableParameterSet<E extends FlightConfigurableParamete
|
|||||||
* Return whether a specific flight configuration ID is using the
|
* Return whether a specific flight configuration ID is using the
|
||||||
* default value.
|
* default value.
|
||||||
*
|
*
|
||||||
* @param id the flight configuration ID
|
* @param fcid the flight configuration ID
|
||||||
* @return whether the default is being used
|
* @return whether the default is being used
|
||||||
*/
|
*/
|
||||||
public boolean isDefault( FlightConfigurationId fcid) {
|
public boolean isDefault( final FlightConfigurationId fcid) {
|
||||||
return ( this.getDefault() == this.map.get(fcid));
|
return ( this.getDefault() == this.map.get(fcid));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset a specific flight configuration ID to use the default parameter value.
|
* Reset a specific flight configuration ID to use the default parameter value.
|
||||||
*
|
*
|
||||||
* @param id the flight configuration ID
|
* @param fcid the flight configuration ID
|
||||||
*/
|
*/
|
||||||
public void reset( FlightConfigurationId fcid) {
|
public void reset( final FlightConfigurationId fcid) {
|
||||||
if( fcid.isValid() ){
|
if( fcid.isValid() ){
|
||||||
set( fcid, null);
|
set( fcid, null);
|
||||||
}
|
}
|
||||||
@ -222,10 +221,11 @@ public class FlightConfigurableParameterSet<E extends FlightConfigurableParamete
|
|||||||
setDefault(tempValue);
|
setDefault(tempValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
public FlightConfigurationId cloneFlightConfiguration(FlightConfigurationId oldConfigId, FlightConfigurationId newConfigId) {
|
public FlightConfigurationId copyFlightConfiguration(FlightConfigurationId oldConfigId, FlightConfigurationId newConfigId) {
|
||||||
// clones the ENTRIES for the given fcid's.
|
// clones the ENTRIES for the given fcid's.
|
||||||
E oldValue = this.get(oldConfigId);
|
E oldValue = this.get(oldConfigId);
|
||||||
this.set(newConfigId, oldValue.clone());
|
E newValue = oldValue.copy( newConfigId);
|
||||||
|
this.set(newConfigId, newValue );
|
||||||
update();
|
update();
|
||||||
return newConfigId;
|
return newConfigId;
|
||||||
}
|
}
|
||||||
@ -235,7 +235,7 @@ public class FlightConfigurableParameterSet<E extends FlightConfigurableParamete
|
|||||||
StringBuilder buf = new StringBuilder();
|
StringBuilder buf = new StringBuilder();
|
||||||
buf.append(String.format("====== Dumping ConfigurationSet<%s> (%d configurations)\n", this.getDefault().getClass().getSimpleName(), this.size() ));
|
buf.append(String.format("====== Dumping ConfigurationSet<%s> (%d configurations)\n", this.getDefault().getClass().getSimpleName(), this.size() ));
|
||||||
final String fmt = " [%-12s]: %s\n";
|
final String fmt = " [%-12s]: %s\n";
|
||||||
for( FlightConfigurationId loopFCID : this.getSortedConfigurationIDs()){
|
for( FlightConfigurationId loopFCID : getIds()){
|
||||||
String shortKey = loopFCID.toShortKey();
|
String shortKey = loopFCID.toShortKey();
|
||||||
E inst = this.map.get(loopFCID);
|
E inst = this.map.get(loopFCID);
|
||||||
if( this.isDefault(inst)){
|
if( this.isDefault(inst)){
|
||||||
@ -246,12 +246,14 @@ public class FlightConfigurableParameterSet<E extends FlightConfigurableParamete
|
|||||||
return buf.toString();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void update(){
|
public void update(){
|
||||||
for( E curValue: this.map.values() ){
|
for( E curValue: this.map.values() ){
|
||||||
curValue.update();
|
curValue.update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public FlightConfiguration[] toArray() {
|
||||||
|
return map.values().toArray( new FlightConfiguration[0]);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@ import java.util.HashMap;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@ -29,18 +28,19 @@ import net.sf.openrocket.util.Monitorable;
|
|||||||
public class FlightConfiguration implements FlightConfigurableParameter<FlightConfiguration>, Monitorable {
|
public class FlightConfiguration implements FlightConfigurableParameter<FlightConfiguration>, Monitorable {
|
||||||
private static final Logger log = LoggerFactory.getLogger(FlightConfiguration.class);
|
private static final Logger log = LoggerFactory.getLogger(FlightConfiguration.class);
|
||||||
|
|
||||||
public final static String DEFAULT_CONFIGURATION_NAME = "Default Configuration".intern();
|
private final static String NO_MOTORS_NAME = "[No Motors Defined]";
|
||||||
public final static String NO_MOTORS_TEXT = "[No Motors Defined]".intern();
|
private final static String DEFAULT_CONFIGURATION_NAME = NO_MOTORS_NAME;
|
||||||
|
|
||||||
protected String configurationName=null;
|
private String configurationName=null;
|
||||||
|
|
||||||
protected final Rocket rocket;
|
protected final Rocket rocket;
|
||||||
protected final FlightConfigurationId fcid;
|
protected final FlightConfigurationId fcid;
|
||||||
|
|
||||||
protected static int instanceCount=0;
|
private static int instanceCount=0;
|
||||||
|
// made public for testing.... there is probably a better way
|
||||||
public final int instanceNumber;
|
public final int instanceNumber;
|
||||||
|
|
||||||
protected class StageFlags implements Cloneable {
|
private class StageFlags implements Cloneable {
|
||||||
public boolean active = true;
|
public boolean active = true;
|
||||||
public int prev = -1;
|
public int prev = -1;
|
||||||
public AxialStage stage = null;
|
public AxialStage stage = null;
|
||||||
@ -51,15 +51,10 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
|
|||||||
this.active = _active;
|
this.active = _active;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getKey(){
|
|
||||||
return this.stage.getStageNumber();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StageFlags clone(){
|
public StageFlags clone(){
|
||||||
return new StageFlags( this.stage, this.prev, true);
|
return new StageFlags( this.stage, this.prev, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Cached data */
|
/* Cached data */
|
||||||
@ -119,7 +114,7 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
|
|||||||
/**
|
/**
|
||||||
* This method flags a stage inactive. Other stages are unaffected.
|
* This method flags a stage inactive. Other stages are unaffected.
|
||||||
*
|
*
|
||||||
* @param stageNumber stage number to inactivate
|
* @param stageNumber stage number to turn off
|
||||||
*/
|
*/
|
||||||
public void clearStage(final int stageNumber) {
|
public void clearStage(final int stageNumber) {
|
||||||
_setStageActive( stageNumber, false );
|
_setStageActive( stageNumber, false );
|
||||||
@ -175,16 +170,14 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
|
|||||||
|
|
||||||
public Collection<RocketComponent> getActiveComponents() {
|
public Collection<RocketComponent> getActiveComponents() {
|
||||||
Queue<RocketComponent> toProcess = new ArrayDeque<RocketComponent>(this.getActiveStages());
|
Queue<RocketComponent> toProcess = new ArrayDeque<RocketComponent>(this.getActiveStages());
|
||||||
ArrayList<RocketComponent> toReturn = new ArrayList<RocketComponent>();
|
ArrayList<RocketComponent> toReturn = new ArrayList<>();
|
||||||
|
|
||||||
while (!toProcess.isEmpty()) {
|
while (!toProcess.isEmpty()) {
|
||||||
RocketComponent comp = toProcess.poll();
|
RocketComponent comp = toProcess.poll();
|
||||||
|
|
||||||
toReturn.add(comp);
|
toReturn.add(comp);
|
||||||
for (RocketComponent child : comp.getChildren()) {
|
for (RocketComponent child : comp.getChildren()) {
|
||||||
if (child instanceof AxialStage) {
|
if (!(child instanceof AxialStage)) {
|
||||||
continue;
|
|
||||||
} else {
|
|
||||||
toProcess.offer(child);
|
toProcess.offer(child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -194,7 +187,7 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<AxialStage> getActiveStages() {
|
public List<AxialStage> getActiveStages() {
|
||||||
List<AxialStage> activeStages = new ArrayList<AxialStage>();
|
List<AxialStage> activeStages = new ArrayList<>();
|
||||||
|
|
||||||
for (StageFlags flags : this.stages.values()) {
|
for (StageFlags flags : this.stages.values()) {
|
||||||
if (flags.active) {
|
if (flags.active) {
|
||||||
@ -216,8 +209,7 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the bottom-most active stage.
|
* @return the component for the bottom-most center, active stage.
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public AxialStage getBottomStage() {
|
public AxialStage getBottomStage() {
|
||||||
AxialStage bottomStage = null;
|
AxialStage bottomStage = null;
|
||||||
@ -256,7 +248,7 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
|
|||||||
}
|
}
|
||||||
|
|
||||||
public FlightConfigurationId getId() {
|
public FlightConfigurationId getId() {
|
||||||
return getFlightConfigurationID();
|
return fcid;
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////// Listeners ////////////////
|
//////////////// Listeners ////////////////
|
||||||
@ -271,7 +263,7 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
|
|||||||
updateMotors();
|
updateMotors();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void updateStages() {
|
private void updateStages() {
|
||||||
if (this.rocket.getStageCount() == this.stages.size()) {
|
if (this.rocket.getStageCount() == this.stages.size()) {
|
||||||
// no changes needed
|
// no changes needed
|
||||||
return;
|
return;
|
||||||
@ -322,17 +314,14 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( 0 == activeMotorCount ){
|
if( 0 == activeMotorCount ){
|
||||||
return NO_MOTORS_TEXT;
|
return DEFAULT_CONFIGURATION_NAME;
|
||||||
}
|
}
|
||||||
buff.append("]");
|
buff.append("]");
|
||||||
return buff.toString();
|
return buff.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() { return this.getName(); }
|
||||||
return this.getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a motor instance to this configuration.
|
* Add a motor instance to this configuration.
|
||||||
@ -344,24 +333,12 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
|
|||||||
if( motorConfig.isEmpty() ){
|
if( motorConfig.isEmpty() ){
|
||||||
throw new IllegalArgumentException("MotorInstance is empty.");
|
throw new IllegalArgumentException("MotorInstance is empty.");
|
||||||
}
|
}
|
||||||
MotorConfigurationId id = motorConfig.getID();
|
|
||||||
if (this.motors.containsKey(id)) {
|
this.motors.put( motorConfig.getID(), motorConfig);
|
||||||
throw new IllegalArgumentException("FlightConfiguration already " +
|
|
||||||
"contains a motor with id " + id);
|
|
||||||
}
|
|
||||||
this.motors.put(id, motorConfig);
|
|
||||||
|
|
||||||
modID++;
|
modID++;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<MotorConfigurationId> getMotorIDs() {
|
|
||||||
return motors.keySet();
|
|
||||||
}
|
|
||||||
|
|
||||||
public MotorConfiguration getMotorInstance(MotorConfigurationId id) {
|
|
||||||
return motors.get(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasMotors() {
|
public boolean hasMotors() {
|
||||||
return (0 < motors.size());
|
return (0 < motors.size());
|
||||||
}
|
}
|
||||||
@ -381,7 +358,7 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
|
|||||||
return activeMotors;
|
return activeMotors;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void updateMotors() {
|
private void updateMotors() {
|
||||||
this.motors.clear();
|
this.motors.clear();
|
||||||
|
|
||||||
Iterator<RocketComponent> iter = rocket.iterator(false);
|
Iterator<RocketComponent> iter = rocket.iterator(false);
|
||||||
@ -394,7 +371,7 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.motors.put( motorConfig.getID(), motorConfig);
|
this.motors.put( motorConfig.getMID(), motorConfig);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -471,14 +448,10 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public FlightConfiguration clone() {
|
public FlightConfiguration clone() {
|
||||||
// Note the motors and stages are updated in the constructor call.
|
|
||||||
FlightConfiguration clone = new FlightConfiguration( this.getRocket(), this.fcid );
|
// Note the stages are updated in the constructor call.
|
||||||
|
FlightConfiguration clone = new FlightConfiguration( this.rocket, this.fcid );
|
||||||
clone.setName("clone[#"+clone.instanceNumber+"]"+clone.fcid.toShortKey());
|
clone.setName("clone[#"+clone.instanceNumber+"]"+clone.fcid.toShortKey());
|
||||||
// log.error(">> Why am I being cloned!?", new IllegalStateException(this.toDebug()+" >to> "+clone.toDebug()));
|
|
||||||
|
|
||||||
|
|
||||||
// DO NOT UPDATE this.stages or this.motors;
|
|
||||||
// these are are updated correctly on their own.
|
|
||||||
|
|
||||||
clone.cachedBounds = this.cachedBounds.clone();
|
clone.cachedBounds = this.cachedBounds.clone();
|
||||||
clone.modID = this.modID;
|
clone.modID = this.modID;
|
||||||
@ -487,6 +460,32 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
|
|||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copy all available information attached to this, and attached copies to the
|
||||||
|
* new configuration
|
||||||
|
*
|
||||||
|
* @param copyId attached the new configuration to this Id
|
||||||
|
* @return the new configuration
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public FlightConfiguration copy( final FlightConfigurationId copyId ) {
|
||||||
|
// Note the stages are updated in the constructor call.
|
||||||
|
FlightConfiguration copy= new FlightConfiguration( this.rocket, copyId );
|
||||||
|
|
||||||
|
// copy motor instances.
|
||||||
|
for( final MotorConfiguration sourceMotor: motors.values() ){
|
||||||
|
MotorConfiguration cloneMotor = sourceMotor.copy( copyId);
|
||||||
|
copy.addMotor( cloneMotor);
|
||||||
|
cloneMotor.getMount().setMotorConfig(cloneMotor, copyId);
|
||||||
|
}
|
||||||
|
|
||||||
|
copy.cachedBounds = this.cachedBounds.clone();
|
||||||
|
copy.modID = this.modID;
|
||||||
|
copy.boundsModID = -1;
|
||||||
|
copy.refLengthModID = -1;
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getModID() {
|
public int getModID() {
|
||||||
// TODO: this doesn't seem consistent...
|
// TODO: this doesn't seem consistent...
|
||||||
@ -502,7 +501,7 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
|
|||||||
if(( null == newName ) ||( "".equals(newName))){
|
if(( null == newName ) ||( "".equals(newName))){
|
||||||
this.configurationName = null;
|
this.configurationName = null;
|
||||||
return;
|
return;
|
||||||
}else if( ! this.getFlightConfigurationID().isValid()){
|
}else if( ! this.getId().isValid()){
|
||||||
return;
|
return;
|
||||||
}else if( newName.equals(this.configurationName)){
|
}else if( newName.equals(this.configurationName)){
|
||||||
return;
|
return;
|
||||||
@ -512,10 +511,8 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object other){
|
public boolean equals(Object other){
|
||||||
if( other instanceof FlightConfiguration ){
|
return (( other instanceof FlightConfiguration ) &&
|
||||||
return this.fcid.equals( ((FlightConfiguration)other).fcid);
|
this.fcid.equals( ((FlightConfiguration)other).fcid));
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -530,10 +527,11 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
|
|||||||
// DEBUG / DEVEL
|
// DEBUG / DEVEL
|
||||||
public String toStageListDetail() {
|
public String toStageListDetail() {
|
||||||
StringBuilder buf = new StringBuilder();
|
StringBuilder buf = new StringBuilder();
|
||||||
buf.append(String.format("\nDumping %d stages for config: %s: (#: %d)\n", this.stages.size(), this.getName(), this.instanceNumber));
|
buf.append(String.format("\nDumping %d stages for config: %s: (%s)(#: %d)\n",
|
||||||
|
stages.size(), getName(), getId().toShortKey(), instanceNumber));
|
||||||
final String fmt = " [%-2s][%4s]: %6s \n";
|
final String fmt = " [%-2s][%4s]: %6s \n";
|
||||||
buf.append(String.format(fmt, "#", "?actv", "Name"));
|
buf.append(String.format(fmt, "#", "?actv", "Name"));
|
||||||
for (StageFlags flags : this.stages.values()) {
|
for (StageFlags flags : stages.values()) {
|
||||||
AxialStage curStage = flags.stage;
|
AxialStage curStage = flags.stage;
|
||||||
buf.append(String.format(fmt, curStage.getStageNumber(), (flags.active?" on": "off"), curStage.getName()));
|
buf.append(String.format(fmt, curStage.getStageNumber(), (flags.active?" on": "off"), curStage.getName()));
|
||||||
}
|
}
|
||||||
@ -545,7 +543,7 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
|
|||||||
public String toMotorDetail(){
|
public String toMotorDetail(){
|
||||||
StringBuilder buf = new StringBuilder();
|
StringBuilder buf = new StringBuilder();
|
||||||
buf.append(String.format("\nDumping %2d Motors for configuration %s (%s)(#: %s)\n",
|
buf.append(String.format("\nDumping %2d Motors for configuration %s (%s)(#: %s)\n",
|
||||||
this.motors.size(), this.getName(), this.getFlightConfigurationID().toFullKey(), this.instanceNumber));
|
motors.size(), getName(), getId().toShortKey(), this.instanceNumber));
|
||||||
|
|
||||||
for( MotorConfiguration curConfig : this.motors.values() ){
|
for( MotorConfiguration curConfig : this.motors.values() ){
|
||||||
buf.append(" "+curConfig.toDebugDetail()+"\n");
|
buf.append(" "+curConfig.toDebugDetail()+"\n");
|
||||||
|
@ -74,10 +74,6 @@ public final class FlightConfigurationId implements Comparable<FlightConfigurati
|
|||||||
return this.key.hashCode();
|
return this.key.hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
public UUID intern() {
|
|
||||||
return this.key;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasError(){
|
public boolean hasError(){
|
||||||
return (ERROR_UUID == this.key);
|
return (ERROR_UUID == this.key);
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,10 @@ public class IgnitionConfiguration implements FlightConfigurableParameter<Igniti
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IgnitionConfiguration clone() {
|
public IgnitionConfiguration clone() {
|
||||||
|
return this.copy(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IgnitionConfiguration copy( final FlightConfigurationId copyId) {
|
||||||
IgnitionConfiguration clone = new IgnitionConfiguration();
|
IgnitionConfiguration clone = new IgnitionConfiguration();
|
||||||
clone.ignitionDelay = this.ignitionDelay;
|
clone.ignitionDelay = this.ignitionDelay;
|
||||||
clone.ignitionEvent = this.ignitionEvent;
|
clone.ignitionEvent = this.ignitionEvent;
|
||||||
@ -41,7 +45,6 @@ public class IgnitionConfiguration implements FlightConfigurableParameter<Igniti
|
|||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(){
|
public void update(){
|
||||||
}
|
}
|
||||||
|
@ -304,10 +304,14 @@ public class InnerTube extends ThicknessRingComponent implements Clusterable, Ra
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void cloneFlightConfiguration(FlightConfigurationId oldConfigId, FlightConfigurationId newConfigId) {
|
public void copyFlightConfiguration(FlightConfigurationId oldConfigId, FlightConfigurationId newConfigId) {
|
||||||
motors.cloneFlightConfiguration(oldConfigId, newConfigId);
|
motors.copyFlightConfiguration(oldConfigId, newConfigId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reset( final FlightConfigurationId fcid){
|
||||||
|
this.motors.reset(fcid);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setMotorMount(boolean _active){
|
public void setMotorMount(boolean _active){
|
||||||
|
@ -81,8 +81,8 @@ public class ParallelStage extends AxialStage implements FlightConfigurableCompo
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void cloneFlightConfiguration(FlightConfigurationId oldConfigId, FlightConfigurationId newConfigId) {
|
public void copyFlightConfiguration(FlightConfigurationId oldConfigId, FlightConfigurationId newConfigId) {
|
||||||
this.separations.cloneFlightConfiguration(oldConfigId, newConfigId);
|
this.separations.copyFlightConfiguration(oldConfigId, newConfigId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -90,10 +90,14 @@ public abstract class RecoveryDevice extends MassObject implements FlightConfigu
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void cloneFlightConfiguration(FlightConfigurationId oldConfigId, FlightConfigurationId newConfigId) {
|
public void copyFlightConfiguration(FlightConfigurationId oldConfigId, FlightConfigurationId newConfigId) {
|
||||||
deploymentConfigurations.cloneFlightConfiguration(oldConfigId, newConfigId);
|
deploymentConfigurations.copyFlightConfiguration(oldConfigId, newConfigId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reset( final FlightConfigurationId fcid){
|
||||||
|
deploymentConfigurations.reset(fcid);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getComponentMass() {
|
public double getComponentMass() {
|
||||||
|
@ -34,14 +34,12 @@ public class Rocket extends RocketComponent {
|
|||||||
private static final Logger log = LoggerFactory.getLogger(Rocket.class);
|
private static final Logger log = LoggerFactory.getLogger(Rocket.class);
|
||||||
private static final Translator trans = Application.getTranslator();
|
private static final Translator trans = Application.getTranslator();
|
||||||
|
|
||||||
public static final String DEFAULT_NAME = "[{motors}]";
|
protected static final double DEFAULT_REFERENCE_LENGTH = 0.01;
|
||||||
public static final double DEFAULT_REFERENCE_LENGTH = 0.01;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of component change listeners.
|
* List of component change listeners.
|
||||||
*/
|
*/
|
||||||
private List<EventListener> listenerList = new ArrayList<EventListener>();
|
private List<EventListener> listenerList = new ArrayList<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When freezeList != null, events are not dispatched but stored in the list.
|
* When freezeList != null, events are not dispatched but stored in the list.
|
||||||
@ -68,8 +66,8 @@ public class Rocket extends RocketComponent {
|
|||||||
|
|
||||||
// Flight configuration list
|
// Flight configuration list
|
||||||
private FlightConfiguration selectedConfiguration;
|
private FlightConfiguration selectedConfiguration;
|
||||||
private HashMap<FlightConfigurationId, FlightConfiguration> configSet = new HashMap<FlightConfigurationId, FlightConfiguration>();
|
private FlightConfigurableParameterSet<FlightConfiguration> configSet;
|
||||||
private HashMap<Integer, AxialStage> stageMap = new HashMap<Integer, AxialStage>();
|
private HashMap<Integer, AxialStage> stageMap = new HashMap<>();
|
||||||
|
|
||||||
// Does the rocket have a perfect finish (a notable amount of laminar flow)
|
// Does the rocket have a perfect finish (a notable amount of laminar flow)
|
||||||
private boolean perfectFinish = false;
|
private boolean perfectFinish = false;
|
||||||
@ -85,10 +83,10 @@ public class Rocket extends RocketComponent {
|
|||||||
treeModID = modID;
|
treeModID = modID;
|
||||||
functionalModID = modID;
|
functionalModID = modID;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// must be after the hashmaps :P
|
// must be after the hashmaps :P
|
||||||
this.selectedConfiguration = new FlightConfiguration( this, null);
|
FlightConfiguration defaultConfig = new FlightConfiguration(this, FlightConfigurationId.DEFAULT_VALUE_FCID);
|
||||||
|
configSet = new FlightConfigurableParameterSet<>( defaultConfig );
|
||||||
|
this.selectedConfiguration = defaultConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDesigner() {
|
public String getDesigner() {
|
||||||
@ -210,7 +208,7 @@ public class Rocket extends RocketComponent {
|
|||||||
*
|
*
|
||||||
* @Return a reference to the topmost stage
|
* @Return a reference to the topmost stage
|
||||||
*/
|
*/
|
||||||
public AxialStage getBottomCoreStage(){
|
/*package-local*/ AxialStage getBottomCoreStage(){
|
||||||
// get last stage that's a direct child of the rocket.
|
// get last stage that's a direct child of the rocket.
|
||||||
return (AxialStage) children.get( children.size()-1 );
|
return (AxialStage) children.get( children.size()-1 );
|
||||||
}
|
}
|
||||||
@ -223,7 +221,7 @@ public class Rocket extends RocketComponent {
|
|||||||
return guess;
|
return guess;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void trackStage(final AxialStage newStage) {
|
/*package-local*/ void trackStage(final AxialStage newStage) {
|
||||||
int stageNumber = newStage.getStageNumber();
|
int stageNumber = newStage.getStageNumber();
|
||||||
AxialStage value = stageMap.get(stageNumber);
|
AxialStage value = stageMap.get(stageNumber);
|
||||||
|
|
||||||
@ -236,7 +234,7 @@ public class Rocket extends RocketComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void forgetStage(final AxialStage oldStage) {
|
/*package-local*/ void forgetStage(final AxialStage oldStage) {
|
||||||
this.stageMap.remove(oldStage.getStageNumber());
|
this.stageMap.remove(oldStage.getStageNumber());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -311,7 +309,8 @@ public class Rocket extends RocketComponent {
|
|||||||
|
|
||||||
// Rocket copy is cloned, so non-trivial members must be cloned as well:
|
// Rocket copy is cloned, so non-trivial members must be cloned as well:
|
||||||
copy.stageMap = new HashMap<Integer, AxialStage>();
|
copy.stageMap = new HashMap<Integer, AxialStage>();
|
||||||
copy.configSet = new HashMap<FlightConfigurationId, FlightConfiguration>();
|
copy.configSet = new FlightConfigurableParameterSet<FlightConfiguration>( this.configSet );
|
||||||
|
new HashMap<FlightConfigurationId, FlightConfiguration>();
|
||||||
if( 0 < this.configSet.size() ){
|
if( 0 < this.configSet.size() ){
|
||||||
Rocket.cloneConfigs( this, copy);
|
Rocket.cloneConfigs( this, copy);
|
||||||
}
|
}
|
||||||
@ -324,8 +323,8 @@ public class Rocket extends RocketComponent {
|
|||||||
source.checkState();
|
source.checkState();
|
||||||
dest.checkState();
|
dest.checkState();
|
||||||
dest.selectedConfiguration = source.selectedConfiguration.clone();
|
dest.selectedConfiguration = source.selectedConfiguration.clone();
|
||||||
for( final FlightConfiguration config : source.configSet.values() ){
|
for( final FlightConfiguration config : source.configSet ){
|
||||||
dest.configSet.put( config.getId(), config.clone() );
|
dest.configSet.set( config.getId(), config.clone() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -473,7 +472,7 @@ public class Rocket extends RocketComponent {
|
|||||||
|
|
||||||
private void updateConfigurations(){
|
private void updateConfigurations(){
|
||||||
this.selectedConfiguration.update();
|
this.selectedConfiguration.update();
|
||||||
for( FlightConfiguration config : configSet.values() ){
|
for( FlightConfiguration config : configSet ){
|
||||||
config.update();
|
config.update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -483,6 +482,11 @@ public class Rocket extends RocketComponent {
|
|||||||
// Copy the list before iterating to prevent concurrent modification exceptions.
|
// Copy the list before iterating to prevent concurrent modification exceptions.
|
||||||
EventListener[] list = listenerList.toArray(new EventListener[0]);
|
EventListener[] list = listenerList.toArray(new EventListener[0]);
|
||||||
for (EventListener l : list) {
|
for (EventListener l : list) {
|
||||||
|
{ // vvvv DEVEL vvvv
|
||||||
|
//System.err.println("notifying listener. (type= "+l.getClass().getSimpleName()+")");
|
||||||
|
//System.err.println(" (type= "+l.getClass().getName()+")");
|
||||||
|
} // ^^^^ DEVEL ^^^^
|
||||||
|
|
||||||
if (l instanceof ComponentChangeListener) {
|
if (l instanceof ComponentChangeListener) {
|
||||||
((ComponentChangeListener) l).componentChanged(cce);
|
((ComponentChangeListener) l).componentChanged(cce);
|
||||||
} else if (l instanceof StateChangeListener) {
|
} else if (l instanceof StateChangeListener) {
|
||||||
@ -512,7 +516,7 @@ public class Rocket extends RocketComponent {
|
|||||||
public void freeze() {
|
public void freeze() {
|
||||||
checkState();
|
checkState();
|
||||||
if (freezeList == null) {
|
if (freezeList == null) {
|
||||||
freezeList = new LinkedList<ComponentChangeEvent>();
|
freezeList = new LinkedList<>();
|
||||||
log.debug("Freezing Rocket");
|
log.debug("Freezing Rocket");
|
||||||
} else {
|
} else {
|
||||||
Application.getExceptionHandler().handleErrorCondition("Attempting to freeze Rocket when it is already frozen, " +
|
Application.getExceptionHandler().handleErrorCondition("Attempting to freeze Rocket when it is already frozen, " +
|
||||||
@ -567,24 +571,7 @@ public class Rocket extends RocketComponent {
|
|||||||
*/
|
*/
|
||||||
public FlightConfiguration getSelectedConfiguration() {
|
public FlightConfiguration getSelectedConfiguration() {
|
||||||
checkState();
|
checkState();
|
||||||
return this.selectedConfiguration;
|
return selectedConfiguration;
|
||||||
}
|
|
||||||
|
|
||||||
public FlightConfiguration createFlightConfiguration( final FlightConfigurationId fcid) {
|
|
||||||
checkState();
|
|
||||||
if( null == fcid ){
|
|
||||||
throw new NullPointerException("Attempted to create a flightConfiguration from a null key!");
|
|
||||||
}else if( fcid.hasError() ){
|
|
||||||
throw new NullPointerException("Attempted to create a flightConfiguration from an error key!");
|
|
||||||
}else if( configSet.containsKey(fcid)){
|
|
||||||
return this.configSet.get(fcid);
|
|
||||||
}else{
|
|
||||||
FlightConfiguration nextConfig = new FlightConfiguration(this, fcid);
|
|
||||||
this.configSet.put(fcid, nextConfig);
|
|
||||||
this.selectedConfiguration = nextConfig;
|
|
||||||
fireComponentChangeEvent(ComponentChangeEvent.TREE_CHANGE);
|
|
||||||
return nextConfig;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getConfigurationCount(){
|
public int getConfigurationCount(){
|
||||||
@ -592,42 +579,40 @@ public class Rocket extends RocketComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<FlightConfigurationId> getIds(){
|
public List<FlightConfigurationId> getIds(){
|
||||||
ArrayList<FlightConfigurationId> toReturn = new ArrayList<FlightConfigurationId>(this.configSet.keySet());
|
return configSet.getIds();
|
||||||
|
|
||||||
// Java 1.8:
|
|
||||||
//toReturn.sort( null );
|
|
||||||
|
|
||||||
// Java 1.7:
|
|
||||||
Collections.sort(toReturn);
|
|
||||||
|
|
||||||
return toReturn;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Primarily for use with UI elements
|
|
||||||
*
|
|
||||||
* @return list of attached flight configurations (unordered)
|
|
||||||
*/
|
|
||||||
public FlightConfiguration[] toConfigArray(){
|
|
||||||
return this.configSet.values().toArray( new FlightConfiguration[0]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove a flight configuration ID from the configuration IDs. The <code>null</code>
|
* Remove a flight configuration ID from the configuration IDs. The
|
||||||
* ID cannot be removed, and an attempt to remove it will be silently ignored.
|
* <code>FlightConfigurationId.DEFAULT_VALUE_FCID</code> ID cannot be removed,
|
||||||
|
* and an attempt to remove it will be silently ignored.
|
||||||
*
|
*
|
||||||
* @param id the flight configuration ID to remove
|
* @param fcid the flight configuration ID to remove
|
||||||
*/
|
*/
|
||||||
public void removeFlightConfigurationID(FlightConfigurationId fcid) {
|
public void removeFlightConfiguration(final FlightConfigurationId fcid) {
|
||||||
checkState();
|
checkState();
|
||||||
if( fcid.hasError() ){
|
if( fcid.hasError() ){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( selectedConfiguration.getId().equals( fcid)){
|
||||||
|
selectedConfiguration = configSet.getDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
// removed any component configuration tied to this FCID
|
||||||
|
Iterator<RocketComponent> iterator = this.iterator();
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
RocketComponent comp = iterator.next();
|
||||||
|
|
||||||
|
if (comp instanceof FlightConfigurableComponent){
|
||||||
|
FlightConfigurableComponent confbl = (FlightConfigurableComponent)comp;
|
||||||
|
confbl.reset( fcid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Get current configuration:
|
// Get current configuration:
|
||||||
this.configSet.remove( fcid);
|
this.configSet.reset( fcid);
|
||||||
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
|
fireComponentChangeEvent(ComponentChangeEvent.MASS_CHANGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -637,19 +622,19 @@ public class Rocket extends RocketComponent {
|
|||||||
* @param id the configuration ID.
|
* @param id the configuration ID.
|
||||||
* @return whether a motor configuration with that ID exists.
|
* @return whether a motor configuration with that ID exists.
|
||||||
*/
|
*/
|
||||||
public boolean containsFlightConfigurationID(FlightConfigurationId id) {
|
public boolean containsFlightConfigurationID(final FlightConfigurationId id) {
|
||||||
checkState();
|
checkState();
|
||||||
if( id.hasError() ){
|
if( id.hasError() ){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return configSet.containsKey( id);
|
return configSet.containsId( id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check whether the given motor configuration ID has motors defined for it.
|
* Check whether the given motor configuration ID has motors defined for it.
|
||||||
*
|
*
|
||||||
* @param id the FlightConfigurationID containing the motor (may be invalid).
|
* @param fcid the FlightConfigurationID containing the motor (may be invalid).
|
||||||
* @return whether any motors are defined for it.
|
* @return whether any motors are defined for it.
|
||||||
*/
|
*/
|
||||||
public boolean hasMotors(FlightConfigurationId fcid) {
|
public boolean hasMotors(FlightConfigurationId fcid) {
|
||||||
@ -678,53 +663,83 @@ public class Rocket extends RocketComponent {
|
|||||||
/**
|
/**
|
||||||
* Return a flight configuration. If the supplied id does not have a specific instance, the default is returned.
|
* Return a flight configuration. If the supplied id does not have a specific instance, the default is returned.
|
||||||
*
|
*
|
||||||
* @param id the flight configuration id
|
* @param fcid the flight configuration id
|
||||||
|
* @return FlightConfiguration instance
|
||||||
|
*/
|
||||||
|
public FlightConfiguration createFlightConfiguration( final FlightConfigurationId fcid) {
|
||||||
|
checkState();
|
||||||
|
|
||||||
|
if( null == fcid ){
|
||||||
|
// fall-through to the default case...
|
||||||
|
// creating a FlightConfiguration( null ) just allocates a fresh new FCID
|
||||||
|
}else if( fcid.hasError() ){
|
||||||
|
return configSet.getDefault();
|
||||||
|
}else if( configSet.containsId(fcid)){
|
||||||
|
return this.getFlightConfiguration(fcid);
|
||||||
|
}
|
||||||
|
FlightConfiguration nextConfig = new FlightConfiguration(this, fcid);
|
||||||
|
this.configSet.set(nextConfig.getId(), nextConfig);
|
||||||
|
fireComponentChangeEvent(ComponentChangeEvent.TREE_CHANGE);
|
||||||
|
return nextConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a flight configuration. If the supplied id does not have a specific instance, the default is returned.
|
||||||
|
*
|
||||||
|
* @param fcid the flight configuration id
|
||||||
* @return a FlightConfiguration instance
|
* @return a FlightConfiguration instance
|
||||||
*/
|
*/
|
||||||
public FlightConfiguration getFlightConfiguration(final FlightConfigurationId fcid) {
|
public FlightConfiguration getFlightConfiguration(final FlightConfigurationId fcid) {
|
||||||
checkState();
|
checkState();
|
||||||
return this.createFlightConfiguration(fcid);
|
return this.configSet.get(fcid);
|
||||||
|
}
|
||||||
|
|
||||||
|
public FlightConfiguration getFlightConfigurationByIndex(final int configIndex) {
|
||||||
|
return getFlightConfigurationByIndex( configIndex, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a flight configuration. If the supplied index is out of bounds, an exception is thrown.
|
* Return a flight configuration. If the supplied index is out of bounds, an exception is thrown.
|
||||||
|
* If the default instance is allowed, the default will be at index 0.
|
||||||
*
|
*
|
||||||
* @param id the flight configuration index number
|
* @param includeDefault Whether to allow returning the default instance
|
||||||
|
* @param configIndex The flight configuration index number
|
||||||
* @return a FlightConfiguration instance
|
* @return a FlightConfiguration instance
|
||||||
*/
|
*/
|
||||||
public FlightConfiguration getFlightConfiguration(final int configIndex) {
|
public FlightConfiguration getFlightConfigurationByIndex( int configIndex, final boolean allowDefault ) {
|
||||||
|
if( allowDefault ){
|
||||||
|
if( 0 == configIndex ){
|
||||||
|
return configSet.getDefault();
|
||||||
|
}
|
||||||
|
--configIndex;
|
||||||
|
}
|
||||||
return this.configSet.get( this.getId(configIndex));
|
return this.configSet.get( this.getId(configIndex));
|
||||||
}
|
}
|
||||||
|
|
||||||
public FlightConfigurationId getId( final int configIndex) {
|
public FlightConfigurationId getId( final int configIndex) {
|
||||||
List<FlightConfigurationId> idList = this.getIds();
|
List<FlightConfigurationId> idList = configSet.getIds();
|
||||||
return idList.get(configIndex);
|
return idList.get(configIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSelectedConfiguration(final FlightConfiguration config) {
|
public void setSelectedConfiguration(final FlightConfigurationId selectId) {
|
||||||
checkState();
|
|
||||||
this.selectedConfiguration = config;
|
|
||||||
fireComponentChangeEvent(ComponentChangeEvent.NONFUNCTIONAL_CHANGE);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDefaultConfiguration(final FlightConfigurationId fcid) {
|
|
||||||
checkState();
|
checkState();
|
||||||
|
|
||||||
if( fcid.hasError() ){
|
if( selectId.equals( selectedConfiguration.getFlightConfigurationID())){
|
||||||
log.error("attempt to set a 'fcid = config' with a error fcid. Ignored.", new IllegalArgumentException("error id:"+fcid));
|
// if desired configuration is already selected, skip the event
|
||||||
return;
|
return;
|
||||||
}else if( this.configSet.containsKey(fcid)){
|
|
||||||
this.selectedConfiguration = configSet.get(fcid);
|
|
||||||
fireComponentChangeEvent(ComponentChangeEvent.NONFUNCTIONAL_CHANGE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.selectedConfiguration = this.configSet.get( selectId );
|
||||||
|
fireComponentChangeEvent(ComponentChangeEvent.NONFUNCTIONAL_CHANGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Associate the given ID and flight configuration.
|
* Associate the given ID and flight configuration.
|
||||||
* <code>null</code> or an empty string.
|
* <code>null</code> or an empty string.
|
||||||
*
|
*
|
||||||
* @param id the flight configuration id
|
* @param fcid the flight configuration id
|
||||||
* @param name the name for the flight configuration
|
* @param newConfig new FlightConfiguration to store
|
||||||
*/
|
*/
|
||||||
public void setFlightConfiguration(final FlightConfigurationId fcid, FlightConfiguration newConfig) {
|
public void setFlightConfiguration(final FlightConfigurationId fcid, FlightConfiguration newConfig) {
|
||||||
checkState();
|
checkState();
|
||||||
@ -734,13 +749,16 @@ public class Rocket extends RocketComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (null == newConfig){
|
if (null == newConfig){
|
||||||
newConfig = createFlightConfiguration(fcid);
|
configSet.reset( fcid);
|
||||||
|
}else if( fcid.equals( configSet.get(fcid).getFlightConfigurationID())){
|
||||||
|
// this mapping already exists; skip the event
|
||||||
|
return;
|
||||||
|
}else{
|
||||||
|
configSet.set(fcid, newConfig);
|
||||||
}
|
}
|
||||||
configSet.put(fcid, newConfig);
|
|
||||||
fireComponentChangeEvent(ComponentChangeEvent.NONFUNCTIONAL_CHANGE);
|
fireComponentChangeEvent(ComponentChangeEvent.NONFUNCTIONAL_CHANGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//////// Obligatory component information
|
//////// Obligatory component information
|
||||||
@Override
|
@Override
|
||||||
public String getComponentName() {
|
public String getComponentName() {
|
||||||
@ -820,9 +838,10 @@ public class Rocket extends RocketComponent {
|
|||||||
|
|
||||||
public String toDebugConfigs(){
|
public String toDebugConfigs(){
|
||||||
StringBuilder buf = new StringBuilder();
|
StringBuilder buf = new StringBuilder();
|
||||||
buf.append(String.format("====== Dumping %d Configurations from rocket: \n", this.getConfigurationCount(), this.getName()));
|
buf.append(String.format("====== Dumping %d Configurations from rocket: %s ======\n",
|
||||||
|
this.getConfigurationCount(), this.getName()));
|
||||||
final String fmt = " [%12s]: %s\n";
|
final String fmt = " [%12s]: %s\n";
|
||||||
for( FlightConfiguration config : this.configSet.values() ){
|
for( FlightConfiguration config : this.configSet ){
|
||||||
String shortKey = config.getId().toShortKey();
|
String shortKey = config.getId().toShortKey();
|
||||||
if( this.selectedConfiguration.equals( config)){
|
if( this.selectedConfiguration.equals( config)){
|
||||||
shortKey = "=>" + shortKey;
|
shortKey = "=>" + shortKey;
|
||||||
|
@ -135,6 +135,10 @@ public class StageSeparationConfiguration implements FlightConfigurableParameter
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StageSeparationConfiguration clone() {
|
public StageSeparationConfiguration clone() {
|
||||||
|
return copy(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public StageSeparationConfiguration copy( final FlightConfigurationId copyId){
|
||||||
StageSeparationConfiguration clone = new StageSeparationConfiguration();
|
StageSeparationConfiguration clone = new StageSeparationConfiguration();
|
||||||
clone.separationEvent = this.separationEvent;
|
clone.separationEvent = this.separationEvent;
|
||||||
clone.separationDelay = this.separationDelay;
|
clone.separationDelay = this.separationDelay;
|
||||||
|
@ -1,31 +0,0 @@
|
|||||||
package net.sf.openrocket.rocketvisitors;
|
|
||||||
|
|
||||||
import net.sf.openrocket.rocketcomponent.FlightConfigurableComponent;
|
|
||||||
import net.sf.openrocket.rocketcomponent.FlightConfigurationId;
|
|
||||||
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
|
||||||
|
|
||||||
public class CopyFlightConfigurationVisitor extends DepthFirstRecusiveVisitor<Void> {
|
|
||||||
|
|
||||||
private final FlightConfigurationId oldConfigId;
|
|
||||||
private final FlightConfigurationId newConfigId;
|
|
||||||
|
|
||||||
public CopyFlightConfigurationVisitor(FlightConfigurationId oldConfigId, FlightConfigurationId newConfigId) {
|
|
||||||
super();
|
|
||||||
this.oldConfigId = oldConfigId;
|
|
||||||
this.newConfigId = newConfigId;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void doAction(RocketComponent visitable) {
|
|
||||||
|
|
||||||
if (visitable instanceof FlightConfigurableComponent) {
|
|
||||||
((FlightConfigurableComponent) visitable).cloneFlightConfiguration(oldConfigId, newConfigId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Void getResult() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -101,14 +101,13 @@ public class TestRockets {
|
|||||||
// Motor.Type type, double[] delays, double diameter, double length,
|
// Motor.Type type, double[] delays, double diameter, double length,
|
||||||
// double[] time, double[] thrust,
|
// double[] time, double[] thrust,
|
||||||
// Coordinate[] cg, String digest);
|
// Coordinate[] cg, String digest);
|
||||||
ThrustCurveMotor mtr = new ThrustCurveMotor(
|
return new ThrustCurveMotor(
|
||||||
Manufacturer.getManufacturer("Estes"),"A8", " SU Black Powder",
|
Manufacturer.getManufacturer("Estes"),"A8", " SU Black Powder",
|
||||||
Motor.Type.SINGLE, new double[] {0,3,5}, 0.018, 0.070,
|
Motor.Type.SINGLE, new double[] {0,3,5}, 0.018, 0.070,
|
||||||
new double[] { 0, 1, 2 }, new double[] { 0, 9, 0 },
|
new double[] { 0, 1, 2 }, new double[] { 0, 9, 0 },
|
||||||
new Coordinate[] {
|
new Coordinate[] {
|
||||||
new Coordinate(0.035, 0, 0, 0.0164),new Coordinate(.035, 0, 0, 0.0145),new Coordinate(.035, 0, 0, 0.0131)},
|
new Coordinate(0.035, 0, 0, 0.0164),new Coordinate(.035, 0, 0, 0.0145),new Coordinate(.035, 0, 0, 0.0131)},
|
||||||
"digest A8 test");
|
"digest A8 test");
|
||||||
return mtr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function is used for unit, integration tests, DO NOT CHANGE (without updating tests).
|
// This function is used for unit, integration tests, DO NOT CHANGE (without updating tests).
|
||||||
@ -117,14 +116,13 @@ public class TestRockets {
|
|||||||
// Motor.Type type, double[] delays, double diameter, double length,
|
// Motor.Type type, double[] delays, double diameter, double length,
|
||||||
// double[] time, double[] thrust,
|
// double[] time, double[] thrust,
|
||||||
// Coordinate[] cg, String digest);
|
// Coordinate[] cg, String digest);
|
||||||
ThrustCurveMotor mtr = new ThrustCurveMotor(
|
return new ThrustCurveMotor(
|
||||||
Manufacturer.getManufacturer("Estes"),"B4", " SU Black Powder",
|
Manufacturer.getManufacturer("Estes"),"B4", " SU Black Powder",
|
||||||
Motor.Type.SINGLE, new double[] {0,3,5}, 0.018, 0.070,
|
Motor.Type.SINGLE, new double[] {0,3,5}, 0.018, 0.070,
|
||||||
new double[] { 0, 1, 2 }, new double[] { 0, 11.4, 0 },
|
new double[] { 0, 1, 2 }, new double[] { 0, 11.4, 0 },
|
||||||
new Coordinate[] {
|
new Coordinate[] {
|
||||||
new Coordinate(0.035, 0, 0, 0.0195),new Coordinate(.035, 0, 0, 0.0155),new Coordinate(.035, 0, 0, 0.013)},
|
new Coordinate(0.035, 0, 0, 0.0195),new Coordinate(.035, 0, 0, 0.0155),new Coordinate(.035, 0, 0, 0.013)},
|
||||||
"digest B4 test");
|
"digest B4 test");
|
||||||
return mtr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function is used for unit, integration tests, DO NOT CHANGE (without updating tests).
|
// This function is used for unit, integration tests, DO NOT CHANGE (without updating tests).
|
||||||
@ -133,26 +131,24 @@ public class TestRockets {
|
|||||||
// Motor.Type type, double[] delays, double diameter, double length,
|
// Motor.Type type, double[] delays, double diameter, double length,
|
||||||
// double[] time, double[] thrust,
|
// double[] time, double[] thrust,
|
||||||
// Coordinate[] cg, String digest);
|
// Coordinate[] cg, String digest);
|
||||||
ThrustCurveMotor mtr = new ThrustCurveMotor(
|
return new ThrustCurveMotor(
|
||||||
Manufacturer.getManufacturer("Estes"),"C6", " SU Black Powder",
|
Manufacturer.getManufacturer("Estes"),"C6", " SU Black Powder",
|
||||||
Motor.Type.SINGLE, new double[] {0,3,5,7}, 0.018, 0.070,
|
Motor.Type.SINGLE, new double[] {0,3,5,7}, 0.018, 0.070,
|
||||||
new double[] { 0, 1, 2 }, new double[] { 0, 6, 0 },
|
new double[] { 0, 1, 2 }, new double[] { 0, 6, 0 },
|
||||||
new Coordinate[] {
|
new Coordinate[] {
|
||||||
new Coordinate(0.035, 0, 0, 0.0227),new Coordinate(.035, 0, 0, 0.0165),new Coordinate(.035, 0, 0, 0.012)},
|
new Coordinate(0.035, 0, 0, 0.0227),new Coordinate(.035, 0, 0, 0.0165),new Coordinate(.035, 0, 0, 0.012)},
|
||||||
"digest C6 test");
|
"digest C6 test");
|
||||||
return mtr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function is used for unit, integration tests, DO NOT CHANGE (without updating tests).
|
// This function is used for unit, integration tests, DO NOT CHANGE (without updating tests).
|
||||||
private static Motor generateMotor_D21_18mm(){
|
private static Motor generateMotor_D21_18mm(){
|
||||||
ThrustCurveMotor mtr = new ThrustCurveMotor(
|
return new ThrustCurveMotor(
|
||||||
Manufacturer.getManufacturer("AeroTech"),"D21", "Desc",
|
Manufacturer.getManufacturer("AeroTech"),"D21", "Desc",
|
||||||
Motor.Type.SINGLE, new double[] {}, 0.018, 0.07,
|
Motor.Type.SINGLE, new double[] {}, 0.018, 0.07,
|
||||||
new double[] { 0, 1, 2 }, new double[] { 0, 32, 0 },
|
new double[] { 0, 1, 2 }, new double[] { 0, 32, 0 },
|
||||||
new Coordinate[] {
|
new Coordinate[] {
|
||||||
new Coordinate(.035, 0, 0, 0.025),new Coordinate(.035, 0, 0, .020),new Coordinate(.035, 0, 0, 0.0154)},
|
new Coordinate(.035, 0, 0, 0.025),new Coordinate(.035, 0, 0, .020),new Coordinate(.035, 0, 0, 0.0154)},
|
||||||
"digest D21 test");
|
"digest D21 test");
|
||||||
return mtr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function is used for unit, integration tests, DO NOT CHANGE (without updating tests).
|
// This function is used for unit, integration tests, DO NOT CHANGE (without updating tests).
|
||||||
@ -161,14 +157,13 @@ public class TestRockets {
|
|||||||
// Motor.Type type, double[] delays, double diameter, double length,
|
// Motor.Type type, double[] delays, double diameter, double length,
|
||||||
// double[] time, double[] thrust,
|
// double[] time, double[] thrust,
|
||||||
// Coordinate[] cg, String digest);
|
// Coordinate[] cg, String digest);
|
||||||
ThrustCurveMotor mtr = new ThrustCurveMotor(
|
return new ThrustCurveMotor(
|
||||||
Manufacturer.getManufacturer("AeroTech"),"M1350", "Desc",
|
Manufacturer.getManufacturer("AeroTech"),"M1350", "Desc",
|
||||||
Motor.Type.SINGLE, new double[] {}, 0.075, 0.622,
|
Motor.Type.SINGLE, new double[] {}, 0.075, 0.622,
|
||||||
new double[] { 0, 1, 2 }, new double[] { 0, 1357, 0 },
|
new double[] { 0, 1, 2 }, new double[] { 0, 1357, 0 },
|
||||||
new Coordinate[] {
|
new Coordinate[] {
|
||||||
new Coordinate(.311, 0, 0, 4.808),new Coordinate(.311, 0, 0, 3.389),new Coordinate(.311, 0, 0, 1.970)},
|
new Coordinate(.311, 0, 0, 4.808),new Coordinate(.311, 0, 0, 3.389),new Coordinate(.311, 0, 0, 1.970)},
|
||||||
"digest M1350 test");
|
"digest M1350 test");
|
||||||
return mtr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function is used for unit, integration tests, DO NOT CHANGE (without updating tests).
|
// This function is used for unit, integration tests, DO NOT CHANGE (without updating tests).
|
||||||
@ -177,14 +172,13 @@ public class TestRockets {
|
|||||||
// Motor.Type type, double[] delays, double diameter, double length,
|
// Motor.Type type, double[] delays, double diameter, double length,
|
||||||
// double[] time, double[] thrust,
|
// double[] time, double[] thrust,
|
||||||
// Coordinate[] cg, String digest);
|
// Coordinate[] cg, String digest);
|
||||||
ThrustCurveMotor mtr = new ThrustCurveMotor(
|
return new ThrustCurveMotor(
|
||||||
Manufacturer.getManufacturer("AeroTech"),"G77", "Desc",
|
Manufacturer.getManufacturer("AeroTech"),"G77", "Desc",
|
||||||
Motor.Type.SINGLE, new double[] {4,7,10},0.029, 0.124,
|
Motor.Type.SINGLE, new double[] {4,7,10},0.029, 0.124,
|
||||||
new double[] { 0, 1, 2 }, new double[] { 0, 1, 0 },
|
new double[] { 0, 1, 2 }, new double[] { 0, 1, 0 },
|
||||||
new Coordinate[] {
|
new Coordinate[] {
|
||||||
new Coordinate(.062, 0, 0, 0.123),new Coordinate(.062, 0, 0, .0935),new Coordinate(.062, 0, 0, 0.064)},
|
new Coordinate(.062, 0, 0, 0.123),new Coordinate(.062, 0, 0, .0935),new Coordinate(.062, 0, 0, 0.064)},
|
||||||
"digest G77 test");
|
"digest G77 test");
|
||||||
return mtr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -384,7 +378,7 @@ public class TestRockets {
|
|||||||
public static final Rocket makeEstesAlphaIII(){
|
public static final Rocket makeEstesAlphaIII(){
|
||||||
Rocket rocket = new Rocket();
|
Rocket rocket = new Rocket();
|
||||||
FlightConfigurationId fcid[] = new FlightConfigurationId[5];
|
FlightConfigurationId fcid[] = new FlightConfigurationId[5];
|
||||||
fcid[0] = rocket.getSelectedConfiguration().getFlightConfigurationID();
|
fcid[0] = new FlightConfigurationId();
|
||||||
rocket.createFlightConfiguration(fcid[0]);
|
rocket.createFlightConfiguration(fcid[0]);
|
||||||
fcid[1] = new FlightConfigurationId();
|
fcid[1] = new FlightConfigurationId();
|
||||||
rocket.createFlightConfiguration(fcid[1]);
|
rocket.createFlightConfiguration(fcid[1]);
|
||||||
@ -521,7 +515,7 @@ public class TestRockets {
|
|||||||
bodytube.setMaterial(material);
|
bodytube.setMaterial(material);
|
||||||
finset.setMaterial(material);
|
finset.setMaterial(material);
|
||||||
|
|
||||||
rocket.setSelectedConfiguration( rocket.getFlightConfiguration( fcid[0]));
|
rocket.setSelectedConfiguration( fcid[0] );
|
||||||
rocket.getSelectedConfiguration().setAllStages();
|
rocket.getSelectedConfiguration().setAllStages();
|
||||||
rocket.enableEvents();
|
rocket.enableEvents();
|
||||||
return rocket;
|
return rocket;
|
||||||
@ -541,7 +535,6 @@ public class TestRockets {
|
|||||||
fcid[i] = new FlightConfigurationId();
|
fcid[i] = new FlightConfigurationId();
|
||||||
rocket.createFlightConfiguration(fcid[i]);
|
rocket.createFlightConfiguration(fcid[i]);
|
||||||
}
|
}
|
||||||
FlightConfiguration selectedConfiguration = rocket.getFlightConfiguration(fcid[0]);
|
|
||||||
|
|
||||||
double noseconeLength = 0.07;
|
double noseconeLength = 0.07;
|
||||||
double noseconeRadius = 0.012;
|
double noseconeRadius = 0.012;
|
||||||
@ -714,7 +707,7 @@ public class TestRockets {
|
|||||||
|
|
||||||
}
|
}
|
||||||
rocket.getSelectedConfiguration().setAllStages();
|
rocket.getSelectedConfiguration().setAllStages();
|
||||||
rocket.setSelectedConfiguration( selectedConfiguration );
|
rocket.setSelectedConfiguration( fcid[0] );
|
||||||
rocket.enableEvents();
|
rocket.enableEvents();
|
||||||
return rocket;
|
return rocket;
|
||||||
}
|
}
|
||||||
@ -1029,8 +1022,10 @@ public class TestRockets {
|
|||||||
public static Rocket makeFalcon9Heavy() {
|
public static Rocket makeFalcon9Heavy() {
|
||||||
Rocket rocket = new Rocket();
|
Rocket rocket = new Rocket();
|
||||||
rocket.setName("Falcon9H Scale Rocket");
|
rocket.setName("Falcon9H Scale Rocket");
|
||||||
FlightConfiguration selConfig = rocket.getSelectedConfiguration();
|
|
||||||
|
FlightConfiguration selConfig = rocket.createFlightConfiguration(null);
|
||||||
FlightConfigurationId selFCID = selConfig.getFlightConfigurationID();
|
FlightConfigurationId selFCID = selConfig.getFlightConfigurationID();
|
||||||
|
rocket.setSelectedConfiguration(selFCID);
|
||||||
|
|
||||||
// ====== Payload Stage ======
|
// ====== Payload Stage ======
|
||||||
// ====== ====== ====== ======
|
// ====== ====== ====== ======
|
||||||
@ -1178,7 +1173,7 @@ public class TestRockets {
|
|||||||
}
|
}
|
||||||
|
|
||||||
rocket.enableEvents();
|
rocket.enableEvents();
|
||||||
rocket.setSelectedConfiguration(selConfig);
|
rocket.setSelectedConfiguration( selFCID);
|
||||||
selConfig.setAllStages();
|
selConfig.setAllStages();
|
||||||
|
|
||||||
return rocket;
|
return rocket;
|
||||||
|
@ -131,6 +131,7 @@ public class OpenRocketSaverTest {
|
|||||||
rocketDocs.add(TestRockets.makeTestRocket_v106_withRecoveryDeviceDeploymentConfig());
|
rocketDocs.add(TestRockets.makeTestRocket_v106_withRecoveryDeviceDeploymentConfig());
|
||||||
rocketDocs.add(TestRockets.makeTestRocket_v106_withStageSeparationConfig());
|
rocketDocs.add(TestRockets.makeTestRocket_v106_withStageSeparationConfig());
|
||||||
rocketDocs.add(TestRockets.makeTestRocket_v107_withSimulationExtension(SIMULATION_EXTENSION_SCRIPT));
|
rocketDocs.add(TestRockets.makeTestRocket_v107_withSimulationExtension(SIMULATION_EXTENSION_SCRIPT));
|
||||||
|
rocketDocs.add(TestRockets.makeTestRocket_v108_withBoosters());
|
||||||
rocketDocs.add(TestRockets.makeTestRocket_for_estimateFileSize());
|
rocketDocs.add(TestRockets.makeTestRocket_for_estimateFileSize());
|
||||||
|
|
||||||
StorageOptions options = new StorageOptions();
|
StorageOptions options = new StorageOptions();
|
||||||
|
@ -143,11 +143,26 @@ public class FlightConfigurationTest extends BaseTestCase {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Single stage rocket specific configuration tests
|
|
||||||
*/
|
|
||||||
@Test
|
@Test
|
||||||
public void testConfigurationSwitching() {
|
public void testCreateConfigurationNullId() {
|
||||||
|
/* Setup */
|
||||||
|
Rocket rkt = TestRockets.makeEstesAlphaIII();
|
||||||
|
|
||||||
|
// PRE-CONDITION:
|
||||||
|
// test that all configurations correctly loaded:
|
||||||
|
int expectedConfigCount = 5;
|
||||||
|
int actualConfigCount = rkt.getConfigurationCount();
|
||||||
|
assertThat("number of loaded configuration counts doesn't actually match.", actualConfigCount, equalTo(expectedConfigCount));
|
||||||
|
|
||||||
|
// create with
|
||||||
|
rkt.createFlightConfiguration(null);
|
||||||
|
expectedConfigCount = 6;
|
||||||
|
actualConfigCount = rkt.getConfigurationCount();
|
||||||
|
assertThat("createFlightConfiguration with null: doesn't actually work.", actualConfigCount, equalTo(expectedConfigCount));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMotorConfigurations() {
|
||||||
/* Setup */
|
/* Setup */
|
||||||
Rocket rkt = TestRockets.makeEstesAlphaIII();
|
Rocket rkt = TestRockets.makeEstesAlphaIII();
|
||||||
|
|
||||||
@ -157,12 +172,40 @@ public class FlightConfigurationTest extends BaseTestCase {
|
|||||||
int actualMotorCount = smmt.getMotorCount();
|
int actualMotorCount = smmt.getMotorCount();
|
||||||
assertThat("number of motor configurations doesn't match.", actualMotorCount, equalTo(expectedMotorCount));
|
assertThat("number of motor configurations doesn't match.", actualMotorCount, equalTo(expectedMotorCount));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFlightConfigurationGetters(){
|
||||||
|
Rocket rkt = TestRockets.makeEstesAlphaIII();
|
||||||
|
|
||||||
// test that all configurations correctly loaded:
|
// test that all configurations correctly loaded:
|
||||||
int expectedConfigCount = 5;
|
int expectedConfigCount = 5;
|
||||||
int actualConfigCount = rkt.getConfigurationCount();
|
int actualConfigCount = rkt.getConfigurationCount();
|
||||||
assertThat("number of loaded configuration counts doesn't actually match.", actualConfigCount, equalTo(expectedConfigCount));
|
assertThat("number of loaded configuration counts doesn't actually match.", actualConfigCount, equalTo(expectedConfigCount));
|
||||||
|
|
||||||
|
actualConfigCount = rkt.getIds().size();
|
||||||
|
assertThat("number of configuration array ids doesn't actually match.",
|
||||||
|
actualConfigCount, equalTo(expectedConfigCount));
|
||||||
|
|
||||||
|
// upon success, these silently complete.
|
||||||
|
// upon failure, they'll throw exceptions:
|
||||||
|
rkt.getFlightConfigurationByIndex(4);
|
||||||
|
rkt.getFlightConfigurationByIndex(5, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test(expected=java.lang.IndexOutOfBoundsException.class)
|
||||||
|
public void testGetFlightConfigurationOutOfBounds(){
|
||||||
|
Rocket rkt = TestRockets.makeEstesAlphaIII();
|
||||||
|
|
||||||
|
// test that all configurations correctly loaded:
|
||||||
|
int expectedConfigCount = 5;
|
||||||
|
int actualConfigCount = rkt.getConfigurationCount();
|
||||||
|
assertThat("number of loaded configuration counts doesn't actually match.", actualConfigCount, equalTo(expectedConfigCount));
|
||||||
|
|
||||||
|
// this SHOULD throw an exception --
|
||||||
|
// it's out of bounds on, and no configuration exists at index 5.
|
||||||
|
rkt.getFlightConfigurationByIndex(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -56,6 +56,11 @@ public class ParameterSetTest extends BaseTestCase {
|
|||||||
public TestParameter clone(){
|
public TestParameter clone(){
|
||||||
return new TestParameter();
|
return new TestParameter();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TestParameter copy( final FlightConfigurationId copyId){
|
||||||
|
return new TestParameter();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
@ -138,7 +143,7 @@ public class ParameterSetTest extends BaseTestCase {
|
|||||||
// testSet.getSortedConfigurationIDs()
|
// testSet.getSortedConfigurationIDs()
|
||||||
// >> this function should ONLY return ids for the overrides
|
// >> this function should ONLY return ids for the overrides
|
||||||
assertThat("getIds() broken!\n"+testSet.toDebug(), testSet.getIds().size(), equalTo( testSet.size()));
|
assertThat("getIds() broken!\n"+testSet.toDebug(), testSet.getIds().size(), equalTo( testSet.size()));
|
||||||
assertThat("getIds() broken!\n"+testSet.toDebug(), testSet.getSortedConfigurationIDs().size(), equalTo( testSet.getIds().size() ) );
|
assertThat("getIds() broken!\n"+testSet.toDebug(), testSet.getIds().size(), equalTo( testSet.getIds().size() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -230,7 +235,7 @@ public class ParameterSetTest extends BaseTestCase {
|
|||||||
assertThat("set stores default value correctly: ", testSet.get(fcid2), equalTo( tp2 ));
|
assertThat("set stores default value correctly: ", testSet.get(fcid2), equalTo( tp2 ));
|
||||||
|
|
||||||
FlightConfigurationId fcid3 = new FlightConfigurationId();
|
FlightConfigurationId fcid3 = new FlightConfigurationId();
|
||||||
testSet.cloneFlightConfiguration(fcid2, fcid3);
|
testSet.copyFlightConfiguration(fcid2, fcid3);
|
||||||
// fcid <=> tp2 should be stored....
|
// fcid <=> tp2 should be stored....
|
||||||
assertThat("set should contain zero overrides: ", testSet.size(), equalTo( 2 ));
|
assertThat("set should contain zero overrides: ", testSet.size(), equalTo( 2 ));
|
||||||
assertThat("set stores default value correctly: ", testSet.get(fcid3), not( testSet.getDefault() ));
|
assertThat("set stores default value correctly: ", testSet.get(fcid3), not( testSet.getDefault() ));
|
||||||
|
@ -39,7 +39,6 @@ public class RocketTest extends BaseTestCase {
|
|||||||
FlightConfigurationId fcid5 = config5.getId();
|
FlightConfigurationId fcid5 = config5.getId();
|
||||||
assertThat("fcids should match: ", config2.getId(), equalTo(fcid5));
|
assertThat("fcids should match: ", config2.getId(), equalTo(fcid5));
|
||||||
assertThat("Configurations should bef different match: "+config2.toDebug()+"=?="+config5.toDebug(), config2.instanceNumber, not( config5.instanceNumber));
|
assertThat("Configurations should bef different match: "+config2.toDebug()+"=?="+config5.toDebug(), config2.instanceNumber, not( config5.instanceNumber));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<classpath>
|
<classpath>
|
||||||
<classpathentry kind="src" path="src"/>
|
<classpathentry kind="src" path="src"/>
|
||||||
|
<classpathentry kind="src" path="test"/>
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||||
<classpathentry kind="lib" path="lib/jogl/jogl-all.jar"/>
|
<classpathentry kind="lib" path="lib/jogl/jogl-all.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/iText-5.0.2.jar"/>
|
<classpathentry kind="lib" path="lib/iText-5.0.2.jar"/>
|
||||||
@ -22,5 +23,12 @@
|
|||||||
<classpathentry kind="lib" path="/OpenRocket Core/lib/annotation-detector-3.0.2.jar"/>
|
<classpathentry kind="lib" path="/OpenRocket Core/lib/annotation-detector-3.0.2.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/miglayout-4.0-swing.jar" sourcepath="reference/miglayout-4.0-sources.jar"/>
|
<classpathentry kind="lib" path="lib/miglayout-4.0-swing.jar" sourcepath="reference/miglayout-4.0-sources.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/rsyntaxtextarea-2.5.6.jar"/>
|
<classpathentry kind="lib" path="lib/rsyntaxtextarea-2.5.6.jar"/>
|
||||||
|
<classpathentry kind="lib" path="/OpenRocket Test Libraries/hamcrest-core-1.3.0RC1.jar"/>
|
||||||
|
<classpathentry kind="lib" path="/OpenRocket Test Libraries/hamcrest-library-1.3.0RC1.jar"/>
|
||||||
|
<classpathentry kind="lib" path="/OpenRocket Test Libraries/jmock-2.6.0-RC2.jar"/>
|
||||||
|
<classpathentry kind="lib" path="/OpenRocket Test Libraries/jmock-junit4-2.6.0-RC2.jar"/>
|
||||||
|
<classpathentry kind="lib" path="/OpenRocket Test Libraries/junit-dep-4.8.2.jar"/>
|
||||||
|
<classpathentry kind="lib" path="/OpenRocket Test Libraries/test-plugin.jar"/>
|
||||||
|
<classpathentry kind="lib" path="/OpenRocket Test Libraries/uispec4j-2.3-jdk16.jar"/>
|
||||||
<classpathentry kind="output" path="bin"/>
|
<classpathentry kind="output" path="bin"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
@ -4,7 +4,7 @@ import java.util.Comparator;
|
|||||||
|
|
||||||
import javax.swing.table.TableRowSorter;
|
import javax.swing.table.TableRowSorter;
|
||||||
|
|
||||||
public class ColumnTableRowSorter extends TableRowSorter {
|
public class ColumnTableRowSorter extends TableRowSorter<ColumnTableModel> {
|
||||||
|
|
||||||
private final ColumnTableModel columnTableModel;
|
private final ColumnTableModel columnTableModel;
|
||||||
|
|
||||||
@ -14,8 +14,8 @@ public class ColumnTableRowSorter extends TableRowSorter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Comparator getComparator(int column) {
|
public Comparator<?> getComparator(int column) {
|
||||||
Comparator c = columnTableModel.getColumn(column).getComparator();
|
Comparator<?> c = columnTableModel.getColumn(column).getComparator();
|
||||||
return (c!= null) ? c : super.getComparator(column);
|
return (c!= null) ? c : super.getComparator(column);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ public class ColumnTableRowSorter extends TableRowSorter {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected boolean useToString(int column) {
|
protected boolean useToString(int column) {
|
||||||
Comparator c = columnTableModel.getColumn(column).getComparator();
|
Comparator<?> c = columnTableModel.getColumn(column).getComparator();
|
||||||
return ( c != null ) ? false : super.useToString(column);
|
return ( c != null ) ? false : super.useToString(column);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ public class ParameterSetModel<T extends FlightConfigurableParameter<T>> impleme
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getSize() {
|
public int getSize() {
|
||||||
this.idList = this.sourceSet.getSortedConfigurationIDs();
|
this.idList = this.sourceSet.getIds();
|
||||||
return this.idList.size();
|
return this.idList.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,7 +109,7 @@ public class ParameterSetModel<T extends FlightConfigurableParameter<T>> impleme
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fireListDataEvent();
|
fireListDataEvent();
|
||||||
this.idList = this.sourceSet.getSortedConfigurationIDs();
|
this.idList = this.sourceSet.getIds();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,86 @@
|
|||||||
|
package net.sf.openrocket.gui.components;
|
||||||
|
|
||||||
|
import net.sf.openrocket.rocketcomponent.FlightConfigurationId;
|
||||||
|
import net.sf.openrocket.rocketcomponent.Rocket;
|
||||||
|
import net.sf.openrocket.rocketcomponent.FlightConfiguration;
|
||||||
|
import net.sf.openrocket.util.StateChangeListener;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import javax.swing.event.ListDataListener;
|
||||||
|
|
||||||
|
import java.util.EventObject;
|
||||||
|
|
||||||
|
public class ConfigurationModel implements MutableComboBoxModel<FlightConfiguration>, StateChangeListener {
|
||||||
|
|
||||||
|
private final Rocket rkt;
|
||||||
|
private final JComboBox<FlightConfiguration> combo;
|
||||||
|
|
||||||
|
public ConfigurationModel( final Rocket _rkt, final JComboBox<FlightConfiguration> _combo) {
|
||||||
|
this.rkt = _rkt;
|
||||||
|
this.combo = _combo;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void stateChanged(EventObject eo) {
|
||||||
|
combo.revalidate();
|
||||||
|
combo.repaint();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getSelectedItem() {
|
||||||
|
return rkt.getSelectedConfiguration();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setSelectedItem(Object nextItem) {
|
||||||
|
if( nextItem instanceof FlightConfiguration ){
|
||||||
|
FlightConfigurationId selectedId = ((FlightConfiguration)nextItem).getId();
|
||||||
|
rkt.setSelectedConfiguration(selectedId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addListDataListener(ListDataListener l) {
|
||||||
|
// let the rocket send events, if necessary
|
||||||
|
// ignore any listen requests here...
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public FlightConfiguration getElementAt( final int configIndex) {
|
||||||
|
return rkt.getFlightConfigurationByIndex(configIndex, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getSize() {
|
||||||
|
// plus the default config
|
||||||
|
return rkt.getConfigurationCount()+1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeListDataListener(ListDataListener l) {
|
||||||
|
// delegate event handling to the rocket
|
||||||
|
// ignore any listen requests here...
|
||||||
|
}
|
||||||
|
|
||||||
|
// ====== MutableComboBoxModel Functions ======
|
||||||
|
// these functions don't need to do anything, just being a 'mutable' version of the combo box
|
||||||
|
// is enough to allow updating the UI
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addElement(FlightConfiguration arg0) {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void insertElementAt(FlightConfiguration arg0, int arg1) {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeElement(Object arg0) {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeElementAt(int arg0) {}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -12,6 +12,7 @@ import javax.swing.JButton;
|
|||||||
*
|
*
|
||||||
* @author Sampo Niskanen <sampo.niskanen@iki.fi>
|
* @author Sampo Niskanen <sampo.niskanen@iki.fi>
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("serial")
|
||||||
public class FlatButton extends JButton {
|
public class FlatButton extends JButton {
|
||||||
|
|
||||||
public FlatButton() {
|
public FlatButton() {
|
||||||
|
@ -11,6 +11,7 @@ import javax.swing.JLabel;
|
|||||||
*
|
*
|
||||||
* @author Sampo Niskanen <sampo.niskanen@iki.fi>
|
* @author Sampo Niskanen <sampo.niskanen@iki.fi>
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("serial")
|
||||||
public class HtmlLabel extends JLabel {
|
public class HtmlLabel extends JLabel {
|
||||||
|
|
||||||
public HtmlLabel() {
|
public HtmlLabel() {
|
||||||
|
@ -47,6 +47,7 @@ import net.sf.openrocket.gui.adaptors.ColumnTable;
|
|||||||
import net.sf.openrocket.gui.adaptors.ColumnTableModel;
|
import net.sf.openrocket.gui.adaptors.ColumnTableModel;
|
||||||
import net.sf.openrocket.gui.adaptors.DoubleModel;
|
import net.sf.openrocket.gui.adaptors.DoubleModel;
|
||||||
import net.sf.openrocket.gui.components.BasicSlider;
|
import net.sf.openrocket.gui.components.BasicSlider;
|
||||||
|
import net.sf.openrocket.gui.components.ConfigurationModel;
|
||||||
import net.sf.openrocket.gui.components.StageSelector;
|
import net.sf.openrocket.gui.components.StageSelector;
|
||||||
import net.sf.openrocket.gui.components.StyledLabel;
|
import net.sf.openrocket.gui.components.StyledLabel;
|
||||||
import net.sf.openrocket.gui.components.UnitSelector;
|
import net.sf.openrocket.gui.components.UnitSelector;
|
||||||
@ -75,7 +76,7 @@ public class ComponentAnalysisDialog extends JDialog implements StateChangeListe
|
|||||||
|
|
||||||
|
|
||||||
private final FlightConditions conditions;
|
private final FlightConditions conditions;
|
||||||
private final FlightConfiguration configuration;
|
private final Rocket rkt;
|
||||||
private final DoubleModel theta, aoa, mach, roll;
|
private final DoubleModel theta, aoa, mach, roll;
|
||||||
private final JToggleButton worstToggle;
|
private final JToggleButton worstToggle;
|
||||||
private boolean fakeChange = false;
|
private boolean fakeChange = false;
|
||||||
@ -105,11 +106,11 @@ public class ComponentAnalysisDialog extends JDialog implements StateChangeListe
|
|||||||
JPanel panel = new JPanel(new MigLayout("fill"));
|
JPanel panel = new JPanel(new MigLayout("fill"));
|
||||||
add(panel);
|
add(panel);
|
||||||
|
|
||||||
this.configuration = rocketPanel.getConfiguration();
|
rkt = rocketPanel.getDocument().getRocket();
|
||||||
this.aerodynamicCalculator = rocketPanel.getAerodynamicCalculator().newInstance();
|
this.aerodynamicCalculator = rocketPanel.getAerodynamicCalculator().newInstance();
|
||||||
|
|
||||||
|
|
||||||
conditions = new FlightConditions(configuration);
|
conditions = new FlightConditions(rkt.getSelectedConfiguration());
|
||||||
|
|
||||||
rocketPanel.setCPAOA(0);
|
rocketPanel.setCPAOA(0);
|
||||||
aoa = new DoubleModel(rocketPanel, "CPAOA", UnitGroup.UNITS_ANGLE, 0, Math.PI);
|
aoa = new DoubleModel(rocketPanel, "CPAOA", UnitGroup.UNITS_ANGLE, 0, Math.PI);
|
||||||
@ -169,7 +170,6 @@ public class ComponentAnalysisDialog extends JDialog implements StateChangeListe
|
|||||||
// Stage and motor selection:
|
// Stage and motor selection:
|
||||||
//// Active stages:
|
//// Active stages:
|
||||||
panel.add(new JLabel(trans.get("componentanalysisdlg.lbl.activestages")), "spanx, split, gapafter rel");
|
panel.add(new JLabel(trans.get("componentanalysisdlg.lbl.activestages")), "spanx, split, gapafter rel");
|
||||||
Rocket rkt = rocketPanel.getDocument().getRocket();
|
|
||||||
panel.add(new StageSelector( rkt), "gapafter paragraph");
|
panel.add(new StageSelector( rkt), "gapafter paragraph");
|
||||||
|
|
||||||
//// Motor configuration:
|
//// Motor configuration:
|
||||||
@ -177,9 +177,10 @@ public class ComponentAnalysisDialog extends JDialog implements StateChangeListe
|
|||||||
label.setHorizontalAlignment(JLabel.RIGHT);
|
label.setHorizontalAlignment(JLabel.RIGHT);
|
||||||
panel.add(label, "growx, right");
|
panel.add(label, "growx, right");
|
||||||
|
|
||||||
JComboBox<FlightConfiguration> combo = new JComboBox<FlightConfiguration>( configuration.getRocket().toConfigArray());
|
final JComboBox<FlightConfiguration> configComboBox = new JComboBox<>();
|
||||||
|
final ConfigurationModel configModel = new ConfigurationModel(rkt, configComboBox);
|
||||||
panel.add(combo, "wrap");
|
configComboBox.setModel( configModel);
|
||||||
|
panel.add( configComboBox, "wrap");
|
||||||
|
|
||||||
|
|
||||||
// Tabbed pane
|
// Tabbed pane
|
||||||
@ -517,6 +518,7 @@ public class ComponentAnalysisDialog extends JDialog implements StateChangeListe
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void stateChanged(EventObject e) {
|
public void stateChanged(EventObject e) {
|
||||||
|
final FlightConfiguration configuration = rkt.getSelectedConfiguration();
|
||||||
AerodynamicForces forces;
|
AerodynamicForces forces;
|
||||||
WarningSet set = new WarningSet();
|
WarningSet set = new WarningSet();
|
||||||
conditions.setAOA(aoa.getValue());
|
conditions.setAOA(aoa.getValue());
|
||||||
@ -580,12 +582,12 @@ public class ComponentAnalysisDialog extends JDialog implements StateChangeListe
|
|||||||
data[1] = MassCalcType.LAUNCH_MASS.getCG(motorConfig);
|
data[1] = MassCalcType.LAUNCH_MASS.getCG(motorConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
forces = aeroData.get(configuration.getRocket());
|
forces = aeroData.get(rkt);
|
||||||
if (forces != null) {
|
if (forces != null) {
|
||||||
Object[] data = new Object[3];
|
Object[] data = new Object[3];
|
||||||
cgData.add(data);
|
cgData.add(data);
|
||||||
data[0] = configuration.getRocket();
|
data[0] = rkt;
|
||||||
data[1] = massData.get(configuration.getRocket());
|
data[1] = massData.get(rkt);
|
||||||
data[2] = forces;
|
data[2] = forces;
|
||||||
dragData.add(forces);
|
dragData.add(forces);
|
||||||
rollData.add(forces);
|
rollData.add(forces);
|
||||||
|
@ -23,6 +23,7 @@ import net.sf.openrocket.gui.util.GUIUtil;
|
|||||||
import net.sf.openrocket.l10n.Translator;
|
import net.sf.openrocket.l10n.Translator;
|
||||||
import net.sf.openrocket.startup.Application;
|
import net.sf.openrocket.startup.Application;
|
||||||
|
|
||||||
|
@SuppressWarnings("serial")
|
||||||
public class EditDecalDialog extends JDialog {
|
public class EditDecalDialog extends JDialog {
|
||||||
|
|
||||||
private static final Translator trans = Application.getTranslator();
|
private static final Translator trans = Application.getTranslator();
|
||||||
|
@ -1166,10 +1166,6 @@ public class GeneralOptimizationDialog extends JDialog {
|
|||||||
selectedModifierDescription.setText("");
|
selectedModifierDescription.setText("");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the active configuration
|
|
||||||
FlightConfigurationId fcid = getSelectedSimulation().getId();
|
|
||||||
getSelectedSimulation().getRocket().setDefaultConfiguration(fcid);
|
|
||||||
|
|
||||||
updating = false;
|
updating = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ public class PhotoPanel extends JPanel implements GLEventListener {
|
|||||||
((GLAutoDrawable) canvas).invoke(false, new GLRunnable() {
|
((GLAutoDrawable) canvas).invoke(false, new GLRunnable() {
|
||||||
@Override
|
@Override
|
||||||
public boolean run(final GLAutoDrawable drawable) {
|
public boolean run(final GLAutoDrawable drawable) {
|
||||||
PhotoPanel.this.configuration = doc.getDefaultConfiguration();
|
PhotoPanel.this.configuration = doc.getSelectedConfiguration();
|
||||||
cachedBounds = null;
|
cachedBounds = null;
|
||||||
rr = new RealisticRenderer(doc);
|
rr = new RealisticRenderer(doc);
|
||||||
rr.init(drawable);
|
rr.init(drawable);
|
||||||
|
@ -29,9 +29,10 @@ import net.sf.openrocket.rocketcomponent.Rocket;
|
|||||||
import net.sf.openrocket.startup.Application;
|
import net.sf.openrocket.startup.Application;
|
||||||
import net.sf.openrocket.util.Pair;
|
import net.sf.openrocket.util.Pair;
|
||||||
|
|
||||||
|
|
||||||
|
@SuppressWarnings("serial")
|
||||||
public abstract class FlightConfigurablePanel<T extends FlightConfigurableComponent> extends JPanel {
|
public abstract class FlightConfigurablePanel<T extends FlightConfigurableComponent> extends JPanel {
|
||||||
|
|
||||||
private static final long serialVersionUID = 3359871704879603700L;
|
|
||||||
protected static final Translator trans = Application.getTranslator();
|
protected static final Translator trans = Application.getTranslator();
|
||||||
private static final Logger log = LoggerFactory.getLogger(FlightConfigurablePanel.class);
|
private static final Logger log = LoggerFactory.getLogger(FlightConfigurablePanel.class);
|
||||||
protected RocketDescriptor descriptor = Application.getInjector().getInstance(RocketDescriptor.class);
|
protected RocketDescriptor descriptor = Application.getInjector().getInstance(RocketDescriptor.class);
|
||||||
@ -136,6 +137,7 @@ public abstract class FlightConfigurablePanel<T extends FlightConfigurableCompon
|
|||||||
}
|
}
|
||||||
Object tableValue = table.getModel().getValueAt(row, col);
|
Object tableValue = table.getModel().getValueAt(row, col);
|
||||||
if ( tableValue instanceof Pair ) {
|
if ( tableValue instanceof Pair ) {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
Pair<String,T> selectedComponent = (Pair<String,T>) tableValue;
|
Pair<String,T> selectedComponent = (Pair<String,T>) tableValue;
|
||||||
return selectedComponent.getV();
|
return selectedComponent.getV();
|
||||||
}
|
}
|
||||||
@ -150,6 +152,7 @@ public abstract class FlightConfigurablePanel<T extends FlightConfigurableCompon
|
|||||||
}
|
}
|
||||||
Object tableValue = table.getModel().getValueAt(row, col);
|
Object tableValue = table.getModel().getValueAt(row, col);
|
||||||
if ( tableValue instanceof Pair ) {
|
if ( tableValue instanceof Pair ) {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
Pair<FlightConfigurationId,T> selectedComponent = (Pair<FlightConfigurationId,T>) tableValue;
|
Pair<FlightConfigurationId,T> selectedComponent = (Pair<FlightConfigurationId,T>) tableValue;
|
||||||
FlightConfigurationId fcid = selectedComponent.getU();
|
FlightConfigurationId fcid = selectedComponent.getU();
|
||||||
return fcid;
|
return fcid;
|
||||||
@ -160,7 +163,6 @@ public abstract class FlightConfigurablePanel<T extends FlightConfigurableCompon
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected abstract class FlightConfigurableCellRenderer extends DefaultTableCellRenderer {
|
protected abstract class FlightConfigurableCellRenderer extends DefaultTableCellRenderer {
|
||||||
private static final long serialVersionUID = 2026945220957913776L;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Component getTableCellRendererComponent(JTable table, Object newValue, boolean isSelected, boolean hasFocus, int row, int column) {
|
public Component getTableCellRendererComponent(JTable table, Object newValue, boolean isSelected, boolean hasFocus, int row, int column) {
|
||||||
|
@ -26,9 +26,8 @@ import net.sf.openrocket.rocketvisitors.ListMotorMounts;
|
|||||||
import net.sf.openrocket.startup.Application;
|
import net.sf.openrocket.startup.Application;
|
||||||
import net.sf.openrocket.util.StateChangeListener;
|
import net.sf.openrocket.util.StateChangeListener;
|
||||||
|
|
||||||
|
@SuppressWarnings("serial")
|
||||||
public class FlightConfigurationPanel extends JPanel implements StateChangeListener {
|
public class FlightConfigurationPanel extends JPanel implements StateChangeListener {
|
||||||
private static final long serialVersionUID = -5467500312467789009L;
|
|
||||||
//private static final Logger log = LoggerFactory.getLogger(FlightConfigurationPanel.class);
|
|
||||||
private static final Translator trans = Application.getTranslator();
|
private static final Translator trans = Application.getTranslator();
|
||||||
|
|
||||||
private final OpenRocketDocument document;
|
private final OpenRocketDocument document;
|
||||||
@ -117,36 +116,36 @@ public class FlightConfigurationPanel extends JPanel implements StateChangeListe
|
|||||||
updateButtonState();
|
updateButtonState();
|
||||||
|
|
||||||
this.add(tabs, "spanx, grow, wrap rel");
|
this.add(tabs, "spanx, grow, wrap rel");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addConfiguration() {
|
private void addConfiguration() {
|
||||||
FlightConfigurationId newFCID = new FlightConfigurationId();
|
FlightConfigurationId newId = new FlightConfigurationId();
|
||||||
FlightConfiguration newConfig = new FlightConfiguration( rocket, newFCID );
|
FlightConfiguration newConfig = new FlightConfiguration( rocket, newId );
|
||||||
|
rocket.setFlightConfiguration( newId, newConfig);
|
||||||
rocket.setFlightConfiguration(newFCID, newConfig);
|
|
||||||
|
|
||||||
// Create a new simulation for this configuration.
|
// Create a new simulation for this configuration.
|
||||||
createSimulationForNewConfiguration();
|
createSimulationForNewConfiguration( newId );
|
||||||
|
|
||||||
configurationChanged();
|
configurationChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void copyConfiguration() {
|
private void copyConfiguration() {
|
||||||
FlightConfiguration oldConfig = rocket.getSelectedConfiguration();
|
FlightConfigurationId oldId = this.motorConfigurationPanel.getSelectedConfigurationId();
|
||||||
FlightConfiguration newConfig = oldConfig.clone();
|
FlightConfiguration oldConfig = rocket.getFlightConfiguration(oldId);
|
||||||
FlightConfigurationId oldId = oldConfig.getFlightConfigurationID();
|
|
||||||
FlightConfigurationId newId = newConfig.getFlightConfigurationID();
|
FlightConfigurationId newId = new FlightConfigurationId();
|
||||||
|
FlightConfiguration newConfig = oldConfig.copy( newId);
|
||||||
|
|
||||||
for (RocketComponent c : rocket) {
|
for (RocketComponent c : rocket) {
|
||||||
if (c instanceof FlightConfigurableComponent) {
|
if (c instanceof FlightConfigurableComponent) {
|
||||||
((FlightConfigurableComponent) c).cloneFlightConfiguration(oldId, newId);
|
((FlightConfigurableComponent) c).copyFlightConfiguration(oldId, newId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rocket.setFlightConfiguration(newId, newConfig);
|
rocket.setFlightConfiguration( newId, newConfig);
|
||||||
|
|
||||||
|
|
||||||
// Create a new simulation for this configuration.
|
// Create a new simulation for this configuration.
|
||||||
createSimulationForNewConfiguration();
|
createSimulationForNewConfiguration( newId);
|
||||||
|
|
||||||
configurationChanged();
|
configurationChanged();
|
||||||
}
|
}
|
||||||
@ -160,6 +159,7 @@ public class FlightConfigurationPanel extends JPanel implements StateChangeListe
|
|||||||
FlightConfigurationId currentId = this.motorConfigurationPanel.getSelectedConfigurationId();
|
FlightConfigurationId currentId = this.motorConfigurationPanel.getSelectedConfigurationId();
|
||||||
if (currentId == null)
|
if (currentId == null)
|
||||||
return;
|
return;
|
||||||
|
System.err.println(this.rocket.toDebugConfigs());
|
||||||
document.removeFlightConfigurationAndSimulations(currentId);
|
document.removeFlightConfigurationAndSimulations(currentId);
|
||||||
configurationChanged();
|
configurationChanged();
|
||||||
}
|
}
|
||||||
@ -167,12 +167,14 @@ public class FlightConfigurationPanel extends JPanel implements StateChangeListe
|
|||||||
/**
|
/**
|
||||||
* prereq - assumes that the new configuration has been set as the default configuration.
|
* prereq - assumes that the new configuration has been set as the default configuration.
|
||||||
*/
|
*/
|
||||||
private void createSimulationForNewConfiguration() {
|
private void createSimulationForNewConfiguration( final FlightConfigurationId fcid ) {
|
||||||
Simulation newSim = new Simulation(rocket);
|
Simulation newSim = new Simulation(rocket);
|
||||||
OpenRocketDocument doc = BasicFrame.findDocument(rocket);
|
OpenRocketDocument doc = BasicFrame.findDocument(rocket);
|
||||||
|
if (doc != null) {
|
||||||
newSim.setName(doc.getNextSimulationName());
|
newSim.setName(doc.getNextSimulationName());
|
||||||
doc.addSimulation(newSim);
|
doc.addSimulation(newSim);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void configurationChanged() {
|
private void configurationChanged() {
|
||||||
motorConfigurationPanel.fireTableDataChanged();
|
motorConfigurationPanel.fireTableDataChanged();
|
||||||
@ -192,7 +194,7 @@ public class FlightConfigurationPanel extends JPanel implements StateChangeListe
|
|||||||
int motorMountCount = rocket.accept(new ListMotorMounts()).size();
|
int motorMountCount = rocket.accept(new ListMotorMounts()).size();
|
||||||
|
|
||||||
// Count the number of recovery devices
|
// Count the number of recovery devices
|
||||||
int recoveryDeviceCount = rocket.accept(new ListComponents<RecoveryDevice>(RecoveryDevice.class)).size();
|
int recoveryDeviceCount = rocket.accept(new ListComponents<>(RecoveryDevice.class)).size();
|
||||||
|
|
||||||
// Count the number of stages
|
// Count the number of stages
|
||||||
int stageCount = rocket.getStageCount();
|
int stageCount = rocket.getStageCount();
|
||||||
|
@ -28,14 +28,15 @@ import net.sf.openrocket.gui.dialogs.motor.MotorChooserDialog;
|
|||||||
import net.sf.openrocket.motor.IgnitionEvent;
|
import net.sf.openrocket.motor.IgnitionEvent;
|
||||||
import net.sf.openrocket.motor.Motor;
|
import net.sf.openrocket.motor.Motor;
|
||||||
import net.sf.openrocket.motor.MotorConfiguration;
|
import net.sf.openrocket.motor.MotorConfiguration;
|
||||||
|
import net.sf.openrocket.rocketcomponent.FlightConfiguration;
|
||||||
import net.sf.openrocket.rocketcomponent.FlightConfigurationId;
|
import net.sf.openrocket.rocketcomponent.FlightConfigurationId;
|
||||||
import net.sf.openrocket.rocketcomponent.MotorMount;
|
import net.sf.openrocket.rocketcomponent.MotorMount;
|
||||||
import net.sf.openrocket.rocketcomponent.Rocket;
|
import net.sf.openrocket.rocketcomponent.Rocket;
|
||||||
import net.sf.openrocket.unit.UnitGroup;
|
import net.sf.openrocket.unit.UnitGroup;
|
||||||
import net.sf.openrocket.util.Chars;
|
import net.sf.openrocket.util.Chars;
|
||||||
|
|
||||||
|
@SuppressWarnings("serial")
|
||||||
public class MotorConfigurationPanel extends FlightConfigurablePanel<MotorMount> {
|
public class MotorConfigurationPanel extends FlightConfigurablePanel<MotorMount> {
|
||||||
private static final long serialVersionUID = -5046535300435793744L;
|
|
||||||
|
|
||||||
private static final String NONE = trans.get("edtmotorconfdlg.tbl.None");
|
private static final String NONE = trans.get("edtmotorconfdlg.tbl.None");
|
||||||
|
|
||||||
@ -60,7 +61,6 @@ public class MotorConfigurationPanel extends FlightConfigurablePanel<MotorMount>
|
|||||||
subpanel.add(label, "wrap");
|
subpanel.add(label, "wrap");
|
||||||
|
|
||||||
MotorMountConfigurationPanel mountConfigPanel = new MotorMountConfigurationPanel(this,rocket) {
|
MotorMountConfigurationPanel mountConfigPanel = new MotorMountConfigurationPanel(this,rocket) {
|
||||||
private static final long serialVersionUID = -238261338962282816L;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDataChanged() {
|
public void onDataChanged() {
|
||||||
@ -138,8 +138,6 @@ public class MotorConfigurationPanel extends FlightConfigurablePanel<MotorMount>
|
|||||||
protected JTable initializeTable() {
|
protected JTable initializeTable() {
|
||||||
//// Motor selection table.
|
//// Motor selection table.
|
||||||
configurationTableModel = new FlightConfigurableTableModel<MotorMount>(MotorMount.class,rocket) {
|
configurationTableModel = new FlightConfigurableTableModel<MotorMount>(MotorMount.class,rocket) {
|
||||||
private static final long serialVersionUID = -1210899988369000567L;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean includeComponent(MotorMount component) {
|
protected boolean includeComponent(MotorMount component) {
|
||||||
return component.isMotorMount();
|
return component.isMotorMount();
|
||||||
@ -204,10 +202,9 @@ public class MotorConfigurationPanel extends FlightConfigurablePanel<MotorMount>
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//MotorInstance curInstance = curMount.getMotorInstance( fcid );
|
if( fcid.equals( FlightConfigurationId.DEFAULT_VALUE_FCID)){
|
||||||
// curInstance may be empty here...
|
throw new IllegalStateException("Attempting to set a motor on the default FCID.");
|
||||||
//String mountName = ((RocketComponent)curMount).getName();
|
}
|
||||||
//System.err.println("?? Selecting motor "+curInstance+" for mount: "+mountName+" for config: "+fcid.toShortKey());
|
|
||||||
|
|
||||||
motorChooserDialog.setMotorMountAndConfig( fcid, curMount );
|
motorChooserDialog.setMotorMountAndConfig( fcid, curMount );
|
||||||
motorChooserDialog.setVisible(true);
|
motorChooserDialog.setVisible(true);
|
||||||
@ -215,11 +212,11 @@ public class MotorConfigurationPanel extends FlightConfigurablePanel<MotorMount>
|
|||||||
Motor mtr = motorChooserDialog.getSelectedMotor();
|
Motor mtr = motorChooserDialog.getSelectedMotor();
|
||||||
double d = motorChooserDialog.getSelectedDelay();
|
double d = motorChooserDialog.getSelectedDelay();
|
||||||
if (mtr != null) {
|
if (mtr != null) {
|
||||||
MotorConfiguration curConfig = curMount.getMotorConfig(fcid);
|
final MotorConfiguration templateConfig = curMount.getMotorConfig(fcid);
|
||||||
curConfig.setMotor(mtr);
|
final MotorConfiguration newConfig = new MotorConfiguration( curMount, fcid, templateConfig);
|
||||||
curConfig.setEjectionDelay(d);
|
newConfig.setMotor(mtr);
|
||||||
curConfig.setIgnitionEvent( IgnitionEvent.NEVER);
|
newConfig.setEjectionDelay(d);
|
||||||
curMount.setMotorConfig( curConfig, fcid);
|
curMount.setMotorConfig( newConfig, fcid);
|
||||||
}
|
}
|
||||||
|
|
||||||
fireTableDataChanged();
|
fireTableDataChanged();
|
||||||
@ -270,7 +267,6 @@ public class MotorConfigurationPanel extends FlightConfigurablePanel<MotorMount>
|
|||||||
|
|
||||||
|
|
||||||
private class MotorTableCellRenderer extends FlightConfigurablePanel<MotorMount>.FlightConfigurableCellRenderer {
|
private class MotorTableCellRenderer extends FlightConfigurablePanel<MotorMount>.FlightConfigurableCellRenderer {
|
||||||
private static final long serialVersionUID = -7462331042920067984L;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected JLabel format( MotorMount mount, FlightConfigurationId configId, JLabel l ) {
|
protected JLabel format( MotorMount mount, FlightConfigurationId configId, JLabel l ) {
|
||||||
|
@ -49,8 +49,8 @@ import net.sf.openrocket.util.Transformation;
|
|||||||
*
|
*
|
||||||
* @author Sampo Niskanen <sampo.niskanen@iki.fi>
|
* @author Sampo Niskanen <sampo.niskanen@iki.fi>
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("serial")
|
||||||
public class RocketFigure extends AbstractScaleFigure {
|
public class RocketFigure extends AbstractScaleFigure {
|
||||||
private static final long serialVersionUID = 45884403769043138L;
|
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(BasicEventSimulationEngine.class);
|
private static final Logger log = LoggerFactory.getLogger(BasicEventSimulationEngine.class);
|
||||||
|
|
||||||
|
@ -5,8 +5,6 @@ import java.awt.BorderLayout;
|
|||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
import java.awt.Point;
|
import java.awt.Point;
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
import java.awt.event.InputEvent;
|
import java.awt.event.InputEvent;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -42,6 +40,7 @@ import net.sf.openrocket.gui.adaptors.DoubleModel;
|
|||||||
import net.sf.openrocket.gui.components.BasicSlider;
|
import net.sf.openrocket.gui.components.BasicSlider;
|
||||||
import net.sf.openrocket.gui.components.StageSelector;
|
import net.sf.openrocket.gui.components.StageSelector;
|
||||||
import net.sf.openrocket.gui.components.UnitSelector;
|
import net.sf.openrocket.gui.components.UnitSelector;
|
||||||
|
import net.sf.openrocket.gui.components.ConfigurationModel;
|
||||||
import net.sf.openrocket.gui.configdialog.ComponentConfigDialog;
|
import net.sf.openrocket.gui.configdialog.ComponentConfigDialog;
|
||||||
import net.sf.openrocket.gui.figure3d.RocketFigure3d;
|
import net.sf.openrocket.gui.figure3d.RocketFigure3d;
|
||||||
import net.sf.openrocket.gui.figureelements.CGCaret;
|
import net.sf.openrocket.gui.figureelements.CGCaret;
|
||||||
@ -75,18 +74,19 @@ import net.sf.openrocket.util.Coordinate;
|
|||||||
import net.sf.openrocket.util.MathUtil;
|
import net.sf.openrocket.util.MathUtil;
|
||||||
import net.sf.openrocket.util.StateChangeListener;
|
import net.sf.openrocket.util.StateChangeListener;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A JPanel that contains a RocketFigure and buttons to manipulate the figure.
|
* A JPanel that contains a RocketFigure and buttons to manipulate the figure.
|
||||||
*
|
*
|
||||||
* @author Sampo Niskanen <sampo.niskanen@iki.fi>
|
* @author Sampo Niskanen <sampo.niskanen@iki.fi>
|
||||||
* @author Bill Kuker <bkuker@billkuker.com>
|
* @author Bill Kuker <bkuker@billkuker.com>
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("serial")
|
||||||
public class RocketPanel extends JPanel implements TreeSelectionListener, ChangeSource {
|
public class RocketPanel extends JPanel implements TreeSelectionListener, ChangeSource {
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
private static final Translator trans = Application.getTranslator();
|
private static final Translator trans = Application.getTranslator();
|
||||||
|
|
||||||
public static enum VIEW_TYPE {
|
public enum VIEW_TYPE {
|
||||||
SideView(false, RocketFigure.VIEW_SIDE),
|
SideView(false, RocketFigure.VIEW_SIDE),
|
||||||
BackView(false, RocketFigure.VIEW_BACK),
|
BackView(false, RocketFigure.VIEW_BACK),
|
||||||
Figure3D(true, RocketFigure3d.TYPE_FIGURE),
|
Figure3D(true, RocketFigure3d.TYPE_FIGURE),
|
||||||
@ -96,7 +96,7 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change
|
|||||||
public final boolean is3d;
|
public final boolean is3d;
|
||||||
private final int type;
|
private final int type;
|
||||||
|
|
||||||
private VIEW_TYPE(final boolean is3d, final int type) {
|
VIEW_TYPE(final boolean is3d, final int type) {
|
||||||
this.is3d = is3d;
|
this.is3d = is3d;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
};
|
};
|
||||||
@ -271,12 +271,21 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change
|
|||||||
* Creates the layout and components of the panel.
|
* Creates the layout and components of the panel.
|
||||||
*/
|
*/
|
||||||
private void createPanel() {
|
private void createPanel() {
|
||||||
|
final Rocket rkt = document.getRocket();
|
||||||
|
|
||||||
|
rkt.addChangeListener(new StateChangeListener(){
|
||||||
|
@Override
|
||||||
|
public void stateChanged(EventObject eo) {
|
||||||
|
updateExtras();
|
||||||
|
updateFigures();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
setLayout(new MigLayout("", "[shrink][grow]", "[shrink][shrink][grow][shrink]"));
|
setLayout(new MigLayout("", "[shrink][grow]", "[shrink][shrink][grow][shrink]"));
|
||||||
|
|
||||||
setPreferredSize(new Dimension(800, 300));
|
setPreferredSize(new Dimension(800, 300));
|
||||||
|
|
||||||
// View Type Dropdown
|
// View Type drop-down
|
||||||
@SuppressWarnings("serial") // because java throws a warning without this.
|
|
||||||
ComboBoxModel<VIEW_TYPE> cm = new DefaultComboBoxModel<VIEW_TYPE>(VIEW_TYPE.values()) {
|
ComboBoxModel<VIEW_TYPE> cm = new DefaultComboBoxModel<VIEW_TYPE>(VIEW_TYPE.values()) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -301,7 +310,6 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change
|
|||||||
add(scaleSelector);
|
add(scaleSelector);
|
||||||
|
|
||||||
// Stage selector
|
// Stage selector
|
||||||
final Rocket rkt = document.getRocket();
|
|
||||||
StageSelector stageSelector = new StageSelector( rkt );
|
StageSelector stageSelector = new StageSelector( rkt );
|
||||||
rkt.addChangeListener(stageSelector);
|
rkt.addChangeListener(stageSelector);
|
||||||
add(stageSelector);
|
add(stageSelector);
|
||||||
@ -312,20 +320,12 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change
|
|||||||
label.setHorizontalAlignment(JLabel.RIGHT);
|
label.setHorizontalAlignment(JLabel.RIGHT);
|
||||||
add(label, "growx, right");
|
add(label, "growx, right");
|
||||||
|
|
||||||
final JComboBox<FlightConfiguration> configComboBox = new JComboBox<FlightConfiguration>( document.getRocket().toConfigArray());
|
final JComboBox<FlightConfiguration> configComboBox = new JComboBox<>();
|
||||||
|
final ConfigurationModel configModel = new ConfigurationModel(rkt, configComboBox);
|
||||||
|
rkt.addChangeListener( configModel );
|
||||||
|
configComboBox.setModel(configModel);
|
||||||
add(configComboBox, "wrap, width 16%, wmin 100");
|
add(configComboBox, "wrap, width 16%, wmin 100");
|
||||||
|
|
||||||
configComboBox.addActionListener(new ActionListener(){
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent ae) {
|
|
||||||
FlightConfiguration newConfig = (FlightConfiguration)configComboBox.getSelectedItem();
|
|
||||||
document.getRocket().setSelectedConfiguration( newConfig);
|
|
||||||
updateExtras();
|
|
||||||
updateFigures();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
// Create slider and scroll pane
|
// Create slider and scroll pane
|
||||||
DoubleModel theta = new DoubleModel(figure, "Rotation",
|
DoubleModel theta = new DoubleModel(figure, "Rotation",
|
||||||
@ -361,8 +361,8 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change
|
|||||||
return aerodynamicCalculator;
|
return aerodynamicCalculator;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FlightConfiguration getConfiguration() {
|
public FlightConfiguration getSelectedConfiguration() {
|
||||||
return document.getDefaultConfiguration();
|
return document.getSelectedConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -565,7 +565,7 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change
|
|||||||
Coordinate cp, cg;
|
Coordinate cp, cg;
|
||||||
double cpx, cgx;
|
double cpx, cgx;
|
||||||
|
|
||||||
FlightConfiguration curConfig = document.getDefaultConfiguration();
|
FlightConfiguration curConfig = document.getSelectedConfiguration();
|
||||||
// TODO: MEDIUM: User-definable conditions
|
// TODO: MEDIUM: User-definable conditions
|
||||||
FlightConditions conditions = new FlightConditions(curConfig);
|
FlightConditions conditions = new FlightConditions(curConfig);
|
||||||
warnings.clear();
|
warnings.clear();
|
||||||
@ -644,7 +644,7 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change
|
|||||||
extraText.setLength(length);
|
extraText.setLength(length);
|
||||||
extraText.setDiameter(diameter);
|
extraText.setDiameter(diameter);
|
||||||
extraText.setMass(cg.weight);
|
extraText.setMass(cg.weight);
|
||||||
extraText.setMassWithoutMotors( massCalculator.getCG( getConfiguration(), MassCalcType.NO_MOTORS ).weight );
|
extraText.setMassWithoutMotors( massCalculator.getCG( getSelectedConfiguration(), MassCalcType.NO_MOTORS ).weight );
|
||||||
extraText.setWarnings(warnings);
|
extraText.setWarnings(warnings);
|
||||||
|
|
||||||
if (figure.getType() == RocketPanel.VIEW_TYPE.SideView && length > 0) {
|
if (figure.getType() == RocketPanel.VIEW_TYPE.SideView && length > 0) {
|
||||||
@ -672,12 +672,12 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change
|
|||||||
|
|
||||||
// Check whether data is already up to date
|
// Check whether data is already up to date
|
||||||
if (flightDataFunctionalID == curConfig.getRocket().getFunctionalModID() &&
|
if (flightDataFunctionalID == curConfig.getRocket().getFunctionalModID() &&
|
||||||
flightDataMotorID == curConfig.getFlightConfigurationID()) {
|
flightDataMotorID == curConfig.getId()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
flightDataFunctionalID = curConfig.getRocket().getFunctionalModID();
|
flightDataFunctionalID = curConfig.getRocket().getFunctionalModID();
|
||||||
flightDataMotorID = curConfig.getFlightConfigurationID();
|
flightDataMotorID = curConfig.getId();
|
||||||
|
|
||||||
// Stop previous computation (if any)
|
// Stop previous computation (if any)
|
||||||
stopBackgroundSimulation();
|
stopBackgroundSimulation();
|
||||||
@ -695,7 +695,7 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change
|
|||||||
|
|
||||||
Rocket duplicate = (Rocket) document.getRocket().copy();
|
Rocket duplicate = (Rocket) document.getRocket().copy();
|
||||||
Simulation simulation = ((SwingPreferences) Application.getPreferences()).getBackgroundSimulation(duplicate);
|
Simulation simulation = ((SwingPreferences) Application.getPreferences()).getBackgroundSimulation(duplicate);
|
||||||
simulation.setFlightConfigurationId( document.getDefaultConfiguration().getFlightConfigurationID());
|
simulation.setFlightConfigurationId( document.getSelectedConfiguration().getId());
|
||||||
|
|
||||||
backgroundSimulationWorker = new BackgroundSimulationWorker(document, simulation);
|
backgroundSimulationWorker = new BackgroundSimulationWorker(document, simulation);
|
||||||
backgroundSimulationExecutor.execute(backgroundSimulationWorker);
|
backgroundSimulationExecutor.execute(backgroundSimulationWorker);
|
||||||
@ -781,7 +781,7 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change
|
|||||||
* Adds the extra data to the figure. Currently this includes the CP and CG carets.
|
* Adds the extra data to the figure. Currently this includes the CP and CG carets.
|
||||||
*/
|
*/
|
||||||
private void addExtras() {
|
private void addExtras() {
|
||||||
FlightConfiguration curConfig = document.getDefaultConfiguration();
|
FlightConfiguration curConfig = document.getSelectedConfiguration();
|
||||||
extraCG = new CGCaret(0, 0);
|
extraCG = new CGCaret(0, 0);
|
||||||
extraCP = new CPCaret(0, 0);
|
extraCP = new CPCaret(0, 0);
|
||||||
extraText = new RocketInfo(curConfig);
|
extraText = new RocketInfo(curConfig);
|
||||||
|
@ -21,10 +21,12 @@ import javax.swing.event.DocumentListener;
|
|||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
import net.sf.openrocket.document.OpenRocketDocument;
|
import net.sf.openrocket.document.OpenRocketDocument;
|
||||||
import net.sf.openrocket.document.Simulation;
|
import net.sf.openrocket.document.Simulation;
|
||||||
|
import net.sf.openrocket.gui.components.ConfigurationModel;
|
||||||
import net.sf.openrocket.gui.util.GUIUtil;
|
import net.sf.openrocket.gui.util.GUIUtil;
|
||||||
import net.sf.openrocket.l10n.Translator;
|
import net.sf.openrocket.l10n.Translator;
|
||||||
import net.sf.openrocket.rocketcomponent.FlightConfiguration;
|
import net.sf.openrocket.rocketcomponent.FlightConfiguration;
|
||||||
import net.sf.openrocket.rocketcomponent.FlightConfigurationId;
|
import net.sf.openrocket.rocketcomponent.FlightConfigurationId;
|
||||||
|
import net.sf.openrocket.rocketcomponent.Rocket;
|
||||||
import net.sf.openrocket.simulation.extension.SimulationExtension;
|
import net.sf.openrocket.simulation.extension.SimulationExtension;
|
||||||
import net.sf.openrocket.startup.Application;
|
import net.sf.openrocket.startup.Application;
|
||||||
|
|
||||||
@ -145,8 +147,10 @@ public class SimulationEditDialog extends JDialog {
|
|||||||
label.setToolTipText(trans.get("simedtdlg.lbl.ttip.Flightcfg"));
|
label.setToolTipText(trans.get("simedtdlg.lbl.ttip.Flightcfg"));
|
||||||
panel.add(label, "growx 0, gapright para");
|
panel.add(label, "growx 0, gapright para");
|
||||||
|
|
||||||
final JComboBox<FlightConfiguration> configComboBox = new JComboBox<FlightConfiguration>( document.getRocket().toConfigArray());
|
final Rocket rkt = document.getRocket();
|
||||||
configComboBox.setSelectedItem( document.getRocket().getSelectedConfiguration().getId() );
|
final JComboBox<FlightConfiguration> configComboBox = new JComboBox<>();
|
||||||
|
final ConfigurationModel configModel = new ConfigurationModel(rkt, configComboBox);
|
||||||
|
configComboBox.setModel( configModel);
|
||||||
|
|
||||||
//// Select the motor configuration to use.
|
//// Select the motor configuration to use.
|
||||||
configComboBox.setToolTipText(trans.get("simedtdlg.combo.ttip.Flightcfg"));
|
configComboBox.setToolTipText(trans.get("simedtdlg.combo.ttip.Flightcfg"));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user