| Modifier and Type | Field and Description |
|---|---|
private Rectangle |
clipBounds |
private Point |
p1 |
private Point |
p2 |
| Constructor and Description |
|---|
LineClip(Point p1,
Point p2,
Rectangle clipBounds)
Constructs a new
LineClip. |
| Modifier and Type | Method and Description |
|---|---|
private boolean |
cohenSutherland(long x1,
long y1,
long x2,
long y2,
long xmin,
long ymin,
long xmax,
long ymax)
Cohen–Sutherland algorithm.
|
private static int |
computeOutCode(long x,
long y,
long xmin,
long ymin,
long xmax,
long ymax)
The outcode of the point.
|
boolean |
execute()
run the clipping algorithm
|
Point |
getP1() |
Point |
getP2() |
public boolean execute()
private boolean cohenSutherland(long x1, long y1, long x2, long y2, long xmin, long ymin, long xmax, long ymax)
x1 - X coordinate of first pointy1 - Y coordinate of first pointx2 - X coordinate of second pointy2 - Y coordinate of second pointxmin - minimal X coordinateymin - minimal Y coordinatexmax - maximal X coordinateymax - maximal Y coordinateprivate static int computeOutCode(long x, long y, long xmin, long ymin, long xmax, long ymax)
Rectangle.outcode(double, double) since it does not work with long ints.x - X coordinatey - Y coordinatexmin - minimal X coordinateymin - minimal Y coordinatexmax - maximal X coordinateymax - maximal Y coordinate