Example #1
0
 /**
  * Erases a String on the Canvas.
  *
  * @param text the String to be displayed
  * @param x x co-ordinate for text placement
  * @param y y co-ordinate for text placement
  */
 public void eraseString(String text, int x, int y) {
   Color original = graphic.getColor();
   graphic.setColor(backgroundColour);
   graphic.drawString(text, x, y);
   graphic.setColor(original);
   canvas.repaint();
 }
 /** Redraw ell shapes currently on the Canvas. */
 private void redraw() {
   erase();
   for (Object shape : objects) {
     shapes.get(shape).draw(graphic);
   }
   canvas.repaint();
 }
Example #3
0
 /**
  * Erases a given shape's outline on the screen.
  *
  * @param shape the shape object to be erased
  */
 public void eraseOutline(Shape shape) {
   Color original = graphic.getColor();
   graphic.setColor(backgroundColour);
   graphic.draw(shape); // erase by drawing background colour
   graphic.setColor(original);
   canvas.repaint();
 }
Example #4
0
 /** Redraw ell shapes currently on the Canvas. */
 private void redraw() {
   erase();
   for (Iterator i = objects.iterator(); i.hasNext(); ) {
     shapes.get(i.next()).draw(graphic);
   }
   canvas.repaint();
 }
Example #5
0
 /**
  * Fills the internal dimensions of a given shape with the current foreground colour of the
  * canvas.
  *
  * @param shape the shape object to be filled
  */
 public void fill(Shape shape) {
   graphic.fill(shape);
   canvas.repaint();
 }
Example #6
0
 /**
  * Draws a given shape onto the canvas.
  *
  * @param shape the shape object to be drawn on the canvas
  */
 public void draw(Shape shape) {
   graphic.draw(shape);
   canvas.repaint();
 }
Example #7
0
 /**
  * Draws a line on the Canvas.
  *
  * @param x1 x co-ordinate of start of line
  * @param y1 y co-ordinate of start of line
  * @param x2 x co-ordinate of end of line
  * @param y2 y co-ordinate of end of line
  */
 public void drawLine(int x1, int y1, int x2, int y2) {
   graphic.drawLine(x1, y1, x2, y2);
   canvas.repaint();
 }
Example #8
0
 /**
  * Draws a String on the Canvas.
  *
  * @param text the String to be displayed
  * @param x x co-ordinate for text placement
  * @param y y co-ordinate for text placement
  */
 public void drawString(String text, int x, int y) {
   graphic.drawString(text, x, y);
   canvas.repaint();
 }
Example #9
0
 /**
  * Draws an image onto the canvas.
  *
  * @param image the Image object to be displayed
  * @param x x co-ordinate for Image placement
  * @param y y co-ordinate for Image placement
  * @return returns boolean value representing whether the image was completely loaded
  */
 public boolean drawImage(Image image, int x, int y) {
   boolean result = graphic.drawImage(image, x, y, null);
   canvas.repaint();
   return result;
 }