java.lang.Object
com.github.weisj.jsvg.geometry.path.PathCommand
com.github.weisj.jsvg.geometry.path.Arc

final class Arc extends PathCommand
This is a little used SVG function, as most editors will save curves as Béziers. To reduce the need to rely on the Batik library, this functionality is being bypassed for the time being. In the future, it would be nice to extend the GeneralPath command to include the arcTo ability provided by Batik.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final boolean
     
    private final float
     
    private final float
     
    private final boolean
     
    private final float
     
    private final float
     
    private final float
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Arc(boolean isRelative, float rx, float ry, float xAxisRot, boolean largeArc, boolean sweep, float x, float y)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    appendPath(@NotNull Path2D path, @NotNull BuildHistory hist)
     
    private void
    arcTo(@NotNull Path2D path, float rx, float ry, float angle, boolean largeArcFlag, boolean sweepFlag, float x, float y, float x0, float y0)
    Adds an elliptical arc, defined by two radii, an angle from the x-axis, a flag to choose the large arc or not, a flag to indicate if we increase or decrease the angles and the final point of the arc.
    private static @NotNull Arc2D
    computeRawArc(double x0, double y0, double rx, double ry, double angle, boolean largeArcFlag, boolean sweepFlag, double x, double y)
    This constructs a non-rotated Arc2D from the SVG specification of an Elliptical arc.
     

    Methods inherited from class com.github.weisj.jsvg.geometry.path.PathCommand

    isRelative, lastKnotReflection, nodeCount, offset

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • rx

      private final float rx
    • ry

      private final float ry
    • xAxisRot

      private final float xAxisRot
    • largeArc

      private final boolean largeArc
    • sweep

      private final boolean sweep
    • x

      private final float x
    • y

      private final float y
  • Constructor Details

    • Arc

      public Arc(boolean isRelative, float rx, float ry, float xAxisRot, boolean largeArc, boolean sweep, float x, float y)
  • Method Details

    • appendPath

      public void appendPath(@NotNull @NotNull Path2D path, @NotNull @NotNull BuildHistory hist)
      Specified by:
      appendPath in class PathCommand
    • arcTo

      private void arcTo(@NotNull @NotNull Path2D path, float rx, float ry, float angle, boolean largeArcFlag, boolean sweepFlag, float x, float y, float x0, float y0)
      Adds an elliptical arc, defined by two radii, an angle from the x-axis, a flag to choose the large arc or not, a flag to indicate if we increase or decrease the angles and the final point of the arc.
      Parameters:
      path - The path that the arc will be appended to.
      rx - the x radius of the ellipse
      ry - the y radius of the ellipse
      angle - the angle from the x-axis of the current coordinate system to the x-axis of the ellipse in degrees.
      largeArcFlag - the large arc flag. If true the arc spanning less than or equal to 180 degrees is chosen, otherwise the arc spanning greater than 180 degrees is chosen
      sweepFlag - the sweep flag. If true the line joining center to arc sweeps through decreasing angles otherwise it sweeps through increasing angles
      x - the absolute x coordinate of the final point of the arc.
      y - the absolute y coordinate of the final point of the arc.
      x0 - - The absolute x coordinate of the initial point of the arc.
      y0 - - The absolute y coordinate of the initial point of the arc.
    • computeRawArc

      @NotNull private static @NotNull Arc2D computeRawArc(double x0, double y0, double rx, double ry, double angle, boolean largeArcFlag, boolean sweepFlag, double x, double y)
      This constructs a non-rotated Arc2D from the SVG specification of an Elliptical arc. To get the final arc you need to apply a rotation transform such as:

      AffineTransform.getRotateInstance (angle, arc.getX()+arc.getWidth()/2, arc.getY()+arc.getHeight()/2);

      Parameters:
      x0 - origin of arc in x
      y0 - origin of arc in y
      rx - radius of arc in x
      ry - radius of arc in y
      angle - number of radians in arc
      largeArcFlag - the large arc flag
      sweepFlag - the sweep flag
      x - ending coordinate of arc in x
      y - ending coordinate of arc in y
      Returns:
      arc shape
    • toString

      public String toString()
      Overrides:
      toString in class Object