Removed code duplication. Fixed bug in setTransform(t).

This commit is contained in:
Michael Bayne
2011-07-01 15:59:52 -07:00
parent ff27ebcb6a
commit ab28f8390e
2 changed files with 10 additions and 37 deletions
@@ -29,30 +29,16 @@ public class AffineTransform implements Cloneable, Serializable
public static final int TYPE_MASK_ROTATION = TYPE_QUADRANT_ROTATION | TYPE_GENERAL_ROTATION; public static final int TYPE_MASK_ROTATION = TYPE_QUADRANT_ROTATION | TYPE_GENERAL_ROTATION;
public AffineTransform () { public AffineTransform () {
this.type = TYPE_IDENTITY; setToIdentity();
this.m00 = this.m11 = 1f;
this.m10 = this.m01 = this.m02 = this.m12 = 0;
} }
public AffineTransform (AffineTransform t) { public AffineTransform (AffineTransform t) {
this.type = t.type; setTransform(t);
this.m00 = t.m00;
this.m10 = t.m10;
this.m01 = t.m01;
this.m11 = t.m11;
this.m02 = t.m02;
this.m12 = t.m12;
} }
public AffineTransform (double m00, double m10, double m01, public AffineTransform (double m00, double m10, double m01,
double m11, double m02, double m12) { double m11, double m02, double m12) {
this.type = TYPE_UNKNOWN; setTransform(m00, m10, m01, m11, m02, m12);
this.m00 = m00;
this.m10 = m10;
this.m01 = m01;
this.m11 = m11;
this.m02 = m02;
this.m12 = m12;
} }
public AffineTransform (double[] matrix) { public AffineTransform (double[] matrix) {
@@ -166,7 +152,8 @@ public class AffineTransform implements Cloneable, Serializable
return m00 * m11 - m01 * m10; return m00 * m11 - m01 * m10;
} }
public void setTransform (double m00, double m10, double m01, double m11, double m02, double m12) { public void setTransform (double m00, double m10, double m01, double m11,
double m02, double m12) {
this.type = TYPE_UNKNOWN; this.type = TYPE_UNKNOWN;
this.m00 = m00; this.m00 = m00;
this.m10 = m10; this.m10 = m10;
@@ -177,8 +164,8 @@ public class AffineTransform implements Cloneable, Serializable
} }
public void setTransform (AffineTransform t) { public void setTransform (AffineTransform t) {
type = t.type;
setTransform(t.m00, t.m10, t.m01, t.m11, t.m02, t.m12); setTransform(t.m00, t.m10, t.m01, t.m11, t.m02, t.m12);
type = t.type;
} }
public void setToIdentity () { public void setToIdentity () {
@@ -29,29 +29,15 @@ public class AffineTransform implements Cloneable, Serializable
public static final int TYPE_MASK_ROTATION = TYPE_QUADRANT_ROTATION | TYPE_GENERAL_ROTATION; public static final int TYPE_MASK_ROTATION = TYPE_QUADRANT_ROTATION | TYPE_GENERAL_ROTATION;
public AffineTransform () { public AffineTransform () {
this.type = TYPE_IDENTITY; setToIdentity();
this.m00 = this.m11 = 1f;
this.m10 = this.m01 = this.m02 = this.m12 = 0;
} }
public AffineTransform (AffineTransform t) { public AffineTransform (AffineTransform t) {
this.type = t.type; setTransform(t);
this.m00 = t.m00;
this.m10 = t.m10;
this.m01 = t.m01;
this.m11 = t.m11;
this.m02 = t.m02;
this.m12 = t.m12;
} }
public AffineTransform (float m00, float m10, float m01, float m11, float m02, float m12) { public AffineTransform (float m00, float m10, float m01, float m11, float m02, float m12) {
this.type = TYPE_UNKNOWN; setTransform(m00, m10, m01, m11, m02, m12);
this.m00 = m00;
this.m10 = m10;
this.m01 = m01;
this.m11 = m11;
this.m02 = m02;
this.m12 = m12;
} }
public AffineTransform (float[] matrix) { public AffineTransform (float[] matrix) {
@@ -176,8 +162,8 @@ public class AffineTransform implements Cloneable, Serializable
} }
public void setTransform (AffineTransform t) { public void setTransform (AffineTransform t) {
type = t.type;
setTransform(t.m00, t.m10, t.m01, t.m11, t.m02, t.m12); setTransform(t.m00, t.m10, t.m01, t.m11, t.m02, t.m12);
type = t.type;
} }
public void setToIdentity () { public void setToIdentity () {