com.vistech.graphics
Class DrawShapes

java.lang.Object
  |
  +--com.vistech.graphics.DrawShapes
All Implemented Interfaces:
DrawShapesController, java.util.EventListener, java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener

public class DrawShapes
extends java.lang.Object
implements DrawShapesController, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.KeyListener

Enables users to interactively draw a variety of shapes.

Version:
1.0 24 July 199
Author:
Larry Rodrigues This class performs shape-related tasks.These include draw, move, fill, erase, copy and paste. It expects a client object to set the task type and shape type.

Field Summary
protected  GraphicsDisplay grCanvas
           
protected  int savedShapeType
           
protected  int shapeType
           
 
Fields inherited from interface com.vistech.graphics.DrawShapesController
COPY, DRAW, ERASE, ERASE_ALL, FILL, LOAD, MOVE, PASTE, SAVE
 
Constructor Summary
DrawShapes(GraphicsDisplay c)
           
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener p)
           
 void addShapesEventListener(ShapesEventListener s)
           
protected  void createAndDrawShape(int x, int y)
           
protected  void drawGraphics(int x, int y)
           
 void eraseShapes()
           
protected  void fireShapesEvent()
           
 int getCommand()
           
 java.lang.String getCommandAsString()
           
static java.lang.String getCommandAsText(int command)
           
 int getShapeType()
           
protected  void hitTest(int x, int y, int command)
           
protected  void initGraphics(int x, int y)
           
 void keyPressed(java.awt.event.KeyEvent k)
           
 void keyReleased(java.awt.event.KeyEvent k)
           
 void keyTyped(java.awt.event.KeyEvent k)
           
 void loadShapes()
           
static void main(java.lang.String[] args)
           
 void mouseClicked(java.awt.event.MouseEvent e)
           
 void mouseDragged(java.awt.event.MouseEvent e)
           
 void mouseEntered(java.awt.event.MouseEvent e)
           
 void mouseExited(java.awt.event.MouseEvent e)
           
 void mouseMoved(java.awt.event.MouseEvent e)
           
 void mousePressed(java.awt.event.MouseEvent e)
           
 void mouseReleased(java.awt.event.MouseEvent e)
           
protected  void moveShape(int x, int y)
           
protected  void pasteShape(int x, int y)
           
protected  void redraw()
           
protected  void releaseDrag(int x, int y)
           
 void removePropertyChangeListener(java.beans.PropertyChangeListener p)
           
 void removeShapesEventListener(ShapesEventListener s)
           
 void reset()
           
 void saveShapes()
           
 void setCommand(int command)
          Sets the operation type, which are defined as constants in this interface.
 void setCommandAsString(java.lang.String command)
           
 void setShapesOn(boolean onOrOff)
           
 void setShapeType(int shapeType)
          Sets the shape type
 void setTextOn(boolean onOrOff)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

shapeType

protected int shapeType

savedShapeType

protected int savedShapeType

grCanvas

protected GraphicsDisplay grCanvas
Constructor Detail

DrawShapes

public DrawShapes(GraphicsDisplay c)
Method Detail

setTextOn

public void setTextOn(boolean onOrOff)

setShapesOn

public void setShapesOn(boolean onOrOff)

setShapeType

public void setShapeType(int shapeType)
Description copied from interface: DrawShapesController
Sets the shape type
Specified by:
setShapeType in interface DrawShapesController
Following copied from interface: com.vistech.graphics.DrawShapesController
Parameters:
shapeType - the shape type.

getShapeType

public int getShapeType()
Specified by:
getShapeType in interface DrawShapesController

setCommandAsString

public void setCommandAsString(java.lang.String command)

getCommandAsString

public java.lang.String getCommandAsString()

setCommand

public void setCommand(int command)
Description copied from interface: DrawShapesController
Sets the operation type, which are defined as constants in this interface.
Specified by:
setCommand in interface DrawShapesController
Following copied from interface: com.vistech.graphics.DrawShapesController
Parameters:
command - the operation type.

getCommand

public int getCommand()
Specified by:
getCommand in interface DrawShapesController

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Specified by:
mouseReleased in interface java.awt.event.MouseListener

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Specified by:
mouseClicked in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Specified by:
mouseExited in interface java.awt.event.MouseListener

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener

initGraphics

protected void initGraphics(int x,
                            int y)

createAndDrawShape

protected void createAndDrawShape(int x,
                                  int y)

pasteShape

protected void pasteShape(int x,
                          int y)

moveShape

protected void moveShape(int x,
                         int y)

hitTest

protected void hitTest(int x,
                       int y,
                       int command)

drawGraphics

protected void drawGraphics(int x,
                            int y)

releaseDrag

protected void releaseDrag(int x,
                           int y)

keyTyped

public void keyTyped(java.awt.event.KeyEvent k)
Specified by:
keyTyped in interface java.awt.event.KeyListener

keyReleased

public void keyReleased(java.awt.event.KeyEvent k)
Specified by:
keyReleased in interface java.awt.event.KeyListener

keyPressed

public void keyPressed(java.awt.event.KeyEvent k)
Specified by:
keyPressed in interface java.awt.event.KeyListener

redraw

protected void redraw()

loadShapes

public void loadShapes()

saveShapes

public void saveShapes()

eraseShapes

public void eraseShapes()

reset

public void reset()

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener p)

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener p)

addShapesEventListener

public void addShapesEventListener(ShapesEventListener s)

removeShapesEventListener

public void removeShapesEventListener(ShapesEventListener s)

fireShapesEvent

protected void fireShapesEvent()

main

public static void main(java.lang.String[] args)

getCommandAsText

public static java.lang.String getCommandAsText(int command)