de.unifreiburg.twodeedoo.world
Class AwtCanvas

java.lang.Object
  extended by de.unifreiburg.twodeedoo.world.AwtCanvas
All Implemented Interfaces:
ICanvas

public class AwtCanvas
extends java.lang.Object
implements ICanvas

Implementation of ICanvas using AWT Graphics.

Author:
anton

Constructor Summary
AwtCanvas(java.awt.Graphics g)
           
 
Method Summary
 void drawFilledCircle(int x, int y, int radius, java.awt.Color color)
          Draw a filled circle.
 void drawFilledRect(int upperLeftX, int upperLeftY, int width, int height, java.awt.Color color)
          Draw a filled rectangle.
 void drawImage(java.awt.Image img, int x, int y)
          Draws as much of the specified area of the specified image as is currently available.
 void drawImage(java.awt.Image img, int x, int y, int sx1, int sy1, int sx2, int sy2)
          Draws as much of the specified area of the specified image as is currently available.
 void drawLine(int x0, int y0, int x1, int y1, java.awt.Color color)
          Draw a line.
 void drawText(int x, int y, java.lang.String msg, java.awt.Color color)
          Draw text in the standard font.
 java.awt.Graphics getAwtGraphics()
          Return the inner Graphics; you can use it to draw complicated shapes beyond what this interface offers.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AwtCanvas

public AwtCanvas(java.awt.Graphics g)
Method Detail

drawFilledCircle

public void drawFilledCircle(int x,
                             int y,
                             int radius,
                             java.awt.Color color)
Description copied from interface: ICanvas
Draw a filled circle.

Specified by:
drawFilledCircle in interface ICanvas
Parameters:
x - X of center (in pixels)
y - Y of center (in pixels)
radius - radius in pixels
color - color for the circle.

drawText

public void drawText(int x,
                     int y,
                     java.lang.String msg,
                     java.awt.Color color)
Description copied from interface: ICanvas
Draw text in the standard font. The (x,y) point specifies where the baseline of the first character is drawn.

Specified by:
drawText in interface ICanvas
Parameters:
x - x coordinate of baseline of first character
y - y coordinate of baseline of first character
msg - a text
color - text color

drawFilledRect

public void drawFilledRect(int upperLeftX,
                           int upperLeftY,
                           int width,
                           int height,
                           java.awt.Color color)
Description copied from interface: ICanvas
Draw a filled rectangle.

Specified by:
drawFilledRect in interface ICanvas
Parameters:
upperLeftX - X of upper left corner
upperLeftY - Y of upper left corner
width - width of rectangle
height - height of rectangle
color - fill color

drawLine

public void drawLine(int x0,
                     int y0,
                     int x1,
                     int y1,
                     java.awt.Color color)
Description copied from interface: ICanvas
Draw a line.

Specified by:
drawLine in interface ICanvas
Parameters:
x0 - first point
y0 - first point
x1 - second point
y1 - second point
color - color

getAwtGraphics

public java.awt.Graphics getAwtGraphics()
Description copied from interface: ICanvas
Return the inner Graphics; you can use it to draw complicated shapes beyond what this interface offers.

Specified by:
getAwtGraphics in interface ICanvas
Returns:
the inner Graphics

drawImage

public void drawImage(java.awt.Image img,
                      int x,
                      int y)
Description copied from interface: ICanvas
Draws as much of the specified area of the specified image as is currently available. Transparent pixels do not affect whatever pixels are already there.

Specified by:
drawImage in interface ICanvas
Parameters:
img - the specified image to be drawn. This method does nothing if img is null.
x - the x coordinate.
y - the y coordinate.
See Also:
Image

drawImage

public void drawImage(java.awt.Image img,
                      int x,
                      int y,
                      int sx1,
                      int sy1,
                      int sx2,
                      int sy2)
Description copied from interface: ICanvas
Draws as much of the specified area of the specified image as is currently available. Transparent pixels do not affect whatever pixels are already there.

Specified by:
drawImage in interface ICanvas
x - the x coordinate.
y - the y coordinate.
sx1 - the x coordinate of the first corner of the source rectangle.
sy1 - the y coordinate of the first corner of the source rectangle.
sx2 - the x coordinate of the second corner of the source rectangle.
sy2 - the y coordinate of the second corner of the source rectangle.
See Also:
Image