I like it better when the close button copies the SimulationOptions.

Only SimulationOptions needs to be a little bit smarter about when to
fire the change event.
This commit is contained in:
kruland2607 2013-06-05 21:20:50 -05:00
parent 4cfc65fbe2
commit 7d30bcb67b
2 changed files with 66 additions and 19 deletions

View File

@ -213,6 +213,7 @@ public class SimulationEditDialog extends JDialog {
close.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
copyChangesToAllSims();
SimulationEditDialog.this.dispose();
}
});

View File

@ -452,25 +452,71 @@ public class SimulationOptions implements ChangeSource, Cloneable {
fireChangeEvent();
}
public void copyConditionsFrom(SimulationOptions src) {
this.launchAltitude = src.launchAltitude;
this.launchLatitude = src.launchLatitude;
this.launchLongitude = src.launchLongitude;
this.launchPressure = src.launchPressure;
this.launchRodAngle = src.launchRodAngle;
this.launchRodDirection = src.launchRodDirection;
this.launchRodLength = src.launchRodLength;
this.launchTemperature = src.launchTemperature;
this.maximumAngle = src.maximumAngle;
this.timeStep = src.timeStep;
this.windAverage = src.windAverage;
this.windTurbulence = src.windTurbulence;
this.calculateExtras = src.calculateExtras;
this.randomSeed = src.randomSeed;
fireChangeEvent();
}
public void copyConditionsFrom(SimulationOptions src) {
// Be a little smart about triggering the change event.
// only do it if one of the "important" (user specified) parameters has really changed.
boolean isChanged = false;
if (this.launchAltitude != src.launchAltitude) {
isChanged = true;
this.launchAltitude = src.launchAltitude;
}
if (this.launchLatitude != src.launchLatitude) {
isChanged = true;
this.launchLatitude = src.launchLatitude;
}
if (this.launchLongitude != src.launchLongitude) {
isChanged = true;
this.launchLongitude = src.launchLongitude;
}
if (this.launchPressure != src.launchPressure) {
isChanged = true;
this.launchPressure = src.launchPressure;
}
if (this.launchRodAngle != src.launchRodAngle) {
isChanged = true;
this.launchRodAngle = src.launchRodAngle;
}
if (this.launchRodDirection != src.launchRodDirection) {
isChanged = true;
this.launchRodDirection = src.launchRodDirection;
}
if (this.launchRodLength != src.launchRodLength) {
isChanged = true;
this.launchRodLength = src.launchRodLength;
}
if (this.launchTemperature != src.launchTemperature) {
isChanged = true;
this.launchTemperature = src.launchTemperature;
}
if (this.maximumAngle != src.maximumAngle) {
isChanged = true;
this.maximumAngle = src.maximumAngle;
}
this.maximumAngle = src.maximumAngle;
if (this.timeStep != src.timeStep) {
isChanged = true;
this.timeStep = src.timeStep;
}
if (this.windAverage != src.windAverage) {
isChanged = true;
this.windAverage = src.windAverage;
}
if (this.windTurbulence != src.windTurbulence) {
isChanged = true;
this.windTurbulence = src.windTurbulence;
}
if (this.calculateExtras != src.calculateExtras) {
isChanged = true;
this.calculateExtras = src.calculateExtras;
}
if (isChanged) {
// Only copy the randomSeed if something else has changed.
// Honestly, I don't really see a need for that.
this.randomSeed = src.randomSeed;
fireChangeEvent();
}
}
/**