org.millscript.millscript.datatypes
Class Image

java.lang.Object
  extended by org.millscript.millscript.datatypes.Image
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
RasterImage

public abstract class Image
extends java.lang.Object
implements java.lang.Cloneable

Abstract super class of images in MillScript, intended to abstract the different types of image. In particular we want to abstract the difference between raster and vector graphics, so that they can be treated in the same way.


Constructor Summary
Image()
           
 
Method Summary
protected  java.lang.Object clone()
           
abstract  void drawLine(int x1, int y1, int x2, int y2)
          Draws a line in the current colour, between the points ( x1, y1 ) and ( x2, y2 ).
abstract  void drawOval(int x, int y, int width, int height)
          Draws the outline of an oval in the current color.
abstract  void drawRect(int x, int y, int width, int height)
          Draws the outline of a rectangle in the current color.
abstract  void drawString(java.lang.String s, int x, int y)
          Draws the text using the current font, in the current color, at the specified position.
abstract  void fillOval(int x, int y, int width, int height)
          Draws a filled oval in the current color.
abstract  void fillRect(int x, int y, int width, int height)
          Draws a filled rectangle in the current color.
abstract  java.awt.Graphics2D getGraphics2D()
          Returns a Graphics2D object to draw on this image.
abstract  int height()
          Returns the height of this image, in pixels.
abstract  void renderAsRasterToStream(java.io.OutputStream ostream, ImageRender render)
          Renders this image to the specified stream as a raster image.
abstract  void setColor(java.awt.Color color)
          Sets the current color to the specified value.
 void showImage()
          Entry point for showing an image.
abstract  int width()
          Returns the width of this image, in pixels.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Image

public Image()
Method Detail

clone

protected java.lang.Object clone()
                          throws java.lang.CloneNotSupportedException
Overrides:
clone in class java.lang.Object
Throws:
java.lang.CloneNotSupportedException
See Also:
Object.clone()

drawLine

public abstract void drawLine(int x1,
                              int y1,
                              int x2,
                              int y2)
Draws a line in the current colour, between the points ( x1, y1 ) and ( x2, y2 ).

Parameters:
x1 - the first point's x coordinate
y1 - the first point's y coordinate
x2 - the second point's x coordinate
y2 - the second point's y coordinate

drawOval

public abstract void drawOval(int x,
                              int y,
                              int width,
                              int height)
Draws the outline of an oval in the current color. The oval fits in the rectangle specified by the starting point ( x, y ) coordinate and the rectangles width and height.

Parameters:
x - the starting point x coordinate
y - the starting point y coordinate
width - the width of the rectangle the oval fits in
height - the height of the rectangle the oval fits in

drawRect

public abstract void drawRect(int x,
                              int y,
                              int width,
                              int height)
Draws the outline of a rectangle in the current color. The rectangle is specified by the starting point ( x, y ) coordinate, the width and height.

Parameters:
x - the starting point x coordinate
y - the starting point y coordinate
width - the width of the rectangle
height - the height of the rectangle

drawString

public abstract void drawString(java.lang.String s,
                                int x,
                                int y)
Draws the text using the current font, in the current color, at the specified position.

Parameters:
s - the string to draw
x - the starting point x coordinate
y - the starting point y coordinate

fillOval

public abstract void fillOval(int x,
                              int y,
                              int width,
                              int height)
Draws a filled oval in the current color. The oval fits in the rectangle specified by the starting point ( x, y ) coordinate and the rectangles width and height.

Parameters:
x - the starting point x coordinate
y - the starting point y coordinate
width - the width of the rectangle the oval fits in
height - the height of the rectangle the oval fits in

fillRect

public abstract void fillRect(int x,
                              int y,
                              int width,
                              int height)
Draws a filled rectangle in the current color. The rectangle is specified by the starting point ( x, y ) coordinate, the width and height.

Parameters:
x - the starting point x coordinate
y - the starting point y coordinate
width - the width of the rectangle
height - the height of the rectangle

getGraphics2D

public abstract java.awt.Graphics2D getGraphics2D()
Returns a Graphics2D object to draw on this image.

Returns:
a Graphics2D object to draw on this image.

height

public abstract int height()
Returns the height of this image, in pixels.

Returns:
the height of this image

renderAsRasterToStream

public abstract void renderAsRasterToStream(java.io.OutputStream ostream,
                                            ImageRender render)
                                     throws java.io.IOException
Renders this image to the specified stream as a raster image.

Parameters:
ostream - the stream to render to
render - the image renderer to use for rasterising the image
Throws:
java.io.IOException - thrown if problems occur with the stream

setColor

public abstract void setColor(java.awt.Color color)
Sets the current color to the specified value.

Parameters:
color - the new color to draw in

showImage

public void showImage()
Entry point for showing an image. This contains the basic frame setup code that is relevant to all image types.


width

public abstract int width()
Returns the width of this image, in pixels.

Returns:
the width of this image


Copyright © 2001-2007 Open World Ltd. All Rights Reserved.