Class Shape

  • All Implemented Interfaces:
    java.io.Externalizable, java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<Shape>
    Direct Known Subclasses:
    AbstractEllipse, AbstractPolygon

    public abstract class Shape
    extends java.lang.Object
    implements java.lang.Cloneable, java.lang.Comparable<Shape>, java.io.Externalizable
    Represents an abstract shape.

    WARNING: this API is experimental and will likely change in the near future.

    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      Shape()  
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      abstract void addArguments​(java.lang.StringBuilder buffer)  
      Shape clone()  
      int compareTo​(Shape other)
      Shape comparison compares bounding box area.
      abstract boolean contains​(double x, double y)
      Return true if this shape contains the point defined by (x, y).
      boolean contains​(Point point)
      Return true if this shape contains point.
      abstract boolean fastIntersects​(Rectangle box)
      Check if this shape's bounding box intersects with box.
      abstract Rectangle getBoundingBox()
      Get the rectangle that represents the bounding box that fully contains this shape.
      abstract double getHeight()
      Get the height of this shape's bounding box.
      abstract java.lang.String getTypeName()  
      abstract double getWidth()
      Get the width of this shape's bounding box.
      int hashCode()
      abstract boolean intersects​(Rectangle box, Shape other)
      Check if this shape intersects with other.
      boolean intersects​(Shape other)
      Check if this shape intersects with other.
      abstract Shape readExternal​(java.io.DataInput in)  
      void readExternal​(java.io.ObjectInput in)
      GWT Incompatible - hence no @Override annotation.
      java.lang.String toString()
      void toString​(java.lang.StringBuilder buffer)
      Write the string representation of this shape to buffer.
      protected static void toString​(java.lang.StringBuilder buffer, double x, double y)
      Write the string representation of a point to buffer.
      static Shape valueOf​(java.lang.Object value)  
      abstract void writeExternal​(java.io.DataOutput out)  
      void writeExternal​(java.io.ObjectOutput out)
      GWT Incompatible - hence no @Override annotation.
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Shape

        public Shape()
    • Method Detail

      • contains

        public final boolean contains​(Point point)
        Return true if this shape contains point.
      • getWidth

        public abstract double getWidth()
        Get the width of this shape's bounding box.
      • getHeight

        public abstract double getHeight()
        Get the height of this shape's bounding box.
      • contains

        public abstract boolean contains​(double x,
                                         double y)
        Return true if this shape contains the point defined by (x, y).
      • intersects

        public abstract boolean intersects​(Rectangle box,
                                           Shape other)
        Check if this shape intersects with other.
        Parameters:
        box - The bounding box of this shape from getBoundingBox().
        other - The shape to check for intersection with
      • fastIntersects

        public abstract boolean fastIntersects​(Rectangle box)
        Check if this shape's bounding box intersects with box.
      • getBoundingBox

        public abstract Rectangle getBoundingBox()
        Get the rectangle that represents the bounding box that fully contains this shape.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • toString

        public final void toString​(java.lang.StringBuilder buffer)
        Write the string representation of this shape to buffer.
      • addArguments

        public abstract void addArguments​(java.lang.StringBuilder buffer)
      • toString

        protected static void toString​(java.lang.StringBuilder buffer,
                                       double x,
                                       double y)
        Write the string representation of a point to buffer.
      • getTypeName

        public abstract java.lang.String getTypeName()
      • clone

        public Shape clone()
        Overrides:
        clone in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • valueOf

        public static Shape valueOf​(java.lang.Object value)
      • compareTo

        public final int compareTo​(Shape other)
        Shape comparison compares bounding box area.
        Specified by:
        compareTo in interface java.lang.Comparable<Shape>
      • readExternal

        public final void readExternal​(java.io.ObjectInput in)
                                throws java.io.IOException,
                                       java.lang.ClassNotFoundException
        GWT Incompatible - hence no @Override annotation. See com.google.gwt.emul.java.io.Externalizable
        Specified by:
        readExternal in interface java.io.Externalizable
        Throws:
        java.io.IOException
        java.lang.ClassNotFoundException
      • writeExternal

        public final void writeExternal​(java.io.ObjectOutput out)
                                 throws java.io.IOException
        GWT Incompatible - hence no @Override annotation. See com.google.gwt.emul.java.io.Externalizable
        Specified by:
        writeExternal in interface java.io.Externalizable
        Throws:
        java.io.IOException
      • readExternal

        public abstract Shape readExternal​(java.io.DataInput in)
                                    throws java.io.IOException,
                                           java.lang.ClassNotFoundException
        Throws:
        java.io.IOException
        java.lang.ClassNotFoundException
      • writeExternal

        public abstract void writeExternal​(java.io.DataOutput out)
                                    throws java.io.IOException
        Throws:
        java.io.IOException