NGP.Graphics
Class Line

java.lang.Object
  extended byNGP.Graphics.Shape
      extended byNGP.Graphics.Line
All Implemented Interfaces:
Colorable, EventListener, Graphic, MouseListener, MouseMotionListener, Reactor, Rotatable

public class Line
extends Shape

A Line is a Shape composed of two endpoints. Right now, it doesn't react, or wrap for that matter like Shapes do. It has some of its own methods that are line specific.

Author:
Matt Chotin (mhc)

Field Summary
 
Fields inherited from class NGP.Graphics.Shape
_awtShape, _dpanel
 
Fields inherited from interface NGP.Colorable
DEFAULT_GRAY
 
Constructor Summary
Line(DrawingPanel dp)
          Create a line with the given DrawingPanel
 
Method Summary
 void actualPaint(Graphics2D g)
          Normal users need not use this!
 Rectangle getBounds()
          Return the bounding rectangle.
 Point getP1()
          Gets the first endpoint
 Point getP2()
          Gets the second endpoint
 float getThickness()
          Get the thickness of the Line
 void react()
          Lines cannot react.
 void setPoints(Point p1, Point p2)
          Set the endpoints for this Line.
 void setThickness(float thickness)
          Set the thickness of the Line
 
Methods inherited from class NGP.Graphics.Shape
contains, drag, getCenterLocation, getColor, getDrawingPanel, getRotation, hide, intersects, mouseClicked, mouseDragged, mouseEntered, mouseExited, mouseMoved, mousePressed, mouseReleased, paint, setColor, setDrawingPanel, setRotation, show
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Line

public Line(DrawingPanel dp)
Create a line with the given DrawingPanel

Parameters:
dp - the DrawingPanel for this Line
Method Detail

setPoints

public void setPoints(Point p1,
                      Point p2)
Set the endpoints for this Line.

Parameters:
p1 - the first Point
p2 - the second Point

getP1

public Point getP1()
Gets the first endpoint

Returns:
the first endpoint

getP2

public Point getP2()
Gets the second endpoint

Returns:
the second endpoint

setThickness

public void setThickness(float thickness)
Set the thickness of the Line

Parameters:
thickness - the float (you might need to cast) representing the thickness

getThickness

public float getThickness()
Get the thickness of the Line

Returns:
the float representing the thickness of the Line

actualPaint

public void actualPaint(Graphics2D g)
Normal users need not use this!

Play with the stroke and paint the line.

Specified by:
actualPaint in class Shape

getBounds

public Rectangle getBounds()
Return the bounding rectangle. If the rotation is along an axis grow the rectangle so that it will paint correctly.

Specified by:
getBounds in interface Graphic
Overrides:
getBounds in class Shape
Returns:
the java.awt.Rectangle that represents the bounds of the line

react

public final void react()
Lines cannot react. I'm not sure why they don't pick up the clicks, but for now, just accept that they don't.

Specified by:
react in interface Reactor
Overrides:
react in class Shape