Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.vistech.shapes
Class Box

    java.lang.Object
      |
      +--com.vistech.shapes.Shapes
            |
            +--com.vistech.shapes.Box

All Implemented Interfaces:
  java.lang.Cloneable, Drawable, Fillable, java.io.Serializable

public class Box
extends Shapes
implements Fillable

Represents an interactively drawable rectangle. Although the Box shape is a rectangle, it is drawn as a polygon in this implementation. The drawing of a rectangle requires the upper left hand corner coordinates as the starting position. So the drawRect will draw the rectangle from top to bottom and left to right. If the current position moves up or right with respect to the starting position, the rectangle will not be drawn because the width and height values are negative. So there are two options. 1. Switch the starting and current positions whenever the rectangle is drawn from bottom to top or right to left. 2. Use the drawPolygon method. We chose the second option because it involved less programming.

Version:
  1.0 30 July 1999
Author:
  Larry Rodrigues
See Also:
  Serialized Form

Field Summary
`protected int[]` | `xp` xp the x coordinates of the Box corners
`protected int[]` | `yp` yp the y coordinates of the Box corners

Fields inherited from class com.vistech.shapes.Shapes
`basicStroke, cur, drawingColor, fillColor, fillOn, font, path, shapeCount, smallRectsOn, st`

Fields inherited from interface com.vistech.shapes.Drawable
`ANNOTEXT, ARROW, BOX, CUBIC_CURVE, CURVE, DOUBLE_HEADED_ARROW, ELLIPSE, LINE, NONE, POLYGON`

Constructor Summary
`Box()`

Method Summary
`boolean` | `contains(java.awt.Graphics2D g, int x, int y)` Vhecks whether the specified point contained in the shape.
`void` | `draw(java.awt.Graphics2D g)` Draws the shape permanently, which happens when the mouse is released.
`void` | `drawInteractive(java.awt.Graphics2D g)` Draws interactively on a Graphics context g.
`void` | `drawPolygon(java.awt.Graphics2D g, int[] x, int[] y)` Draws the box with the specified vertices.
`void` | `drawSmallRects(java.awt.Graphics2D g)` Draws small rectangle at the shape corners to indicate that the shape is active.
`void` | `erase(java.awt.Graphics2D g)` Erases the box
`void` | `fill(java.awt.Graphics2D g, java.awt.Color color)` Fills with a given color.
`void` | `fillPolygon(java.awt.Graphics2D g, int[] x, int[] y)` Fills the box.
`void` | `init(int x, int y)` Initializes the Box parameters.
`void` | `move(java.awt.Graphics2D g, int diffx, int diffy)` Moves the shape by a specified displacement.
`void` | `setCurrentPosition(java.awt.Point cp)` Sets the current position.

Methods inherited from class com.vistech.shapes.Shapes
`contains, copy, getCurrentPosition, getDrawingColor, getFillColor, getFillOn, getFont, getGeneralPath, getShapeCount, getSmallRectsOn, getStartPosition, getStroke, setDrawingColor, setFillColor, setFillOn, setFont, setGeneralPath, setShapeCount, setSmallRectsOn, setStartPosition, setStroke`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### xp

    protected int[] xp

  xp the x coordinates of the Box corners

### yp

    protected int[] yp

  yp the y coordinates of the Box corners

Constructor Detail

### Box

    public Box()

Method Detail

### init

    public void init(int x,
                     int y)

  Initializes the Box parameters. The arguments provide the starting point of the box which may be the upper left hand corner(ULHC) or bottom righthand corner coordinates(BRHC) of the Box.
  Specified by:
    `init` in interface `Drawable`
  Overrides:
    `init` in class `Shapes`
  Parameters:
    `x` - the x coordinate of the starting position.
    `y` - the y coordinate of the starting poistion.

### setCurrentPosition

    public void setCurrentPosition(java.awt.Point cp)

  Sets the current position.
  Specified by:
    `setCurrentPosition` in interface `Drawable`
  Overrides:
    `setCurrentPosition` in class `Shapes`
  Parameters:
    `x` - the x coordinate of the current position.
    `y` - the y coordinate of the current poistion.

### drawInteractive

    public void drawInteractive(java.awt.Graphics2D g)

  Draws interactively on a Graphics context g. This API does not check whether the Box overflows the borders of the component. This method uses the XOR paint mode. It erases the previously drawn shape and draws a new shape in its place.
  Specified by:
    `drawInteractive` in interface `Drawable`
  Parameters:
    `g` - the graphics object on which the shape is to be drawn.

### draw

    public void draw(java.awt.Graphics2D g)

  Description copied from interface: `Drawable`
  Draws the shape permanently, which happens when the mouse is released.
  Specified by:
    `draw` in interface `Drawable`
  Following copied from interface: `com.vistech.shapes.Drawable`
  Parameters:
    `g` - the graphcs context on which the shape is drawn.

### move

    public void move(java.awt.Graphics2D g,
                     int diffx,
                     int diffy)

  Description copied from interface: `Drawable`
  Moves the shape by a specified displacement.
  Specified by:
    `move` in interface `Drawable`
  Following copied from interface: `com.vistech.shapes.Drawable`
  Parameters:
    `x` - the displacement.
    `y` - the displacement.

### erase

    public void erase(java.awt.Graphics2D g)

  Erases the box
  Specified by:
    `erase` in interface `Drawable`
  Parameters:
    `g` - the graphics object on which the shape is drawn.

### fill

    public void fill(java.awt.Graphics2D g,
                     java.awt.Color color)

  Fills with a given color.
  Specified by:
    `fill` in interface `Fillable`
  Parameters:
    `g` - the graphics object on which the shape is to be drawn.
    `color` - the filling color.

### contains

    public boolean contains(java.awt.Graphics2D g,
                            int x,
                            int y)

  Description copied from class: `Shapes`
  Vhecks whether the specified point contained in the shape.
  Overrides:
    `contains` in class `Shapes`
  Following copied from class: `com.vistech.shapes.Shapes`
  Parameters:
    `g` - the graphics context on which the shape was drawn.
    `x` - the coordinate of the point that is being checked for containment.
    `y` - the coordinate of the point that is being checked for containment.

### drawSmallRects

    public void drawSmallRects(java.awt.Graphics2D g)

  Description copied from class: `Shapes`
  Draws small rectangle at the shape corners to indicate that the shape is active. For example, a shape that is being moved is surrounded by small rectagles at the shape corners. small rectab
  Overrides:
    `drawSmallRects` in class `Shapes`
  Following copied from class: `com.vistech.shapes.Shapes`
  Parameters:
    `g` - the graphics context on which the shape was drawn.

### drawPolygon

    public void drawPolygon(java.awt.Graphics2D g,
                            int[] x,
                            int[] y)

  Draws the box with the specified vertices.
  Parameters:
    `g` - the graphics object on which the shape is to be drawn.
    `x` - an array of x coordinates.
    `y` - an array of y coordinates.

### fillPolygon

    public void fillPolygon(java.awt.Graphics2D g,
                            int[] x,
                            int[] y)

  Fills the box.
  Parameters:
    `g` - the graphics object on which the shape is to be drawn.
    `x` - an array of x coordinates.
    `y` - an array of y coordinates.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD