|
PenProfile 2.x | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.livescribe.geom.Shape
public abstract class Shape
This class is the superclass for all shapes handled by the system. Shapes created by the system are also aware of the page address on which they were created.
Note that there is no validation checking on the points. It may be possible to create, for example, rectangles or ellipses having a negative height or width.
Note: This class is not thread safe.
| Field Summary | |
|---|---|
static int |
COORD_MAX
The maximum coordinate value, unsigned. |
static int |
COORD_MIN
The minimum coordinate value, unsigned. |
static int |
INTERSECT_CLIP
The shapes intersect at one or more points. |
static int |
INTERSECT_EXTERNAL
The shapes do not intersect at all. |
static int |
INTERSECT_INTERNAL1
This shape is completely inside the other shape. |
static int |
INTERSECT_INTERNAL2
The other shape is completely inside this shape. |
protected static int |
SHAPE_COMPOSITE
The composite type. |
protected static int |
SHAPE_ELLIPSE
The ellipse type. |
protected static int |
SHAPE_LINESEGMENT
The line segment type. |
protected static int |
SHAPE_POINT
The point type. |
protected static int |
SHAPE_POLYGON
The polygon type. |
protected static int |
SHAPE_POLYLINE
The polyline type. |
protected static int |
SHAPE_RECTANGLE
The rectangle type. |
protected static int |
SHAPE_STROKE
The stroke type. |
protected int |
type
The shape type, one of the SHAPE_XXX constants. |
protected int[] |
vertex
The vertex array must be allocated by subclasses. |
| Constructor Summary | |
|---|---|
protected |
Shape(int type)
Creates a new shape having the specified type. |
| Method Summary | |
|---|---|
boolean |
contains(int x,
int y)
Indicates if the point specified by (x,y) is contained within this shape. |
Rectangle |
getBoundingBox()
Gets the bounding box of this shape. |
int |
getNumberofVertices()
Deprecated. Use getNumberOfVertices(). |
int |
getNumberOfVertices()
Returns the number of vertices in this shape. |
int |
getSize()
Gets the geometrical area or length of this shape, depending on the type. |
protected int |
getType()
Returns the shape type, one of the SHAPE_XXX
constants. |
static Rectangle |
getUnion(Shape a,
Shape b)
Finds the smallest possible rectangle that contains both shapes. |
int |
getX(int i)
Gets the X-coordinate at the specified index. |
int[] |
getXY()
Gets an array of the coordinates in this shape. |
int |
getY(int i)
Gets the Y-coordinate at the specified index. |
int |
intersectsWith(Shape shape)
Detects any intersection between the this shape and the given shape. |
void |
setVertexArray(int[] v)
Sets the internal vertex array. |
void |
setX(int i,
int x)
Sets the X-coordinate at the specified index. |
void |
setXY(int[] xy)
Sets the shape's coordinates to the specified X- and Y-coordinates. |
void |
setXY(int i,
int x,
int y)
Sets the coordinate at the specified index. |
void |
setY(int i,
int y)
Sets the Y-coordinate at the specified index. |
String |
toString()
Returns a string representation of this object. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected static final int SHAPE_POINT
protected static final int SHAPE_LINESEGMENT
protected static final int SHAPE_RECTANGLE
protected static final int SHAPE_ELLIPSE
protected static final int SHAPE_POLYGON
protected static final int SHAPE_POLYLINE
protected static final int SHAPE_STROKE
protected static final int SHAPE_COMPOSITE
public static final int COORD_MIN
public static final int COORD_MAX
public static final int INTERSECT_EXTERNAL
public static final int INTERSECT_INTERNAL1
public static final int INTERSECT_INTERNAL2
public static final int INTERSECT_CLIP
protected int[] vertex
protected final int type
SHAPE_XXX constants.
| Constructor Detail |
|---|
protected Shape(int type)
SHAPE_XXX constants.
Note that the internal vertex array is set to
null.
type - the shape type| Method Detail |
|---|
public int intersectsWith(Shape shape)
shape - check for intersection with this shape
INTERSECT_XXX constants
describing how the shapes intersect.
NullPointerException - if the given shape is null.public int getSize()
public int getNumberofVertices()
getNumberOfVertices().
public int getNumberOfVertices()
| Shape | Vertex Count |
|---|---|
Ellipse | 2 |
LineSegment | 2 |
Point | 1 |
Polygon | N |
PolyLine | N |
Rectangle | 2 |
Stroke | N |
public int getX(int i)
i - the coordinate index
IndexOutOfBoundsException - if the index is out of range.getNumberOfVertices()public int getY(int i)
i - the coordinate index
IndexOutOfBoundsException - if the index is out of range.getNumberOfVertices()public int[] getXY()
setXY(int[]),
getNumberOfVertices()
public void setX(int i,
int x)
i - the coordinate indexx - the new X-coordinate
IndexOutOfBoundsException - if the index is out of range.getNumberOfVertices()
public void setY(int i,
int y)
i - the coordinate indexy - the new Y-coordinate
IndexOutOfBoundsException - if the index is out of range.getNumberOfVertices()
public void setXY(int i,
int x,
int y)
i - the coordinate indexx - the X-coordinatey - the Y-coordinate
IndexOutOfBoundsException - if the index is out of range.getNumberOfVertices()public void setXY(int[] xy)
xy - array with an even number of elements containing (X,Y) pairs
IllegalArgumentException - if the array does not have an even
number of elements.public void setVertexArray(int[] v)
vertex documentation for more information.
v - the arrayvertexprotected final int getType()
SHAPE_XXX
constants.
SHAPE_XXX
constants.public Rectangle getBoundingBox()
Rectangle.
Rectangle.
public static Rectangle getUnion(Shape a,
Shape b)
Rectangle instance.
a - the first shapeb - the second shape
Rectangle instance.
NullPointerException - if either shape is null.public String toString()
toString in class Object
public boolean contains(int x,
int y)
Note that is a very generic implementation. Subclasses can override this to provide a more optimized implementation.
x - the X-coordinate to testy - the Y-coordinate to test
true if it is contained and false if not
fully contained.
|
PenProfile 2.x | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||