Added SupportsFlightConfiguration interface and implemented it by
RecoveryDevice.
This commit is contained in:
parent
759facf9dd
commit
e364c10026
@ -95,7 +95,7 @@ public class RecoveryConfigurationPanel extends JPanel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void resetDeployment() {
|
private void resetDeployment() {
|
||||||
selectedComponent.setDeploymentConfiguration(rocket.getDefaultConfiguration().getFlightConfigurationID(), null);
|
selectedComponent.setFlightConfiguration(rocket.getDefaultConfiguration().getFlightConfigurationID(), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateButtonState() {
|
private void updateButtonState() {
|
||||||
@ -144,9 +144,9 @@ public class RecoveryConfigurationPanel extends JPanel {
|
|||||||
case 0:
|
case 0:
|
||||||
return d.getName();
|
return d.getName();
|
||||||
case 1:
|
case 1:
|
||||||
DeploymentConfiguration deployConfig = d.getDeploymentConfiguration(rocket.getDefaultConfiguration().getFlightConfigurationID());
|
DeploymentConfiguration deployConfig = d.getFlightConfiguration(rocket.getDefaultConfiguration().getFlightConfigurationID());
|
||||||
if ( deployConfig == null ) {
|
if ( deployConfig == null ) {
|
||||||
return "[" + d.getDefaultDeploymentConfiguration().toString() + "]";
|
return "[" + d.getDefaultFlightConfiguration().toString() + "]";
|
||||||
} else {
|
} else {
|
||||||
return deployConfig.toString();
|
return deployConfig.toString();
|
||||||
}
|
}
|
||||||
|
@ -32,9 +32,9 @@ public class SelectDeploymentConfigDialog extends JDialog {
|
|||||||
super.setModal(true);
|
super.setModal(true);
|
||||||
final String configId = rocket.getDefaultConfiguration().getFlightConfigurationID();
|
final String configId = rocket.getDefaultConfiguration().getFlightConfigurationID();
|
||||||
|
|
||||||
newConfiguration = component.getDeploymentConfiguration(configId);
|
newConfiguration = component.getFlightConfiguration(configId);
|
||||||
if ( newConfiguration == null ) {
|
if ( newConfiguration == null ) {
|
||||||
newConfiguration = component.getDefaultDeploymentConfiguration().clone();
|
newConfiguration = component.getDefaultFlightConfiguration().clone();
|
||||||
} else {
|
} else {
|
||||||
// Clone the existing so cancel works. When the user selects OK, this configuration
|
// Clone the existing so cancel works. When the user selects OK, this configuration
|
||||||
// is put back in there.
|
// is put back in there.
|
||||||
@ -113,7 +113,7 @@ public class SelectDeploymentConfigDialog extends JDialog {
|
|||||||
double deployAltitude = alt.getCurrentUnit().fromUnit( alt.getValue() );
|
double deployAltitude = alt.getCurrentUnit().fromUnit( alt.getValue() );
|
||||||
newConfiguration.setDeployAltitude(deployAltitude);
|
newConfiguration.setDeployAltitude(deployAltitude);
|
||||||
|
|
||||||
component.setDeploymentConfiguration(configId, newConfiguration);
|
component.setFlightConfiguration(configId, newConfiguration);
|
||||||
|
|
||||||
SelectDeploymentConfigDialog.this.setVisible(false);
|
SelectDeploymentConfigDialog.this.setVisible(false);
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ import net.sf.openrocket.util.MathUtil;
|
|||||||
*
|
*
|
||||||
* @author Sampo Niskanen <sampo.niskanen@iki.fi>
|
* @author Sampo Niskanen <sampo.niskanen@iki.fi>
|
||||||
*/
|
*/
|
||||||
public abstract class RecoveryDevice extends MassObject {
|
public abstract class RecoveryDevice extends MassObject implements SupportsFlightConfiguration<DeploymentConfiguration> {
|
||||||
private static final Translator trans = Application.getTranslator();
|
private static final Translator trans = Application.getTranslator();
|
||||||
|
|
||||||
private Map<String,DeploymentConfiguration> deploymentConfigurations = new HashMap<String,DeploymentConfiguration>();
|
private Map<String,DeploymentConfiguration> deploymentConfigurations = new HashMap<String,DeploymentConfiguration>();
|
||||||
@ -114,16 +114,14 @@ public abstract class RecoveryDevice extends MassObject {
|
|||||||
* @param configID
|
* @param configID
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public DeploymentConfiguration getDeploymentConfiguration( String configID ) {
|
@Override
|
||||||
|
public DeploymentConfiguration getFlightConfiguration( String configID ) {
|
||||||
DeploymentConfiguration config = deploymentConfigurations.get(configID);
|
DeploymentConfiguration config = deploymentConfigurations.get(configID);
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DeploymentConfiguration getDefaultDeploymentConfiguration() {
|
@Override
|
||||||
return defaultDeploymentConfig;
|
public void setFlightConfiguration( String configID, DeploymentConfiguration config ) {
|
||||||
}
|
|
||||||
|
|
||||||
public void setDeploymentConfiguration( String configID, DeploymentConfiguration config ) {
|
|
||||||
if ( config == null ) {
|
if ( config == null ) {
|
||||||
deploymentConfigurations.remove(configID);
|
deploymentConfigurations.remove(configID);
|
||||||
} else {
|
} else {
|
||||||
@ -132,6 +130,22 @@ public abstract class RecoveryDevice extends MassObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DeploymentConfiguration getDefaultFlightConfiguration() {
|
||||||
|
return defaultDeploymentConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setDefaultFlightConfiguration( DeploymentConfiguration config ) {
|
||||||
|
this.defaultDeploymentConfig = config;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void cloneFlightConfiguration( String oldConfigId, String newConfigId ) {
|
||||||
|
DeploymentConfiguration oldConfig = getFlightConfiguration(oldConfigId);
|
||||||
|
setFlightConfiguration( newConfigId, oldConfig.clone() );
|
||||||
|
}
|
||||||
|
|
||||||
public DeployEvent getDefaultDeployEvent() {
|
public DeployEvent getDefaultDeployEvent() {
|
||||||
return defaultDeploymentConfig.getDeployEvent();
|
return defaultDeploymentConfig.getDeployEvent();
|
||||||
}
|
}
|
||||||
@ -171,8 +185,6 @@ public abstract class RecoveryDevice extends MassObject {
|
|||||||
fireComponentChangeEvent(ComponentChangeEvent.EVENT_CHANGE);
|
fireComponentChangeEvent(ComponentChangeEvent.EVENT_CHANGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getComponentMass() {
|
public double getComponentMass() {
|
||||||
return getArea() * getMaterial().getDensity();
|
return getArea() * getMaterial().getDensity();
|
||||||
|
@ -0,0 +1,15 @@
|
|||||||
|
package net.sf.openrocket.rocketcomponent;
|
||||||
|
|
||||||
|
public interface SupportsFlightConfiguration<T> {
|
||||||
|
|
||||||
|
public T getFlightConfiguration( String configId );
|
||||||
|
|
||||||
|
public void setFlightConfiguration( String configId, T config );
|
||||||
|
|
||||||
|
public void cloneFlightConfiguration( String oldConfigId, String newConfigId );
|
||||||
|
|
||||||
|
public T getDefaultFlightConfiguration();
|
||||||
|
|
||||||
|
public void setDefaultFlightConfiguration( T config );
|
||||||
|
|
||||||
|
}
|
@ -375,9 +375,9 @@ public class BasicEventSimulationEngine implements SimulationEngine {
|
|||||||
RocketComponent c = rci.next();
|
RocketComponent c = rci.next();
|
||||||
if (!(c instanceof RecoveryDevice))
|
if (!(c instanceof RecoveryDevice))
|
||||||
continue;
|
continue;
|
||||||
DeploymentConfiguration deployConfig = ((RecoveryDevice) c).getDeploymentConfiguration(flightConfigurationId);
|
DeploymentConfiguration deployConfig = ((RecoveryDevice) c).getFlightConfiguration(flightConfigurationId);
|
||||||
if ( deployConfig == null ) {
|
if ( deployConfig == null ) {
|
||||||
deployConfig = ((RecoveryDevice) c).getDefaultDeploymentConfiguration();
|
deployConfig = ((RecoveryDevice) c).getDefaultFlightConfiguration();
|
||||||
}
|
}
|
||||||
if (deployConfig.isActivationEvent(event, c)) {
|
if (deployConfig.isActivationEvent(event, c)) {
|
||||||
// Delay event by at least 1ms to allow stage separation to occur first
|
// Delay event by at least 1ms to allow stage separation to occur first
|
||||||
|
Loading…
x
Reference in New Issue
Block a user