org.niffty
Class DrawShape

java.lang.Object
  |
  +--org.niffty.DrawShape

public class DrawShape
extends java.lang.Object

A DrawShape holds the points defining a shape to be drawn by the Graphics class. A DrawShape should not be confused with the types implementing the java.awt.Shape interface.


Constructor Summary
DrawShape()
          Creates an empty shape where draw does nothing.
DrawShape(int[] points)
          Creates new DrawShape to be drawn by Graphics drawPolyLine.
 
Method Summary
 void draw(java.awt.Graphics graphics, FinalPoint offset)
          Same as draw (Graphics, int, int) but takes the offset as a FinalPoint.
 void draw(java.awt.Graphics graphics, int offsetX, int offsetY)
          Draw the shape with the given offset using Graphics drawPolyLine.
 void drawLeftOf(java.awt.Graphics graphics, DrawShape target, FinalPoint targetOffset, int gap)
          Same as drawLeftOf (Graphics, DrawShape, int, int, int) but takes the offset as a FinalPoint.
 void drawLeftOf(java.awt.Graphics graphics, DrawShape target, int targetOffsetX, int targetOffsetY, int gap)
          Draw this shape so that it touches the left edge of the target shape, or if gap is > 0 then place that many pixels of gap between the two shapes.
 int getBottomEdge()
          Return the bottom edge of the shape which is the maximum Y coordinate.
 int getLeftEdge()
          Return the left edge of the shape which is the minimum X coordinate.
 int getRightEdge()
          Return the right edge of the shape which is the maximum X coordinate.
 int getTopEdge()
          Return the top edge of the shape which is the minimum Y coordinate.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DrawShape

public DrawShape()
Creates an empty shape where draw does nothing.


DrawShape

public DrawShape(int[] points)
Creates new DrawShape to be drawn by Graphics drawPolyLine. NOTE: drawPolyLine does not draw the endpoint of the last line segment, so the supplied points must compensate for this.

Parameters:
points - An array of size 2 * count, where count is the number of points. The array has the format: {x0, y0, x1, y1, ...} where x0,y0 is the coordinates of the first points, etc.
Method Detail

draw

public void draw(java.awt.Graphics graphics,
                 int offsetX,
                 int offsetY)
Draw the shape with the given offset using Graphics drawPolyLine.

Parameters:
graphics - the Graphics context used to draw the shape
offsetX - the X amount to offset the shape when drawing
offsetY - the Y amount to offset the shape when drawing

draw

public void draw(java.awt.Graphics graphics,
                 FinalPoint offset)
Same as draw (Graphics, int, int) but takes the offset as a FinalPoint.

See Also:
draw(Graphics, int, int)

drawLeftOf

public void drawLeftOf(java.awt.Graphics graphics,
                       DrawShape target,
                       int targetOffsetX,
                       int targetOffsetY,
                       int gap)
Draw this shape so that it touches the left edge of the target shape, or if gap is > 0 then place that many pixels of gap between the two shapes.

Parameters:
graphics - the Graphics context used to draw the shape
target - the target shape on whose left edge this is drawn
targetOffsetX - the X amount to offset the target shape. Note that the target shape is placed with the offset and this shape is placed to the left of it.
targetOffsetY - the Y amount to offset the target shape
gap - amount of space between the two shapes. If zero, then the two shapes touch. If 1, then there is one pixel between them, etc.
See Also:
draw(java.awt.Graphics, int, int)

drawLeftOf

public void drawLeftOf(java.awt.Graphics graphics,
                       DrawShape target,
                       FinalPoint targetOffset,
                       int gap)
Same as drawLeftOf (Graphics, DrawShape, int, int, int) but takes the offset as a FinalPoint.

See Also:
(Graphics, DrawShape, int, int, int)

getLeftEdge

public int getLeftEdge()
Return the left edge of the shape which is the minimum X coordinate.


getRightEdge

public int getRightEdge()
Return the right edge of the shape which is the maximum X coordinate.


getTopEdge

public int getTopEdge()
Return the top edge of the shape which is the minimum Y coordinate.


getBottomEdge

public int getBottomEdge()
Return the bottom edge of the shape which is the maximum Y coordinate.