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

Class Bow

  • All Implemented Interfaces:
    java.io.Externalizable, java.io.Serializable


    public class Bow
    extends OutlinedItem
    implements java.io.Externalizable
    Class Bow provides a DrawingItem that joins two points with a curved (bowed) line. The curve is specified by a "curve factor." If the curve factor is positive, the line curves to the right when going from the starting point to the ending point. If the curve factor is negative, the line curves to the left. The larger the magnitude of the curve factor, the farther the line curves. (The curve factor is the tangent of the angle at which the line leaves the starting point and approaches the ending point.) The line may have an Arrow at either or both ends. The line has an outline but no filled interior.

    The static defaultCurve(), defaultStartArrow(), and defaultEndArrow() methods are provided to set the default curve factor, starting arrow, and ending arrow. If the curve factor, starting arrow, or ending arrow is not specified, the current default curve factor, starting arrow, or ending arrow is used.

    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor and Description
      Bow()
      Construct a new bowed line.
      Bow(Bow theBow)
      Construct a bowed line with the same points, outline, starting arrow, ending arrow, and curve factor as the given line.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      Bow add()
      Add this bowed line to the end of the default drawing's sequence of drawing items.
      Bow add(Drawing theDrawing)
      Add this bowed line to the end of the given drawing's sequence of drawing items.
      Bow addFirst()
      Add this bowed line to the beginning of the default drawing's sequence of drawing items.
      Bow addFirst(Drawing theDrawing)
      Add this bowed line to the beginning of the given drawing's sequence of drawing items.
      double curve()
      Returns this bowed line's curve factor.
      Bow curve(double theCurve)
      Set this bowed line's curve factor.
      static double defaultCurve()
      Returns the default curve factor.
      static void defaultCurve(double theCurve)
      Set the default curve factor.
      static Arrow defaultEndArrow()
      Returns the default ending arrow.
      static void defaultEndArrow(Arrow theArrow)
      Set the default ending arrow.
      static Arrow defaultStartArrow()
      Returns the default starting arrow.
      static void defaultStartArrow(Arrow theArrow)
      Set the default starting arrow.
      void draw(java.awt.Graphics2D g2d)
      Draw this drawing item in the given graphics context.
      Point end()
      Returns this bowed line's ending point.
      Bow end(double x, double y)
      Set this bowed line's ending point.
      Bow end(Point thePoint)
      Set this bowed line's ending point.
      Arrow endArrow()
      Returns this bowed line's ending arrow.
      Bow endArrow(Arrow theArrow)
      Set this bowed line's ending arrow.
      Bow flip()
      Flip this bowed line from curving right to curving left or vice versa.
      double height()
      Returns the height of this drawing item's bounding box.
      Point nw()
      Returns the northwest corner point of this drawing item's bounding box.
      Bow outline(Outline theOutline)
      Set this bowed line's outline.
      void readExternal(java.io.ObjectInput in)
      Read this bowed line from the given object input stream.
      Size size()
      Returns the size of this drawing item's bounding box.
      Point start()
      Returns this bowed line's starting point.
      Bow start(double x, double y)
      Set this bowed line's starting point.
      Bow start(Point thePoint)
      Set this bowed line's starting point.
      Arrow startArrow()
      Returns this bowed line's starting arrow.
      Bow startArrow(Arrow theArrow)
      Set this bowed line's starting arrow.
      double width()
      Returns the width of this drawing item's bounding box.
      void writeExternal(java.io.ObjectOutput out)
      Write this bowed line to the given object output stream.
      • Methods inherited from class java.lang.Object

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

      • NORMAL_START_ARROW

        public static final Arrow NORMAL_START_ARROW
        The normal starting arrow: None.
      • NORMAL_END_ARROW

        public static final Arrow NORMAL_END_ARROW
        The normal ending arrow: None.
      • NORMAL_CURVE

        public static final double NORMAL_CURVE
        The normal curve factor (0.5).
        See Also:
        Constant Field Values
    • Constructor Detail

      • Bow

        public Bow()
        Construct a new bowed line. The line has no points initially. The default outline, starting arrow, ending arrow, and curve factor are used.
      • Bow

        public Bow(Bow theBow)
        Construct a bowed line with the same points, outline, starting arrow, ending arrow, and curve factor as the given line.
        Parameters:
        theBow - Bowed line.
        Throws:
        java.lang.NullPointerException - (unchecked exception) Thrown if theBow is null.
    • Method Detail

      • defaultStartArrow

        public static Arrow defaultStartArrow()
        Returns the default starting arrow.
        Returns:
        Default starting arrow.
      • defaultStartArrow

        public static void defaultStartArrow(Arrow theArrow)
        Set the default starting arrow. Before calling this method the first time, the default starting arrow is Arrow.NONE.
        Parameters:
        theArrow - Default starting arrow.
        Throws:
        java.lang.NullPointerException - (unchecked exception) Thrown if theArrow is null.
      • defaultEndArrow

        public static Arrow defaultEndArrow()
        Returns the default ending arrow.
        Returns:
        Default ending arrow.
      • defaultEndArrow

        public static void defaultEndArrow(Arrow theArrow)
        Set the default ending arrow. Before calling this method the first time, the default ending arrow is Arrow.NONE.
        Parameters:
        theArrow - Default ending arrow.
        Throws:
        java.lang.NullPointerException - (unchecked exception) Thrown if theArrow is null.
      • defaultCurve

        public static double defaultCurve()
        Returns the default curve factor.
        Returns:
        Default curve factor.
      • defaultCurve

        public static void defaultCurve(double theCurve)
        Set the default curve factor. Before calling this method the first time, the default curve factor is 0.5.
        Parameters:
        theCurve - Default curve factor.
      • size

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

        public double width()
        Returns the width of this drawing item's bounding box.
        Specified by:
        width in class DrawingItem
        Returns:
        Width.
      • height

        public double height()
        Returns the height of this drawing item's bounding box.
        Specified by:
        height in class DrawingItem
        Returns:
        Height.
      • nw

        public Point nw()
        Returns the northwest corner point of this drawing item's bounding box.
        Specified by:
        nw in class DrawingItem
        Returns:
        Northwest corner point.
      • outline

        public Bow outline(Outline theOutline)
        Set this bowed line's outline.
        Overrides:
        outline in class OutlinedItem
        Parameters:
        theOutline - Outline, or Outline.NONE.
        Returns:
        This bowed line.
      • start

        public Point start()
        Returns this bowed line's starting point.
        Returns:
        Starting point.
      • start

        public Bow start(double x,
                         double y)
        Set this bowed line's starting point.
        Parameters:
        x - Starting point X coordinate.
        y - Starting point Y coordinate.
        Returns:
        This bowed line.
      • start

        public Bow start(Point thePoint)
        Set this bowed line's starting point.
        Parameters:
        thePoint - Starting point.
        Returns:
        This bowed line.
        Throws:
        java.lang.NullPointerException - (unchecked exception) Thrown if thePoint is null.
      • end

        public Point end()
        Returns this bowed line's ending point.
        Returns:
        Ending point.
      • end

        public Bow end(double x,
                       double y)
        Set this bowed line's ending point.
        Parameters:
        x - Ending point X coordinate.
        y - Ending point Y coordinate.
        Returns:
        This bowed line.
      • end

        public Bow end(Point thePoint)
        Set this bowed line's ending point.
        Parameters:
        thePoint - Ending point.
        Returns:
        This bowed line.
        Throws:
        java.lang.NullPointerException - (unchecked exception) Thrown if thePoint is null.
      • startArrow

        public Arrow startArrow()
        Returns this bowed line's starting arrow.
        Returns:
        Starting arrow.
      • startArrow

        public Bow startArrow(Arrow theArrow)
        Set this bowed line's starting arrow.
        Parameters:
        theArrow - Starting arrow.
        Returns:
        This bowed line.
        Throws:
        java.lang.NullPointerException - (unchecked exception) Thrown if theArrow is null.
      • endArrow

        public Arrow endArrow()
        Returns this bowed line's ending arrow.
        Returns:
        Ending arrow.
      • endArrow

        public Bow endArrow(Arrow theArrow)
        Set this bowed line's ending arrow.
        Parameters:
        theArrow - Ending arrow.
        Returns:
        This bowed line.
        Throws:
        java.lang.NullPointerException - (unchecked exception) Thrown if theArrow is null.
      • curve

        public double curve()
        Returns this bowed line's curve factor.
        Returns:
        Curve factor.
      • curve

        public Bow curve(double theCurve)
        Set this bowed line's curve factor.
        Parameters:
        theCurve - Curve factor.
        Returns:
        This bowed line.
      • flip

        public Bow flip()
        Flip this bowed line from curving right to curving left or vice versa.
        Returns:
        This bowed line.
      • add

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

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

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

        public Bow addFirst(Drawing theDrawing)
        Add this bowed line to the beginning of the given drawing's sequence of drawing items.
        Overrides:
        addFirst in class OutlinedItem
        Parameters:
        theDrawing - Drawing.
        Returns:
        This bowed line.
        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 bowed line to the given object output stream.
        Specified by:
        writeExternal in interface java.io.Externalizable
        Overrides:
        writeExternal in class OutlinedItem
        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 bowed line from the given object input stream.
        Specified by:
        readExternal in interface java.io.Externalizable
        Overrides:
        readExternal in class OutlinedItem
        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 line 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.
        Overrides:
        draw in class DrawingItem
        Parameters:
        g2d - 2-D graphics context.

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.