GP.Graphics
Class Triangle

java.lang.Object
  |
  +--GP.Graphics.Shape
        |
        +--GP.Graphics.Triangle
All Implemented Interfaces:
Behavioral, Colorable, Graphic, Movable, Orientable, Originable, Playable, Positionable, Reactive, Refreshable, Scalable, Selectable, Viewable

public class Triangle
extends Shape


Fields inherited from class GP.Graphics.Shape
ourNumShapes
 
Constructor Summary
Triangle()
          This constructor builds an isosceles triangle within the applet with its center at (0,0).
Triangle(Container container)
          This constructor builds an isosceles triangle in the specified container with its center at (0,0).
Triangle(Triangle other)
          This constructor builds this triangle as an exact copy of the one one passed to it, with the same vertices, size, color, orientation, container, and positio.
 
Method Summary
 Graphic Copy()
          This method returns a triangle which is identical to this one.
 Position GetVertex1()
          This function returns the offset of the first vertex of the triangle from the position (0,0).
 Position GetVertex2()
          This function returns the offset of the second vertex of the triangle from the position (0,0).
 Position GetVertex3()
          This function returns the offset of the third vertex of the triangle from the position (0,0).
 void SetPosition(Position pos)
          This method should set the current position of the object.
 void SetSize(Size size)
          This function is used to set the size of the triangle.
 void SetVertex1(Position vertex1)
          Use this method to set the position of the first vertex in the triangle.
 void SetVertex2(Position vertex2)
          Use this method to set the position of the second vertex in the triangle.
 void SetVertex3(Position vertex3)
          Use this method to set the position of the third vertex in the triangle.
 void SetVertices(Position vertex1, Position vertex2, Position vertex3)
           
 
Methods inherited from class GP.Graphics.Shape
Act, AddBehavior, ApplyBehaviors, ApplyInstincts, DeSelect, equals, Fill, Frame, GetApplet, GetBoxBoundedSize, GetColor, GetContainer, GetCurrentTime, GetFillStyle, GetOrientation, GetPivot, GetPosition, GetSize, Hide, IsPositionInside, IsVisible, Move, Move, Move, MoveBackward, MoveForward, MoveToBack, MoveToFront, Pause, Play, PositionIsOnlyInsideMe, PreferedSize, React, Refresh, RemoveAllBehaviors, RemoveBehavior, ReplaceAllBehaviors, Scale, Scale, Scale, Select, SetColor, SetContainer, SetFillStyle, SetOrientation, SetPivot, Show, Show, Start, Stop, toString, Turn, Turn, Turn, Turn, Turn, Turn
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Triangle

public Triangle()
This constructor builds an isosceles triangle within the applet with its center at (0,0). The triangle's base is 50 pixels wide and its height is 50 pixels. The color of the triangle is Black, and it is shown. The triangle is at an orientation of 0 degrees in this state.

Triangle

public Triangle(Container container)
This constructor builds an isosceles triangle in the specified container with its center at (0,0). The triangle's base is 50 pixels wide and its height is 50 pixels. The color of the triangle is Black, and it is shown. The triangle is at an orientation of 0 degrees in this state.
Parameters:
container - The container of the triangle.

Triangle

public Triangle(Triangle other)
This constructor builds this triangle as an exact copy of the one one passed to it, with the same vertices, size, color, orientation, container, and positio.
Parameters:
t - The triangle to clone.
Method Detail

Copy

public Graphic Copy()
This method returns a triangle which is identical to this one.
Overrides:
Copy in class Shape
Returns:
A copy of this triangle.

SetSize

public void SetSize(Size size)
This function is used to set the size of the triangle. The size it was created with is taken as its base size, then the base size is multiplied by vertical and horizontal scale factors to set the size of the triangle.
Overrides:
SetSize in class Shape
Parameters:
size - The new size of the triangle.

SetPosition

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

SetVertices

public void SetVertices(Position vertex1,
                        Position vertex2,
                        Position vertex3)

SetVertex1

public void SetVertex1(Position vertex1)
Use this method to set the position of the first vertex in the triangle. This vertex position is represented as the offset from (0,0)
Parameters:
vertex1 - The new coordinate of the first vertex.

SetVertex2

public void SetVertex2(Position vertex2)
Use this method to set the position of the second vertex in the triangle. This vertex position is represented as the offset from (0,0)
Parameters:
vertex2 - The new coordinate of the second vertex.

SetVertex3

public void SetVertex3(Position vertex3)
Use this method to set the position of the third vertex in the triangle. This vertex position is represented as the offset from (0,0)
Parameters:
vertex3 - The new coordinate of the first vertex.

GetVertex1

public Position GetVertex1()
This function returns the offset of the first vertex of the triangle from the position (0,0).
Returns:
The offset of the vertex from (0,0)

GetVertex2

public Position GetVertex2()
This function returns the offset of the second vertex of the triangle from the position (0,0).
Returns:
The offset of the vertex from (0,0)

GetVertex3

public Position GetVertex3()
This function returns the offset of the third vertex of the triangle from the position (0,0).
Returns:
The offset of the vertex from (0,0)