computational.geometry
Class Ray

java.lang.Object
  extended by computational.geometry.Ray
All Implemented Interfaces:
Shape, java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
HorizontalRay

public class Ray
extends java.lang.Object
implements Shape, java.lang.Cloneable, java.io.Serializable

See Also:
Serialized Form

Field Summary
protected  Point direction
           
protected  java.lang.String label
           
protected  Point origin
           
 
Constructor Summary
Ray(Point origin, Point direction)
           
Ray(java.lang.String label, Point origin, Point direction)
          Creates a new instance of Ray, the Ray is identified with an origin and a direction (2 Points).
 
Method Summary
 Rectangle boundingBox()
           
 java.lang.Object clone()
          Object Extension
 boolean contains(Point p)
          Tells whether the shape encloses a given point.
 boolean cross(Segment s)
           
 boolean crossLine(Segment s)
           
 void draw(java.awt.Graphics gfx)
          Draws the shape, using the current graphics context's color.
 void drawLabels(java.awt.Graphics gfx)
          Draws the shape's associated labels, using the graphics context's color.
 void drawPoints(java.awt.Graphics gfx)
          Draws the shape's defining points, using the graphics context's color.
 Point getDirection()
           
 java.lang.String getLabel()
          Returns the string label associated to this segment.
 Point getOrigin()
           
 java.util.List getPoints()
          Returns a list containing copies of the shape's defining points.
 void setDirection(Point newDirection)
           
 void setLabel(java.lang.String label)
          Sets the segment's label.
 java.lang.String toString()
          Returns a string representation of this ray.
 void translate(int dx, int dy)
          Translates the shape by the given amount.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

direction

protected Point direction

label

protected java.lang.String label

origin

protected Point origin
Constructor Detail

Ray

public Ray(Point origin,
           Point direction)

Ray

public Ray(java.lang.String label,
           Point origin,
           Point direction)
Creates a new instance of Ray, the Ray is identified with an origin and a direction (2 Points). Direction identifies the direction relative to the origin point

Method Detail

boundingBox

public Rectangle boundingBox()

clone

public java.lang.Object clone()
Object Extension

Overrides:
clone in class java.lang.Object

contains

public boolean contains(Point p)
Description copied from interface: Shape
Tells whether the shape encloses a given point. To the aims of this test, we consider the shape to be closed, so that a point lying on the shape's boundaries results as enclosed in the shape.

Specified by:
contains in interface Shape
Parameters:
p - the point we test for encloseness.
Returns:
true iff the point is enclosed in the shape.

cross

public boolean cross(Segment s)

crossLine

public boolean crossLine(Segment s)

draw

public void draw(java.awt.Graphics gfx)
Description copied from interface: Shape
Draws the shape, using the current graphics context's color.

Specified by:
draw in interface Shape
Parameters:
gfx - the graphics context where this shape has to be drawn.

drawLabels

public void drawLabels(java.awt.Graphics gfx)
Description copied from interface: Shape
Draws the shape's associated labels, using the graphics context's color.

Specified by:
drawLabels in interface Shape
Parameters:
gfx - the graphics context where this shape's labels have to be drawn.

drawPoints

public void drawPoints(java.awt.Graphics gfx)
Description copied from interface: Shape
Draws the shape's defining points, using the graphics context's color.

Specified by:
drawPoints in interface Shape
Parameters:
gfx - the graphics context where this shape's points have to be drawn.

getDirection

public Point getDirection()

getLabel

public java.lang.String getLabel()
Returns the string label associated to this segment. The returned string may possibly be empty, but may never be null.

Specified by:
getLabel in interface Shape
Returns:
the string label associated to this segment.

getOrigin

public Point getOrigin()

getPoints

public java.util.List getPoints()
Description copied from interface: Shape
Returns a list containing copies of the shape's defining points.

Specified by:
getPoints in interface Shape
Returns:
the shape's cloned defining points.

setDirection

public void setDirection(Point newDirection)

setLabel

public void setLabel(java.lang.String label)
Sets the segment's label.

Specified by:
setLabel in interface Shape
Parameters:
the - segment's new label.

toString

public java.lang.String toString()
Returns a string representation of this ray. The string is composed of the ray label (if any), and the ray origin & direction.

Overrides:
toString in class java.lang.Object
Returns:
a string representation of this ray.

translate

public void translate(int dx,
                      int dy)
Description copied from interface: Shape
Translates the shape by the given amount.

Specified by:
translate in interface Shape
Parameters:
dx - the amount to translate along the X-axis