Class Triangle

java.lang.Object
  extended by Triangle

public class Triangle
extends Object

A triangle that can be manipulated and that draws itself on a canvas.

Version:
2006.03.30/2007.01.30/2009.09.09
Author:
Michael Kolling and David J. Barnes, mod.by Denis BUREAU

Constructor Summary
Triangle()
          Create a new triangle at default position with default color.
 
Method Summary
 void changeColor(String pNewColor)
          Change the color.
 void changeSize(int pNewHeight, int pNewWidth)
          Change the size to the new size (in pixels).
 void makeInvisible()
          Make this triangle invisible.
 void makeVisible()
          Make this triangle visible.
 void moveDown()
          Move the triangle a few pixels down.
 void moveHorizontal(int pDistance)
          Move the triangle horizontally by 'pDistance' pixels.
 void moveLeft()
          Move the triangle a few pixels to the left.
 void moveRight()
          Move the triangle a few pixels to the right.
 void moveUp()
          Move the triangle a few pixels up.
 void moveVertical(int pDistance)
          Move the triangle vertically by 'pDistance' pixels.
 void slowMoveHorizontal(int pDistance)
          Slowly move the shape horizontally by 'distance' pixels.
 void slowMoveVertical(int pDistance)
          Slowly move the shape vertically by 'distance' pixels.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Triangle

public Triangle()
Create a new triangle at default position with default color.

Method Detail

changeColor

public void changeColor(String pNewColor)
Change the color. Valid colors are "red", "yellow", "blue", "green", "magenta" and "black".


changeSize

public void changeSize(int pNewHeight,
                       int pNewWidth)
Change the size to the new size (in pixels). Size must be >= 0.


makeInvisible

public void makeInvisible()
Make this triangle invisible. If it was already invisible, do nothing.


makeVisible

public void makeVisible()
Make this triangle visible. If it was already visible, do nothing.


moveDown

public void moveDown()
Move the triangle a few pixels down.


moveHorizontal

public void moveHorizontal(int pDistance)
Move the triangle horizontally by 'pDistance' pixels.


moveLeft

public void moveLeft()
Move the triangle a few pixels to the left.


moveRight

public void moveRight()
Move the triangle a few pixels to the right.


moveUp

public void moveUp()
Move the triangle a few pixels up.


moveVertical

public void moveVertical(int pDistance)
Move the triangle vertically by 'pDistance' pixels.


slowMoveHorizontal

public void slowMoveHorizontal(int pDistance)
Slowly move the shape horizontally by 'distance' pixels.

Parameters:
pDistance - nb of pixels to move towards right

slowMoveVertical

public void slowMoveVertical(int pDistance)
Slowly move the shape vertically by 'distance' pixels.

Parameters:
pDistance - nb of pixels to move towards bottom