funworld
Class WorldImage

java.lang.Object
  extended by funworld.WorldImage
Direct Known Subclasses:
CircleImage, DiskImage, EllipseImage, FrameImage, FromFileImage, LineImage, OvalImage, OverlayImagesXY, RectangleImage, TextImage, TriangleImage

public abstract class WorldImage
extends java.lang.Object

The parent class for all images drawn by the World when drawing on its Canvas.

Since:
February 4 2012, April 25 2012
Author:
Viera K. Proulx

Field Summary
 java.awt.Color color
           
 geometry.Posn pinhole
           
 
Constructor Summary
WorldImage(geometry.Posn pinhole, java.awt.Color color)
          Every image has a pinhole (Posn) and a color (Color).
WorldImage(geometry.Posn pinhole, colors.IColor color)
          A convenience constructor to supply the color in the form of IColor.
 
Method Summary
abstract  int getHeight()
          Produce the height of this image
abstract  int getWidth()
          Produce the width of this image
abstract  WorldImage movePinhole(int dx, int dy)
          Produce the image with the pinhole moved by the given (dx, dy)
abstract  WorldImage moveTo(geometry.Posn p)
          Produce the image with the pinhole moved to the given location
 WorldImage overlayImages(WorldImage... args)
          A convenience method that allows us to combine several images into one on top of this image without the need to explicitly construct OverlayImages
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pinhole

public geometry.Posn pinhole

color

public java.awt.Color color
Constructor Detail

WorldImage

public WorldImage(geometry.Posn pinhole,
                  java.awt.Color color)
Every image has a pinhole (Posn) and a color (Color). The color for the images derived from image files, or constructed by a combination of several images is set to Color.white and ignored in drawing the images.

Parameters:
pinhole - the pinhole location for this image
color - the color for this image

WorldImage

public WorldImage(geometry.Posn pinhole,
                  colors.IColor color)
A convenience constructor to supply the color in the form of IColor.

Parameters:
pinhole - the pinhole location for this image
color - the color for this image
Method Detail

movePinhole

public abstract WorldImage movePinhole(int dx,
                                       int dy)
Produce the image with the pinhole moved by the given (dx, dy)

Parameters:
dx - the horizontal offset
dy - the vertical offset

moveTo

public abstract WorldImage moveTo(geometry.Posn p)
Produce the image with the pinhole moved to the given location

Parameters:
p - the given location

overlayImages

public WorldImage overlayImages(WorldImage... args)

A convenience method that allows us to combine several images into one on top of this image without the need to explicitly construct OverlayImages

The pinhole is placed in the middle of all overlayed images.

Parameters:
args - an arbitrarily long list of WorldImage to add to this image
Returns:
the composite image

getWidth

public abstract int getWidth()
Produce the width of this image

Returns:
the width of this image

getHeight

public abstract int getHeight()
Produce the height of this image

Returns:
the height of this image