[an error occurred while processing this directive]
Domain for sale!
Start Search Contents Index Links About
Triangle.java
/*
 * Author: Havard Rast Blok
 * E-mail: 
 * Web   : www.rememberjava.com
 */

import java.awt.*;
import java.awt.geom.*;


/*
 * Class to represent a Triangle.
 * Implementing the java.awt.Shape inteface.
 */
public class Triangle implements Shape
{
  private Polygon poly;

  public TrianglePolygon p )
  {
    poly = p;
  }

  public TrianglePoint p1, Point p2, Point p3 )
  {
    poly = new Polygon();
    poly.addPointp1.x, p1.y );
    poly.addPointp2.x, p2.y );
    poly.addPointp3.x, p3.y );
  }
  
  public void drawGraphics g )
  {
    g.drawPolygonpoly );
  }

  public void fillGraphics g )
  {
    g.fillPolygonpoly );
  }

  //methods implemented from interface Shape

  public Rectangle getBounds()
  {
    return poly.getBounds();
  }

  public Rectangle2D getBounds2D()
  {
    return poly.getBounds2D();
  }

  public boolean contains(double x, double y)
  {
    return poly.contains(x, y);
  }

  public boolean contains(Point2D p)
  {
    return poly.contains(p);
  }

  public boolean intersects(double x, double y, double w, double h)
  {
    return poly.intersects(x, y, w, h);
  }

  public boolean intersects(Rectangle2D r)
  {
    return poly.intersects(r);
  }

  public boolean contains(double x, double y, double w, double h)
  {
    return poly.contains(x, y, w, h);
  }

  public boolean contains(Rectangle2D r)
  {
    return poly.intersects(r);
  }

  public PathIterator getPathIterator(AffineTransform at)
  {
    return poly.getPathIterator(at);
  }

  public PathIterator getPathIterator(AffineTransform at, double flatness)
  {
    return poly.getPathIterator(at, flatness);
  }

}


site: Håvard Rast Blok
mail:
updated: 16 July 2010