Package com.dkt.graphics.elements
Class GImage
java.lang.Object
com.dkt.graphics.elements.GraphicE
com.dkt.graphics.elements.GImage
- All Implemented Interfaces:
Paint
,Transparency
,Cloneable
Wraps a
BufferedImage
into a GraphicE
object- Author:
- Federico Vera <[email protected]>
-
Field Summary
Fields inherited from interface java.awt.Transparency
BITMASK, OPAQUE, TRANSLUCENT
-
Constructor Summary
ConstructorDescriptionGImage
(int x, int y, BufferedImage img) Create a newGImage
from a givenBufferedImage
Create a newGImage
from a given fileCopy constructorCreate a newGImage
from a given fileCreate a newGImage
from a given path -
Method Summary
Modifier and TypeMethodDescriptionclone()
createContext
(ColorModel cm, Rectangle deviceBounds, Rectangle2D userBounds, AffineTransform xform, RenderingHints hints) void
draw
(Graphics2D g) Draws the component on the given graphicsboolean
final int
Retrieves the current height of theGImage
in pixelsfinal int
Retrieves the original height of theGImage
in pixelsfinal int
Retrieves the original width of theGImage
in pixelsint
final int
getWidth()
Retrieves the current width of theGImage
in pixelsint
hashCode()
void
move
(int x, int y) Moves the center of the image to the given coordinatesvoid
scale
(double scale) Symmetrically scales an image.
Ifscale
is less than 1 then the image will be reduced.void
scale
(double sx, double sy) Scales an image.void
traslate
(int x, int y) Traslates this element on X and Y
-
Constructor Details
-
GImage
Copy constructor- Parameters:
e
-GImage
to copy- Throws:
IllegalArgumentException
- ife
isnull
-
GImage
Create a newGImage
from a given path- Parameters:
path
- path to the image- Throws:
IOException
- if something goes wrong when opening or reading the image file.
-
GImage
Create a newGImage
from a given file- Parameters:
file
- file of the image- Throws:
IOException
- if something goes wrong when opening or reading the image file.
-
GImage
Create a newGImage
from a given file- Parameters:
x
- X coordinate of the center of the imagey
- Y coordinate of the center of the imagefile
- file of the image- Throws:
IOException
- if something goes wrong when opening or reading the image file.
-
GImage
Create a newGImage
from a givenBufferedImage
- Parameters:
x
- X coordinate of the center of the imagey
- Y coordinate of the center of the imageimg
- image to wrap
-
-
Method Details
-
getWidth
public final int getWidth()Retrieves the current width of theGImage
in pixels- Returns:
- width in px
-
getHeight
public final int getHeight()Retrieves the current height of theGImage
in pixels- Returns:
- height in px
-
getOriginalWidth
public final int getOriginalWidth()Retrieves the original width of theGImage
in pixels- Returns:
- width in px
-
getOriginalHeight
public final int getOriginalHeight()Retrieves the original height of theGImage
in pixels- Returns:
- height in px
-
scale
public void scale(double scale) Symmetrically scales an image.
- If
scale
is less than 1 then the image will be reduced. - If
scale
is 1, then nothing noticeable should happen to the image. - If
scale
is more than 1 then the image will be bigger.
- Parameters:
scale
- scale quotient
- If
-
scale
public void scale(double sx, double sy) Scales an image.
- If
scaleX/Y
is less than 1 then the image will be reduced. - If
scaleX/Y
is 1, then nothing noticeable should happen to the image. - If
scaleX/Y
is more than 1 then the image will be bigger.
- Parameters:
sx
- Horizontal scalesy
- Vertical scale- See Also:
- If
-
traslate
public void traslate(int x, int y) Description copied from class:GraphicE
Traslates this element on X and Y -
move
public void move(int x, int y) Moves the center of the image to the given coordinates- Parameters:
x
- new X coordinate of the center of the imagey
- new Y coordinate of the center of the image
-
draw
Description copied from class:GraphicE
Draws the component on the given graphics -
clone
-
hashCode
public int hashCode() -
equals
-
createContext
public PaintContext createContext(ColorModel cm, Rectangle deviceBounds, Rectangle2D userBounds, AffineTransform xform, RenderingHints hints) - Specified by:
createContext
in interfacePaint
-
getTransparency
public int getTransparency()- Specified by:
getTransparency
in interfaceTransparency
-