Package com.dkt.graphics.extras
Class GTransform
java.lang.Object
com.dkt.graphics.elements.GraphicE
com.dkt.graphics.extras.GTransform
- All Implemented Interfaces:
Cloneable
This class wraps a
AffineTransform
in a GraphicE
, in order to
give a bit more "flexibility" to Graphic
objects- Author:
- Federico Vera <[email protected]>
-
Field Summary
-
Constructor Summary
ConstructorDescriptionGTransform
(double sx, double sy) Create a scalingGTransform
GTransform
(int x, int y, double phi) Create a rotatingGTransform
Copy constructor -
Method Summary
Modifier and TypeMethodDescriptionclone()
void
draw
(Graphics2D g) Draws the component on the given graphicsboolean
Retrieves theAffineTransform
used in thisGTransform
int
hashCode()
invert()
Retrieves a newGTransform
that reverses the effects of this onevoid
rotate
(double phi) Rotates the graphics around the origin of coordinates a given anglevoid
rotate
(int x, int y, double phi) Rotates the graphics around the point(x, y)
a given anglevoid
scale
(double sx, double sy) Scales the graphicsvoid
traslate
(int x, int y) Traslates this element on X and Y
-
Constructor Details
-
GTransform
Copy constructor- Parameters:
e
-GTransform
to copy- Throws:
IllegalArgumentException
- ife
isnull
-
GTransform
public GTransform(double sx, double sy) Create a scalingGTransform
- Parameters:
sx
- horizontal scalesy
- vertical scale
-
GTransform
public GTransform(int x, int y, double phi) Create a rotatingGTransform
- Parameters:
x
-x
coordinate of the pivot pointy
-y
coordinate of the pivot pointphi
- angle in degrees
-
-
Method Details
-
scale
public void scale(double sx, double sy) Scales the graphics- Parameters:
sx
- horizontal scalesy
- vertical scale
-
rotate
public void rotate(int x, int y, double phi) Rotates the graphics around the point(x, y)
a given angle- Parameters:
x
-x
coordinate of the pivot pointy
-y
coordinate of the pivot pointphi
- angle in degrees
-
rotate
public void rotate(double phi) Rotates the graphics around the origin of coordinates a given angle- Parameters:
phi
- angle in degrees
-
getTransform
Retrieves theAffineTransform
used in thisGTransform
- Returns:
- transform
-
invert
Retrieves a newGTransform
that reverses the effects of this one- Returns:
- inverse transform
- Throws:
NoninvertibleTransformException
- if the transform is not invertible, this usually happens when using sheer, so it's very unlikely here
-
traslate
public void traslate(int x, int y) Description copied from class:GraphicE
Traslates this element on X and Y -
draw
Description copied from class:GraphicE
Draws the component on the given graphics -
clone
-
hashCode
public int hashCode() -
equals
-