uwcse.graphics
Class Triangle

java.lang.Object
  |
  +--uwcse.graphics.ShapeImpl
        |
        +--uwcse.graphics.PolyShape
              |
              +--uwcse.graphics.Triangle
All Implemented Interfaces:
Shape

public class Triangle
extends PolyShape
implements Shape

A triangle shape. (Really, just a polygon with 3 vertices.) The main operations are to read the x and y coordinates of the upper-left corner and the center of the bounding rectangle around the triangle (getX(), getY(), getCenterX(), and getCenterY()), to change the position of the upper-left corner (moveBy(...) and moveTo(...)), to rotate the triangle around some point (rotateAround(...)), to read and change the color of the triangle (getColor() and setColor(...)), and add to and remove from a GWindow (addTo(...) and removeFromWindow()). Other operations are mainly for internal use, and should not be called by regular client programs.


Constructor Summary
Triangle()
          Create a new blue, filled triangle with default position and size.
Triangle(int x1, int y1, int x2, int y2, int x3, int y3)
          Create a new black, unfilled triangle between the given three vertices
Triangle(int x1, int y1, int x2, int y2, int x3, int y3, java.awt.Color c, boolean fill)
          Create a new triangle of the given color and filledness between the given three vertices
 
Method Summary
 java.lang.String toString()
          Answer the printed representation of this shape.
 
Methods inherited from class uwcse.graphics.PolyShape
addPoint, moveTo, paint, resize, rotateAround
 
Methods inherited from class uwcse.graphics.ShapeImpl
addTo, currentWindow, getBoundingBox, getCenterX, getCenterY, getColor, getHeight, getWidth, getX, getY, intersects, moveBy, recordWindow, removeFromWindow, setColor
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface uwcse.graphics.Shape
addTo, currentWindow, getBoundingBox, getCenterX, getCenterY, getColor, getHeight, getWidth, getX, getY, intersects, moveBy, moveTo, paint, recordWindow, removeFromWindow, rotateAround, setColor
 

Constructor Detail

Triangle

public Triangle()
Create a new blue, filled triangle with default position and size.

Triangle

public Triangle(int x1,
                int y1,
                int x2,
                int y2,
                int x3,
                int y3)
Create a new black, unfilled triangle between the given three vertices
Parameters:
x1 - the X coordinate of the first vertex
y1 - the Y coordinate of the first vertex
x2 - the X coordinate of the second vertex
y2 - the Y coordinate of the second vertex
x3 - the X coordinate of the third vertex
y3 - the Y coordinate of the third vertex

Triangle

public Triangle(int x1,
                int y1,
                int x2,
                int y2,
                int x3,
                int y3,
                java.awt.Color c,
                boolean fill)
Create a new triangle of the given color and filledness between the given three vertices
Parameters:
x1 - the X coordinate of the first vertex
y1 - the Y coordinate of the first vertex
x2 - the X coordinate of the second vertex
y2 - the Y coordinate of the second vertex
x3 - the X coordinate of the third vertex
y3 - the Y coordinate of the third vertex
c - a color for the triangle
fill - should the triangle be filled with the color?
Method Detail

toString

public java.lang.String toString()
Description copied from class: ShapeImpl
Answer the printed representation of this shape.
Overrides:
toString in class PolyShape