1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
|
//
// Description:
// SWFMatrix Class
//
// Authors:
// Jonathan Shore <jshore@e-shuppan.com>
//
// Copyright:
// Copyright 2001 E-Publishing Group Inc. Permission is granted to use or
// modify this code provided that the original copyright notice is included.
//
// This software is distributed with no warranty of liability, merchantability,
// or fitness for any specific purpose.
//
import SWFMovieClip;
import SWFMovie;
//
// SWFMatrix Interface
// a rotation, translation matrix
//
// Notes
// -
//
public class SWFMatrix {
public SWFMatrix ()
{
this.rot = 0f;
this.dx = 0f;
this.dy = 0f;
this.xscale = 1.0f;
this.yscale = 1.0f;
this.xskew = 0.0f;
this.yskew = 0.0f;
this.applied = false;
}
// accessors
public float getRotation ()
{ return rot; }
public void setRotation (float deg)
{ rot = deg; }
public float getDx ()
{ return dx; }
public void setDx (float dx)
{ this.dx = dx; }
public float getDy ()
{ return dy; }
public void setDy (float dy)
{ this.dy = dy; }
public float getXScale ()
{ return xscale; }
public void setXScale (float xscale)
{ this.xscale = xscale; }
public float getYScale ()
{ return yscale; }
public void setYScale (float yscale)
{ this.yscale = yscale; }
public float getXSkew ()
{ return xskew; }
public void setXSkew (float xskew)
{ this.xskew = xskew; }
public float getYSkew ()
{ return yskew; }
public void setYSkew (float yskew)
{ this.yskew = yskew; }
// apply methods
public void apply (SWFDisplayItemI item, boolean force)
{
if (applied && !force)
return;
else
applied = true;
if (NE (this.dx, 0.0f) || NE (this.dy, 0.0f))
item.move (dx, dy);
if (NE (this.xscale, 1.0f) || NE (this.yscale, 1.0f))
item.scaleTo (xscale, yscale);
if (NE (this.xskew, 0.0f))
item.skewX (xskew);
if (NE (this.yskew, 0.0f))
item.skewY (yskew);
if (NE (this.rot, 0f))
item.rotate (rot);
}
public void apply (SWFDisplayItemI item)
{ apply (item, false); }
public boolean applied ()
{ return applied; }
// class methods
public static SWFMatrix identity()
{ return identity; }
private static boolean NE (float a, float b)
{ return Math.abs (a-b) < 1E-5; }
// variables
protected float dx;
protected float dy;
protected float xscale;
protected float yscale;
protected float xskew;
protected float yskew;
protected float rot;
protected boolean applied;
// class variables
protected static SWFMatrix identity;
static {
identity = new SWFMatrix();
identity.applied = true;
}
};
|