Package com.dkt.graphics.elements
Class GImage
- java.lang.Object
-
- com.dkt.graphics.elements.GraphicE
-
- com.dkt.graphics.elements.GImage
-
-
Constructor Summary
Constructors Constructor Description GImage(int x, int y, java.awt.image.BufferedImage img)
Create a newGImage
from a givenBufferedImage
GImage(int x, int y, java.io.File file)
Create a newGImage
from a given fileGImage(GImage e)
Copy constructorGImage(java.io.File file)
Create a newGImage
from a given fileGImage(java.lang.String path)
Create a newGImage
from a given path
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description GImage
clone()
java.awt.PaintContext
createContext(java.awt.image.ColorModel cm, java.awt.Rectangle deviceBounds, java.awt.geom.Rectangle2D userBounds, java.awt.geom.AffineTransform xform, java.awt.RenderingHints hints)
void
draw(java.awt.Graphics2D g)
Draws the component on the given graphicsboolean
equals(java.lang.Object obj)
int
getHeight()
Retrieves the current height of theGImage
in pixelsint
getOriginalHeight()
Retrieves the original height of theGImage
in pixelsint
getOriginalWidth()
Retrieves the original width of theGImage
in pixelsint
getTransparency()
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 Detail
-
GImage
public GImage(GImage e)
Copy constructor- Parameters:
e
-GImage
to copy- Throws:
java.lang.IllegalArgumentException
- ife
isnull
-
GImage
public GImage(java.lang.String path) throws java.io.IOException
Create a newGImage
from a given path- Parameters:
path
- path to the image- Throws:
java.io.IOException
- if something goes wrong when opening or reading the image file.
-
GImage
public GImage(java.io.File file) throws java.io.IOException
Create a newGImage
from a given file- Parameters:
file
- file of the image- Throws:
java.io.IOException
- if something goes wrong when opening or reading the image file.
-
GImage
public GImage(int x, int y, java.io.File file) throws java.io.IOException
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:
java.io.IOException
- if something goes wrong when opening or reading the image file.
-
GImage
public GImage(int x, int y, java.awt.image.BufferedImage img)
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 Detail
-
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:
getOriginalHeight()
,()
- 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
public void draw(java.awt.Graphics2D g)
Description copied from class:GraphicE
Draws the component on the given graphics
-
createContext
public java.awt.PaintContext createContext(java.awt.image.ColorModel cm, java.awt.Rectangle deviceBounds, java.awt.geom.Rectangle2D userBounds, java.awt.geom.AffineTransform xform, java.awt.RenderingHints hints)
- Specified by:
createContext
in interfacejava.awt.Paint
-
getTransparency
public int getTransparency()
- Specified by:
getTransparency
in interfacejava.awt.Transparency
-
-