diff --git a/src/edu/macalester/graphics/Line.java b/src/edu/macalester/graphics/Line.java index 90c47a1..57d1932 100644 --- a/src/edu/macalester/graphics/Line.java +++ b/src/edu/macalester/graphics/Line.java @@ -11,12 +11,12 @@ * A line segment that can be drawn on the screen. *

* A line has a "start point" and an "end point". The only distinction is that the start point is - * the line’s {@link getPosition() position}. If you call {@link setPosition(Point) setPosition()} - * or {@link moveBy(Point) moveBy()}, both endpoints will move so the line segment has the same + * the line’s {@link #getPosition() position}. If you call {@link #setPosition(Point) setPosition()} + * or {@link #moveBy(Point) moveBy()}, both endpoints will move so the line segment has the same * length and angle, and the start point will end up at the position you specify. *

- * To move one endpoint without affecting the other, use {@link setStartPosition(Point) setStartPosition()} - * and {@link setEndPosition(Point) setEndPosition()}. + * To move one endpoint without affecting the other, use {@link #setStartPosition(Point) setStartPosition()} + * and {@link #setEndPosition(Point) setEndPosition()}. * * @author Bret Jackson */ @@ -129,6 +129,20 @@ public double getY2() { return shape.getY2() + getY(); } + /** + * Returns the endpoint of the line segment marked as the “start,” which is (x1, y1). This + * method is equivalent to getPosition(), but note that calling {@link #setStartPosition(Point)} + * moves only that endpoint, whereas calling {@link #setPosition(Point)} moves the entire line + * (i.e. it moves both endpoints by the same amount). + * + * @see #getX1() + * @see #getY1() + * @see #setStartPosition(Point) + */ + public Point getStartPosition() { + return getPosition(); + } + /** * Sets the line's starting position to (x, y) without affecting the end position. */ @@ -145,6 +159,17 @@ public void setStartPosition(Point p) { setStartPosition(p.getX(), p.getY()); } + /** + * Returns the endpoint of the line segment marked as the “end,” which is (x2, y2). + * + * @see #getX2() + * @see #getY2() + * @see #getStartPosition() + */ + public Point getEndPosition() { + return new Point(getX2(), getY2()); + } + /** * Sets the line's ending position to (x, y) without affecting the start position. */ diff --git a/test/edu/macalester/graphics/LineTest.java b/test/edu/macalester/graphics/LineTest.java index f2acbf4..e8d16cb 100644 --- a/test/edu/macalester/graphics/LineTest.java +++ b/test/edu/macalester/graphics/LineTest.java @@ -19,7 +19,6 @@ void horizontal() { line = new Line(10, 50, 90, 50); } - @RenderingTest(modes = { STROKED, HIT_TEST }) void diagonal() { line = new Line(new Point(1, 2), new Point(3, 4)); @@ -32,5 +31,7 @@ void diagonal() { assertEquals(21, line.getY1()); assertEquals(51, line.getX2()); assertEquals(9, line.getY2()); + assertEquals(new Point(31, 21), line.getStartPosition()); + assertEquals(new Point(51, 9), line.getEndPosition()); } } \ No newline at end of file diff --git a/test/imageComparisons/CanvasWindowTest/added-windows_server_2025.expected.png b/test/imageComparisons/CanvasWindowTest/added-windows_server_2025.expected.png new file mode 100644 index 0000000..245e7e3 Binary files /dev/null and b/test/imageComparisons/CanvasWindowTest/added-windows_server_2025.expected.png differ diff --git a/test/imageComparisons/CanvasWindowTest/moved-windows_server_2025.expected.png b/test/imageComparisons/CanvasWindowTest/moved-windows_server_2025.expected.png new file mode 100644 index 0000000..990082c Binary files /dev/null and b/test/imageComparisons/CanvasWindowTest/moved-windows_server_2025.expected.png differ diff --git a/test/imageComparisons/CanvasWindowTest/removed-windows_server_2025.expected.png b/test/imageComparisons/CanvasWindowTest/removed-windows_server_2025.expected.png new file mode 100644 index 0000000..9691a75 Binary files /dev/null and b/test/imageComparisons/CanvasWindowTest/removed-windows_server_2025.expected.png differ