@Test public void testContains() { segment1 = new LineSegment(0, 0, 10, 0); Assert.assertEquals(true, segment1.contains(0, 0)); Assert.assertEquals(true, segment1.contains(10, 0)); Assert.assertEquals(true, segment1.contains(5, 0)); Assert.assertEquals(false, segment1.contains(5, -5)); Assert.assertEquals(false, segment1.contains(5, 5)); Assert.assertEquals(false, segment1.contains(-5, -5)); Assert.assertEquals(false, segment1.contains(15, -5)); Assert.assertEquals(false, segment1.contains(-5, 5)); Assert.assertEquals(false, segment1.contains(15, 5)); }
public boolean contains(float x, float y) { if (pointA.getX() == x && pointA.getY() == y) return true; if (pointB.getX() == x && pointB.getY() == y) return true; Point p3 = new Point(x, y); return p3.isOnLineBetween(pointA, pointB); }
LineSegment implements Disposable { public boolean contains(float x, float y) { if (pointA.getX() == x && pointA.getY() == y) return true; if (pointB.getX() == x && pointB.getY() == y) return true; Point p3 = new Point(x, y); return p3.isOnLineBetween(pointA, pointB); } }
LineSegment implements Disposable { public boolean contains(float x, float y) { if (pointA.getX() == x && pointA.getY() == y) return true; if (pointB.getX() == x && pointB.getY() == y) return true; Point p3 = new Point(x, y); return p3.isOnLineBetween(pointA, pointB); } LineSegment(Geometry geometry);  LineSegment(float x1, float y1, float x2, float y2);  LineSegment(Point pA, Point pB); }
LineSegment implements Disposable { public boolean contains(float x, float y) { if (pointA.getX() == x && pointA.getY() == y) return true; if (pointB.getX() == x && pointB.getY() == y) return true; Point p3 = new Point(x, y); return p3.isOnLineBetween(pointA, pointB); } LineSegment(Geometry geometry);  LineSegment(float x1, float y1, float x2, float y2);  LineSegment(Point pA, Point pB); void dispose(); void setDisposed(boolean disposed); void set(float x1, float y1, float x2, float y2); boolean contains(float x, float y); boolean intersectsLineSegment(float segmentX1, float segmentY1, float segmentX2, float segmentY2); boolean intersects(LineSegment lineSegment); @Deprecated Point getIntersection(LineSegment lineSegment); boolean getIntersection(LineSegment lineSegment, Point result); boolean intersects(Rectangle rectangle); Point getPointA(); void setPointA(Point pointA); Point getPointB(); void setPointB(Point pointB); float getMinX(); float getMinY(); float getMaxX(); float getMaxY(); float getLength(); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); }
LineSegment implements Disposable { public boolean contains(float x, float y) { if (pointA.getX() == x && pointA.getY() == y) return true; if (pointB.getX() == x && pointB.getY() == y) return true; Point p3 = new Point(x, y); return p3.isOnLineBetween(pointA, pointB); } LineSegment(Geometry geometry);  LineSegment(float x1, float y1, float x2, float y2);  LineSegment(Point pA, Point pB); void dispose(); void setDisposed(boolean disposed); void set(float x1, float y1, float x2, float y2); boolean contains(float x, float y); boolean intersectsLineSegment(float segmentX1, float segmentY1, float segmentX2, float segmentY2); boolean intersects(LineSegment lineSegment); @Deprecated Point getIntersection(LineSegment lineSegment); boolean getIntersection(LineSegment lineSegment, Point result); boolean intersects(Rectangle rectangle); Point getPointA(); void setPointA(Point pointA); Point getPointB(); void setPointB(Point pointB); float getMinX(); float getMinY(); float getMaxX(); float getMaxY(); float getLength(); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj);  }