Class JaxoBezierObject

    • Field Detail

    • Constructor Detail

      • JaxoBezierObject

        public JaxoBezierObject()
    • Method Detail

      • getPointCount

        public int getPointCount()
        Returns the number of points it takes to draw this object.
        Overrides:
        getPointCount in class Jaxo3PointObject
        Returns:
        4.
      • getX

        public int getX​(int index)
        X coordinate of Point 0 <= index < getPointCount().
        Overrides:
        getX in class Jaxo3PointObject
        Parameters:
        index - The index of the point to get.
        Returns:
        The x coordinate of the point at the given index.
      • getY

        public int getY​(int index)
        Y coordinate of Point 0 <= index < getPointCount().
        Overrides:
        getY in class Jaxo3PointObject
        Parameters:
        index - The index of the point to get.
        Returns:
        The y coordinate of the point at the given index.
      • setX

        public void setX​(int index,
                         int value)
        Set X coordinate of Point 0 <= index < getPointCount() to 'value'. Throws IllegalArgumentException if the index is not valid for the given object.
        Overrides:
        setX in class Jaxo3PointObject
        Parameters:
        index - The index of the point to set.
        value - The value to set.
      • setY

        public void setY​(int index,
                         int value)
        Set Y coordinate of Point 0 <= index < getPointCount() to 'value'. Throws IllegalArgumentException if the index is not valid for the given object.
        Overrides:
        setY in class Jaxo3PointObject
        Parameters:
        index - The index of the point to set.
        value - The value to set.
      • setNoFreqStretching

        public final void setNoFreqStretching​(boolean nofs)
        Sets the frequency stretching property of this Bezier.
        Parameters:
        nofs - True if this Bezier is not frequency stretched.
      • isNoFreqStretching

        public final boolean isNoFreqStretching()
        Returns the frequency stretching property of this Bezier.
        Returns:
        True if this Bezier is not frequency stretched.
      • setX4

        public final void setX4​(int newx4)
        Sets the x coordinate of the fourth click point of this Bezier.
        Parameters:
        newx4 - The x coordinate of the fourth click point of this Bezier.
      • getX4

        public final int getX4()
        Returns the x coordinate of the fourth click point of this Bezier.
        Returns:
        The x coordinate of the fourth click point of this Bezier.
      • setY4

        public final void setY4​(int newy4)
        Sets the y coordinate of the fourth click point of this Bezier.
        Parameters:
        newy4 - The y coordinate of the fourth click point of this Bezier.
      • getY4

        public final int getY4()
        Returns the y coordinate of the fourth click point of this Bezier.
        Returns:
        The y coordinate of the fourth click point of this Bezier.
      • setBezierPts

        public final void setBezierPts​(int sx1,
                                       int sy1,
                                       int sx2,
                                       int sy2,
                                       int sx3,
                                       int sy3,
                                       int sx4,
                                       int sy4)
        Deprecated.
        Sets the points of this Bezier.
        Parameters:
        sx1 - The x coordinate of the first click point of this Bezier.
        sy1 - The y coordinate of the first click point of this Bezier.
        sx2 - The x coordinate of the second click point of this Bezier.
        sy2 - The y coordinate of the second click point of this Bezier.
        sx3 - The x coordinate of the third click point of this Bezier.
        sy3 - The y coordinate of the third click point of this Bezier.
        sx4 - The x coordinate of the fourth click point of this Bezier.
        sy4 - The y coordinate of the fourth click point of this Bezier.
      • setLocation

        public final void setLocation​(int sx1,
                                      int sy1,
                                      int sx2,
                                      int sy2,
                                      int sx3,
                                      int sy3,
                                      int sx4,
                                      int sy4)
        Sets the points of this Bezier.
        Parameters:
        sx1 - The x coordinate of the first click point of this Bezier.
        sy1 - The y coordinate of the first click point of this Bezier.
        sx2 - The x coordinate of the second click point of this Bezier.
        sy2 - The y coordinate of the second click point of this Bezier.
        sx3 - The x coordinate of the third click point of this Bezier.
        sy3 - The y coordinate of the third click point of this Bezier.
        sx4 - The x coordinate of the fourth click point of this Bezier.
        sy4 - The y coordinate of the fourth click point of this Bezier.
      • isCopy

        public boolean isCopy​(JaxoObject comp)
        Determines if this JaxoObject is a copy of the specified one.
        Overrides:
        isCopy in class Jaxo3PointObject
        Parameters:
        comp - The JaxoObject to compare against.
        Returns:
        True if the JaxoObjects are identical.
      • copyFrom

        public void copyFrom​(JaxoBezierObject temp)
        Sets all parameters from the given object to the current one.
        Parameters:
        temp - The object to copy from.
      • paintVisualAid

        public final void paintVisualAid​(JaxoGraphics2D g2)
        Paints a visual aid for the user during dragging (moving or resizing) of this JaxoObject.
        Overrides:
        paintVisualAid in class JaxoObject
        Parameters:
        g2 - The graphics context to paint the visual aid.
      • paintHandles

        public final void paintHandles​(JaxoGraphics2D g2,
                                       JaxoHandle h,
                                       int editMode)
        Paints the handles of this JaxoObject that allow to move/resize/edit it.
        Overrides:
        paintHandles in class Jaxo3PointObject
        Parameters:
        g2 - The corresponding graphics context.
        h - A handle object to be used for painting.
        editMode - The edit mode that the handles are being painted in.
      • smallestDistanceTo

        public final float smallestDistanceTo​(int px,
                                              int py)
        Determines the smallest distance of any of the handles of this JaxoObject from the given point.
        Overrides:
        smallestDistanceTo in class Jaxo3PointObject
        Parameters:
        px - The x coordinate of the test point.
        py - The y coordinate of the test point.
        Returns:
        The smallest distance.
      • getGrabbedHandle

        public int getGrabbedHandle​(int clickX,
                                    int clickY,
                                    JaxoHandle h)
        Determines which handle the user has selected to move/resize/edit an object.
        Overrides:
        getGrabbedHandle in class Jaxo3PointObject
        Parameters:
        clickX - The x coordinate where the mouse click has ocurred.
        clickY - The y coordinate where the mouse click has ocurred.
        h - A handle object.
        Returns:
        One of the static variables SELECT_* defined for this JaxoObject that specifies the handle which the user has clicked.
      • canBeSelected

        public boolean canBeSelected​(int handle,
                                     int mode)
        Determines if the object can be selected (moved, edited, etc) from the given point in a given edit mode.
        Overrides:
        canBeSelected in class Jaxo3PointObject
        Parameters:
        handle - One of the static variables SELECT_* defined for this JaxoObject.
        mode - The current edit mode.
        Returns:
        True if the object may be selected from the given point, false otherwise.
      • moveBy

        public final void moveBy​(int deltaX,
                                 int deltaY)
        Reset the coordinates of the object when it is moved by deltaX and deltaY.
        Overrides:
        moveBy in class Jaxo3PointObject
        Parameters:
        deltaX - The x displacement.
        deltaY - The y displacement.
      • rescaleObject

        public final void rescaleObject​(int orx,
                                        int ory,
                                        float scale)
        Rescale this JaxoObject by the scale factor scale, keeping the point (orx, ory) fixed.
        Overrides:
        rescaleObject in class Jaxo3PointObject
        Parameters:
        orx - The x-coordinate of the fixed point.
        ory - The y-coordinate of the fixed point.
        scale - The scale parameter.
      • getLatexPoint

        protected static java.awt.geom.Point2D getLatexPoint​(double x,
                                                             double y,
                                                             float scaleFactor,
                                                             int canvasHeight)
        Returns the latex (ie axodraw) coordinates of the point passed of this JaxoObject.
        Parameters:
        x - the x coordinate of the point
        y - the y coordinate of the point
        scaleFactor - A scalefactor.
        canvasHeight - The current height of the canvas.
        Returns:
        A Point2D.
      • getLatexPoint

        protected static java.awt.geom.Point2D getLatexPoint​(java.awt.geom.Point2D p,
                                                             float scaleFactor,
                                                             int canvasHeight)
        Returns the latex (ie axodraw) coordinates of the point passed of this JaxoObject.
        Parameters:
        p - the point
        scaleFactor - A scalefactor.
        canvasHeight - The current height of the canvas.
        Returns:
        A Point2D.
        Since:
        2.1
      • bezierLatexCommand

        protected static java.lang.String bezierLatexCommand​(java.lang.String options,
                                                             java.awt.geom.Point2D p1,
                                                             java.awt.geom.Point2D p2,
                                                             java.awt.geom.Point2D p3,
                                                             java.awt.geom.Point2D p4)
        Return a latex Bezier command.
        Parameters:
        options - the latex options for the command.
        p1 - the first control point of the Bezier.
        p2 - the second control point of the Bezier.
        p3 - the third control point of the Bezier.
        p4 - the fourth control point of the Bezier.
        Returns:
        a latex (axodraw4j) Bezier command.
        Since:
        2.1
      • getArrowCommand

        protected java.lang.String getArrowCommand​(float scale)
      • getPoint

        public java.awt.geom.Point2D getPoint​(double u)
        Returns a point of this Bezier curve at parameter u.
        Parameters:
        u - the parameter value, needs to be between 0 and 1.
        Returns:
        A Point2D.
      • getPointOnCurve

        protected java.awt.geom.Point2D getPointOnCurve​(double t)
        Returns a point of this Bezier curve at a given parameter value. Unlike getPoint(double), the parameter may be outside the interval [0:1]. If it lies outside, the closest end-point of the Bezier curve is returned, i.e. the returned Point is always a point of the Bezier curve. This method should only be used to avoid rounding errors at the end points.
        Parameters:
        t - the curve parameter. If t < 0 then the Point at t=0 will be returned. If t > 1 then the Point at t=1 will be returned.
        Returns:
        a Point of the Bezier curve at given parameter value.
        Since:
        2.1
      • slope

        public double slope​(double u)
        Returns the first derivative of this Bezier curve at parameter u.
        Parameters:
        u - the parameter value, needs to be between 0 and 1.
        Returns:
        the slope (in radians) at t.
      • getBezierLength

        public final double getBezierLength()
        Returns the approximate length of this Bezier curve.
        Returns:
        The length of the Bezier curve.
      • setPreferences

        public void setPreferences()
        Applies default values to this JaxoObject. All fields except location points are initialized with values taken from the preferences.
        Overrides:
        setPreferences in class JaxoParticleObject