|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectwheelsunh.etc.AbstractGraphic
wheelsunh.users.AbstractShape
wheelsunh.users.Shape
wheelsunh.users.Line
public class Line
Class that models a 2D line. Has methods allowing you to adjust the line's points, thickness, color, etc.
Field Summary | |
---|---|
static int |
DEFAULT_LENGTH
|
Fields inherited from class wheelsunh.users.Shape |
---|
_c, _dp, _shape, DEFAULT_COLOR |
Fields inherited from class wheelsunh.users.AbstractShape |
---|
_rot |
Constructor Summary | |
---|---|
Line()
Creates a Line with default endpoints in the wheelsunh.users.Frame's DrawingPanel. |
|
Line(DrawingPanel dp)
Creates a Line with endpoints (0, 0) and (0, 0) in the specified DrawingPanel. |
|
Line(DrawingPanel dp,
int x1,
int y1,
int x2,
int y2)
Creates a Line with the specified endpoint coordinates in the specified DrawingPanel. |
|
Line(DrawingPanel dp,
java.awt.Point p1,
java.awt.Point p2)
Creates a Line with the specified endpoints in the specified DrawingPanel. |
|
Line(int x1,
int y1,
int x2,
int y2)
Creates a Line with the specified coordinates in the wheelsunh.users.Frame's DrawingPanel. |
|
Line(java.awt.Point p1,
java.awt.Point p2)
Creates a Line with the specified endpoints in the wheelsunh.users.Frame's DrawingPanel. |
Method Summary | |
---|---|
void |
actualPaint(java.awt.Graphics2D g)
Subclasses must define this to do the actual painting of the shape. |
java.awt.Rectangle |
getBounds()
Returns the bounding rectangle of the line. |
int |
getHeight()
Returns the Line's height. |
java.awt.Point |
getLocation()
Returns the location of this Line's first point. |
java.awt.Point |
getP1()
Returns the first endpoint. |
java.awt.Point |
getP2()
Returns the second endpoint. |
java.awt.Dimension |
getSize()
Returns the Line's size as an AWT Dimension. |
int |
getThickness()
Returns the thickness of the stroke. |
int |
getWidth()
Returns the Line's width. |
int |
getX1()
Return the x coordinate of the first endpoint. |
int |
getX2()
Return the x coordinate of the second endpoint. |
int |
getXLocation()
Returns the x location of this Line's first point. |
int |
getY1()
Returns the y coordinate of the first endpoint. |
int |
getY2()
Returns the y coordinate of the second endpoint. |
int |
getYLocation()
Returns the location of this Line's first point. |
void |
setLocation(int x,
int y)
Sets the location of this line such that its bounding box is located at (x, y) |
void |
setLocation(java.awt.Point p)
Sets the location of this line such that its first point is located at the point p |
void |
setP1(int x,
int y)
Sets the coordinates of the first endpoint. |
void |
setP1(java.awt.Point p1)
Set the first endpoint. |
void |
setP2(int x,
int y)
Sets the coordinates of the second endpoint. |
void |
setP2(java.awt.Point p2)
Set the second endpoint. |
void |
setPoints(int x1,
int y1,
int x2,
int y2)
Sets the endpoints of the Line to the specified coordinates |
void |
setPoints(java.awt.Point p1,
java.awt.Point p2)
Sets the endpoints of the Line to the specified values. |
void |
setSize(java.awt.Dimension d)
Sets the Line's size to the given Dimension. |
void |
setSize(int width,
int height)
Sets the Line's size to the given dimensions. |
void |
setThickness(int thickness)
Sets the thickness of the stroke used to paint the line. |
Methods inherited from class wheelsunh.users.Shape |
---|
contains, getColor, getRotation, hide, paint, setColor, setRotation, show |
Methods inherited from class wheelsunh.users.AbstractShape |
---|
boundsIntersects, center, distance, getCenter, getCenterX, getCenterY, getIntersection, intersects, intersects, setCenter |
Methods inherited from class wheelsunh.etc.AbstractGraphic |
---|
mouseClicked, mouseDragged, mousePressed, mouseReleased |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_LENGTH
Constructor Detail |
---|
public Line()
public Line(int x1, int y1, int x2, int y2)
x1
- the x value of the first endpointy1
- the y value of the first endpointx2
- the x value of the second endpointy2
- the y value of the second endpointpublic Line(java.awt.Point p1, java.awt.Point p2)
p1
- the first endpointp2
- the second endpointpublic Line(DrawingPanel dp)
public Line(DrawingPanel dp, int x1, int y1, int x2, int y2)
dp
- the DrawingPanel in which the line will be drawnx1
- the x value of the first endpointy1
- the y value of the first endpointx2
- the x value of the second endpointy2
- the y value of the second endpointpublic Line(DrawingPanel dp, java.awt.Point p1, java.awt.Point p2)
dp
- the DrawingPanel in which the line will be drawnp1
- the first endpointp2
- the second endpointMethod Detail |
---|
public void setPoints(int x1, int y1, int x2, int y2)
public void setPoints(java.awt.Point p1, java.awt.Point p2)
public void setP1(int x, int y)
public void setP1(java.awt.Point p1)
public void setP2(int x, int y)
public void setP2(java.awt.Point p2)
public java.awt.Point getP1()
public int getX1()
public int getY1()
public java.awt.Point getP2()
public int getX2()
public int getY2()
public void setThickness(int thickness)
public int getThickness()
public java.awt.Rectangle getBounds()
getBounds
in class Shape
public void actualPaint(java.awt.Graphics2D g)
Shape
paint(java.awt.Graphics2D)
will forward to
this method.
actualPaint
in class Shape
g
- the instance of java.awt.Graphics2D
that should
be used to paint the shapepublic void setLocation(int x, int y)
setLocation
in interface Locatable
setLocation
in class Shape
public void setLocation(java.awt.Point p)
setLocation
in interface Locatable
setLocation
in class Shape
public java.awt.Point getLocation()
getLocation
in interface Locatable
getLocation
in class Shape
public int getXLocation()
getXLocation
in interface Locatable
getXLocation
in class Shape
public int getYLocation()
getYLocation
in interface Locatable
getYLocation
in class Shape
public void setSize(int width, int height)
setSize
in interface Sizeable
public void setSize(java.awt.Dimension d)
setSize
in interface Sizeable
public java.awt.Dimension getSize()
getSize
in interface Sizeable
public int getWidth()
getWidth
in interface Sizeable
getWidth
in class AbstractShape
public int getHeight()
getHeight
in interface Sizeable
getHeight
in class AbstractShape
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |