[Major] Re-Implemented ..ParameterSet to represent the default more simply

- the default value is now simply an entry in the map
  - size() returns only the number of overrides
  - getIds() returns only the ids of overrides
- added ParemeterSetTest to test FlightConfigurableParameterSet
- removed (already defanged) event handling functions from MotorConfig
- removed (already defanged) event handling functions from DeploymentConfig
- removed (already defanged) event handling functions from IgnitionConfig
- FlightConfigurableParameter no longer extends ChangeSet
- fully parameterized DoubleModel to <T extends Enum<T> >
- fully parameterized EnumModel to <T extends Enum<T> >
This commit is contained in:
Daniel_M_Williams 2015-12-23 00:08:50 -05:00
parent 612f64fa4c
commit f59ebdd06e
17 changed files with 307 additions and 241 deletions

View File

@ -1,17 +1,12 @@
package net.sf.openrocket.motor; package net.sf.openrocket.motor;
import java.util.EventObject;
import java.util.List;
import net.sf.openrocket.rocketcomponent.FlightConfigurableParameter; import net.sf.openrocket.rocketcomponent.FlightConfigurableParameter;
import net.sf.openrocket.rocketcomponent.IgnitionEvent; import net.sf.openrocket.rocketcomponent.IgnitionEvent;
import net.sf.openrocket.rocketcomponent.MotorMount; import net.sf.openrocket.rocketcomponent.MotorMount;
import net.sf.openrocket.rocketcomponent.RocketComponent; import net.sf.openrocket.rocketcomponent.RocketComponent;
import net.sf.openrocket.simulation.MotorState; import net.sf.openrocket.simulation.MotorState;
import net.sf.openrocket.util.ArrayList;
import net.sf.openrocket.util.Coordinate; import net.sf.openrocket.util.Coordinate;
import net.sf.openrocket.util.Inertia; import net.sf.openrocket.util.Inertia;
import net.sf.openrocket.util.StateChangeListener;
/** /**
* A single motor configuration. This includes the selected motor * A single motor configuration. This includes the selected motor
@ -83,7 +78,6 @@ public class MotorConfiguration implements FlightConfigurableParameter<MotorConf
public void setMotor(Motor motor){ public void setMotor(Motor motor){
this.motor = motor; this.motor = motor;
fireChangeEvent();
} }
public Motor getMotor() { public Motor getMotor() {
@ -104,7 +98,6 @@ public class MotorConfiguration implements FlightConfigurableParameter<MotorConf
public void setEjectionDelay(double delay) { public void setEjectionDelay(double delay) {
this.ejectionDelay = delay; this.ejectionDelay = delay;
fireChangeEvent();
} }
public Coordinate getPosition() { public Coordinate getPosition() {
@ -114,7 +107,6 @@ public class MotorConfiguration implements FlightConfigurableParameter<MotorConf
public void setPosition(Coordinate _position) { public void setPosition(Coordinate _position) {
this.position = _position; this.position = _position;
modID++; modID++;
fireChangeEvent();
} }
public double getIgnitionTime() { public double getIgnitionTime() {
@ -129,7 +121,6 @@ public class MotorConfiguration implements FlightConfigurableParameter<MotorConf
this.ignitionTime = _time; this.ignitionTime = _time;
this.ignitionOveride = true; this.ignitionOveride = true;
modID++; modID++;
fireChangeEvent();
} }
public double getIgnitionDelay() { public double getIgnitionDelay() {
@ -139,7 +130,6 @@ public class MotorConfiguration implements FlightConfigurableParameter<MotorConf
public void setIgnitionDelay(final double _delay) { public void setIgnitionDelay(final double _delay) {
this.ignitionDelay = _delay; this.ignitionDelay = _delay;
this.ignitionOveride = true; this.ignitionOveride = true;
fireChangeEvent();
} }
public IgnitionEvent getIgnitionEvent() { public IgnitionEvent getIgnitionEvent() {
@ -149,7 +139,6 @@ public class MotorConfiguration implements FlightConfigurableParameter<MotorConf
public void setIgnitionEvent(final IgnitionEvent _event) { public void setIgnitionEvent(final IgnitionEvent _event) {
this.ignitionEvent = _event; this.ignitionEvent = _event;
this.ignitionOveride = true; this.ignitionOveride = true;
fireChangeEvent();
} }
public Coordinate getOffset( ){ public Coordinate getOffset( ){
@ -228,17 +217,6 @@ public class MotorConfiguration implements FlightConfigurableParameter<MotorConf
return clone; return clone;
} }
@Override
public void addChangeListener(StateChangeListener listener) {
}
@Override
public void removeChangeListener(StateChangeListener listener) {
}
protected void fireChangeEvent() {
}
public int getModID() { public int getModID() {
return modID; return modID;
} }

View File

@ -13,18 +13,18 @@ public class MotorConfigurationSet extends FlightConfigurableParameterSet<MotorC
public static final int DEFAULT_MOTOR_EVENT_TYPE = ComponentChangeEvent.MOTOR_CHANGE | ComponentChangeEvent.EVENT_CHANGE; public static final int DEFAULT_MOTOR_EVENT_TYPE = ComponentChangeEvent.MOTOR_CHANGE | ComponentChangeEvent.EVENT_CHANGE;
public MotorConfigurationSet(RocketComponent component ) { public MotorConfigurationSet(RocketComponent component ) {
super(component, DEFAULT_MOTOR_EVENT_TYPE, new MotorConfiguration()); super( new MotorConfiguration());
} }
/** /**
* Construct a copy of an existing FlightConfigurationSet. * Construct a copy of an existing FlightConfigurationSet.
* *
* @param flightConfiguration another flightConfiguration to copy data from. * @param configSet another flightConfiguration to copy data from.
* @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> flightConfiguration, RocketComponent component) { public MotorConfigurationSet(FlightConfigurableParameterSet<MotorConfiguration> configSet, RocketComponent component) {
super(flightConfiguration, component, DEFAULT_MOTOR_EVENT_TYPE); super(configSet);
} }
@Override @Override
@ -35,8 +35,7 @@ public class MotorConfigurationSet extends FlightConfigurableParameterSet<MotorC
@Override @Override
public String toDebug(){ public String toDebug(){
StringBuilder buffer = new StringBuilder(); StringBuilder buffer = new StringBuilder();
buffer.append("====== Dumping MotorConfigurationSet for mount '"+this.component.toDebugName()+" ======\n"); buffer.append("====== Dumping MotorConfigurationSet for mount ("+this.size()+ " motors)\n");
buffer.append(" >> motorSet ("+this.size()+ " motors)\n");
MotorConfiguration emptyInstance = this.getDefault(); MotorConfiguration emptyInstance = this.getDefault();
buffer.append(" >> (["+emptyInstance.toString()+"]= @ "+ emptyInstance.getIgnitionEvent().name +" +"+emptyInstance.getIgnitionDelay()+"sec )\n"); buffer.append(" >> (["+emptyInstance.toString()+"]= @ "+ emptyInstance.getIgnitionEvent().name +" +"+emptyInstance.getIgnitionDelay()+"sec )\n");

View File

@ -17,8 +17,7 @@ public class AxialStage extends ComponentAssembly implements FlightConfigurableC
protected int stageNumber; protected int stageNumber;
public AxialStage(){ public AxialStage(){
this.separations = new FlightConfigurableParameterSet<StageSeparationConfiguration>( this.separations = new FlightConfigurableParameterSet<StageSeparationConfiguration>( new StageSeparationConfiguration());
this, ComponentChangeEvent.EVENT_CHANGE, new StageSeparationConfiguration());
this.relativePosition = Position.AFTER; this.relativePosition = Position.AFTER;
this.stageNumber = 0; this.stageNumber = 0;
} }
@ -80,8 +79,7 @@ public class AxialStage extends ComponentAssembly implements FlightConfigurableC
@Override @Override
protected RocketComponent copyWithOriginalID() { protected RocketComponent copyWithOriginalID() {
AxialStage copy = (AxialStage) super.copyWithOriginalID(); AxialStage copy = (AxialStage) super.copyWithOriginalID();
copy.separations = new FlightConfigurableParameterSet<StageSeparationConfiguration>(separations, copy.separations = new FlightConfigurableParameterSet<StageSeparationConfiguration>(separations);
copy, ComponentChangeEvent.EVENT_CHANGE);
return copy; return copy;
} }

View File

@ -1,16 +1,12 @@
package net.sf.openrocket.rocketcomponent; package net.sf.openrocket.rocketcomponent;
import java.util.EventObject;
import java.util.List;
import net.sf.openrocket.l10n.Translator; import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.simulation.FlightEvent; import net.sf.openrocket.simulation.FlightEvent;
import net.sf.openrocket.startup.Application; import net.sf.openrocket.startup.Application;
import net.sf.openrocket.unit.UnitGroup; import net.sf.openrocket.unit.UnitGroup;
import net.sf.openrocket.util.ArrayList;
import net.sf.openrocket.util.MathUtil; import net.sf.openrocket.util.MathUtil;
import net.sf.openrocket.util.Pair; import net.sf.openrocket.util.Pair;
import net.sf.openrocket.util.StateChangeListener;
public class DeploymentConfiguration implements FlightConfigurableParameter<DeploymentConfiguration> { public class DeploymentConfiguration implements FlightConfigurableParameter<DeploymentConfiguration> {
@ -106,7 +102,6 @@ public class DeploymentConfiguration implements FlightConfigurableParameter<Depl
throw new NullPointerException("deployEvent is null"); throw new NullPointerException("deployEvent is null");
} }
this.deployEvent = deployEvent; this.deployEvent = deployEvent;
fireChangeEvent();
} }
public double getDeployAltitude() { public double getDeployAltitude() {
@ -118,7 +113,6 @@ public class DeploymentConfiguration implements FlightConfigurableParameter<Depl
return; return;
} }
this.deployAltitude = deployAltitude; this.deployAltitude = deployAltitude;
fireChangeEvent();
} }
public double getDeployDelay() { public double getDeployDelay() {
@ -130,7 +124,6 @@ public class DeploymentConfiguration implements FlightConfigurableParameter<Depl
return; return;
} }
this.deployDelay = deployDelay; this.deployDelay = deployDelay;
fireChangeEvent();
} }
@Override @Override
@ -146,25 +139,6 @@ public class DeploymentConfiguration implements FlightConfigurableParameter<Depl
} }
@Override
public void addChangeListener(StateChangeListener listener) {
}
@Override
public void removeChangeListener(StateChangeListener listener) {
}
private void fireChangeEvent() {
}
@Override @Override
public DeploymentConfiguration clone() { public DeploymentConfiguration clone() {
DeploymentConfiguration that = new DeploymentConfiguration(); DeploymentConfiguration that = new DeploymentConfiguration();

View File

@ -8,7 +8,7 @@ import net.sf.openrocket.util.ChangeSource;
* *
* @param <E> the parameter type * @param <E> the parameter type
*/ */
public interface FlightConfigurableParameter<E> extends ChangeSource { public interface FlightConfigurableParameter<E> {
/** /**
* Return a copy of this object. The listeners must not be copied * Return a copy of this object. The listeners must not be copied

View File

@ -1,14 +1,12 @@
package net.sf.openrocket.rocketcomponent; package net.sf.openrocket.rocketcomponent;
import java.util.Collections; import java.util.Collections;
import java.util.EventObject;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
import net.sf.openrocket.util.ArrayList; import net.sf.openrocket.util.ArrayList;
import net.sf.openrocket.util.StateChangeListener;
import net.sf.openrocket.util.Utils; import net.sf.openrocket.util.Utils;
/** /**
@ -24,13 +22,7 @@ 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;
protected E defaultValue;
protected final RocketComponent component;
protected final int eventType;
private final Listener listener = new Listener();
/** /**
* Construct a FlightConfiguration that has no overrides. * Construct a FlightConfiguration that has no overrides.
@ -38,33 +30,25 @@ public class FlightConfigurableParameterSet<E extends FlightConfigurableParamete
* @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 FlightConfigurableParameterSet(RocketComponent component, int eventType, E _defaultValue) { public FlightConfigurableParameterSet(E _defaultValue) {
this.component = component; this.map.put( defaultValueId, _defaultValue);
this.eventType = eventType;
this.defaultValue= _defaultValue;
addListener(_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 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 FlightConfigurableParameterSet(FlightConfigurableParameterSet<E> configSet, RocketComponent component, int eventType) { public FlightConfigurableParameterSet(FlightConfigurableParameterSet<E> configSet ){
this.component = component;
this.eventType = eventType;
this.defaultValue= configSet.getDefault().clone();
for (FlightConfigurationId key : configSet.map.keySet()) { for (FlightConfigurationId key : configSet.map.keySet()) {
E cloneConfig = configSet.map.get(key).clone(); E cloneConfig = configSet.map.get(key).clone();
this.map.put(key, cloneConfig); this.map.put(key, cloneConfig);
} }
} }
@Deprecated
// do we want to keep this? it shouldn't actually be called...
public boolean containsKey( final FlightConfigurationId fcid ){ public boolean containsKey( final FlightConfigurationId fcid ){
return this.map.containsKey(fcid); return this.map.containsKey(fcid);
} }
@ -77,7 +61,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.defaultValue; return this.map.get( defaultValueId);
} }
/** /**
@ -94,7 +78,7 @@ public class FlightConfigurableParameterSet<E extends FlightConfigurableParamete
if( this.isDefault(nextDefaultValue)){ if( this.isDefault(nextDefaultValue)){
return; return;
} }
this.defaultValue = nextDefaultValue; this.map.put( defaultValueId, nextDefaultValue);
} }
@Override @Override
@ -102,13 +86,12 @@ public class FlightConfigurableParameterSet<E extends FlightConfigurableParamete
return map.values().iterator(); return map.values().iterator();
} }
/** /**
* Return the number of specific flight configurations other than the default. * Return the number of specific flight configurations other than the default.
* @return * @return
*/ */
public int size() { public int size() {
return map.size(); return (map.size()-1);
} }
/** /**
@ -119,7 +102,7 @@ public class FlightConfigurableParameterSet<E extends FlightConfigurableParamete
* @param value the parameter to find * @param value the parameter to find
* @return the flight configuration ID * @return the flight configuration ID
*/ */
public FlightConfigurationId get(E testValue) { public FlightConfigurationId getId(E testValue) {
if( null == testValue ){ if( null == testValue ){
return null; return null;
} }
@ -171,13 +154,13 @@ public class FlightConfigurableParameterSet<E extends FlightConfigurableParamete
} }
/** /**
*
* @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> getSortedConfigurationIDs(){
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 );
// Java 1.8: // Java 1.8:
//toReturn.sort( null ); //toReturn.sort( null );
@ -187,7 +170,7 @@ public class FlightConfigurableParameterSet<E extends FlightConfigurableParamete
return toReturn; return toReturn;
} }
public List<FlightConfigurationId> getIDs(){ public List<FlightConfigurationId> getIds(){
return this.getSortedConfigurationIDs(); return this.getSortedConfigurationIDs();
} }
@ -201,15 +184,12 @@ public class FlightConfigurableParameterSet<E extends FlightConfigurableParamete
public void set(FlightConfigurationId fcid, E nextValue) { public void set(FlightConfigurationId fcid, E nextValue) {
if ( nextValue == null) { if ( nextValue == null) {
// null value means to delete this fcid // null value means to delete this fcid
E previousValue = this.map.remove(fcid); this.map.remove(fcid);
removeListener(previousValue);
}else{ }else{
E previousValue = this.map.put(fcid, nextValue); this.map.put(fcid, nextValue);
removeListener(previousValue);
addListener(nextValue);
} }
fireEvent(); update();
} }
@ -241,7 +221,6 @@ public class FlightConfigurableParameterSet<E extends FlightConfigurableParamete
/* /*
* Clears all configuration-specific settings -- meaning querying the parameter for any configuration will return the default value. * Clears all configuration-specific settings -- meaning querying the parameter for any configuration will return the default value.
*
*/ */
public void reset() { public void reset() {
E tempValue = this.getDefault(); E tempValue = this.getDefault();
@ -249,60 +228,32 @@ public class FlightConfigurableParameterSet<E extends FlightConfigurableParamete
setDefault(tempValue); setDefault(tempValue);
} }
private void fireEvent() {
component.fireComponentChangeEvent(eventType);
}
public FlightConfigurationId cloneFlightConfiguration(FlightConfigurationId oldConfigId, FlightConfigurationId newConfigId) { public FlightConfigurationId cloneFlightConfiguration(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()); this.set(newConfigId, oldValue.clone());
fireEvent(); update();
return newConfigId; return newConfigId;
} }
private void addListener(E value) {
if (value != null) {
value.addChangeListener(listener);
}
}
private void removeListener(E value) {
if (value != null) {
value.removeChangeListener(listener);
}
}
private class Listener implements StateChangeListener {
@Override
public void stateChanged(EventObject e) {
fireEvent();
}
}
public String toDebug(){ public String toDebug(){
StringBuilder buf = new StringBuilder(); StringBuilder buf = new StringBuilder();
buf.append(String.format("====== Dumping ConfigurationSet for: '%s' of type: %s ======\n", this.component.getName(), this.component.getClass().getSimpleName() )); buf.append(String.format("====== Dumping ConfigurationSet<%s> (%d configurations)\n", this.getDefault().getClass().getSimpleName(), this.size() ));
buf.append(String.format(" >> ParameterSet<%s> (%d configurations)\n", this.defaultValue.getClass().getSimpleName(), this.size() )); final String fmt = " [%-12s]: %s\n";
buf.append(String.format(" >> [%s]= %s\n", "DEFAULT", this.getDefault().toString() ));
for( FlightConfigurationId loopFCID : this.getSortedConfigurationIDs()){ for( FlightConfigurationId loopFCID : this.getSortedConfigurationIDs()){
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)){
shortKey = "*"+shortKey+"*"; shortKey = "*"+shortKey+"*";
} }
buf.append(String.format(" >> [%s]= %s\n", shortKey, inst )); buf.append(String.format(fmt, shortKey, inst ));
} }
return buf.toString(); return buf.toString();
} }
public void update(){ public void update(){
this.defaultValue.update();
for( E curValue: this.map.values() ){ for( E curValue: this.map.values() ){
curValue.update(); curValue.update();
} }

View File

@ -1,26 +1,17 @@
package net.sf.openrocket.rocketcomponent; package net.sf.openrocket.rocketcomponent;
import java.util.EventObject;
import java.util.List;
import net.sf.openrocket.util.ArrayList;
import net.sf.openrocket.util.StateChangeListener;
public class IgnitionConfiguration implements FlightConfigurableParameter<IgnitionConfiguration> { public class IgnitionConfiguration implements FlightConfigurableParameter<IgnitionConfiguration> {
protected double ignitionDelay = 0.0; protected double ignitionDelay = 0.0;
protected IgnitionEvent ignitionEvent = IgnitionEvent.NEVER; protected IgnitionEvent ignitionEvent = IgnitionEvent.NEVER;
protected double ignitionTime = 0.0; protected double ignitionTime = 0.0;
private final List<StateChangeListener> listeners = new ArrayList<StateChangeListener>();
public double getIgnitionDelay() { public double getIgnitionDelay() {
return ignitionDelay; return ignitionDelay;
} }
public void setIgnitionDelay(double ignitionDelay) { public void setIgnitionDelay(double ignitionDelay) {
this.ignitionDelay = ignitionDelay; this.ignitionDelay = ignitionDelay;
fireChangeEvent();
} }
public IgnitionEvent getIgnitionEvent() { public IgnitionEvent getIgnitionEvent() {
@ -29,7 +20,6 @@ public class IgnitionConfiguration implements FlightConfigurableParameter<Igniti
public void setIgnitionEvent(IgnitionEvent ignitionEvent) { public void setIgnitionEvent(IgnitionEvent ignitionEvent) {
this.ignitionEvent = ignitionEvent; this.ignitionEvent = ignitionEvent;
fireChangeEvent();
} }
public double getIgnitionTime() { public double getIgnitionTime() {
@ -38,7 +28,6 @@ public class IgnitionConfiguration implements FlightConfigurableParameter<Igniti
public void setIgnitionTime(double ignitionTime) { public void setIgnitionTime(double ignitionTime) {
this.ignitionTime = ignitionTime; this.ignitionTime = ignitionTime;
fireChangeEvent();
} }
@Override @Override
@ -50,24 +39,6 @@ public class IgnitionConfiguration implements FlightConfigurableParameter<Igniti
return clone; return clone;
} }
@Override
public void addChangeListener(StateChangeListener listener) {
listeners.add(listener);
}
@Override
public void removeChangeListener(StateChangeListener listener) {
listeners.remove(listener);
}
private void fireChangeEvent() {
EventObject event = new EventObject(this);
Object[] list = listeners.toArray();
for (Object l : list) {
((StateChangeListener) l).stateChanged(event);
}
}
@Override @Override
public void update(){ public void update(){

View File

@ -28,7 +28,7 @@ public abstract class RecoveryDevice extends MassObject implements FlightConfigu
private FlightConfigurableParameterSet<DeploymentConfiguration> deploymentConfigurations; private FlightConfigurableParameterSet<DeploymentConfiguration> deploymentConfigurations;
public RecoveryDevice() { public RecoveryDevice() {
this.deploymentConfigurations = new FlightConfigurableParameterSet<DeploymentConfiguration>(this, ComponentChangeEvent.EVENT_CHANGE, new DeploymentConfiguration()); this.deploymentConfigurations = new FlightConfigurableParameterSet<DeploymentConfiguration>( new DeploymentConfiguration());
setMaterial(Application.getPreferences().getDefaultComponentMaterial(RecoveryDevice.class, Material.Type.SURFACE)); setMaterial(Application.getPreferences().getDefaultComponentMaterial(RecoveryDevice.class, Material.Type.SURFACE));
} }
@ -113,8 +113,7 @@ public abstract class RecoveryDevice extends MassObject implements FlightConfigu
@Override @Override
protected RocketComponent copyWithOriginalID() { protected RocketComponent copyWithOriginalID() {
RecoveryDevice copy = (RecoveryDevice) super.copyWithOriginalID(); RecoveryDevice copy = (RecoveryDevice) super.copyWithOriginalID();
copy.deploymentConfigurations = new FlightConfigurableParameterSet<DeploymentConfiguration>(deploymentConfigurations, copy.deploymentConfigurations = new FlightConfigurableParameterSet<DeploymentConfiguration>(deploymentConfigurations);
copy, ComponentChangeEvent.EVENT_CHANGE);
return copy; return copy;
} }
} }

View File

@ -85,7 +85,7 @@ public class Rocket extends RocketComponent {
functionalModID = modID; functionalModID = modID;
FlightConfiguration defaultConfiguration = new FlightConfiguration( this, null); FlightConfiguration defaultConfiguration = new FlightConfiguration( this, null);
this.configSet = new FlightConfigurableParameterSet<FlightConfiguration>(this, ComponentChangeEvent.CONFIG_CHANGE, defaultConfiguration); this.configSet = new FlightConfigurableParameterSet<FlightConfiguration>( defaultConfiguration);
} }
public String getDesigner() { public String getDesigner() {
@ -301,8 +301,7 @@ public class Rocket extends RocketComponent {
@Override @Override
public Rocket copyWithOriginalID() { public Rocket copyWithOriginalID() {
Rocket copy = (Rocket) super.copyWithOriginalID(); Rocket copy = (Rocket) super.copyWithOriginalID();
copy.configSet = new FlightConfigurableParameterSet<FlightConfiguration>( copy.configSet = new FlightConfigurableParameterSet<FlightConfiguration>( this.configSet);
this.configSet, copy, ComponentChangeEvent.CONFIG_CHANGE);
copy.resetListeners(); copy.resetListeners();
return copy; return copy;
@ -339,7 +338,7 @@ public class Rocket extends RocketComponent {
this.refType = r.refType; this.refType = r.refType;
this.customReferenceLength = r.customReferenceLength; this.customReferenceLength = r.customReferenceLength;
this.configSet = new FlightConfigurableParameterSet<FlightConfiguration>( r.configSet, this, ComponentChangeEvent.CONFIG_CHANGE); this.configSet = new FlightConfigurableParameterSet<FlightConfiguration>( r.configSet );
this.perfectFinish = r.perfectFinish; this.perfectFinish = r.perfectFinish;
this.checkComponentStructure(); this.checkComponentStructure();
@ -440,7 +439,7 @@ public class Rocket extends RocketComponent {
} }
// notify all configurations // notify all configurations
this.configSet.update(); this.update();
// Notify all listeners // Notify all listeners
// Copy the list before iterating to prevent concurrent modification exceptions. // Copy the list before iterating to prevent concurrent modification exceptions.
@ -650,10 +649,14 @@ public class Rocket extends RocketComponent {
* @return a FlightConfiguration instance * @return a FlightConfiguration instance
*/ */
public FlightConfiguration getFlightConfiguration(final int configIndex) { public FlightConfiguration getFlightConfiguration(final int configIndex) {
checkState();
return this.configSet.get(configIndex); return this.configSet.get(configIndex);
} }
public void setDefaultConfiguration(final FlightConfiguration config) {
checkState();
configSet.setDefault( config);
fireComponentChangeEvent(ComponentChangeEvent.NONFUNCTIONAL_CHANGE);
}
public void setDefaultConfiguration(final FlightConfigurationId fcid) { public void setDefaultConfiguration(final FlightConfigurationId fcid) {
checkState(); checkState();

View File

@ -313,7 +313,7 @@ public abstract class RocketComponent implements ChangeSource, Cloneable, Iterab
protected void componentChanged(ComponentChangeEvent e) { protected void componentChanged(ComponentChangeEvent e) {
// No-op // No-op
checkState(); checkState();
this.update(); update();
} }
@ -1090,6 +1090,13 @@ public abstract class RocketComponent implements ChangeSource, Cloneable, Iterab
this.setAxialOffset(this.relativePosition, this.offset); this.setAxialOffset(this.relativePosition, this.offset);
} }
public final void updateChildren(){
this.update();
for( RocketComponent rc : children ){
rc.updateChildren();
}
}
public Coordinate getOffset() { public Coordinate getOffset() {
return this.position; return this.position;
} }

View File

@ -146,14 +146,6 @@ public class StageSeparationConfiguration implements FlightConfigurableParameter
return clone; return clone;
} }
@Override
public void addChangeListener(StateChangeListener listener) {
}
@Override
public void removeChangeListener(StateChangeListener listener) {
}
private void fireChangeEvent() { private void fireChangeEvent() {

View File

@ -5,41 +5,240 @@ package net.sf.openrocket.rocketcomponent;
//import static org.junit.Assert.assertThat; //import static org.junit.Assert.assertThat;
//import static org.junit.Assert.assertTrue; //import static org.junit.Assert.assertTrue;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.not;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
import java.util.Collections;
import java.util.List;
import java.util.Map.Entry;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import net.sf.openrocket.util.MathUtil; import net.sf.openrocket.util.ArrayList;
import net.sf.openrocket.util.StateChangeListener;
import net.sf.openrocket.util.BaseTestCase.BaseTestCase; import net.sf.openrocket.util.BaseTestCase.BaseTestCase;
public class ParameterSetTest extends BaseTestCase { public class ParameterSetTest extends BaseTestCase {
private final static double EPSILON = MathUtil.EPSILON*1E3;
private class Parameter implements FlightConfigurableParameter<Parameter> { static int gid=0;
FlightConfigurableParameterSet<TestParameter> testSet = null;
public Parameter(){} private class TestParameter implements FlightConfigurableParameter<TestParameter> {
public final int id;
@Override public TestParameter(){
public Parameter clone(){ return null; } id = gid++;
}
@Override @Override
public void update(){} public void update(){}
@Override @Override
public void addChangeListener(StateChangeListener listener){} public boolean equals( Object other ){
if( other instanceof TestParameter){
return (this.id == ((TestParameter)other).id);
}
return false;
}
@Override @Override
public void removeChangeListener(StateChangeListener listener){} public int hashCode(){
return this.id;
}
@Override
public String toString(){
return "tp#:"+id;
}
@Override
public TestParameter clone(){
return new TestParameter();
}
}; };
@Before
public void localSetUp() {
gid=0;
TestParameter defaultParam = new TestParameter();
testSet = new FlightConfigurableParameterSet<TestParameter>( defaultParam );
}
// ================ Actual Tests ================
@Test
public void testEmptySet() {
assertThat("set should contain zero overrides: ", testSet.size(), equalTo( 0 ));
TestParameter dtp = new TestParameter();
testSet.setDefault( dtp);
assertThat("set should contain zero overrides: ", testSet.size(), equalTo( 0 ));
assertThat("set stores default value correctly: ", testSet.getDefault(), equalTo( dtp ));
}
@Test
public void testRetrieveDefault(){
FlightConfigurationId fcid2 = new FlightConfigurationId();
// i.e. requesting the value for a non-existent config id should return the default
assertThat("set stores id-value pair correctly : ", testSet.get(fcid2), equalTo( testSet.getDefault() ));
assertThat("set contains wrong number of overrides: ", testSet.size(), equalTo( 0 ));
FlightConfigurationId fcid_def = FlightConfigurationId.DEFAULT_VALUE_FCID;
assertThat("retrieving the via the special default key should produce the default value: ", testSet.get(fcid_def), equalTo( testSet.getDefault() ));
assertThat("set should still contain zero overrides: ", testSet.size(), equalTo( 0 ));
}
@Test
public void testSetGetSecond(){
assertThat("set should contain zero overrides: ", testSet.size(), equalTo( 0 ));
TestParameter tp2 = new TestParameter();
FlightConfigurationId fcid2 = new FlightConfigurationId();
testSet.set(fcid2, tp2);
// fcid <=> tp2 should be stored....
assertThat("set stores default value correctly: ", testSet.get(fcid2), equalTo( tp2 ));
assertThat("set should contain zero overrides: ", testSet.size(), equalTo( 1 ));
}
@Test(expected=IndexOutOfBoundsException.class)
public void testGetByNegativeIndex() {
assertThat("set should contain zero overrides: ", testSet.size(), equalTo( 0 ));
//assertThat
testSet.get(-1);
}
@Test(expected=IndexOutOfBoundsException.class)
public void testGetByTooHighIndex() {
assertThat("set should contain zero overrides: ", testSet.size(), equalTo( 0 ));
TestParameter tp2 = new TestParameter();
FlightConfigurationId fcid2 = new FlightConfigurationId();
testSet.set(fcid2, tp2);
assertThat("set should contain one override: ", testSet.size(), equalTo( 1 ));
//assertThat
testSet.get(1); // this should be off-by-one (too high)
}
@Test
public void testGetIdsLength(){
assertThat("set should contain zero overrides: ", testSet.size(), equalTo( 0 ));
TestParameter tp2 = new TestParameter();
FlightConfigurationId fcid2 = new FlightConfigurationId();
testSet.set(fcid2, tp2);
TestParameter tp3 = new TestParameter();
FlightConfigurationId fcid3 = new FlightConfigurationId();
testSet.set(fcid3, tp3);
assertThat("set should contain two overrides: ", testSet.size(), equalTo( 2 ));
// testSet.getSortedConfigurationIDs()
// >> 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.getSortedConfigurationIDs().size(), equalTo( testSet.getIds().size() ) );
}
@Test
public void testGetByIndex(){
assertThat("set should contain zero overrides: ", testSet.size(), equalTo( 0 ));
TestParameter tp1 = new TestParameter();
FlightConfigurationId fcid1 = new FlightConfigurationId();
testSet.set(fcid1, tp1);
TestParameter tp2 = new TestParameter();
FlightConfigurationId fcid2 = new FlightConfigurationId();
testSet.set(fcid2, tp2);
TestParameter tp3 = new TestParameter();
FlightConfigurationId fcid3 = new FlightConfigurationId();
testSet.set(fcid3, tp3);
TestParameter tp4 = new TestParameter();
FlightConfigurationId fcid4 = new FlightConfigurationId();
testSet.set(fcid4, tp4);
assertThat("set should contain two overrides: ", testSet.size(), equalTo( 4 ));
ArrayList<FlightConfigurationId> refList = new ArrayList<FlightConfigurationId>();
refList.add(fcid1);
refList.add(fcid2);
refList.add(fcid3);
refList.add(fcid4);
Collections.sort(refList); // Java 1.7:
//assertThat
assertThat("retrieve-by-index broken!\n"+testSet.toDebug(), testSet.get(0), equalTo( testSet.get( refList.get(0))));
assertThat("retrieve-by-index broken!\n"+testSet.toDebug(), testSet.get(1), equalTo( testSet.get( refList.get(1))));
assertThat("retrieve-by-index broken!\n"+testSet.toDebug(), testSet.get(2), equalTo( testSet.get( refList.get(2))));
assertThat("retrieve-by-index broken!\n"+testSet.toDebug(), testSet.get(3), equalTo( testSet.get( refList.get(3))));
}
@Test @Test
public void testEmptyRocket() { public void testRemoveSecond(){
//FlightConfigurableParameterSet<Parameter> testSet = new FlightConfigurableParameterSet<Parameter>(); assertThat("set should contain zero overrides: ", testSet.size(), equalTo( 0 ));
TestParameter tp2 = new TestParameter();
FlightConfigurationId fcid2 = new FlightConfigurationId();
testSet.set(fcid2, tp2);
// fcid <=> tp2 should be stored....
assertThat("set stores default value correctly: ", testSet.get(fcid2), equalTo( tp2 ));
assertThat("set should contain one override: ", testSet.size(), equalTo( 1 ));
testSet.set(fcid2, null);
// fcid <=> tp2 should be stored....
assertThat("set stores default value correctly: ", testSet.get(fcid2), equalTo( testSet.getDefault() ));
assertThat("set should contain zero overrides: ", testSet.size(), equalTo( 0 ));
}
@Test
public void testGetByValue(){
assertThat("set should contain zero overrides: ", testSet.size(), equalTo( 0 ));
assertThat("retrieving the default value should produce the special default key: ",
testSet.getId(testSet.getDefault()), equalTo( FlightConfigurationId.DEFAULT_VALUE_FCID));
TestParameter tp2 = new TestParameter();
FlightConfigurationId fcid2 = new FlightConfigurationId();
testSet.set(fcid2, tp2);
// fcid <=> tp2 should be stored....
assertThat("set should contain one override: ", testSet.size(), equalTo( 1 ));
assertThat("set stores default value correctly: ", testSet.get(fcid2), equalTo( tp2 ));
// now retrieve that same parameter by value
FlightConfigurationId fcid3 = testSet.getId(tp2);
assertThat("set should contain one override: ", testSet.size(), equalTo( 1 ));
assertThat("set stores default value correctly: ", fcid2, equalTo( fcid3 ));
assertThat("set stores default value correctly: ", testSet.get( fcid3), equalTo( tp2 ));
}
@Test
public void testCloneSecond(){
assertThat("set should contain zero overrides: ", testSet.size(), equalTo( 0 ));
TestParameter tp2 = new TestParameter();
FlightConfigurationId fcid2 = new FlightConfigurationId();
testSet.set(fcid2, tp2);
// fcid <=> tp2 should be stored....
assertThat("set should contain zero overrides: ", testSet.size(), equalTo( 1 ));
assertThat("set stores default value correctly: ", testSet.get(fcid2), equalTo( tp2 ));
FlightConfigurationId fcid3 = new FlightConfigurationId();
testSet.cloneFlightConfiguration(fcid2, fcid3);
// fcid <=> tp2 should be stored....
assertThat("set should contain zero overrides: ", testSet.size(), equalTo( 2 ));
assertThat("set stores default value correctly: ", testSet.get(fcid3), not( testSet.getDefault() ));
} }

View File

@ -96,7 +96,7 @@ public abstract class Column {
* *
* @return * @return
*/ */
public Comparator getComparator() { public Comparator<?> getComparator() {
return null; return null;
} }

View File

@ -548,7 +548,7 @@ public class DoubleModel implements StateChangeListener, ChangeSource, Invalidat
* The main model handles all values in SI units, i.e. no conversion is made within the model. * The main model handles all values in SI units, i.e. no conversion is made within the model.
*/ */
private final ChangeSource source; private final Object source;
private final String valueName; private final String valueName;
private final double multiplier; private final double multiplier;
@ -643,7 +643,7 @@ public class DoubleModel implements StateChangeListener, ChangeSource, Invalidat
* @param min Minimum value allowed (in SI units) * @param min Minimum value allowed (in SI units)
* @param max Maximum value allowed (in SI units) * @param max Maximum value allowed (in SI units)
*/ */
public DoubleModel(ChangeSource source, String valueName, double multiplier, UnitGroup unit, public DoubleModel(Object source, String valueName, double multiplier, UnitGroup unit,
double min, double max) { double min, double max) {
this.source = source; this.source = source;
this.valueName = valueName; this.valueName = valueName;
@ -689,43 +689,42 @@ public class DoubleModel implements StateChangeListener, ChangeSource, Invalidat
} }
public DoubleModel(ChangeSource source, String valueName, double multiplier, UnitGroup unit, public DoubleModel(Object source, String valueName, double multiplier, UnitGroup unit,
double min) { double min) {
this(source, valueName, multiplier, unit, min, Double.POSITIVE_INFINITY); this(source, valueName, multiplier, unit, min, Double.POSITIVE_INFINITY);
} }
public DoubleModel(ChangeSource source, String valueName, double multiplier, UnitGroup unit) { public DoubleModel(Object source, String valueName, double multiplier, UnitGroup unit) {
this(source, valueName, multiplier, unit, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY); this(source, valueName, multiplier, unit, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY);
} }
public DoubleModel(ChangeSource source, String valueName, UnitGroup unit, public DoubleModel(Object source, String valueName, UnitGroup unit,
double min, double max) { double min, double max) {
this(source, valueName, 1.0, unit, min, max); this(source, valueName, 1.0, unit, min, max);
} }
public DoubleModel(ChangeSource source, String valueName, UnitGroup unit, double min) { public DoubleModel(Object source, String valueName, UnitGroup unit, double min) {
this(source, valueName, 1.0, unit, min, Double.POSITIVE_INFINITY); this(source, valueName, 1.0, unit, min, Double.POSITIVE_INFINITY);
} }
public DoubleModel(ChangeSource source, String valueName, UnitGroup unit) { public DoubleModel(Object source, String valueName, UnitGroup unit) {
this(source, valueName, 1.0, unit, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY); this(source, valueName, 1.0, unit, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY);
} }
public DoubleModel(ChangeSource source, String valueName) { public DoubleModel(Object source, String valueName) {
this(source, valueName, 1.0, UnitGroup.UNITS_NONE, this(source, valueName, 1.0, UnitGroup.UNITS_NONE,
Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY); Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY);
} }
public DoubleModel(ChangeSource source, String valueName, double min) { public DoubleModel(Object source, String valueName, double min) {
this(source, valueName, 1.0, UnitGroup.UNITS_NONE, min, Double.POSITIVE_INFINITY); this(source, valueName, 1.0, UnitGroup.UNITS_NONE, min, Double.POSITIVE_INFINITY);
} }
public DoubleModel(ChangeSource source, String valueName, double min, double max) { public DoubleModel(Object source, String valueName, double min, double max) {
this(source, valueName, 1.0, UnitGroup.UNITS_NONE, min, max); this(source, valueName, 1.0, UnitGroup.UNITS_NONE, min, max);
} }
/** /**
* Returns the value of the variable (in SI units). * Returns the value of the variable (in SI units).
*/ */
@ -880,7 +879,6 @@ public class DoubleModel implements StateChangeListener, ChangeSource, Invalidat
if (listeners.isEmpty()) { if (listeners.isEmpty()) {
if (source != null) { if (source != null) {
source.addChangeListener(this);
lastValue = getValue(); lastValue = getValue();
lastAutomatic = isAutomatic(); lastAutomatic = isAutomatic();
} }
@ -909,9 +907,6 @@ public class DoubleModel implements StateChangeListener, ChangeSource, Invalidat
checkState(false); checkState(false);
listeners.remove(l); listeners.remove(l);
if (listeners.isEmpty() && source != null) {
source.removeChangeListener(this);
}
log.trace(this + " removing listener (total " + listeners.size() + "): " + l); log.trace(this + " removing listener (total " + listeners.size() + "): " + l);
} }
@ -930,9 +925,6 @@ public class DoubleModel implements StateChangeListener, ChangeSource, Invalidat
log.warn("Invalidating " + this + " while still having listeners " + listeners); log.warn("Invalidating " + this + " while still having listeners " + listeners);
} }
listeners.clear(); listeners.clear();
if (source != null) {
source.removeChangeListener(this);
}
MemoryManagement.collectable(this); MemoryManagement.collectable(this);
} }

View File

@ -7,38 +7,37 @@ import javax.swing.AbstractListModel;
import javax.swing.ComboBoxModel; import javax.swing.ComboBoxModel;
import javax.swing.MutableComboBoxModel; import javax.swing.MutableComboBoxModel;
import net.sf.openrocket.util.ChangeSource;
import net.sf.openrocket.util.Reflection; import net.sf.openrocket.util.Reflection;
import net.sf.openrocket.util.StateChangeListener; import net.sf.openrocket.util.StateChangeListener;
public class EnumModel<T extends Enum<T>> extends AbstractListModel public class EnumModel<T extends Enum<T>> extends AbstractListModel<T>
implements ComboBoxModel, MutableComboBoxModel, StateChangeListener { implements ComboBoxModel<T>, MutableComboBoxModel<T>, StateChangeListener {
private static final long serialVersionUID = 7766446027840316797L;
private final ChangeSource source; private final Object source;
private final String valueName; private final String valueName;
private final String nullText; private final String nullText;
private final Enum<T>[] values; private final T[] values;
private Enum<T> currentValue = null; private T currentValue = null;
ArrayList<Enum<T>> displayedValues = new ArrayList<Enum<T>>(); ArrayList<T> displayedValues = new ArrayList<T>();
private final Reflection.Method getMethod; private final Reflection.Method getMethod;
private final Reflection.Method setMethod; private final Reflection.Method setMethod;
public EnumModel(ChangeSource source, String valueName) { public EnumModel(Object source, String valueName) {
this(source,valueName,null,null); this(source,valueName,null,null);
} }
public EnumModel(ChangeSource source, String valueName, Enum<T>[] values) { public EnumModel(Object source, String valueName, T[] values) {
this(source, valueName, values, null); this(source, valueName, values, null);
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public EnumModel(ChangeSource source, String valueName, Enum<T>[] values, String nullText) { public EnumModel(Object source, String valueName, T[] values, String nullText) {
Class<? extends Enum<T>> enumClass; Class<? extends Enum<T>> enumClass;
this.source = source; this.source = source;
this.valueName = valueName; this.valueName = valueName;
@ -62,15 +61,14 @@ public class EnumModel<T extends Enum<T>> extends AbstractListModel
if (values != null) if (values != null)
this.values = values; this.values = values;
else else
this.values = enumClass.getEnumConstants(); this.values = (T[]) enumClass.getEnumConstants();
for (Enum<T> e : this.values){ for (T e : this.values){
this.displayedValues.add( e ); this.displayedValues.add( e );
} }
this.nullText = nullText; this.nullText = nullText;
stateChanged(null); // Update current value stateChanged(null); // Update current value
source.addChangeListener(this);
} }
@ -82,7 +80,7 @@ public class EnumModel<T extends Enum<T>> extends AbstractListModel
return currentValue; return currentValue;
} }
@SuppressWarnings("unchecked")
@Override @Override
public void setSelectedItem(Object item) { public void setSelectedItem(Object item) {
if (item == null) { if (item == null) {
@ -102,19 +100,19 @@ public class EnumModel<T extends Enum<T>> extends AbstractListModel
// Comparison with == ok, since both are enums // Comparison with == ok, since both are enums
if (currentValue == item) if (currentValue == item)
return; return;
// @SuppressWarnings("unchecked")
this.currentValue = (Enum<T>) item; this.currentValue = (T) item;
setMethod.invoke(source, item); setMethod.invoke(source, item);
} }
@Override @Override
public Object getElementAt(int index) { public T getElementAt(int index) {
if( ( index < 0 ) || ( index >= this.displayedValues.size())){ if( ( index < 0 ) || ( index >= this.displayedValues.size())){
return nullText; // bad parameter return null; // bad parameter
} }
if (values[index] == null) if (values[index] == null)
return nullText; return null;
return displayedValues.get( index); return displayedValues.get( index);
} }
@ -126,7 +124,7 @@ public class EnumModel<T extends Enum<T>> extends AbstractListModel
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public void stateChanged(EventObject e) { public void stateChanged(EventObject e) {
Enum<T> value = (Enum<T>) getMethod.invoke(source); T value = (T) getMethod.invoke(source);
if (value != currentValue) { if (value != currentValue) {
currentValue = value; currentValue = value;
this.fireContentsChanged(this, 0, values.length); this.fireContentsChanged(this, 0, values.length);
@ -139,7 +137,7 @@ public class EnumModel<T extends Enum<T>> extends AbstractListModel
} }
@Override @Override
public void addElement(Object item) { public void addElement(T item) {
// Not actually allowed. The model starts out with all the enums, and only allows hiding some. // Not actually allowed. The model starts out with all the enums, and only allows hiding some.
} }
@ -152,7 +150,7 @@ public class EnumModel<T extends Enum<T>> extends AbstractListModel
} }
@Override @Override
public void insertElementAt(Object item, int index) { public void insertElementAt(T item, int index) {
// Not actually allowed. The model starts out with all the enums, and only allows hiding some. // Not actually allowed. The model starts out with all the enums, and only allows hiding some.
} }

View File

@ -51,6 +51,7 @@ import net.sf.openrocket.util.StateChangeListener;
public class InnerTubeConfig extends RocketComponentConfig { public class InnerTubeConfig extends RocketComponentConfig {
private static final long serialVersionUID = 7900041420864324470L;
private static final Translator trans = Application.getTranslator(); private static final Translator trans = Application.getTranslator();
@ -95,11 +96,7 @@ public class InnerTubeConfig extends RocketComponentConfig {
panel.add(spin, "growx"); panel.add(spin, "growx");
panel.add(new UnitSelector(m), "growx"); panel.add(new UnitSelector(m), "growx");
if (od == null) panel.add(new BasicSlider(m.getSliderModel(new DoubleModel(0), od)), "w 100lp, wrap");
panel.add(new BasicSlider(m.getSliderModel(0, 0.04, 0.2)), "w 100lp, wrap");
else
panel.add(new BasicSlider(m.getSliderModel(new DoubleModel(0), od)),
"w 100lp, wrap");
if (m.isAutomaticAvailable()) { if (m.isAutomaticAvailable()) {
JCheckBox check = new JCheckBox(m.getAutomaticAction()); JCheckBox check = new JCheckBox(m.getAutomaticAction());
@ -142,7 +139,7 @@ public class InnerTubeConfig extends RocketComponentConfig {
//// Position relative to: //// Position relative to:
panel.add(new JLabel(trans.get("ringcompcfg.Positionrelativeto"))); panel.add(new JLabel(trans.get("ringcompcfg.Positionrelativeto")));
JComboBox combo = new JComboBox( JComboBox<?> combo = new JComboBox<RocketComponent.Position>(
new EnumModel<RocketComponent.Position>(component, "RelativePosition", new EnumModel<RocketComponent.Position>(component, "RelativePosition",
new RocketComponent.Position[] { new RocketComponent.Position[] {
RocketComponent.Position.TOP, RocketComponent.Position.TOP,
@ -389,6 +386,10 @@ public class InnerTubeConfig extends RocketComponentConfig {
class ClusterSelectionPanel extends JPanel { class ClusterSelectionPanel extends JPanel {
/**
*
*/
private static final long serialVersionUID = 1804786106133398810L;
private static final int BUTTON_SIZE = 50; private static final int BUTTON_SIZE = 50;
private static final int MOTOR_DIAMETER = 10; private static final int MOTOR_DIAMETER = 10;
@ -417,6 +418,10 @@ class ClusterSelectionPanel extends JPanel {
private class ClusterButton extends JPanel implements StateChangeListener, MouseListener, private class ClusterButton extends JPanel implements StateChangeListener, MouseListener,
Resettable { Resettable {
/**
*
*/
private static final long serialVersionUID = 3626386642481889629L;
private Clusterable component; private Clusterable component;
private ClusterConfiguration config; private ClusterConfiguration config;

View File

@ -138,7 +138,7 @@ public class ParachuteConfig extends RecoveryDeviceConfig {
//// Position relative to: //// Position relative to:
panel.add(new JLabel(trans.get("ParachuteCfg.lbl.Posrelativeto"))); panel.add(new JLabel(trans.get("ParachuteCfg.lbl.Posrelativeto")));
combo = new JComboBox( combo = new JComboBox<RocketComponent.Position>(
new EnumModel<RocketComponent.Position>(component, "RelativePosition", new EnumModel<RocketComponent.Position>(component, "RelativePosition",
new RocketComponent.Position[] { new RocketComponent.Position[] {
RocketComponent.Position.TOP, RocketComponent.Position.TOP,