GP.Graphics
Class Shape

java.lang.Object
  |
  +--GP.Graphics.Shape
All Implemented Interfaces:
Behavioral, Colorable, Graphic, Movable, Orientable, Originable, Playable, Positionable, Reactive, Refreshable, Scalable, Selectable, Viewable
Direct Known Subclasses:
Arc, Group, Hexagon, Image, Line, GP.Containers.Manager, None, Oval, Pie, Rectangle, Text, Triangle

public abstract class Shape
extends java.lang.Object
implements Graphic, Reactive


Field Summary
static int ourNumShapes
           
 
Constructor Summary
Shape()
          default size 50x50, default color black, default position 0,0, default oritentation 0 degrees, default visible
Shape(Container container, Drawer drawer)
           
Shape(Shape shape)
          Create a copy of the current shape.
 
Method Summary
 void Act()
          This method is automatically called when the user clicks (presses and releases the mouse button) inside the object.
 void AddBehavior(Behavior behavior)
          This method can be used to add a new behavioral object to this object.
 void ApplyBehaviors(double time)
           
 void ApplyInstincts(double time)
           
abstract  Graphic Copy()
           
 void DeSelect()
           
 boolean equals(java.lang.Object other)
           
 void Fill()
           
 void Frame()
           
 GP.Containers.Applet GetApplet()
           
 Size GetBoxBoundedSize()
           
 Color GetColor()
          This method should return the current color of the object
 Container GetContainer()
          This method should return the graphical container of the object.
 double GetCurrentTime()
          This method should get the object's current time
 GP.Drawers.FillStyle GetFillStyle()
           
 Orientation GetOrientation()
          This method should return the current orientation of the object.
 Position GetPivot()
           
 Position GetPosition()
          This method should return the current position of the object.
 Size GetSize()
          This method should return the current size of the object.
 void Hide()
          Hide the graphical object so that it is no longer visible on the screen.
 boolean IsPositionInside(Position toTest)
          This methods should determine whether the position passed into it is inside the graphical boundries of the object, and return the result of that calculation.
 boolean IsVisible()
          This method should determine if the object is in a visible state, and return the result of that determination.
 void Move(double xChange, double yChange)
           
 void Move(Value xChange, Value yChange)
           
 void Move(Velocity velocity)
           
 void MoveBackward()
           
 void MoveForward()
           
 void MoveToBack()
          This method is to be used to control the layering of drawn objects.
 void MoveToFront()
           
 void Pause()
          This method should tell the object to pause what it is doing.
 void Play()
          This method should tell the object to start playing.
 boolean PositionIsOnlyInsideMe(Position position)
          This method should determine whether the position passed into it is inside the graphical boundries of the object, but not within any of its sub-objects, and return the result of that calculation.
 Size PreferedSize()
           
 void React()
          This method is automatically called when the user clicks (presses and releases the mouse button) inside the object.
 void Refresh()
          This is a method used internally in this package and should not be called or redefined unless you know what you're doing. This method should draw the object to the offscreen graphic.
 void RemoveAllBehaviors()
          This method removes all existing behavioral objects from this object.
 void RemoveBehavior(Behavior behavior)
          This method can be used to remove an existing behavioral object from this object.
 void ReplaceAllBehaviors(Behavior behavior)
           
 void Scale(double widthFactor, double heightFactor)
          This method should scale the object to the proper size give the height and width multiplication factors.
 void Scale(Size factor)
           
 void Scale(Value widthFactor, Value heightFactor)
           
 void Select()
           
 void SetColor(Color color)
          This method should set the current color of the object.
 void SetContainer(Container container)
          This method will modify which container the shape is shown in.
 void SetFillStyle(GP.Drawers.FillStyle fillStyle)
           
 void SetOrientation(Orientation orientation)
          This method should set the current orientation of the object.
 void SetPivot(Position pivot)
           
 void SetPosition(Position position)
          This method should set the current position of the object.
 void SetSize(Size size)
          This method should set the current size of the object.
 void Show()
          Show the graphical object in its current container.
 void Show(Container container)
          Show the graphical object in a new container
 void Start()
           
 void Stop()
          This method should tell the object to stop what it is doing.
 java.lang.String toString()
           
 void Turn(double change)
           
 void Turn(double change, Position pivot)
           
 void Turn(Orientation change)
           
 void Turn(Orientation change, Position pivot)
           
 void Turn(Value change)
           
 void Turn(Value change, Position pivot)
           
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ourNumShapes

public static int ourNumShapes
Constructor Detail

Shape

public Shape()
default size 50x50, default color black, default position 0,0, default oritentation 0 degrees, default visible

Shape

public Shape(Container container,
             Drawer drawer)
Parameters:
container -  
drawer -  

Shape

public Shape(Shape shape)
Create a copy of the current shape.
Parameters:
shape -  
Method Detail

equals

public boolean equals(java.lang.Object other)
Overrides:
equals in class java.lang.Object

GetContainer

