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

Class Arc

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


    public class Arc
    extends OutlinedItem
    implements java.io.Externalizable
    Class Arc provides a DrawingItem that is a circular arc. The arc has an outline but no filled interior. The arc is defined by the following attributes:
    • center() -- The arc's center point. The default is (0,0).
       
    • radius() -- The arc's radius. The default is 1.
       
    • start() -- The arc's starting angle in radians. This is the angle from the positive X axis to the arc's starting point. The default is 0.
       
    • extent() -- The arc's angular extent in radians. This is the angle from the arc's starting point to the arc's ending point. The default is π/2.

    Angles increase from the positive X axis towards the positive Y axis. Since the positive X axis points to the right and the positive Y axis points down, angles increase in the clockwise direction. (This is the opposite of the usual mathematical convention, where the positive Y axis points upwards.)

    The static defaultCenter(), defaultRadius(), defaultStart(), and defaultExtent() methods are provided to set the default center point, radius, starting angle, and angular extent. If the center point, radius, starting angle, or angular extent is not specified, the current default center point, radius, starting angle, or angular extent is used.

    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor and Description
      Arc()
      Construct a new arc.
      Arc(Arc theArc)
      Construct a new arc with the same center point, radius, starting angle, and angular extent as the given arc.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      Arc add()
      Add this arc to the end of the default drawing's sequence of drawing items.
      Arc add(Drawing theDrawing)
      Add this arc to the end of the given drawing's sequence of drawing items.
      Arc addFirst()
      Add this arc to the beginning of the default drawing's sequence of drawing items.
      Arc addFirst(Drawing theDrawing)
      Add this arc to the beginning of the given drawing's sequence of drawing items.
      Point center()
      Returns this arc's center point.
      Arc center(Point theCenter)
      Set this arc's center point.
      static Point defaultCenter()
      Returns the default center point.
      static void defaultCenter(Point theCenter)
      Set the default center point.
      static double defaultExtent()
      Returns the default angular extent.
      static void defaultExtent(double theExtent)
      Set the default angular extent.
      static double defaultRadius()
      Returns the default radius.
      static void defaultRadius(double theRadius)
      Set the default radius.
      static double defaultStart()
      Returns the default starting angle.
      static void defaultStart(double theStart)
      Set the default starting angle.
      void draw(java.awt.Graphics2D g2d)
      Draw this drawing item in the given graphics context.
      double extent()
      Returns this arc's angular extent.
      Arc extent(double theExtent)
      Set this arc's angular extent.
      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.
      Arc outline(Outline theOutline)
      Set this arc's outline.
      double radius()
      Returns this arc's radius.
      Arc radius(double theRadius)
      Set this arc's radius.
      void readExternal(java.io.ObjectInput in)
      Read this arc from the given object input stream.
      Size size()
      Returns the size of this drawing item's bounding box.
      double start()
      Returns this arc's starting angle.
      Arc start(double theStart)
      Set this arc's starting angle.
      double width()
      Returns the width of this drawing item's bounding box.
      void writeExternal(java.io.ObjectOutput out)
      Write this arc 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_CENTER

        public static final Point NORMAL_CENTER
        The normal center point: (0,0).
      • NORMAL_RADIUS

        public static final double NORMAL_RADIUS
        The normal radius: 1.
        See Also:
        Constant Field Values
      • NORMAL_START

        public static final double NORMAL_START
        The normal starting angle: 0.
        See Also:
        Constant Field Values
      • NORMAL_EXTENT

        public static final double NORMAL_EXTENT
        The normal angular extent: π/2.
        See Also:
        Constant Field Values
    • Constructor Detail

      • Arc

        public Arc()
        Construct a new arc. The default center point, radius, starting angle, and angular extent are used.
      • Arc

        public Arc(Arc theArc)
        Construct a new arc with the same center point, radius, starting angle, and angular extent as the given arc.
        Parameters:
        theArc - Arc.
        Throws:
        java.lang.NullPointerException - (unchecked exception) Thrown if theArc is null.
    • Method Detail

      • defaultCenter

        public static Point defaultCenter()
        Returns the default center point.
        Returns:
        Default center point.
      • defaultCenter

        public static void defaultCenter(Point theCenter)
        Set the default center point. Before calling this method the first time, the default center point is (0,0).
        Parameters:
        theCenter - Default center point.
        Throws:
        java.lang.NullPointerException - (unchecked exception) Thrown if theCenter is null.
      • defaultRadius

        public static double defaultRadius()
        Returns the default radius.
        Returns:
        Default radius.
      • defaultRadius

        public static void defaultRadius(double theRadius)
        Set the default radius. Before calling this method the first time, the default radius is 1.
        Parameters:
        theRadius - Default radius.
        Throws:
        java.lang.IllegalArgumentException - (unchecked exception) Thrown if theRadius <= 0.
      • defaultStart

        public static double defaultStart()
        Returns the default starting angle.
        Returns:
        Default starting angle (radians).
      • defaultStart

        public static void defaultStart(double theStart)
        Set the default starting angle. Before calling this method the first time, the default starting angle is 0.
        Parameters:
        theStart - Default starting angle (radians).
      • defaultExtent

        public static double defaultExtent()
        Returns the default angular extent.
        Returns:
        Default angular extent (radians).
      • defaultExtent

        public static void defaultExtent(double theExtent)
        Set the default angular extent. Before calling this method the first time, the default angular extent is π/2.
        Parameters:
        theExtent - Default angular extent (radians).
      • 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 Arc outline(Outline theOutline)
        Set this arc's outline.
        Overrides:
        outline in class OutlinedItem
        Parameters:
        theOutline - Outline, or Outline.NONE.
        Returns:
        This arc.
      • center

        public Point center()
        Returns this arc's center point.
        Returns:
        Center point.
      • center

        public Arc center(Point theCenter)
        Set this arc's center point.
        Parameters:
        theCenter - Center point.
        Returns:
        This arc.
        Throws:
        java.lang.NullPointerException - (unchecked exception) Thrown if theCenter is null.
      • radius

        public double radius()
        Returns this arc's radius.
        Returns:
        Radius.
      • radius

        public Arc radius(double theRadius)
        Set this arc's radius.
        Parameters:
        theRadius - Radius.
        Returns:
        This arc.
        Throws:
        java.lang.IllegalArgumentException - (unchecked exception) Thrown if theRadius <= 0.
      • start

        public double start()
        Returns this arc's starting angle.
        Returns:
        Starting angle (radians).
      • start

        public Arc start(double theStart)
        Set this arc's starting angle.
        Parameters:
        theStart - Starting angle (radians).
        Returns:
        This arc.
      • extent

        public double extent()
        Returns this arc's angular extent.
        Returns:
        Angular extent (radians).
      • extent

        public Arc extent(double theExtent)
        Set this arc's angular extent.
        Parameters:
        theExtent - Angular extent (radians).
        Returns:
        This arc.
      • add

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

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

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

        public Arc addFirst(Drawing theDrawing)
        Add this arc to the beginning of the given drawing's sequence of drawing items.
        Overrides:
        addFirst in class OutlinedItem
        Parameters:
        theDrawing - Drawing.
        Returns:
        This arc.
        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 arc 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 arc 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.