java.lang.Objectcomputational.geometry.Segment
public class Segment
Constructor Summary | |
---|---|
Segment(int x0,
int y0,
int x1,
int y1)
CONSTRUCTORS |
|
Segment(Point p0,
Point p1)
|
|
Segment(java.lang.String label,
int x0,
int y0,
int x1,
int y1)
|
|
Segment(java.lang.String label,
Point p0,
Point p1)
|
Method Summary | |
---|---|
Rectangle |
boundingBox()
|
java.lang.Object |
clone()
Object Extension |
boolean |
contains(Point p)
Tells whether the shape encloses a given point. |
void |
draw(java.awt.Graphics gfx)
Draws the shape, using the current graphics context's color. |
void |
drawArrows(java.awt.Graphics gfx)
|
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. |
boolean |
equals(java.lang.Object obj)
Determines whether or not two segments are equal. |
java.lang.String |
getLabel()
Returns the string label associated to this segment. |
java.util.List |
getPoints()
Returns a list containing copies of the shape's defining points. |
boolean |
intersect(Segment s)
|
double |
length()
|
boolean |
movePoint(Point p,
int dx,
int dy)
GET /SET METHODS |
void |
setLabel(java.lang.String label)
Sets the segment's label. |
java.lang.String |
toString()
Returns a string representation of this segment. |
void |
translate(int dx,
int dy)
Translates the shape by the given amount. |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Segment(int x0, int y0, int x1, int y1)
public Segment(Point p0, Point p1)
public Segment(java.lang.String label, int x0, int y0, int x1, int y1)
public Segment(java.lang.String label, Point p0, Point p1)
Method Detail |
---|
public Rectangle boundingBox()
public java.lang.Object clone()
clone
in class java.lang.Object
public boolean contains(Point p)
Shape
contains
in interface Shape
p
- the point we test for encloseness.
public void draw(java.awt.Graphics gfx)
Shape
draw
in interface Shape
gfx
- the graphics context where this shape has to be drawn.public void drawArrows(java.awt.Graphics gfx)
public void drawLabels(java.awt.Graphics gfx)
Shape
drawLabels
in interface Shape
gfx
- the graphics context where this shape's labels have
to be drawn.public void drawPoints(java.awt.Graphics gfx)
Shape
drawPoints
in interface Shape
gfx
- the graphics context where this shape's points have
to be drawn.public boolean equals(java.lang.Object obj)
Segment
are equal if their extreme
points are equal.
equals
in class java.lang.Object
obj
- an object to be compared with this Segment
true
if the object to be compared is
an instance of Segment
and has
the same extreme points; false
otherwise.public java.lang.String getLabel()
null
.
getLabel
in interface Shape
public java.util.List getPoints()
Shape
getPoints
in interface Shape
public boolean intersect(Segment s)
public double length()
public boolean movePoint(Point p, int dx, int dy)
public void setLabel(java.lang.String label)
setLabel
in interface Shape
the
- segment's new label.public java.lang.String toString()
toString
in class java.lang.Object
public void translate(int dx, int dy)
Shape
translate
in interface Shape
dx
- the amount to translate along the X-axis