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
ConstructorsConstructorDescriptionGImage(int x, int y, BufferedImage img) Create a newGImagefrom a givenBufferedImageCreate a newGImagefrom a given fileCopy constructorCreate a newGImagefrom a given fileCreate a newGImagefrom a given path - 
Method Summary
Modifier and TypeMethodDescriptionclone()createContext(ColorModel cm, Rectangle deviceBounds, Rectangle2D userBounds, AffineTransform xform, RenderingHints hints) voiddraw(Graphics2D g) Draws the component on the given graphicsbooleanfinal intRetrieves the current height of theGImagein pixelsfinal intRetrieves the original height of theGImagein pixelsfinal intRetrieves the original width of theGImagein pixelsintfinal intgetWidth()Retrieves the current width of theGImagein pixelsinthashCode()voidmove(int x, int y) Moves the center of the image to the given coordinatesvoidscale(double scale) Symmetrically scales an image.
Ifscaleis less than 1 then the image will be reduced.voidscale(double sx, double sy) Scales an image.voidtraslate(int x, int y) Traslates this element on X and Y 
- 
Constructor Details
- 
GImage
Copy constructor- Parameters:
 e-GImageto copy- Throws:
 IllegalArgumentException- ifeisnull
 - 
GImage
Create a newGImagefrom 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 newGImagefrom 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 newGImagefrom 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 newGImagefrom 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 theGImagein pixels- Returns:
 - width in px
 
 - 
getHeight
public final int getHeight()Retrieves the current height of theGImagein pixels- Returns:
 - height in px
 
 - 
getOriginalWidth
public final int getOriginalWidth()Retrieves the original width of theGImagein pixels- Returns:
 - width in px
 
 - 
getOriginalHeight
public final int getOriginalHeight()Retrieves the original height of theGImagein pixels- Returns:
 - height in px
 
 - 
scale
public void scale(double scale) Symmetrically scales an image.
- If 
scaleis less than 1 then the image will be reduced. - If 
scaleis 1, then nothing noticeable should happen to the image. - If 
scaleis 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/Yis less than 1 then the image will be reduced. - If 
scaleX/Yis 1, then nothing noticeable should happen to the image. - If 
scaleX/Yis 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:GraphicETraslates 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:GraphicEDraws 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:
 createContextin interfacePaint
 - 
getTransparency
public int getTransparency()- Specified by:
 getTransparencyin interfaceTransparency
 
 -