public interface DrawScreen
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clears the entire screen.
|
void |
drawCircle(int xCenter,
int yCenter,
int width,
int height,
Colour colour,
boolean fill)
Draws a circle.
|
void |
drawImage(java.awt.image.BufferedImage image,
int xTopLeft,
int yTopLeft)
Draws an image in its original dimensions.
|
void |
drawImage(java.awt.image.BufferedImage image,
int width,
int height,
int xTopLeft,
int yTopLeft)
Draws an image with custom dimensions.
|
void |
drawLine(int xStart,
int yStart,
int xEnd,
int yEnd,
Colour colour)
Draws a line.
|
void |
drawPixel(int x,
int y,
Colour colour)
Draws a single pixel.
|
void |
drawSquare(int xTopLeft,
int yTopLeft,
int width,
int height,
Colour colour,
boolean fill)
Draws a square.
|
void |
drawText(int xTopLeft,
int yTopLeft,
java.lang.String text,
Colour colour)
Draws a piece of text.
|
int |
getHeight()
Returns the screen height.
|
int |
getTextHeight(java.lang.String text)
Determines the height of a piece of text.
|
int |
getTextWidth(java.lang.String text)
Determines the width of a piece of text.
|
int |
getWidth()
Returns the screen width.
|
java.awt.image.BufferedImage |
readImage(java.lang.String location)
Reads an image from local storage.
|
void |
setCircleHotspot(int xCenter,
int yCenter,
int width,
int height,
java.lang.String name)
Places a round hotspot on the screen.
|
void |
setSquareHotspot(int xTopLeft,
int yTopLeft,
int width,
int height,
java.lang.String name)
Places a square hotspot on the screen.
|
void |
showChanges()
Shows all the changes made to the screen.
|
void drawPixel(int x, int y, Colour colour)
x
- x coordinate of the pixel, starting at 0y
- y coordinate of the pixel, starting at 0colour
- the colour of the pixelvoid drawLine(int xStart, int yStart, int xEnd, int yEnd, Colour colour)
xStart
- x coordinate of the starting point of the line, in pixels
starting at 0.yStart
- y coordinate of the starting point of the line, in pixels
starting at 0.xEnd
- x x coordinate of the ending point of the line, in pixels
starting at 0.yEnd
- y y coordinate of the ending point of the line, in pixels
starting at 0.colour
- the colour of the line.void drawCircle(int xCenter, int yCenter, int width, int height, Colour colour, boolean fill)
xCenter
- The x coordinate of the circle center, in pixels
starting at 0.yCenter
- The y coordinate of the circle center, in pixels
starting at 0.width
- The width of the circle, in pixels.height
- The height of the circle, in pixels.colour
- The colour of the circle.fill
- If true, the circle is filled, if false, only the border is drawn.void drawSquare(int xTopLeft, int yTopLeft, int width, int height, Colour colour, boolean fill)
xTopLeft
- The x coordinate of the top left corner of
the square, in pixels starting at 0.yTopLeft
- The y coordinate of the top left corner of
the square, in pixels starting at 0.width
- The width of the square, in pixels.height
- The height of the square, in pixels.colour
- The colour of the square.fill
- If true, the square is filled, if false, only the border is drawn.void drawText(int xTopLeft, int yTopLeft, java.lang.String text, Colour colour)
getTextWidth(String)
and
getTextHeight(String)
.xTopLeft
- The x coordinate of the top left corner of
the text, in pixels starting at 0.yTopLeft
- The y coordinate of the top left corner of
the text, in pixels starting at 0.text
- The text to be drawncolour
- The colour of the text.void showChanges()
void clear()
int getTextWidth(java.lang.String text)
text
- The text of which the width has to be returned.int getTextHeight(java.lang.String text)
text
- The text of which the height has to be returned.int getWidth()
int getHeight()
java.awt.image.BufferedImage readImage(java.lang.String location)
location
- The location of the image.
A location can be relative:
For example, if the program is located in /home/student/program/
and the location argument is "image.png",
/home/student/program/image.png will be read.
A location can also be absolute:
"/home/student/program/image.png". Mind that the slash is an
escape character in Java, therefore, use
"C:\\program\\images\\image.png".BufferedImage
void drawImage(java.awt.image.BufferedImage image, int xTopLeft, int yTopLeft)
BufferedImage.getWidth()
and BufferedImage.getHeight()
to obtain the dimensions of the image.image
- The image read with readImage(String)
.xTopLeft
- The x coordinate of the top left corner of
the image, in pixels starting at 0.yTopLeft
- The y coordinate of the top left corner of
the image, in pixels starting at 0.void drawImage(java.awt.image.BufferedImage image, int width, int height, int xTopLeft, int yTopLeft)
BufferedImage.getWidth()
and BufferedImage.getHeight()
to obtain the dimensions of the image.image
- The image read with readImage(String)
.width
- The width with which the image should be drawn.height
- The height with which the image should be drawn.xTopLeft
- The x coordinate of the top left corner of
the image, in pixels starting at 0.yTopLeft
- The y coordinate of the top left corner of
the image, in pixels starting at 0.void setSquareHotspot(int xTopLeft, int yTopLeft, int width, int height, java.lang.String name)
xTopLeft
- The x coordinate of the top left corner of
the square, in pixels starting at 0.yTopLeft
- The y coordinate of the top left corner of
the square, in pixels starting at 0.width
- The width of the square, in pixels.height
- The height of the square, in pixels.name
- The data which is provided to the event.void setCircleHotspot(int xCenter, int yCenter, int width, int height, java.lang.String name)
xCenter
- The x coordinate of the circle center, in pixels
starting at 0.yCenter
- The y coordinate of the circle center, in pixels
starting at 0.width
- The width of the circle, in pixels.height
- The height of the circle, in pixels.name
- The data which is provided to the event.