From: kruland2607 Date: Wed, 16 May 2012 06:17:22 +0000 (+0000) Subject: Added protected copy constructor which makes a deep copy. This is used in the androi... X-Git-Tag: upstream/12.09^2~262 X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=108da63bf2f6e88de0f48976a7bc7af4f5183cc2;p=debian%2Fopenrocket Added protected copy constructor which makes a deep copy. This is used in the android application so ExtendedThrustCurveMotor can extend ThrustCurveMotor instead of use delegation. git-svn-id: https://openrocket.svn.sourceforge.net/svnroot/openrocket/trunk@686 180e2498-e6e9-4542-8430-84ac67f01cd8 --- diff --git a/core/src/net/sf/openrocket/motor/ThrustCurveMotor.java b/core/src/net/sf/openrocket/motor/ThrustCurveMotor.java index e1ba1d77..8467c0a3 100644 --- a/core/src/net/sf/openrocket/motor/ThrustCurveMotor.java +++ b/core/src/net/sf/openrocket/motor/ThrustCurveMotor.java @@ -43,6 +43,31 @@ public class ThrustCurveMotor implements Motor, Comparable { private double averageThrust; private double totalImpulse; + /** + * Deep copy constructor. + * Constructs a new ThrustCurveMotor from an existing ThrustCurveMotor. + * @param m + */ + protected ThrustCurveMotor( ThrustCurveMotor m ) { + this.digest = m.digest; + this.manufacturer = m.manufacturer; + this.designation = m.designation; + this.description = m.description; + this.type = m.type; + this.delays = Arrays.copyOf(m.delays, m.delays.length); + this.diameter = m.diameter; + this.length = m.length; + this.time = Arrays.copyOf(m.time, m.time.length); + this.thrust = Arrays.copyOf(m.thrust, m.thrust.length); + this.cg = new Coordinate[ m.cg.length ]; + for( int i = 0; i< cg.length; i++ ) { + this.cg[i] = m.cg[i].clone(); + } + this.maxThrust = m.maxThrust; + this.burnTime = m.burnTime; + this.averageThrust = m.averageThrust; + this.totalImpulse = m.totalImpulse; + } /** * Sole constructor. Sets all the properties of the motor.