Documentation of 'edu.rit.draw.item.DrawingItem' Java class
DrawingItem
edu.rit.draw.item

Class DrawingItem

  • All Implemented Interfaces:
    java.io.Externalizable, java.io.Serializable
    Direct Known Subclasses:
    Group, Image, OutlinedItem, Text


    public abstract class DrawingItem
    extends java.lang.Object
    implements java.io.Externalizable
    Class DrawingItem is the abstract base class for each item on a Drawing. Subclasses provide different kinds of drawing items, such as text, lines, and shapes.

    Each drawing item is contained within a rectangular bounding box. Class DrawingItem's methods return the location and dimensions of the bounding box.

    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor and Description
      DrawingItem()
      Construct a new drawing item.
      DrawingItem(DrawingItem theItem)
      Construct a new drawing item that is the same as the given drawing item.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method and Description
      DrawingItem add()
      Add this drawing item to the end of the default drawing's sequence of drawing items.
      DrawingItem add(Drawing theDrawing)
      Add this drawing item to the end of the given drawing's sequence of drawing items.
      DrawingItem addFirst()
      Add this drawing item to the beginning of the default drawing's sequence of drawing items.
      DrawingItem addFirst(Drawing theDrawing)
      Add this drawing item to the beginning of the given drawing's sequence of drawing items.
      java.awt.geom.Rectangle2D boundingBox()
      Returns the rectangular region this drawing item occupies.
      Point c()
      Returns the center point of this drawing item's bounding box.
      void draw(java.awt.Graphics2D g2d)
      Draw this drawing item in the given graphics context.
      Point e()
      Returns the east middle point of this drawing item's bounding box.
      abstract double height()
      Returns the height of this drawing item's bounding box.
      Point n()
      Returns the north middle point of this drawing item's bounding box.
      Point ne()
      Returns the northeast corner point of this drawing item's bounding box.
      abstract Point nw()
      Returns the northwest corner point of this drawing item's bounding box.
      void readExternal(java.io.ObjectInput in)
      Read this drawing item from the given object input stream.
      Point s()
      Returns the south middle point of this drawing item's bounding box.
      Point se()
      Returns the southeast corner point of this drawing item's bounding box.
      Size size()
      Returns the size of this drawing item's bounding box.
      Point sw()
      Returns the southwest corner point of this drawing item's bounding box.
      Point w()
      Returns the west middle point of this drawing item's bounding box.
      abstract double width()
      Returns the width of this drawing item's bounding box.
      void writeExternal(java.io.ObjectOutput out)
      Write this drawing item to the given object output stream.
      • Methods inherited from class java.lang.Object

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

      • DrawingItem

        public DrawingItem()
        Construct a new drawing item.
      • DrawingItem

        public DrawingItem(DrawingItem theItem)
        Construct a new drawing item that is the same as the given drawing item.
        Parameters:
        theItem - Drawing item.
        Throws:
        java.lang.NullPointerException - (unchecked exception) Thrown if theItem is null.
    • Method Detail

      • size

        public Size size()
        Returns the size of this drawing item's bounding box.
        Returns:
        Size.
      • width

        public abstract double width()
        Returns the width of this drawing item's bounding box.
        Returns:
        Width.
      • height

        public abstract double height()
        Returns the height of this drawing item's bounding box.
        Returns:
        Height.
      • nw

        public abstract Point nw()
        Returns the northwest corner point of this drawing item's bounding box.
        Returns:
        Northwest corner point.
      • n

        public Point n()
        Returns the north middle point of this drawing item's bounding box.
        Returns:
        North middle point.
      • ne

        public Point ne()
        Returns the northeast corner point of this drawing item's bounding box.
        Returns:
        Northeast corner point.
      • w

        public Point w()
        Returns the west middle point of this drawing item's bounding box.
        Returns:
        West middle point.
      • c

        public Point c()
        Returns the center point of this drawing item's bounding box.
        Returns:
        Center point.
      • e

        public Point e()
        Returns the east middle point of this drawing item's bounding box.
        Returns:
        East middle point.
      • sw

        public Point sw()
        Returns the southwest corner point of this drawing item's bounding box.
        Returns:
        Southwest corner point.
      • s

        public Point s()
        Returns the south middle point of this drawing item's bounding box.
        Returns:
        South middle point.
      • se

        public Point se()
        Returns the southeast corner point of this drawing item's bounding box.
        Returns:
        Southeast corner point.
      • add

        public DrawingItem add()
        Add this drawing item to the end of the default drawing's sequence of drawing items.
        Returns:
        This drawing item.
        Throws:
        java.lang.NullPointerException - (unchecked exception) Thrown if there is no default drawing.
        See Also:
        Drawing.defaultDrawing()
      • add

        public DrawingItem add(Drawing theDrawing)
        Add this drawing item to the end of the given drawing's sequence of drawing items.
        Parameters:
        theDrawing - Drawing.
        Returns:
        This drawing item.
        Throws:
        java.lang.NullPointerException - (unchecked exception) Thrown if theDrawing is null.
      • addFirst

        public DrawingItem addFirst()
        Add this drawing item to the beginning of the default drawing's sequence of drawing items.
        Returns:
        This drawing item.
        Throws:
        java.lang.NullPointerException - (unchecked exception) Thrown if there is no default drawing.
        See Also:
        Drawing.defaultDrawing()
      • addFirst

        public DrawingItem addFirst(Drawing theDrawing)
        Add this drawing item to the beginning of the given drawing's sequence of drawing items.
        Parameters:
        theDrawing - Drawing.
        Returns:
        This drawing item.
        Throws:
        java.lang.NullPointerException - (unchecked exception) Thrown if theDrawing is null.
      • writeExternal

        public void writeExternal(java.io.ObjectOutput out)
                           throws java.io.IOException
        Write this drawing item to the given object output stream.
        Specified by:
        writeExternal in interface java.io.Externalizable
        Parameters:
        out - Object output stream.
        Throws:
        java.io.IOException - Thrown if an I/O error occurred.
      • readExternal

        public void readExternal(java.io.ObjectInput in)
                          throws java.io.IOException,
                                 java.lang.ClassNotFoundException
        Read this drawing item from the given object input stream.
        Specified by:
        readExternal in interface java.io.Externalizable
        Parameters:
        in - Object input stream.
        Throws:
        java.io.IOException - Thrown if an I/O error occurred.
        java.lang.ClassNotFoundException - Thrown if any class needed to deserialize this drawing item cannot be found.
      • draw

        public void draw(java.awt.Graphics2D g2d)
        Draw this drawing item in the given graphics context. This method is allowed to change the graphics context's paint, stroke, and transform, and it doesn't have to change them back.
        Parameters:
        g2d - 2-D graphics context.
      • boundingBox

        public java.awt.geom.Rectangle2D boundingBox()
        Returns the rectangular region this drawing item occupies.
        Returns:
        Bounding box.

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.