Package nl.saxion.app.canvas.drawable
Class Image
java.lang.Object
nl.saxion.app.canvas.CanvasElement
nl.saxion.app.canvas.drawable.DrawableElement
nl.saxion.app.canvas.drawable.Image
Draw an image on top of the canvas
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncreateSubImage
(String originFileName, String newName, int x, int y, int width, int height) Take part of another image to create a new one.void
draw
(Graphics2D g) int
int
getWidth()
void
setFilename
(String filename) void
setHeight
(int height) void
setWidth
(int width)
-
Constructor Details
-
Image
-
Image
-
Image
public Image(int x, int y, int width, int height) Creates a new empty image that you can add content to through thegetGraphicsContext()
.- Parameters:
x
- position of the image x.y
- position of the image y.width
- width of the image.height
- height of the image.
-
Image
public Image(int width, int height)
-
-
Method Details
-
getFilename
-
getWidth
public int getWidth() -
getHeight
public int getHeight() -
getGraphicsContext
-
setFilename
-
createSubImage
public Image createSubImage(String originFileName, String newName, int x, int y, int width, int height) Take part of another image to create a new one. Afterward you need to set the position and size to actually place the new image. Please note, you only need to do this once, then you can simply create an image using the new name.- Parameters:
originFileName
- name of the original image.newName
- name of the sub-image.x
- position of the sub-image xy
- position of the sub-image ywidth
- width of the sub-imageheight
- height of the sub-image- Returns:
- a new Image that is a section of a larger original image.
-
setWidth
public void setWidth(int width) -
setHeight
public void setHeight(int height) -
draw
- Specified by:
draw
in classCanvasElement
-