⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 affinetransform.java

📁 Hecl编程语言是一个高层次的脚本语言的Java实现。其用意是要小
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
	    m00 = sx;	    m11 = sy;	    if (sx != 1.0 || sy != 1.0) {		this.state = state | APPLY_SCALE;		this.type = TYPE_UNKNOWN;	    }	    return;	}    }    /**     * Concatenates this transform with a shearing transformation.     * This is equivalent to calling concatenate(SH), where SH is an     * <code>AffineTransform</code> represented by the following matrix:     * <pre>     *		[   1   shx   0   ]     *		[  shy   1    0   ]     *		[   0    0    1   ]     * </pre>     * @param shx the multiplier by which coordinates are shifted in the     * direction of the positive X axis as a factor of their Y coordinate     * @param shy the multiplier by which coordinates are shifted in the     * direction of the positive Y axis as a factor of their X coordinate     */    public void shear(double shx, double shy) {	int state = this.state;	switch (state) {	  default:	    stateError();	    break;	    /* NOTREACHED */	  case (APPLY_SHEAR | APPLY_SCALE | APPLY_TRANSLATE):	  case (APPLY_SHEAR | APPLY_SCALE):	    double M0, M1;	    M0 = m00;	    M1 = m01;	    m00 = M0 + M1 * shy;	    m01 = M0 * shx + M1;	    M0 = m10;	    M1 = m11;	    m10 = M0 + M1 * shy;	    m11 = M0 * shx + M1;	    updateState();	    break;	  case (APPLY_SHEAR | APPLY_TRANSLATE):	  case (APPLY_SHEAR):	    m00 = m01 * shy;	    m11 = m10 * shx;	    if (m00 != 0.0 || m11 != 0.0) {		this.state = state | APPLY_SCALE;	    }	    this.type = TYPE_UNKNOWN;	    break;	  case (APPLY_SCALE | APPLY_TRANSLATE):	  case (APPLY_SCALE):	    m01 = m00 * shx;	    m10 = m11 * shy;	    if (m01 != 0.0 || m10 != 0.0) {		this.state = state | APPLY_SHEAR;	    }	    this.type = TYPE_UNKNOWN;	    break;	  case (APPLY_TRANSLATE):	  case (APPLY_IDENTITY):	    m01 = shx;	    m10 = shy;	    if (m01 != 0.0 || m10 != 0.0) {		this.state = state | APPLY_SCALE | APPLY_SHEAR;		this.type = TYPE_UNKNOWN;	    }	    break;	}    }    /**     * Resets this transform to the Identity transform.     */    public void setToIdentity() {	m00 = m11 = 1.0;	m10 = m01 = m02 = m12 = 0.0;	state = APPLY_IDENTITY;	type = TYPE_IDENTITY;    }    /**     * Sets this transform to a translation transformation.     * The matrix representing this transform becomes:     * <pre>     *		[   1    0    tx  ]     *		[   0    1    ty  ]     *		[   0    0    1   ]     * </pre>     * @param tx the distance by which coordinates are translated in the     * X axis direction     * @param ty the distance by which coordinates are translated in the     * Y axis direction     */    public void setToTranslation(double tx, double ty) {	m00 = m11 = 1.0;	m10 = m01 = 0.0;	m02 = tx;	m12 = ty;	if (tx != 0.0 || ty != 0.0) {	    state = APPLY_TRANSLATE;	    type = TYPE_TRANSLATION;	} else {	    state = APPLY_IDENTITY;	    type = TYPE_IDENTITY;	}    }    /**     * Sets this transform to a rotation transformation.     * The matrix representing this transform becomes:     * <pre>     *		[   cos(theta)    -sin(theta)    0   ]     *		[   sin(theta)     cos(theta)    0   ]     *		[       0              0         1   ]     * </pre>     * Rotating with a positive angle theta rotates points on the positive     * x axis toward the positive y axis.     * @param theta the angle of rotation in radians     */    public void setToRotation(double theta) {	m02 = m12 = 0.0;	double sin = Math.sin(theta);	double cos = Math.cos(theta);	if (Math.abs(sin) < 1E-15) {	    m01 = m10 = 0.0;	    if (cos < 0) {		m00 = m11 = -1.0;		state = APPLY_SCALE;		type = TYPE_QUADRANT_ROTATION;	    } else {		m00 = m11 = 1.0;		state = APPLY_IDENTITY;		type = TYPE_IDENTITY;	    }	    return;	}	if (Math.abs(cos) < 1E-15) {	    m00 = m11 = 0.0;	    if (sin < 0.0) {		m01 = 1.0;		m10 = -1.0;	    } else {		m01 = -1.0;		m10 = 1.0;	    }	    state = APPLY_SHEAR;	    type = TYPE_QUADRANT_ROTATION;	    return;	}	m00 = cos;	m01 = -sin;	m10 = sin;	m11 = cos;	state = APPLY_SHEAR | APPLY_SCALE;	type = TYPE_GENERAL_ROTATION;    }    /**     * Sets this transform to a translated rotation transformation.     * This operation is equivalent to translating the coordinates so     * that the anchor point is at the origin (S1), then rotating them     * about the new origin (S2), and finally translating so that the     * intermediate origin is restored to the coordinates of the original     * anchor point (S3).     * <p>     * This operation is equivalent to the following sequence of calls:     * <pre>     *	    setToTranslation(x, y);	// S3: final translation     *	    rotate(theta);		// S2: rotate around anchor     *	    translate(-x, -y);		// S1: translate anchor to origin     * </pre>     * The matrix representing this transform becomes:     * <pre>     *		[   cos(theta)    -sin(theta)    x-x*cos+y*sin  ]     *		[   sin(theta)     cos(theta)    y-x*sin-y*cos  ]     *		[       0              0               1        ]     * </pre>     * Rotating with a positive angle theta rotates points on the positive     * x axis toward the positive y axis.     * @param theta the angle of rotation in radians     * @param x,&nbsp;y the coordinates of the anchor point of the     * rotation     */    public void setToRotation(double theta, double x, double y) {	setToRotation(theta);	double sin = m10;	double oneMinusCos = 1.0 - m00;	m02 = x * oneMinusCos + y * sin;	m12 = y * oneMinusCos - x * sin;	if (m02 != 0.0 || m12 != 0.0) {	    state |= APPLY_TRANSLATE;	    type |= TYPE_TRANSLATION;	}    }    /**     * Sets this transform to a scaling transformation.     * The matrix representing this transform becomes:     * <pre>     *		[   sx   0    0   ]     *		[   0    sy   0   ]     *		[   0    0    1   ]     * </pre>     * @param sx the factor by which coordinates are scaled along the     * X axis direction     * @param sy the factor by which coordinates are scaled along the     * Y axis direction     */    public void setToScale(double sx, double sy) {	m01 = m02 = m10 = m12 = 0.0;	m00 = sx;	m11 = sy;	if (sx != 1.0 || sy != 1.0) {	    state = APPLY_SCALE;	    type = TYPE_UNKNOWN;	} else {	    state = APPLY_IDENTITY;	    type = TYPE_IDENTITY;	}    }    /**     * Sets this transform to a shearing transformation.     * The matrix representing this transform becomes:     * <pre>     *		[   1   shx   0   ]     *		[  shy   1    0   ]     *		[   0    0    1   ]     * </pre>     * @param shx the multiplier by which coordinates are shifted in the     * direction of the positive X axis as a factor of their Y coordinate     * @param shy the multiplier by which coordinates are shifted in the     * direction of the positive Y axis as a factor of their X coordinate     */    public void setToShear(double shx, double shy) {	m00 = m11 = 1.0;	m02 = m12 = 0.0;	m01 = shx;	m10 = shy;	if (shx != 0.0 || shy != 0.0) {	    state = (APPLY_SHEAR | APPLY_SCALE);	    type = TYPE_UNKNOWN;	} else {	    state = APPLY_IDENTITY;	    type = TYPE_IDENTITY;	}    }    /**     * Sets this transform to a copy of the transform in the specified     * <code>AffineTransform</code> object.     * @param Tx the <code>AffineTransform</code> object from which to     * copy the transform     */    public void setTransform(AffineTransform Tx) {	this.m00 = Tx.m00;	this.m10 = Tx.m10;	this.m01 = Tx.m01;	this.m11 = Tx.m11;	this.m02 = Tx.m02;	this.m12 = Tx.m12;	this.state = Tx.state;	this.type = Tx.type;    }    /**     * Sets this transform to the matrix specified by the 6     * double precision values.     * @param m00,&nbsp;m01,&nbsp;m02,&nbsp;m10,&nbsp;m11,&nbsp;m12 the     * 6 floating point values that compose the 3x3 transformation matrix     */    public void setTransform(double m00, double m10,			     double m01, double m11,			     double m02, double m12) {	this.m00 = m00;	this.m10 = m10;	this.m01 = m01;	this.m11 = m11;	this.m02 = m02;	this.m12 = m12;	updateState();    }    /**     * Concatenates an <code>AffineTransform</code> <code>Tx</code> to     * this <code>AffineTransform</code> Cx in the most commonly useful     * way to provide a new user space     * that is mapped to the former user space by <code>Tx</code>.     * Cx is updated to perform the combined transformation.     * Transforming a point p by the updated transform Cx' is     * equivalent to first transforming p by <code>Tx</code> and then     * transforming the result by the original transform Cx like this:     * Cx'(p) = Cx(Tx(p))       * In matrix notation, if this transform Cx is     * represented by the matrix [this] and <code>Tx</code> is represented     * by the matrix [Tx] then this method does the following:     * <pre>     *		[this] = [this] x [Tx]     * </pre>     * @param Tx the <code>AffineTransform</code> object to be     * concatenated with this <code>AffineTransform</code> object.     * @see #preConcatenate     */    public void concatenate(AffineTransform Tx) {        double M0, M1;	double T00, T01, T10, T11;	double T02, T12;	int mystate = state;	int txstate = Tx.state;	switch ((txstate << HI_SHIFT) | mystate) {	    /* ---------- Tx == IDENTITY cases ---------- */	  case (HI_IDENTITY | APPLY_IDENTITY):	  case (HI_IDENTITY | APPLY_TRANSLATE):	  case (HI_IDENTITY | APPLY_SCALE):	  case (HI_IDENTITY | APPLY_SCALE | APPLY_TRANSLATE):	  case (HI_IDENTITY | APPLY_SHEAR):	  case (HI_IDENTITY | APPLY_SHEAR | APPLY_TRANSLATE):	  case (HI_IDENTITY | APPLY_SHEAR | APPLY_SCALE):	  case (HI_IDENTITY | APPLY_SHEAR | APPLY_SCALE | APPLY_TRANSLATE):	    return;	    /* ---------- this == IDENTITY cases ---------- */	  case (HI_SHEAR | HI_SCALE | HI_TRANSLATE | APPLY_IDENTITY):	    m01 = Tx.m01;	    m10 = Tx.m10;	    /* NOBREAK */	  case (HI_SCALE | HI_TRANSLATE | APPLY_IDENTITY):	    m00 = Tx.m00;	    m11 = Tx.m11;	    /* NOBREAK */	  case (HI_TRANSLATE | APPLY_IDENTITY):	    m02 = Tx.m02;	    m12 = Tx.m12;	    state = txstate;	    type = Tx.type;	    return;	  case (HI_SHEAR | HI_SCALE | APPLY_IDENTITY):	    m01 = Tx.m01;	    m10 = Tx.m10;	    /* NOBREAK */	  case (HI_SCALE | APPLY_IDENTITY):	    m00 = Tx.m00;	    m11 = Tx.m11;	    state = txstate;	    type = Tx.type;	    return;	  case (HI_SHEAR | HI_TRANSLATE | APPLY_IDENTITY):	    m02 = Tx.m02;	    m12 = Tx.m12;	    /* NOBREAK */	  case (HI_SHEAR | APPLY_IDENTITY):	    m01 = Tx.m01;	    m10 = Tx.m10;            m00 = m11 = 0.0;	    state = txstate;	    type = Tx.type;	    return;	    /* ---------- Tx == TRANSLATE cases ---------- */	  case (HI_TRANSLATE | APPLY_SHEAR | APPLY_SCALE | APPLY_TRANSLATE):	  case (HI_TRANSLATE | APPLY_SHEAR | APPLY_SCALE):	  case (HI_TRANSLATE | APPLY_SHEAR | APPLY_TRANSLATE):	  case (HI_TRANSLATE | APPLY_SHEAR):	  case (HI_TRANSLATE | APPLY_SCALE | APPLY_TRANSLATE):	  case (HI_TRANSLATE | APPLY_SCALE):	  case (HI_TRANSLATE | APPLY_TRANSLATE):	    translate(Tx.m02, Tx.m12);	    return;	    /* ---------- Tx == SCALE cases ---------- */	  case (HI_SCALE | APPLY_SHEAR | APPLY_SCALE | APPLY_TRANSLATE):	  case (HI_SCALE | APPLY_SHEAR | APPLY_SCALE):	  case (HI_SCALE | APPLY_SHEAR | APPLY_TRANSLATE):	  case (HI_SCALE | APPLY_SHEAR):	  case (HI_SCALE | APPLY_SCALE | APPLY_TRANSLATE):	  case (HI_SCALE | APPLY_SCALE):	  case (HI_SCALE | APPLY_TRANSLATE):	    scale(Tx.m00, Tx.m11);	    return;	    /* ---------- Tx == SHEAR cases ---------- */	  case (HI_SHEAR | APPLY_SHEAR | APPLY_SCALE | APPLY_TRANSLATE):	  case (HI_SHEAR | APPLY_SHEAR | APPLY_SCALE):	    T01 = Tx.m01; T10 = Tx.m10;	    M0 = m00;	    m00 = m01 * T10;	    m01 = M0 * T01;	    M0 = m10;	    m10 = m11 * T10;	    m11 = M0 * T01;	    type = TYPE_UNKNOWN;	    return;	  case (HI_SHEAR | APPLY_SHEAR | APPLY_TRANSLATE):	  case (HI_SHEAR | APPLY_SHEAR):	    m00 = m01 * Tx.m10;	    m01 = 0.0;	    m11 = m10 * Tx.m01;	    m10 = 0.0;	    state = mystate ^ (APPLY_SHEAR | APPLY_SCALE);	    type = TYPE_UNKNOWN;	    return;	  case (HI_SHEAR | APPLY_SCALE | APPLY_TRANSLATE):	  case (HI_SHEAR | APPLY_SCALE):	    m01 = m00 * Tx.m01;	    m00 = 0.0;	    m10 = m11 * Tx.m10;	    m11 = 0.0;	    state = mystate ^ (APPLY_SHEAR | APPLY_SCALE);	    type = TYPE_UNKNOWN;	    return;	  case (HI_SHEAR | APPLY_TRANSLATE):	    m00 = 0.0;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -