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
ConstructorsConstructorDescriptionGTransform(double sx, double sy) Create a scalingGTransformGTransform(int x, int y, double phi) Create a rotatingGTransformCopy constructor -
Method Summary
Modifier and TypeMethodDescriptionclone()voiddraw(Graphics2D g) Draws the component on the given graphicsbooleanRetrieves theAffineTransformused in thisGTransforminthashCode()invert()Retrieves a newGTransformthat reverses the effects of this onevoidrotate(double phi) Rotates the graphics around the origin of coordinates a given anglevoidrotate(int x, int y, double phi) Rotates the graphics around the point(x, y)a given anglevoidscale(double sx, double sy) Scales the graphicsvoidtraslate(int x, int y) Traslates this element on X and Y
-
Constructor Details
-
GTransform
Copy constructor- Parameters:
e-GTransformto copy- Throws:
IllegalArgumentException- ifeisnull
-
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-xcoordinate of the pivot pointy-ycoordinate 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-xcoordinate of the pivot pointy-ycoordinate 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 theAffineTransformused in thisGTransform- Returns:
- transform
-
invert
Retrieves a newGTransformthat 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:GraphicETraslates this element on X and Y -
draw
Description copied from class:GraphicEDraws the component on the given graphics -
clone
-
hashCode
public int hashCode() -
equals
-