classes.shapes
Class RectangleShape

java.lang.Object
  extended by interfaces.CommandColleague
      extended by classes.shapes.RectangleShape
All Implemented Interfaces:
IShape, IShapeDrawer, IVisitable, java.lang.Cloneable

public class RectangleShape
extends CommandColleague
implements IShape, IVisitable

Class for rectangle shape objects

Version:
1.0, 21-Mar-07
Author:
Prathab, Mukesh

Field Summary
 boolean isPermanentShape
           
 ShapeCoordinates shapeCoordinates
           
 
Fields inherited from class interfaces.CommandColleague
commandMediator
 
Constructor Summary
RectangleShape(ShapeCoordinates shapeCoordinates, ICommandMediator commandMediator)
          Initializes with the deafult shape coordinates and mediator object
 
Method Summary
 void accept(IShapeVisitor shapeVisitor)
          Accepts the visitor and execute its method
 void changeShapeXYCoordinates(int x, int y)
          Relocate the shape at external specified location
 java.lang.Object clone()
          Creates clone of the object
 void drawShape()
          Draws the rectangle shape This method acts as proxy to draw the shape.
 void drawShape(int x, int y)
          Draws the shape at the specified location
 java.awt.Color getColor()
          Returns the color attribute for the shape
 boolean IsPermanentShape()
          Return whether the shape is permanent
 void setAsPermanentShape(boolean isPermanent)
          Sets whether the shape is permanent or tempory with respect to drawing
 void setColor(java.awt.Color color)
          Sets the color attribute for the shape
 void setCommandObject(Command command)
          Set the Command object which contains the commands to draw the shape
 void setGraphicsObject(java.awt.Graphics g)
          Set the Graphics object which is responsible to draw the graphics
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

shapeCoordinates

public ShapeCoordinates shapeCoordinates

isPermanentShape

public boolean isPermanentShape
Constructor Detail

RectangleShape

public RectangleShape(ShapeCoordinates shapeCoordinates,
                      ICommandMediator commandMediator)
Initializes with the deafult shape coordinates and mediator object

See Also:
ShapeCoordinates, ICommandMediator
Method Detail

drawShape

public void drawShape()
Draws the rectangle shape This method acts as proxy to draw the shape. The drawing command is encapsulated using Command object and sent to the command mediator (CommandContainer) object

Specified by:
drawShape in interface IShapeDrawer
See Also:
IShapeDrawer.drawShape(), Command

setGraphicsObject

public void setGraphicsObject(java.awt.Graphics g)
Set the Graphics object which is responsible to draw the graphics

Specified by:
setGraphicsObject in interface IShapeDrawer
Parameters:
g - Graphics object to be set
See Also:
IShapeDrawer.setGraphicsObject(java.awt.Graphics)

setCommandObject

public void setCommandObject(Command command)
Set the Command object which contains the commands to draw the shape

Specified by:
setCommandObject in interface IShapeDrawer
Parameters:
command - Command object to set
See Also:
IShapeDrawer.setCommandObject(types.Command)

drawShape

public void drawShape(int x,
                      int y)
Draws the shape at the specified location

Specified by:
drawShape in interface IShape
Parameters:
x - x-coordinate
y - y-coordinate
See Also:
IShape.drawShape(int, int)

changeShapeXYCoordinates

public void changeShapeXYCoordinates(int x,
                                     int y)
Relocate the shape at external specified location

Specified by:
changeShapeXYCoordinates in interface IShape
Parameters:
x - x-coordinate
y - y-coordinate
See Also:
IShape.drawShape(int, int)

setAsPermanentShape

public void setAsPermanentShape(boolean isPermanent)
Sets whether the shape is permanent or tempory with respect to drawing

Specified by:
setAsPermanentShape in interface IShape
Parameters:
isPermanent - status of the shape
See Also:
IShape.setAsPermanentShape(boolean)

IsPermanentShape

public boolean IsPermanentShape()
Return whether the shape is permanent

Specified by:
IsPermanentShape in interface IShape
Returns:
true if shape is permanent
See Also:
IShape.IsPermanentShape()

clone

public java.lang.Object clone()
Creates clone of the object

Specified by:
clone in interface IShape
Overrides:
clone in class java.lang.Object
Returns:
the clone of the current object
See Also:
IShape.clone()

setColor

public void setColor(java.awt.Color color)
Sets the color attribute for the shape

Specified by:
setColor in interface IShape
Parameters:
color - color of the shape
See Also:
IShape.setColor(java.awt.Color)

getColor

public java.awt.Color getColor()
Returns the color attribute for the shape

Specified by:
getColor in interface IShape
Returns:
object of the shape
See Also:
IShape.getColor()

accept

public void accept(IShapeVisitor shapeVisitor)
Accepts the visitor and execute its method

Specified by:
accept in interface IVisitable
Parameters:
shapeVisitor - the shapeVisitor object to be accepted
See Also:
IVisitable.accept(interfaces.IShapeVisitor)