|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.colorado.cs.ns2.graphics.LineDrawable
public class LineDrawable
This class represents a Link (a line) as drawn on the screen.
| Field Summary | |
|---|---|
private double |
c
The y-intercept of the line. |
static int |
HEIGHT
The HEIGHT of the line. |
private Link |
link
A reference to the NS2 link that the current graphical link represents. |
private double |
m
The slope of the line. |
private static long |
serialVersionUID
Default serial version UID. |
static int |
WIDTH
The WIDTH of the line. |
private int |
X1
The X-coordinate of the first endpoint. |
private int |
X2
The X-coordinate of the second endpoint. |
private int |
Y1
The Y-coodinate of the first endpoint. |
private int |
Y2
The Y-coordinate of the second endpoint. |
| Constructor Summary | |
|---|---|
LineDrawable(int x1,
int y1,
int x2,
int y2)
Four-argument constructor: Sets the line's endpoint coordinates. |
|
| Method Summary | |
|---|---|
private void |
calcLineSlope(int x1,
int y1,
int x2,
int y2)
Calculates Slope and c to represent equation of line as y = mx + c |
void |
drawSelf(java.awt.Graphics g,
boolean clear)
Draws a Line with the current co-ordinates. |
Link |
getLink()
Get the Link associated with the Line |
java.awt.Point |
getPoint1()
Get first endpoint of Line |
java.awt.Point |
getPoint2()
Get second endpoint of Line |
void |
move(int dX,
int dY)
Inherited from interface; not used for this subclass. |
void |
moveLine(int dX,
int dY,
int which)
Change the co-ordinates of the Line |
void |
setLink(Link link)
Associate a Link with the Line. |
boolean |
within(int X,
int Y)
Check to see if (X,Y) corresponds to this Line. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static final long serialVersionUID
private int X1
private int Y1
private int X2
private int Y2
private double m
private double c
private Link link
public static final int HEIGHT
public static final int WIDTH
| Constructor Detail |
|---|
public LineDrawable(int x1,
int y1,
int x2,
int y2)
x1 - X-coordinate of the first endpoint.y1 - Y-coordinate of the first endpoint.x2 - X-coordinate of the second endpoint.y2 - Y-coordinate of the second endpoint.| Method Detail |
|---|
private void calcLineSlope(int x1,
int y1,
int x2,
int y2)
x1 - x1y1 - y1x2 - x2y2 - y2public void setLink(Link link)
link - - Linkpublic Link getLink()
public void drawSelf(java.awt.Graphics g,
boolean clear)
drawSelf in interface Drawableg - Reference to the Graphics object.clear - Set it to false to erase the Node.Drawable.drawSelf(java.awt.Graphics, boolean)
public void move(int dX,
int dY)
move in interface DrawabledX - - change in x co-ordinate.dY - - change in y co-ordinate.Drawable.move(int, int)
public void moveLine(int dX,
int dY,
int which)
dX - change in x positiondY - change in y positionwhich - select co-ordinate to update (0 or 1)
public boolean within(int X,
int Y)
within in interface DrawableX - X-coordinate.Y - Y-coordinate.
Drawable.within(int, int)public java.awt.Point getPoint1()
public java.awt.Point getPoint2()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||