Implement simulation & flightdata(branch) cloning
This commit is contained in:
parent
0e1cd01377
commit
3eb513c78f
@ -524,6 +524,37 @@ public class Simulation implements ChangeSource, Cloneable {
|
||||
}
|
||||
}
|
||||
|
||||
public Simulation clone() {
|
||||
mutex.lock("clone");
|
||||
try {
|
||||
Simulation clone = (Simulation) super.clone();
|
||||
|
||||
clone.mutex = SafetyMutex.newInstance();
|
||||
clone.status = status;
|
||||
clone.options = this.options.clone();
|
||||
clone.simulationExtensions = new ArrayList<>();
|
||||
for (SimulationExtension c : this.simulationExtensions) {
|
||||
clone.simulationExtensions.add(c.clone());
|
||||
}
|
||||
clone.listeners = new ArrayList<>();
|
||||
if (simulatedConditions != null) {
|
||||
clone.simulatedConditions = simulatedConditions.clone();
|
||||
} else {
|
||||
clone.simulatedConditions = null;
|
||||
}
|
||||
clone.simulatedConfigurationDescription = simulatedConfigurationDescription;
|
||||
clone.simulatedData = simulatedData.clone();
|
||||
clone.simulatedConfigurationID = simulatedConfigurationID;
|
||||
|
||||
return clone;
|
||||
|
||||
} catch (CloneNotSupportedException e) {
|
||||
throw new BugException("Clone not supported, BUG", e);
|
||||
} finally {
|
||||
mutex.unlock("clone");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a duplicate of this simulation with the specified rocket. The new
|
||||
|
@ -273,7 +273,23 @@ public class FlightData {
|
||||
return mutable.isMutable();
|
||||
}
|
||||
|
||||
|
||||
public FlightData clone() {
|
||||
FlightData clone = new FlightData();
|
||||
clone.warnings.addAll(warnings);
|
||||
for (FlightDataBranch b : branches) {
|
||||
clone.branches.add(b.clone());
|
||||
}
|
||||
clone.maxAltitude = maxAltitude;
|
||||
clone.maxVelocity = maxVelocity;
|
||||
clone.maxAcceleration = maxAcceleration;
|
||||
clone.maxMachNumber = maxMachNumber;
|
||||
clone.timeToApogee = timeToApogee;
|
||||
clone.flightTime = flightTime;
|
||||
clone.groundHitVelocity = groundHitVelocity;
|
||||
clone.launchRodVelocity = launchRodVelocity;
|
||||
clone.deploymentVelocity = deploymentVelocity;
|
||||
return clone;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the maximum acceleration before apogee.
|
||||
|
@ -364,4 +364,19 @@ public class FlightDataBranch implements Monitorable {
|
||||
return modID;
|
||||
}
|
||||
|
||||
public FlightDataBranch clone() {
|
||||
FlightDataType[] types = getTypes();
|
||||
FlightDataBranch clone = new FlightDataBranch(branchName, types);
|
||||
for (FlightDataType type : values.keySet()) {
|
||||
clone.values.put(type, values.get(type).clone());
|
||||
}
|
||||
clone.minValues.putAll(minValues);
|
||||
clone.maxValues.putAll(maxValues);
|
||||
clone.events.addAll(events);
|
||||
clone.timeToOptimumAltitude = timeToOptimumAltitude;
|
||||
clone.optimumAltitude = optimumAltitude;
|
||||
clone.modID = modID;
|
||||
return clone;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user