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 (or null) and the given RoundedPolygon reference.
  • Method Summary

    Modifier and Type Method Description
    boolean contains​(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.
    String getDrawingCommands()
    Returns this polygon's drawing commands.
    drawit.shapegroups1.ShapeGroup getParent()
    Returns the ShapeGroup reference stored by this object.
    drawit.RoundedPolygon getPolygon()
    Returns the RoundedPolygon reference stored by this object.
    drawit.IntPoint toGlobalCoordinates​(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.IntPoint toShapeCoordinates​(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.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • RoundedPolygonShape

      public RoundedPolygonShape​(drawit.shapegroups1.ShapeGroup parent, drawit.RoundedPolygon polygon)
      Initializes this object to store the given ShapeGroup reference (or null) and the given RoundedPolygon reference.
  • Method Details

    • getPolygon

      public drawit.RoundedPolygon getPolygon()
      Returns the RoundedPolygon reference 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.
      Specified by:
      contains in interface Shape
    • getDrawingCommands

      public String getDrawingCommands()
      Returns this polygon's drawing commands.
      Specified by:
      getDrawingCommands in interface Shape
    • getParent

      public drawit.shapegroups1.ShapeGroup getParent()
      Returns the ShapeGroup reference stored by this object.
      Specified by:
      getParent in interface Shape
    • createControlPoints

      public ControlPoint[] 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 calling move on one of the returned ControlPoint objects, a client is no longer allowed to call getLocation or remove on any of the returned ControlPoint objects, and after calling remove on one of the returned ControlPoint objects, a client is no longer allowed to call getLocation or move on any of the returned ControlPoint objects. There is one exception: a client can perform any number of consecutive move calls on the same ControlPoint object.
      Specified by:
      createControlPoints in interface Shape
      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: Shape
      Given the coordinates of a point in the global coordinate system, returns the coordinates of the point in the shape coordinate system.
      Specified by:
      toShapeCoordinates in interface Shape
    • toGlobalCoordinates

      public drawit.IntPoint toGlobalCoordinates​(drawit.IntPoint p)
      Description copied from interface: Shape
      Given the coordinates of a point in the shape coordinate system, returns the coordinates of the point in the global coordinate system.
      Specified by:
      toGlobalCoordinates in interface Shape