public Container GetContainer()
Description copied from interface: Graphic
This method should return the graphical container of the object.
Specified by:
GetContainer in interface Graphic
Following copied from interface: GP.Graphic
Returns:
the graphical container

GetApplet

public GP.Containers.Applet GetApplet()

PreferedSize

public Size PreferedSize()
Specified by:
PreferedSize in interface Graphic
Following copied from interface: GP.Graphic
Returns:
the prefered drawing size

SetColor

public void SetColor(Color color)
Description copied from interface: Colorable
This method should set the current color of the object.
Specified by:
SetColor in interface Colorable
Following copied from interface: GP.Colorable
Parameters:
color - the new color

GetColor

public Color GetColor()
Description copied from interface: Colorable
This method should return the current color of the object
Specified by:
GetColor in interface Colorable
Following copied from interface: GP.Colorable
Returns:
the current color of the object

Fill

public void Fill()

Frame

public void Frame()

SetFillStyle

public void SetFillStyle(GP.Drawers.FillStyle fillStyle)
Specified by:
SetFillStyle in interface Graphic

GetFillStyle

public GP.Drawers.FillStyle GetFillStyle()
Specified by:
GetFillStyle in interface Graphic

SetSize

public void SetSize(Size size)
Description copied from interface: Scalable
This method should set the current size of the object.
Specified by:
SetSize in interface Scalable
Following copied from interface: GP.Scalable
Parameters:
size - the new size

GetSize

public Size GetSize()
Description copied from interface: Scalable
This method should return the current size of the object.
Specified by:
GetSize in interface Scalable
Following copied from interface: GP.Scalable
Returns:
the current size of the object

Scale

public void Scale(double widthFactor,
                  double heightFactor)
Description copied from interface: Scalable
This method should scale the object to the proper size give the height and width multiplication factors.
Specified by:
Scale in interface Scalable
Following copied from interface: GP.Scalable
Parameters:
widthFactor -  
heightFactor -  

Scale

public void Scale(Value widthFactor,
                  Value heightFactor)
Specified by:
Scale in interface Scalable

Scale

public void Scale(Size factor)
Specified by:
Scale in interface Scalable

SetPosition

public void SetPosition(Position position)
Description copied from interface: Positionable
This method should set the current position of the object.
Specified by:
SetPosition in interface Positionable
Following copied from interface: GP.Positionable
Parameters:
position - the new position

GetPosition

public Position GetPosition()
Description copied from interface: Positionable
This method should return the current position of the object.
Specified by:
GetPosition in interface Positionable
Following copied from interface: GP.Positionable
Returns:
the current position of the object

Move

public void Move(double xChange,
                 double yChange)
Specified by:
Move in interface Positionable

Move

public void Move(Value xChange,
                 Value yChange)
Specified by:
Move in interface Positionable

Move

public void Move(Velocity velocity)
Specified by:
Move in interface Positionable

SetPivot

public void SetPivot(Position pivot)

GetPivot

public Position GetPivot()
Specified by:
GetPivot in interface Orientable

SetOrientation

public void SetOrientation(Orientation orientation)
Description copied from interface: Orientable
This method should set the current orientation of the object.
Specified by:
SetOrientation in interface Orientable
Following copied from interface: GP.Orientable
Parameters:
orientation - the new orientation

GetOrientation

public Orientation GetOrientation()
Description copied from interface: Orientable
This method should return the current orientation of the object.
Specified by:
GetOrientation in interface Orientable
Following copied from interface: GP.Orientable
Returns:
the current orientation of the object

Turn

public void Turn(double change)
Specified by:
Turn in interface Orientable

Turn

public void Turn(Value change)
Specified by:
Turn in interface Orientable

Turn

public void Turn(Orientation change)
Specified by:
Turn in interface Orientable

Turn

public void Turn(double change,
                 Position pivot)
Specified by:
Turn in interface Orientable

Turn

public void Turn(Value change,
                 Position pivot)
Specified by:
Turn in interface Orientable

Turn

public void Turn(Orientation change,
                 Position pivot)
Specified by:
Turn in interface Orientable

AddBehavior

public void AddBehavior(Behavior behavior)
Description copied from interface: Behavioral
This method can be used to add a new behavioral object to this object. There should be no limit to how many behavioral object that you can add. Behavioral object added with this method will work in parallel. Their order of being applied is not guarenteed, only that all behaviors will be appiled at the same time interval.
Specified by:
AddBehavior in interface Behavioral
Following copied from interface: GP.Behavioral
Parameters:
behavior - the new behavior to be added

RemoveBehavior

public void RemoveBehavior(Behavior behavior)
Description copied from interface: Behavioral
This method can be used to remove an existing behavioral object from this object. No error is returned if the behavior is not found to be removed.
Specified by:
RemoveBehavior in interface Behavioral
Following copied from interface: GP.Behavioral
Parameters:
behavior - the existing behavior to be removed

RemoveAllBehaviors

public void RemoveAllBehaviors()
Description copied from interface: Behavioral
This method removes all existing behavioral objects from this object. No error is returned if there are no existing behaviors on this object.
Specified by:
RemoveAllBehaviors in interface Behavioral

