Package drawit.shapes1
Class RoundedPolygonShape
java.lang.Object
drawit.shapes1.RoundedPolygonShape
- All Implemented Interfaces:
Shape
public class RoundedPolygonShape extends Object
Each instance of this class stores a reference to a RoundedPolygon object and, optionally,
a reference to a ShapeGroup object that contains it.
We define this object's shape coordinate system as the referenced ShapeGroup object's inner coordinate system,
if the stored ShapeGroup reference is non-null,
or the global coordinate system otherwise.
We interpret the polygon's vertex coordinates as being expressed in this object's shape coordinate system.
-
Constructor Summary
Constructors Constructor Description RoundedPolygonShape(drawit.shapegroups1.ShapeGroup parent, drawit.RoundedPolygon polygon)Initializes this object to store the given ShapeGroup reference (ornull) and the given RoundedPolygon reference. -
Method Summary
Modifier and Type Method Description booleancontains(drawit.IntPoint p)Returns whether this polygon contains this point, given in shape coordinates.ControlPoint[]createControlPoints()Returns one control point for each of this polygon's vertices.StringgetDrawingCommands()Returns this polygon's drawing commands.drawit.shapegroups1.ShapeGroupgetParent()Returns the ShapeGroup reference stored by this object.drawit.RoundedPolygongetPolygon()Returns theRoundedPolygonreference stored by this object.drawit.IntPointtoGlobalCoordinates(drawit.IntPoint p)Given the coordinates of a point in the shape coordinate system, returns the coordinates of the point in the global coordinate system.drawit.IntPointtoShapeCoordinates(drawit.IntPoint p)Given the coordinates of a point in the global coordinate system, returns the coordinates of the point in the shape coordinate system.
-
Constructor Details
-
RoundedPolygonShape
public RoundedPolygonShape(drawit.shapegroups1.ShapeGroup parent, drawit.RoundedPolygon polygon)Initializes this object to store the given ShapeGroup reference (ornull) and the given RoundedPolygon reference.
-
-
Method Details
-
getPolygon
public drawit.RoundedPolygon getPolygon()Returns theRoundedPolygonreference stored by this object.- Immutable
- Any two calls of this method on the same target object return equal values.
-
contains
public boolean contains(drawit.IntPoint p)Returns whether this polygon contains this point, given in shape coordinates. -
getDrawingCommands
Returns this polygon's drawing commands.- Specified by:
getDrawingCommandsin interfaceShape
-
getParent
public drawit.shapegroups1.ShapeGroup getParent()Returns the ShapeGroup reference stored by this object. -
createControlPoints
Returns one control point for each of this polygon's vertices. If, after calling this method, a client mutates either the polygon or the shape group graph referenced by this object, it shall no longer call any methods on the returned ControlPoint objects. That is, any mutation of the polygon or the shape group graph referenced by this object invalidates the ControlPoint objects returned by any preceding createControlPoints call. This is true even if the mutation occurred through the returned ControlPoint objects themselves. For example, after callingmoveon one of the returned ControlPoint objects, a client is no longer allowed to callgetLocationorremoveon any of the returned ControlPoint objects, and after callingremoveon one of the returned ControlPoint objects, a client is no longer allowed to callgetLocationormoveon any of the returned ControlPoint objects. There is one exception: a client can perform any number of consecutivemovecalls on the same ControlPoint object.- Specified by:
createControlPointsin interfaceShape- Creates:
- This method creates the returned array, as well as its elements.
result, ...result
-
toShapeCoordinates
public drawit.IntPoint toShapeCoordinates(drawit.IntPoint p)Description copied from interface:ShapeGiven the coordinates of a point in the global coordinate system, returns the coordinates of the point in the shape coordinate system.- Specified by:
toShapeCoordinatesin interfaceShape
-
toGlobalCoordinates
public drawit.IntPoint toGlobalCoordinates(drawit.IntPoint p)Description copied from interface:ShapeGiven the coordinates of a point in the shape coordinate system, returns the coordinates of the point in the global coordinate system.- Specified by:
toGlobalCoordinatesin interfaceShape
-