Package lejos.robotics.geometry
Class RectangularShape
- java.lang.Object
-
- lejos.robotics.geometry.RectangularShape
-
- All Implemented Interfaces:
java.lang.Cloneable,Shape
- Direct Known Subclasses:
Rectangle2D
public abstract class RectangularShape extends java.lang.Object implements Shape, java.lang.Cloneable
An abstract base class for shapes based on a rectangular frame.- Author:
- Lawrie Griffiths
-
-
Constructor Summary
Constructors Constructor Description RectangularShape()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.lang.Objectclone()booleancontains(Point2D p)Test if the shape contains a Point2Dbooleancontains(Rectangle2D r)Test if this shape contains a given Rectangle2DRectangleInt32getBounds()Get the bounds of this rectangular shape as a RectangledoublegetCenterX()Get the x coordinate of the center of the shapedoublegetCenterY()Get the y coordinate of the center of the shapeRectangle2DgetFrame()Get the framing rectangleabstract doublegetHeight()Get the height as a doubledoublegetMaxX()Get the maximum value of the x coordinatedoublegetMaxY()Get the maximum value of the y coordinatedoublegetMinX()Get the minimum value of the x x coordinatedoublegetMinY()Get the minimum value of the y coordinateabstract doublegetWidth()Get the width as a doubleabstract doublegetX()Get the x coordinate as a doubleabstract doublegetY()Get the y coordinate as a doublebooleanintersects(Rectangle2D r)Test if this shape intersects a given Rectangle2Dabstract booleanisEmpty()Test if the rectangular shape is emptyabstract voidsetFrame(double x, double y, double w, double h)Set the frame for the rectangular shapevoidsetFrame(Rectangle2D r)Set the frame of the rectangular shape-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface lejos.robotics.geometry.Shape
contains, contains, getBounds2D, intersects
-
-
-
-
Method Detail
-
getX
public abstract double getX()
Get the x coordinate as a double- Returns:
- the x coordinate
-
getY
public abstract double getY()
Get the y coordinate as a double- Returns:
- the y coordinate
-
getWidth
public abstract double getWidth()
Get the width as a double- Returns:
- the width
-
getHeight
public abstract double getHeight()
Get the height as a double- Returns:
- the height
-
getMinX
public double getMinX()
Get the minimum value of the x x coordinate- Returns:
- the minimum x coordinate
-
getMinY
public double getMinY()
Get the minimum value of the y coordinate- Returns:
- the minimum y coordinate
-
getMaxX
public double getMaxX()
Get the maximum value of the x coordinate- Returns:
- the maximum y coordinate
-
getMaxY
public double getMaxY()
Get the maximum value of the y coordinate- Returns:
- the maximim y coordinate
-
getCenterX
public double getCenterX()
Get the x coordinate of the center of the shape- Returns:
- the x coordinate of the center
-
getCenterY
public double getCenterY()
Get the y coordinate of the center of the shape- Returns:
- the y coordinate of the center
-
getFrame
public Rectangle2D getFrame()
Get the framing rectangle- Returns:
- the framing rectangle
-
isEmpty
public abstract boolean isEmpty()
Test if the rectangular shape is empty- Returns:
- true iff the shape is empty
-
setFrame
public abstract void setFrame(double x, double y, double w, double h)Set the frame for the rectangular shape- Parameters:
x- the x coordinate of the top left cornery- the y coordinate iof the top left cornerw- the widthh- the height
-
setFrame
public void setFrame(Rectangle2D r)
Set the frame of the rectangular shape- Parameters:
r- the framing rectangle
-
contains
public boolean contains(Point2D p)
Test if the shape contains a Point2D
-
intersects
public boolean intersects(Rectangle2D r)
Test if this shape intersects a given Rectangle2D- Specified by:
intersectsin interfaceShape- Parameters:
r- the Rectangle2D- Returns:
- true iff this shape intersects the given Rectangle2D
-
contains
public boolean contains(Rectangle2D r)
Test if this shape contains a given Rectangle2D
-
getBounds
public RectangleInt32 getBounds()
Get the bounds of this rectangular shape as a Rectangle
-
clone
public java.lang.Object clone()
- Overrides:
clonein classjava.lang.Object
-
-