ReplaceAllBehaviors

public void ReplaceAllBehaviors(Behavior behavior)
Specified by:
ReplaceAllBehaviors in interface Behavioral
Following copied from interface: GP.Behavioral
Parameters:
behavior - the new behvaior that will replace all existing behaviors on this object

IsPositionInside

public boolean IsPositionInside(Position toTest)
Description copied from interface: Graphic
This methods should determine whether the position passed into it is inside the graphical boundries of the object, and return the result of that calculation.
Specified by:
IsPositionInside in interface Graphic
Following copied from interface: GP.Graphic
Parameters:
position - the position in question
Returns:
true if the position is inside, false otherwise

PositionIsOnlyInsideMe

public boolean PositionIsOnlyInsideMe(Position position)
Description copied from interface: Graphic
This method should determine whether the position passed into it is inside the graphical boundries of the object, but not within any of its sub-objects, and return the result of that calculation. This will usually be an identaical result to IsPositionInside(GP.Attributes.Position), but may differ when dealing with composite structures such as GP.MultiManagers
Specified by:
PositionIsOnlyInsideMe in interface Graphic
Following copied from interface: GP.Graphic
Parameters:
position - the position in question
Returns:
true if the position is inside this object only, false otherwise

Copy

public abstract Graphic Copy()
Specified by:
Copy in interface Graphic

Start

public void Start()

Play

public void Play()
Description copied from interface: Playable
This method should tell the object to start playing.
Specified by:
Play in interface Playable

Pause

public void Pause()
Description copied from interface: Playable
This method should tell the object to pause what it is doing.
Specified by:
Pause in interface Playable

Stop

public void Stop()
Description copied from interface: Playable
This method should tell the object to stop what it is doing.
Specified by:
Stop in interface Playable

GetCurrentTime

public double GetCurrentTime()
Description copied from interface: Playable
This method should get the object's current time
Specified by:
GetCurrentTime in interface Playable
Following copied from interface: GP.Playable
Returns:
the current time in seconds

ApplyBehaviors

public void ApplyBehaviors(double time)
Specified by:
ApplyBehaviors in interface Behavioral
Following copied from interface: GP.Behavioral
Parameters:
time - the current time in seconds

ApplyInstincts

public void ApplyInstincts(double time)
Specified by:
ApplyInstincts in interface Behavioral
Following copied from interface: GP.Behavioral
Parameters:
time - the current time in seconds

Refresh

public void Refresh()
Description copied from interface: Refreshable
This is a method used internally in this package and should not be called or redefined unless you know what you're doing. This method should draw the object to the offscreen graphic.
Specified by:
Refresh in interface Refreshable

Show

public void Show()
Description copied from interface: Viewable
Show the graphical object in its current container.
Specified by:
Show in interface Viewable

Show

public void Show(Container container)
Description copied from interface: Graphic
Show the graphical object in a new container
Specified by:
Show in interface Graphic
Following copied from interface: GP.Graphic
Parameters:
container -  

SetContainer

public void SetContainer(Container container)
This method will modify which container the shape is shown in. This will not change the visibility of the object. If it was visible, it will still be visible in the new container. If it was hidden, it will still be hidden.
Specified by:
SetContainer in interface Graphic
Parameters:
container - the new container

Hide

public void Hide()
Description copied from interface: Viewable
Hide the graphical object so that it is no longer visible on the screen.
Specified by:
Hide in interface Viewable

IsVisible

public boolean IsVisible()
Description copied from interface: Viewable
This method should determine if the object is in a visible state, and return the result of that determination.
Specified by:
IsVisible in interface Viewable
Following copied from interface: GP.Viewable
Returns:
true if the object is visible, false otherwise

GetBoxBoundedSize

public Size GetBoxBoundedSize()
Specified by:
GetBoxBoundedSize in interface Graphic

Select

public void Select()
Specified by:
Select in interface Selectable

DeSelect

public void DeSelect()
Specified by:
DeSelect in interface Selectable

MoveToBack

public void MoveToBack()
Description copied from interface: Movable
This method is to be used to control the layering of drawn objects. You can use this method to move the passed in object to the very back of all other objects contained in this container.
Specified by:
MoveToBack in interface Movable
Following copied from interface: GP.Movable
Parameters:
object - the object you want to move to the back of the container

MoveToFront

public void MoveToFront()
Specified by:
MoveToFront in interface Movable

MoveBackward

public void MoveBackward()
Specified by:
MoveBackward in interface Movable

MoveForward

public void MoveForward()
Specified by:
MoveForward in interface Movable

React

public void React()
This method is automatically called when the user clicks (presses and releases the mouse button) inside the object. The programer should never need to call this method directly. The programer should override this method in a subclass to do something useful.
Specified by:
React in interface Reactive

Act

public void Act()
This method is automatically called when the user clicks (presses and releases the mouse button) inside the object. The programer should never need to call this method directly. The programer should override this method in a subclass to do something useful.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object