Class BezierNode

java.lang.Object
org.jhotdraw8.geom.shape.BezierNode

public class BezierNode extends Object
Represents a node of a bezier path. A node has up to three control points:
  • px,py: POINT is the point through which the curve passes.
  • ix,iy: IN controls the tangent of the curve going towards C0.
  • ox,oy: OUT controls the tangent of the curve going away from C0.
A bit mask specifies which control points are in use.
Author:
Werner Randelshofer
  • Field Details

    • POINT_MASK

      public static final int POINT_MASK
      Constant for having control point C0 in effect
      See Also:
    • IN_MASK

      public static final int IN_MASK
      Constant for having control point C1 in effect (in addition to C0). C1 controls the curve going towards C0.
      See Also:
    • POINT_OUT_MASK

      public static final int POINT_OUT_MASK
      Constant for having control points C0 and C1 in effect.
      See Also:
    • OUT_MASK

      public static final int OUT_MASK
      Constant for having control point C2 in effect (in addition to C0). C2 controls the curve going away from C0.
      See Also:
    • IN_OUT_MASK

      public static final int IN_OUT_MASK
      Constant for having control points C1 and C2 in effect.
      See Also:
    • POINT_IN_OUT_MASK

      public static final int POINT_IN_OUT_MASK
      Constant for having control points C0, C1 and C2 in effect.
      See Also:
    • C0C2_MASK

      public static final int C0C2_MASK
      Constant for having control points C0 and C2 in effect.
      See Also:
    • MOVE_MASK

      public static final int MOVE_MASK
      Constant for moving to this bezier node.
      See Also:
    • CLOSE_MASK

      public static final int CLOSE_MASK
      Constant for closing the path by drawing a line or curve from this bezier node to the last node with a MOVE_MASK.
      See Also:
  • Constructor Details

    • BezierNode

      public BezierNode(double pointX, double pointY)
    • BezierNode

      public BezierNode(@NonNull Point2D p)
    • BezierNode

      public BezierNode(@NonNull javafx.geometry.Point2D p)
    • BezierNode

      public BezierNode(int mask, boolean equidistant, boolean collinear, @NonNull Point2D p, @NonNull Point2D i, @NonNull Point2D o)
    • BezierNode

      public BezierNode(int mask, boolean equidistant, boolean collinear, double pointX, double pointY, double inX, double inY, double outX, double outY)
  • Method Details

    • computeIsCollinear

      public boolean computeIsCollinear()
    • computeIsEquidistant

      public boolean computeIsEquidistant()
    • equals

      public boolean equals(@Nullable Object obj)
      Overrides:
      equals in class Object
    • getC

      public @NonNull Point2D getC(int mask)
      Gets a control point given the specified mask.
      Parameters:
      mask - a mask, one of POINT_MASK,IN_MASK,OUT_MASK.
      Returns:
      the point
    • getC

      public <T> @NonNull T getC(int mask, @NonNull BiFunction<Double,Double,T> f)
    • getPoint

      public @NonNull Point2D getPoint()
      Gets the point through which the curve passes.
      Returns:
      curve point
    • getIn

      public @NonNull Point2D getIn()
      Gets the incoming tangent point.
      Returns:
      incoming tangent point
    • getOut

      public <T> @NonNull T getOut(@NonNull BiFunction<Double,Double,T> f)
      Gets the outgoing tangent point.
      Returns:
      outgoing tangent point
    • getPoint

      public <T> @NonNull T getPoint(@NonNull BiFunction<Double,Double,T> f)
      Gets the point through which the curve passes.
      Returns:
      curve point
    • getIn

      public <T> @NonNull T getIn(@NonNull BiFunction<Double,Double,T> f)
      Gets the incoming tangent point.
      Returns:
      incoming tangent point
    • getOut

      public @NonNull Point2D getOut()
      Gets the outgoing tangent point.
      Returns:
      outgoing tangent point
    • getMask

      public int getMask()
      Returns:
      the mask
    • hasMask

      public boolean hasMask(int probe)
    • getMaxX

      public double getMaxX()
    • getMaxY

      public double getMaxY()
    • getMinX

      public double getMinX()
    • getMinY

      public double getMinY()
    • getX

      public double getX(int mask)
      Gets the x-coordinate of a control point given the specified mask.
      Parameters:
      mask - a mask, one of POINT_MASK,IN_MASK,OUT_MASK.
      Returns:
      the point
    • pointX

      public double pointX()
      Returns:
      the px
    • withPx

      public @NonNull BezierNode withPx(double px)
      Parameters:
      px - the p to set
      Returns:
      a new instance
    • inX

      public double inX()
      Returns:
      the ix
    • withIx

      public @NonNull BezierNode withIx(double ix)
      Parameters:
      ix - the x1 to set
      Returns:
      a new instance
    • outX

      public double outX()
      Returns:
      the x2
    • withOx

      public @NonNull BezierNode withOx(double ox)
      Parameters:
      ox - the x2 to set
      Returns:
      a new instance
    • getY

      public double getY(int mask)
    • pointY

      public double pointY()
      Returns:
      the y0
    • withPointY

      public @NonNull BezierNode withPointY(double py)
      Parameters:
      py - the y0 to set
      Returns:
      a new instance
    • inY

      public double inY()
      Returns:
      the y1
    • withIy

      public @NonNull BezierNode withIy(double iy)
      Parameters:
      iy - the y1 to set
      Returns:
      a new instance
    • outY

      public double outY()
      Returns:
      the y2
    • withOy

      public @NonNull BezierNode withOy(double oy)
      Parameters:
      oy - the y2 to set
      Returns:
      a new instance
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • hasMaskBits

      public boolean hasMaskBits(int mask)
    • hasIn

      public boolean hasIn()
    • hasOut

      public boolean hasOut()
    • isCollinear

      public boolean isCollinear()
      Returns:
      the collinear
    • isEquidistant

      public boolean isEquidistant()
      Returns:
      the equidistant
    • isMoveTo

      public boolean isMoveTo()
    • isClosePath

      public boolean isClosePath()
    • withC

      public @NonNull BezierNode withC(int mask, @NonNull Point2D c)
      Parameters:
      mask - specifies which control point must be set
      c - the c to set
      Returns:
      a new instance
    • withC

      public @NonNull BezierNode withC(int mask, double x, double y)
    • withPoint

      public @NonNull BezierNode withPoint(@NonNull Point2D c0)
      Parameters:
      c0 - the c0 to set
      Returns:
      a new instance
    • withPoint

      public @NonNull BezierNode withPoint(double x0, double y0)
      Parameters:
      x0 - the x0 to set
      y0 - the y0 to set
      Returns:
      a new instance
    • withPointAndTranslatedInOut

      public @NonNull BezierNode withPointAndTranslatedInOut(@NonNull Point2D c0)
      Parameters:
      c0 - the c0 to set
      Returns:
      a new instance
    • withPointAndTranslatedInOut

      public @NonNull BezierNode withPointAndTranslatedInOut(@NonNull javafx.geometry.Point2D c0)
      Parameters:
      c0 - the c0 to set
      Returns:
      a new instance
    • withIn

      public @NonNull BezierNode withIn(@NonNull Point2D c1)
      Parameters:
      c1 - the c0 to set
      Returns:
      a new instance
    • withIn

      public @NonNull BezierNode withIn(double inX, double inY)
      Parameters:
      inX - the x1 to set
      inY - the y1to set
      Returns:
      a new instance
    • withOut

      public @NonNull BezierNode withOut(@NonNull Point2D c2)
      Parameters:
      c2 - the c0 to set
      Returns:
      a new instance
    • withOut

      public @NonNull BezierNode withOut(double outX, double outY)
      Parameters:
      outX - the x2 to set
      outY - the y2 to set
      Returns:
      a new instance
    • withCollinear

      public @NonNull BezierNode withCollinear(boolean collinear)
      Parameters:
      collinear - the collinear to set
      Returns:
      a new instance
    • withEquidistant

      public @NonNull BezierNode withEquidistant(boolean equidistant)
      Parameters:
      equidistant - the equidistant to set
      Returns:
      a new instance
    • withMask

      public @NonNull BezierNode withMask(int mask)
      Parameters:
      mask - the mask to set
      Returns:
      a new instance
    • withMaskBitsSet

      public @NonNull BezierNode withMaskBitsSet(int mask)
      Sets all the bits in the specified mask.
      Parameters:
      mask - the mask to set
      Returns:
      a new instance
    • withMaskBitsClears

      public @NonNull BezierNode withMaskBitsClears(int mask)
      Clears all the bits in the specified mask.
      Parameters:
      mask - the mask to set
      Returns:
      a new instance
    • toString

      public @NonNull String toString()
      Overrides:
      toString in class Object
    • transform

      public @NonNull BezierNode transform(@NonNull AffineTransform transform)
    • transform

      public @NonNull BezierNode transform(@NonNull javafx.scene.transform.Transform transform)