Class ZoomableGraphicsContext


  • public class ZoomableGraphicsContext
    extends Object
    This class is used to issue draw calls to a ZoomableCanvas using a buffer.

    The ZoomableGraphicsContext is a wrapper to the GraphicsContext embedded within the ZoomableCanvas.

    The coordinates that are supported by the ZoomableGraphicsContext are document coordinates (not the screen coordinates). Consequently, the ZoomableGraphicsContext translates any coordinates from the document standard to the JavaFX standard.

    Since:
    15.0
    Version:
    17.0 2020-01-04 14:41:52
    Author:
    Stéphane GALLAND
    See Also:
    ZoomableCanvas, GraphicsContext
    Maven Group Id:
    org.arakhne.afc.advanced
    Maven Artifact Id:
    nodefx
    • Constructor Summary

      Constructors 
      Constructor Description
      ZoomableGraphicsContext​(javafx.scene.canvas.GraphicsContext gc, javafx.beans.property.DoubleProperty scale, javafx.beans.property.ReadOnlyObjectProperty<Rectangle2afp<?,​?,​?,​?,​?,​?>> documentBounds, javafx.beans.property.ReadOnlyObjectProperty<Rectangle2afp<?,​?,​?,​?,​?,​?>> visibleArea, javafx.beans.property.DoubleProperty canvasWidth, javafx.beans.property.DoubleProperty canvasHeight, javafx.beans.property.IntegerProperty drawableElementBudget, CenteringTransform centeringTransform)
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void applyEffect​(javafx.scene.effect.Effect effect)
      Applies the given effect to the entire bounds of the canvas and stores the result back into the same canvas.
      void arc​(double centerX, double centerY, double radiusX, double radiusY, double startAngle, double length)
      Adds path elements to the current path to make an arc that uses Euclidean radians.
      void arcTo​(double x1, double y1, double x2, double y2, double radius)
      Adds segments to the current path to make an arc.
      void beginPath()
      Resets the current path to empty.
      void bezierCurveTo​(double xc1, double yc1, double xc2, double yc2, double x1, double y1)
      Adds segments to the current path to make a cubic Bezier curve.
      void clearRect​(double x, double y, double width, double height)
      Clears a portion of the canvas with a transparent color value.
      void clip()
      Intersects the current clip with the current path and applies it to subsequent rendering operation as an anti-aliased mask.
      void closePath()
      Closes the path.
      boolean consumeBudget()
      Consume the budget.
      double doc2fxAngle​(double angle)
      Transform a document angle to its JavaFX equivalent.
      Point2d doc2fxRectBase​(double x, double y, double width, double height)
      Transform a document rectangle's minimum point to its JavaFX equivalent.
      double doc2fxSize​(double size)
      Transform a document size (or distance) to its JavaFX equivalent.
      double doc2fxX​(double x)
      Transform a document x coordinate to its JavaFX equivalent.
      double doc2fxY​(double y)
      Transform a document y coordinate to its JavaFX equivalent.
      void drawImage​(javafx.scene.image.Image img, double x, double y)
      Draws an image at the given x, y position using the width and height of the given image.
      void drawImage​(javafx.scene.image.Image img, double x, double y, double width, double height)
      Draws an image into the given destination rectangle of the canvas.
      void drawImage​(javafx.scene.image.Image img, double sx, double sy, double sw, double sh, double dx, double dy, double dw, double dh)
      Draws the specified source rectangle of the given image to the given destination rectangle of the Canvas.
      void fill()
      Fills the path with the current fill paint.
      void fillArc​(double x, double y, double width, double height, double startAngle, double arcExtent, javafx.scene.shape.ArcType closure)
      Fills an arc using the current fill paint.
      void fillOval​(double x, double y, double width, double height)
      Fills an oval using the current fill paint.
      void fillRect​(double x, double y, double width, double height)
      Fills a rectangle using the current fill paint.
      void fillRoundRect​(double x, double y, double width, double height, double arcWidth, double arcHeight)
      Fills a rounded rectangle using the current fill paint.
      void fillText​(String text, double x, double y)
      Fills the given string of text at position x, y with the current fill paint attribute.
      void fillText​(String text, double x, double y, double maxWidth)
      Fills text and includes a maximum width of the string.
      double fx2docAngle​(double angle)
      Transform a JavaFX angle to its document equivalent.
      Point2d fx2docRectBase​(double x, double y, double width, double height)
      Transform a JavaFX rectangle's minimum point to its document equivalent.
      double fx2docSize​(double size)
      Transform a JavaFX size (or distance) to its document equivalent.
      double fx2docX​(double x)
      Transform a JavaFX x coordinate to its document equivalent.
      double fx2docY​(double y)
      Transform a JavaFX y coordinate to its document equivalent.
      int getBudget()
      Replies the budget.
      ZoomableCanvas<?> getCanvas()
      Gets the ZoomableCanvas that the GraphicsContext is issuing draw commands to.
      Rectangle2afp<?,​?,​?,​?,​?,​?> getDocumentBounds()
      Replies the document bounds in document coordinates.
      javafx.scene.effect.Effect getEffect​(javafx.scene.effect.Effect effect)
      Gets a copy of the effect to be applied after the next draw call.
      javafx.scene.paint.Paint getFill()
      Gets the current fill paint attribute.
      javafx.scene.shape.FillRule getFillRule()
      Get the filling rule attribute for determining the interior of paths in fill and clip operations.
      javafx.scene.text.Font getFont()
      Gets the current Font.
      javafx.scene.text.FontSmoothingType getFontSmoothingType()
      Gets the current Font Smoothing Type.
      double getGlobalAlpha()
      Gets the current global alpha.
      javafx.scene.effect.BlendMode getGlobalBlendMode()
      Gets the global blend mode.
      LevelOfDetails getLevelOfDetails()
      Replies the current level of details.
      javafx.scene.shape.StrokeLineCap getLineCap()
      Gets the current stroke line cap.
      double[] getLineDashesInMeters()
      Gets a copy of the current line dash array in meters.
      double[] getLineDashesInPixels()
      Gets a copy of the current line dash array in pixels.
      double getLineDashOffsetInMeters()
      Gets the current line dash offset in meters.
      double getLineDashOffsetInPixels()
      Gets the current line dash offset in pixels.
      javafx.scene.shape.StrokeLineJoin getLineJoin()
      Gets the current stroke line join.
      double getLineWidthInMeters()
      Gets the current line width in meters.
      double getLineWidthInPixels()
      Gets the current line width in pixels.
      double getMiterLimitInMeters()
      Gets the current miter limit in meters.
      double getMiterLimitInPixels()
      Gets the current miter limit in pixels.
      javafx.scene.image.PixelWriter getPixelWriter()
      Returns a PixelWriter object that can be used to modify the pixels of the Canvas associated with this GraphicsContext.
      int getState()
      Replies the user-defined state of the context.
      javafx.scene.paint.Paint getStroke()
      Gets the current stroke.
      javafx.scene.text.TextAlignment getTextAlign()
      Gets the current TextAlignment.
      javafx.geometry.VPos getTextBaseline()
      Gets the current Text Baseline.
      Rectangle2afp<?,​?,​?,​?,​?,​?> getVisibleArea()
      Replies the bounds of the visible area in document coordinates.
      javafx.scene.canvas.GraphicsContext getWrappedGraphicsContext2D()
      Gets the GraphicsContext that is wrapped by this object.
      void lineTo​(double x1, double y1)
      Adds segments to the current path to make a line to the given x,y coordinate.
      void moveTo​(double x0, double y0)
      Issues a move command for the current path to the given x,y coordinate.
      void prepareRendering()
      Prepare the rendering by reseting the budget and the state.
      void quadraticCurveTo​(double xc, double yc, double x1, double y1)
      Adds segments to the current path to make a quadratic Bezier curve.
      void rect​(double x, double y, double width, double height)
      Adds path elements to the current path to make a rectangle.
      void restore()
      Pops the state off of the stack, setting the following attributes to their value at the time when that state was pushed onto the stack.
      javafx.scene.paint.Color rgb​(int color)
      Parse the given RGB color.
      javafx.scene.paint.Color rgba​(int color)
      Parse the given RGBA color.
      javafx.scene.paint.Color rgba​(int rgb, double opacity)
      Parse the given RGBA color.
      javafx.scene.paint.Color rgba​(javafx.scene.paint.Color rgb, double opacity)
      Parse the given RGBA color.
      void rotate​(double radians)
      Rotates the current transform in radians.
      void save()
      Saves the following attributes onto a stack.
      void scale​(double x, double y)
      Scales the current transform by x, y.
      void setEffect​(javafx.scene.effect.Effect effect)
      Sets the effect to be applied after the next draw call, or null to disable effects.
      void setFill​(javafx.scene.paint.Paint paint)
      Sets the current fill paint attribute.
      void setFillRule​(javafx.scene.shape.FillRule fillRule)
      Set the filling rule attribute for determining the interior of paths in fill or clip operations.
      void setFont​(javafx.scene.text.Font font)
      Sets the current Font.
      void setFontSmoothingType​(javafx.scene.text.FontSmoothingType fontsmoothing)
      Sets the current Font Smoothing Type.
      void setGlobalAlpha​(double alpha)
      Sets the global alpha of the current state.
      void setGlobalBlendMode​(javafx.scene.effect.BlendMode op)
      Sets the global blend mode.
      void setLineCap​(javafx.scene.shape.StrokeLineCap cap)
      Sets the current stroke line cap.
      void setLineDashesInMeters​(double... dashes)
      Sets the current stroke line dash pattern in meters to a normalized copy of the argument.
      void setLineDashesInPixels​(double... dashes)
      Sets the current stroke line dash pattern in pixels to a normalized copy of the argument.
      void setLineDashOffsetInMeters​(double dashOffset)
      Sets the line dash offset in meters.
      void setLineDashOffsetInPixels​(double dashOffset)
      Sets the line dash offset in pixels.
      void setLineJoin​(javafx.scene.shape.StrokeLineJoin join)
      Sets the current stroke line join.
      void setLineWidthInMeters​(double lw)
      Sets the current line width in meters.
      void setLineWidthInPixels​(double lw)
      Sets the current line width in pixels.
      void setMiterLimitInMeters​(double ml)
      Sets the current miter limit in meters.
      void setMiterLimitInPixels​(double ml)
      Sets the current miter limit in pixels.
      void setState​(int state)
      Change the user-defined state of the context.
      void setStroke​(javafx.scene.paint.Paint paint)
      Sets the current stroke paint attribute.
      void setTextAlign​(javafx.scene.text.TextAlignment align)
      Defines horizontal text alignment, relative to the text x origin.
      void setTextBaseline​(javafx.geometry.VPos baseline)
      Sets the current Text Baseline.
      void stroke()
      Strokes the path with the current stroke paint.
      void strokeArc​(double x, double y, double width, double height, double startAngle, double arcExtent, javafx.scene.shape.ArcType closure)
      Strokes an Arc using the current stroke paint.
      void strokeLine​(double x1, double y1, double x2, double y2)
      Strokes a line using the current stroke paint.
      void strokeOval​(double x, double y, double width, double height)
      Strokes an oval using the current stroke paint.
      void strokeRect​(double x, double y, double width, double height)
      Strokes a rectangle using the current stroke paint.
      void strokeRoundRect​(double x, double y, double width, double height, double arcWidth, double arcHeight)
      Strokes a rounded rectangle using the current stroke paint.
      void strokeText​(String text, double x, double y)
      Draws the given string of text at position x, y with the current stroke paint attribute.
      void strokeText​(String text, double x, double y, double maxWidth)
      Draws text with stroke paint and includes a maximum width of the string.
      void translate​(double x, double y)
      Translates the current transform by x, y.
    • Constructor Detail

      • ZoomableGraphicsContext

        public ZoomableGraphicsContext​(javafx.scene.canvas.GraphicsContext gc,
                                       javafx.beans.property.DoubleProperty scale,
                                       javafx.beans.property.ReadOnlyObjectProperty<Rectangle2afp<?,​?,​?,​?,​?,​?>> documentBounds,
                                       javafx.beans.property.ReadOnlyObjectProperty<Rectangle2afp<?,​?,​?,​?,​?,​?>> visibleArea,
                                       javafx.beans.property.DoubleProperty canvasWidth,
                                       javafx.beans.property.DoubleProperty canvasHeight,
                                       javafx.beans.property.IntegerProperty drawableElementBudget,
                                       CenteringTransform centeringTransform)
        Constructor.
        Parameters:
        gc - the JavaFX graphics context.
        scale - is the scaling value.
        documentBounds - the bounds of the document.
        visibleArea - the visible part of the document.
        canvasWidth - width of the graphical canvas.
        canvasHeight - height of the graphical canvas.
        drawableElementBudget - the drawable element budget.
        centeringTransform - is the transform to apply to the points to change from/to the coordinate system from the "global" document coordinate system to/from the "centered" document coordinate system.
    • Method Detail

      • prepareRendering

        public void prepareRendering()
        Prepare the rendering by reseting the budget and the state.
        See Also:
        getBudget(), getState()
      • getBudget

        public int getBudget()
        Replies the budget.
        Returns:
        the budget.
      • consumeBudget

        public boolean consumeBudget()
        Consume the budget.
        Returns:
        true if an unit of the budget is consumed. false if no consumption.
      • getState

        public int getState()
        Replies the user-defined state of the context.
        Returns:
        the state.
      • setState

        public void setState​(int state)
        Change the user-defined state of the context.
        Parameters:
        state - the state.
      • getLevelOfDetails

        public LevelOfDetails getLevelOfDetails()
        Replies the current level of details.
        Returns:
        the level of details.
      • getDocumentBounds

        @Pure
        public Rectangle2afp<?,​?,​?,​?,​?,​?> getDocumentBounds()
        Replies the document bounds in document coordinates.
        Returns:
        the document bounds.
      • getVisibleArea

        @Pure
        public Rectangle2afp<?,​?,​?,​?,​?,​?> getVisibleArea()
        Replies the bounds of the visible area in document coordinates.
        Returns:
        the visible area bounds.
      • getCanvas

        @Pure
        public ZoomableCanvas<?> getCanvas()
        Gets the ZoomableCanvas that the GraphicsContext is issuing draw commands to. There is only ever one ZoomableCanvas for a GraphicsContext.
        Returns:
        Canvas the canvas that this GraphicsContext is issuing draw commands to.
      • getWrappedGraphicsContext2D

        @Pure
        public javafx.scene.canvas.GraphicsContext getWrappedGraphicsContext2D()
        Gets the GraphicsContext that is wrapped by this object.
        Returns:
        the wrapped GraphicsContext.
      • rgb

        @Pure
        public javafx.scene.paint.Color rgb​(int color)
        Parse the given RGB color.

        Opacity is always 1.

        Parameters:
        color - the RGB color.
        Returns:
        the JavaFX color.
      • rgba

        @Pure
        public javafx.scene.paint.Color rgba​(int color)
        Parse the given RGBA color.
        Parameters:
        color - the RGBA color.
        Returns:
        the JavaFX color.
      • rgba

        @Pure
        public javafx.scene.paint.Color rgba​(int rgb,
                                             double opacity)
        Parse the given RGBA color.
        Parameters:
        rgb - the RGB color.
        opacity - the opacity, 0 for fully transparent, 1 for fully opaque.
        Returns:
        the JavaFX color.
      • rgba

        @Pure
        public javafx.scene.paint.Color rgba​(javafx.scene.paint.Color rgb,
                                             double opacity)
        Parse the given RGBA color. The opacity component of the given color is replaced by the given opacity.
        Parameters:
        rgb - the color.
        opacity - the opacity, 0 for fully transparent, 1 for fully opaque.
        Returns:
        the JavaFX color.
        Since:
        16.0
      • doc2fxX

        @Pure
        public double doc2fxX​(double x)
        Transform a document x coordinate to its JavaFX equivalent.
        Parameters:
        x - the document x coordinate.
        Returns:
        the JavaFX x coordinate.
      • fx2docX

        @Pure
        public double fx2docX​(double x)
        Transform a JavaFX x coordinate to its document equivalent.
        Parameters:
        x - the document x coordinate.
        Returns:
        the JavaFX x coordinate.
      • doc2fxY

        @Pure
        public double doc2fxY​(double y)
        Transform a document y coordinate to its JavaFX equivalent.
        Parameters:
        y - the document y coordinate.
        Returns:
        the JavaFX y coordinate.
      • fx2docY

        @Pure
        public double fx2docY​(double y)
        Transform a JavaFX y coordinate to its document equivalent.
        Parameters:
        y - the JavaFX y coordinate.
        Returns:
        the document y coordinate.
      • doc2fxSize

        @Pure
        public double doc2fxSize​(double size)
        Transform a document size (or distance) to its JavaFX equivalent.

        The JavaFX size fx_x is equal to:

        fx_size = size * scale
        Parameters:
        size - the document size.
        Returns:
        the JavaFX size.
      • fx2docSize

        @Pure
        public double fx2docSize​(double size)
        Transform a JavaFX size (or distance) to its document equivalent.

        The document size doc_size is equal to:

        doc_size = size / scale
        Parameters:
        size - the JavaFX size.
        Returns:
        the document size.
      • doc2fxAngle

        @Pure
        public double doc2fxAngle​(double angle)
        Transform a document angle to its JavaFX equivalent.
        Parameters:
        angle - the document angle.
        Returns:
        the JavaFX angle.
      • fx2docAngle

        @Pure
        public double fx2docAngle​(double angle)
        Transform a JavaFX angle to its document equivalent.
        Parameters:
        angle - the JavaFX angle.
        Returns:
        the document angle.
      • doc2fxRectBase

        @Pure
        public Point2d doc2fxRectBase​(double x,
                                      double y,
                                      double width,
                                      double height)
        Transform a document rectangle's minimum point to its JavaFX equivalent.
        Parameters:
        x - the document x coordinate.
        y - the document y coordinate.
        width - the document width.
        height - the document height.
        Returns:
        the rectangle's minimum point into the JavaFX coordinates.
        Since:
        16.0
      • fx2docRectBase

        @Pure
        public Point2d fx2docRectBase​(double x,
                                      double y,
                                      double width,
                                      double height)
        Transform a JavaFX rectangle's minimum point to its document equivalent.
        Parameters:
        x - the JavaFX x coordinate.
        y - the JavaFX y coordinate.
        width - the JavaFX width.
        height - the JavaFX height.
        Returns:
        the rectangle's minimum point into the document FX coordinates.
        Since:
        16.0
      • save

        public void save()
        Saves the following attributes onto a stack.
        • Global Alpha
        • Global Blend Operation
        • Transform
        • Fill Paint
        • Stroke Paint
        • Line Width
        • Line Cap
        • Line Join
        • Miter Limit
        • Clip
        • Font
        • Text Align
        • Text Baseline
        • Effect
        • Fill Rule
        This method does NOT alter the current state in any way. Also, note that the current path is not saved.
      • restore

        public void restore()
        Pops the state off of the stack, setting the following attributes to their value at the time when that state was pushed onto the stack. If the stack is empty then nothing is changed.
        • Global Alpha
        • Global Blend Operation
        • Transform
        • Fill Paint
        • Stroke Paint
        • Line Width
        • Line Cap
        • Line Join
        • Miter Limit
        • Clip
        • Font
        • Text Align
        • Text Baseline
        • Effect
        • Fill Rule
        Note that the current path is not restored.
      • translate

        public void translate​(double x,
                              double y)
        Translates the current transform by x, y.
        Parameters:
        x - value to translate along the x axis.
        y - value to translate along the y axis.
      • scale

        public void scale​(double x,
                          double y)
        Scales the current transform by x, y.
        Parameters:
        x - value to scale in the x axis.
        y - value to scale in the y axis.
      • rotate

        public void rotate​(double radians)
        Rotates the current transform in radians.
        Parameters:
        radians - value in radians to rotate the current transform.
      • setGlobalAlpha

        public void setGlobalAlpha​(double alpha)
        Sets the global alpha of the current state. The default value is 1.0. Any valid double can be set, but only values in the range [0.0, 1.0] are valid and the nearest value in that range will be used for rendering. The global alpha is a common attribute used for nearly all rendering methods as specified in the Rendering Attributes Table of GraphicsContext.
        Parameters:
        alpha - the new alpha value, clamped to [0.0, 1.0] during actual use.
      • getGlobalAlpha

        public double getGlobalAlpha()
        Gets the current global alpha. The default value is 1.0. The global alpha is a common attribute used for nearly all rendering methods as specified in the Rendering Attributes Table of GraphicsContext.
        Returns:
        the current global alpha.
      • setGlobalBlendMode

        public void setGlobalBlendMode​(javafx.scene.effect.BlendMode op)
        Sets the global blend mode. The default value is SRC_OVER. A null value will be ignored and the current value will remain unchanged. The blend mode is a common attribute used for nearly all rendering methods as specified in the Rendering Attributes Table of GraphicsContext.
        Parameters:
        op - the BlendMode that will be set or null.
      • getGlobalBlendMode

        public javafx.scene.effect.BlendMode getGlobalBlendMode()
        Gets the global blend mode. The default value is SRC_OVER. The blend mode is a common attribute used for nearly all rendering methods as specified in the Rendering Attributes Table of GraphicsContext.
        Returns:
        the global BlendMode of the current state.
      • setFill

        public void setFill​(javafx.scene.paint.Paint paint)
        Sets the current fill paint attribute. The default value is BLACK. The fill paint is a fill attribute used for any of the fill methods as specified in the Rendering Attributes Table of GraphicsContext. A null value will be ignored and the current value will remain unchanged.
        Parameters:
        paint - The Paint to be used as the fill Paint or null.
      • getFill

        public javafx.scene.paint.Paint getFill()
        Gets the current fill paint attribute. The default value is BLACK. The fill paint is a fill attribute used for any of the fill methods as specified in the Rendering Attributes Table of GraphicsContext.
        Returns:
        The Paint to be used as the fill Paint.
      • setStroke

        public void setStroke​(javafx.scene.paint.Paint paint)
        Sets the current stroke paint attribute. The default value is BLACK. The stroke paint is a stroke attribute used for any of the stroke methods as specified in the Rendering Attributes Table of GraphicsContext. A null value will be ignored and the current value will remain unchanged.
        Parameters:
        paint - The Paint to be used as the stroke Paint or null.
      • getStroke

        public javafx.scene.paint.Paint getStroke()
        Gets the current stroke. The default value is BLACK. The stroke paint is a stroke attribute used for any of the stroke methods as specified in the Rendering Attributes Table of GraphicsContext.
        Returns:
        the Paint to be used as the stroke Paint.
      • setLineWidthInPixels

        public void setLineWidthInPixels​(double lw)
        Sets the current line width in pixels. The default value is 1.0. The line width is a stroke attribute used for any of the stroke methods as specified in the Rendering Attributes Table of GraphicsContext. An infinite or non-positive value outside of the range (0, +inf) will be ignored and the current value will remain unchanged.
        Parameters:
        lw - pixel value in the range {0-positive infinity}, with any other value being ignored and leaving the value unchanged.
        See Also:
        setLineWidthInMeters(double)
      • setLineWidthInMeters

        public void setLineWidthInMeters​(double lw)
        Sets the current line width in meters. The default value is 1.0 * scale. The line width is a stroke attribute used for any of the stroke methods as specified in the Rendering Attributes Table of GraphicsContext. An infinite or non-positive value outside of the range (0, +inf) will be ignored and the current value will remain unchanged.
        Parameters:
        lw - metric value in the range {0-positive infinity}, with any other value being ignored and leaving the value unchanged.
        See Also:
        setLineWidthInPixels(double)
      • getLineWidthInPixels

        public double getLineWidthInPixels()
        Gets the current line width in pixels. The default value is 1.0. The line width is a stroke attribute used for any of the stroke methods as specified in the Rendering Attributes Table of GraphicsContext.
        Returns:
        pixel value between 0 and infinity.
        See Also:
        getLineWidthInMeters()
      • getLineWidthInMeters

        public double getLineWidthInMeters()
        Gets the current line width in meters. The default value is 1.0. The line width is a stroke attribute used for any of the stroke methods as specified in the Rendering Attributes Table of GraphicsContext.
        Returns:
        metric value between 0 and infinity.
        See Also:
        getLineWidthInPixels()
      • setLineCap

        public void setLineCap​(javafx.scene.shape.StrokeLineCap cap)
        Sets the current stroke line cap. The default value is SQUARE. The line cap is a stroke attribute used for any of the stroke methods as specified in the Rendering Attributes Table of GraphicsContext. A null value will be ignored and the current value will remain unchanged.
        Parameters:
        cap - StrokeLineCap with a value of Butt, Round, or Square or null.
      • getLineCap

        public javafx.scene.shape.StrokeLineCap getLineCap()
        Gets the current stroke line cap. The default value is SQUARE. The line cap is a stroke attribute used for any of the stroke methods as specified in the Rendering Attributes Table of GraphicsContext.
        Returns:
        StrokeLineCap with a value of Butt, Round, or Square.
      • setLineJoin

        public void setLineJoin​(javafx.scene.shape.StrokeLineJoin join)
        Sets the current stroke line join. The default value is StrokeLineJoin.MITER. The line join is a stroke attribute used for any of the stroke methods as specified in the Rendering Attributes Table of GraphicsContext. A null value will be ignored and the current value will remain unchanged.
        Parameters:
        join - StrokeLineJoin with a value of Miter, Bevel, or Round or null.
      • getLineJoin

        public javafx.scene.shape.StrokeLineJoin getLineJoin()
        Gets the current stroke line join. The default value is StrokeLineJoin.MITER. The line join is a stroke attribute used for any of the stroke methods as specified in the Rendering Attributes Table of GraphicsContext.
        Returns:
        StrokeLineJoin with a value of Miter, Bevel, or Round.
      • setMiterLimitInPixels

        public void setMiterLimitInPixels​(double ml)
        Sets the current miter limit in pixels. The default value is 10.0. The miter limit is a stroke attribute used for any of the stroke methods as specified in the Rendering Attributes Table of GraphicsContext. An infinite or non-positive value outside of the range (0, +inf) will be ignored and the current value will remain unchanged.
        Parameters:
        ml - pixel miter limit value between 0 and positive infinity with any other value being ignored and leaving the value unchanged.
        See Also:
        setMiterLimitInMeters(double)
      • setMiterLimitInMeters

        public void setMiterLimitInMeters​(double ml)
        Sets the current miter limit in meters. The default value is 10.0 * scale. The miter limit is a stroke attribute used for any of the stroke methods as specified in the Rendering Attributes Table of GraphicsContext. An infinite or non-positive value outside of the range (0, +inf) will be ignored and the current value will remain unchanged.
        Parameters:
        ml - metric miter limit value between 0 and positive infinity with any other value being ignored and leaving the value unchanged.
        See Also:
        setMiterLimitInPixels(double)
      • getMiterLimitInPixels

        public double getMiterLimitInPixels()
        Gets the current miter limit in pixels. The default value is 10.0. The miter limit is a stroke attribute used for any of the stroke methods as specified in the Rendering Attributes Table of GraphicsContext.
        Returns:
        the pixel miter limit value in the range 0.0-positive infinity
        See Also:
        getMiterLimitInMeters()
      • getMiterLimitInMeters

        public double getMiterLimitInMeters()
        Gets the current miter limit in meters. The default value is 10.0 * scale. The miter limit is a stroke attribute used for any of the stroke methods as specified in the Rendering Attributes Table of GraphicsContext.
        Returns:
        the metric miter limit value in the range 0.0-positive infinity
      • setLineDashesInPixels

        public void setLineDashesInPixels​(double... dashes)
        Sets the current stroke line dash pattern in pixels to a normalized copy of the argument. The default value is null. The line dash array is a stroke attribute used for any of the stroke methods as specified in the Rendering Attributes Table of GraphicsContext. If the array is null or empty or contains all 0 elements then dashing will be disabled and the current dash array will be set to null. If any of the elements of the array are a negative, infinite, or NaN value outside the range [0, +inf) then the entire array will be ignored and the current dash array will remain unchanged. If the array is an odd length then it will be treated as if it were two copies of the array appended to each other.
        Parameters:
        dashes - the array of finite non-negative dash lengths.
        See Also:
        setLineDashesInMeters(double...)
      • setLineDashesInMeters

        public void setLineDashesInMeters​(double... dashes)
        Sets the current stroke line dash pattern in meters to a normalized copy of the argument. The default value is null. The line dash array is a stroke attribute used for any of the stroke methods as specified in the Rendering Attributes Table of GraphicsContext. If the array is null or empty or contains all 0 elements then dashing will be disabled and the current dash array will be set to null. If any of the elements of the array are a negative, infinite, or NaN value outside the range [0, +inf) then the entire array will be ignored and the current dash array will remain unchanged. If the array is an odd length then it will be treated as if it were two copies of the array appended to each other.
        Parameters:
        dashes - the array of finite non-negative dash lengths
        See Also:
        setLineDashesInPixels(double...)
      • getLineDashesInPixels

        public double[] getLineDashesInPixels()
        Gets a copy of the current line dash array in pixels. The default value is null. The array may be normalized by the validation tests in the setLineDashesInPixels(double...) method. The line dash array is a stroke attribute used for any of the stroke methods as specified in the Rendering Attributes Table of GraphicsContext.
        Returns:
        a copy of the current line dash array.
        See Also:
        getLineDashesInMeters()
      • getLineDashesInMeters

        public double[] getLineDashesInMeters()
        Gets a copy of the current line dash array in meters. The default value is null. The array may be normalized by the validation tests in the setLineDashesInMeters(double...) method. The line dash array is a stroke attribute used for any of the stroke methods as specified in the Rendering Attributes Table of GraphicsContext.
        Returns:
        a copy of the current line dash array.
        See Also:
        getLineDashesInPixels()
      • setLineDashOffsetInPixels

        public void setLineDashOffsetInPixels​(double dashOffset)
        Sets the line dash offset in pixels. The default value is 0.0. The line dash offset is a stroke attribute used for any of the stroke methods as specified in the Rendering Attributes Table of GraphicsContext. An infinite or NaN value outside of the range (-inf, +inf) will be ignored and the current value will remain unchanged.
        Parameters:
        dashOffset - the line dash offset in the range (-inf, +inf)
        See Also:
        setLineDashOffsetInMeters(double)
      • setLineDashOffsetInMeters

        public void setLineDashOffsetInMeters​(double dashOffset)
        Sets the line dash offset in meters. The default value is 0.0 * scale. The line dash offset is a stroke attribute used for any of the stroke methods as specified in the Rendering Attributes Table of GraphicsContext. An infinite or NaN value outside of the range (-inf, +inf) will be ignored and the current value will remain unchanged.
        Parameters:
        dashOffset - the line dash offset in the range (-inf, +inf)
        See Also:
        setLineDashOffsetInPixels(double)
      • getLineDashOffsetInPixels

        public double getLineDashOffsetInPixels()
        Gets the current line dash offset in pixels. The default value is 0.0. The line dash offset is a stroke attribute used for any of the stroke methods as specified in the Rendering Attributes Table of GraphicsContext.
        Returns:
        the line dash offset in the range (-inf, +inf)
        See Also:
        getLineDashOffsetInMeters()
      • getLineDashOffsetInMeters

        public double getLineDashOffsetInMeters()
        Gets the current line dash offset in meters. The default value is 0.0. The line dash offset is a stroke attribute used for any of the stroke methods as specified in the Rendering Attributes Table of GraphicsContext.
        Returns:
        the line dash offset in the range (-inf, +inf)
        See Also:
        getLineDashOffsetInPixels()
      • setFont

        public void setFont​(javafx.scene.text.Font font)
        Sets the current Font. The default value is specified by Font.getDefault(). The font is a text attribute used for any of the text methods as specified in the Rendering Attributes Table of GraphicsContext. A null value will be ignored and the current value will remain unchanged.
        Parameters:
        font - the Font or null.
      • getFont

        public javafx.scene.text.Font getFont()
        Gets the current Font. The default value is specified by Font.getDefault(). The font is a text attribute used for any of the text methods as specified in the Rendering Attributes Table of GraphicsContext.
        Returns:
        the Font
      • setFontSmoothingType

        public void setFontSmoothingType​(javafx.scene.text.FontSmoothingType fontsmoothing)
        Sets the current Font Smoothing Type. The default value is GRAY. The font smoothing type is a text attribute used for any of the text methods as specified in the Rendering Attributes Table of GraphicsContext. A null value will be ignored and the current value will remain unchanged.

        Note that the FontSmoothingType value of LCD is only supported over an opaque background. LCD text will generally appear as GRAY text over transparent or partially transparent pixels, and in some implementations it may not be supported at all on a Canvas because the required support does not exist for surfaces which contain an alpha channel as all Canvas objects do.

        Parameters:
        fontsmoothing - the FontSmoothingType or null
      • getFontSmoothingType

        public javafx.scene.text.FontSmoothingType getFontSmoothingType()
        Gets the current Font Smoothing Type. The default value is GRAY. The font smoothing type is a text attribute used for any of the text methods as specified in the Rendering Attributes Table of GraphicsContext.
        Returns:
        the FontSmoothingType
      • setTextAlign

        public void setTextAlign​(javafx.scene.text.TextAlignment align)
        Defines horizontal text alignment, relative to the text x origin. The default value is LEFT. The text alignment is a text attribute used for any of the text methods as specified in the Rendering Attributes Table of GraphicsContext.

        Let horizontal bounds represent the logical width of a single line of text. Where each line of text has a separate horizontal bounds.

        Then TextAlignment is specified as:

        • Left: the left edge of the horizontal bounds will be at x.
        • Center: the center, halfway between left and right edge, of the horizontal bounds will be at x.
        • Right: the right edge of the horizontal bounds will be at x.

        Note: Canvas does not support line wrapping, therefore the text alignment Justify is identical to left aligned text.

        A null value will be ignored and the current value will remain unchanged.

        Parameters:
        align - TextAlignment with values of Left, Center, Right or null.
      • getTextAlign

        public javafx.scene.text.TextAlignment getTextAlign()
        Gets the current TextAlignment. The default value is LEFT. The text alignment is a text attribute used for any of the text methods as specified in the Rendering Attributes Table of GraphicsContext.
        Returns:
        TextAlignment with values of Left, Center, Right, or Justify.
      • setTextBaseline

        public void setTextBaseline​(javafx.geometry.VPos baseline)
        Sets the current Text Baseline. The default value is BASELINE. The text baseline is a text attribute used for any of the text methods as specified in the Rendering Attributes Table of GraphicsContext. A null value will be ignored and the current value will remain unchanged.
        Parameters:
        baseline - VPos with values of Top, Center, Baseline, or Bottom or null.
      • getTextBaseline

        public javafx.geometry.VPos getTextBaseline()
        Gets the current Text Baseline. The default value is BASELINE. The text baseline is a text attribute used for any of the text methods as specified in the Rendering Attributes Table of GraphicsContext.
        Returns:
        VPos with values of Top, Center, Baseline, or Bottom
      • fillText

        public void fillText​(String text,
                             double x,
                             double y)
        Fills the given string of text at position x, y with the current fill paint attribute. A null text value will be ignored.

        This method will be affected by any of the global common, fill, or text attributes as specified in the Rendering Attributes Table of GraphicsContext.

        Parameters:
        text - the string of text or null.
        x - position on the x axis.
        y - position on the y axis.
      • fillText

        public void fillText​(String text,
                             double x,
                             double y,
                             double maxWidth)
        Fills text and includes a maximum width of the string. If the width of the text extends past max width, then it will be sized to fit. A null text value will be ignored.

        This method will be affected by any of the global common, fill, or text attributes as specified in the Rendering Attributes Table of GraphicsContext.

        Parameters:
        text - the string of text or null.
        x - position on the x axis.
        y - position on the y axis.
        maxWidth - maximum width the text string can have.
      • strokeText

        public void strokeText​(String text,
                               double x,
                               double y)
        Draws the given string of text at position x, y with the current stroke paint attribute. A null text value will be ignored.

        This method will be affected by any of the global common, stroke, or text attributes as specified in the Rendering Attributes Table of GraphicsContext.

        Parameters:
        text - the string of text or null.
        x - position on the x axis.
        y - position on the y axis.
      • strokeText

        public void strokeText​(String text,
                               double x,
                               double y,
                               double maxWidth)
        Draws text with stroke paint and includes a maximum width of the string. If the width of the text extends past max width, then it will be sized to fit. A null text value will be ignored.

        This method will be affected by any of the global common, stroke, or text attributes as specified in the Rendering Attributes Table of GraphicsContext.

        Parameters:
        text - the string of text or null.
        x - position on the x axis.
        y - position on the y axis.
        maxWidth - maximum width the text string can have.
      • setFillRule

        public void setFillRule​(javafx.scene.shape.FillRule fillRule)
        Set the filling rule attribute for determining the interior of paths in fill or clip operations. The default value is FillRule.NON_ZERO. A null value will be ignored and the current value will remain unchanged. The fill rule is a path attribute used for any of the fill or clip path methods as specified in the Rendering Attributes Table of GraphicsContext.
        Parameters:
        fillRule - FillRule with a value of Even_odd or Non_zero or null.
      • getFillRule

        public javafx.scene.shape.FillRule getFillRule()
        Get the filling rule attribute for determining the interior of paths in fill and clip operations. The default value is FillRule.NON_ZERO. The fill rule is a path attribute used for any of the fill or clip path methods as specified in the Rendering Attributes Table of GraphicsContext.
        Returns:
        current fill rule.
      • beginPath

        public void beginPath()
        Resets the current path to empty. The default path is empty. The current path is a path attribute used for any of the path methods as specified in the Rendering Attributes Table of GraphicsContext and is not affected by the save() and restore() operations.
      • moveTo

        public void moveTo​(double x0,
                           double y0)
        Issues a move command for the current path to the given x,y coordinate. The coordinates are transformed by the current transform as they are added to the path and unaffected by subsequent changes to the transform. The current path is a path attribute used for any of the path methods as specified in the Rendering Attributes Table of GraphicsContext and is not affected by the save() and restore() operations.
        Parameters:
        x0 - the X position for the move to command.
        y0 - the Y position for the move to command.
      • lineTo

        public void lineTo​(double x1,
                           double y1)
        Adds segments to the current path to make a line to the given x,y coordinate. The coordinates are transformed by the current transform as they are added to the path and unaffected by subsequent changes to the transform. The current path is a path attribute used for any of the path methods as specified in the Rendering Attributes Table of GraphicsContext and is not affected by the save() and restore() operations.
        Parameters:
        x1 - the X coordinate of the ending point of the line.
        y1 - the Y coordinate of the ending point of the line.
      • quadraticCurveTo

        public void quadraticCurveTo​(double xc,
                                     double yc,
                                     double x1,
                                     double y1)
        Adds segments to the current path to make a quadratic Bezier curve. The coordinates are transformed by the current transform as they are added to the path and unaffected by subsequent changes to the transform. The current path is a path attribute used for any of the path methods as specified in the Rendering Attributes Table of GraphicsContext and is not affected by the save() and restore() operations.
        Parameters:
        xc - the X coordinate of the control point
        yc - the Y coordinate of the control point
        x1 - the X coordinate of the end point
        y1 - the Y coordinate of the end point
      • bezierCurveTo

        public void bezierCurveTo​(double xc1,
                                  double yc1,
                                  double xc2,
                                  double yc2,
                                  double x1,
                                  double y1)
        Adds segments to the current path to make a cubic Bezier curve. The coordinates are transformed by the current transform as they are added to the path and unaffected by subsequent changes to the transform. The current path is a path attribute used for any of the path methods as specified in the Rendering Attributes Table of GraphicsContext and is not affected by the save() and restore() operations.
        Parameters:
        xc1 - the X coordinate of first Bezier control point.
        yc1 - the Y coordinate of the first Bezier control point.
        xc2 - the X coordinate of the second Bezier control point.
        yc2 - the Y coordinate of the second Bezier control point.
        x1 - the X coordinate of the end point.
        y1 - the Y coordinate of the end point.
      • arcTo

        public void arcTo​(double x1,
                          double y1,
                          double x2,
                          double y2,
                          double radius)
        Adds segments to the current path to make an arc. The coordinates are transformed by the current transform as they are added to the path and unaffected by subsequent changes to the transform. The current path is a path attribute used for any of the path methods as specified in the Rendering Attributes Table of GraphicsContext and is not affected by the save() and restore() operations.

        If p0 is the current point in the path and p1 is the point specified by (x1, y1) and p2 is the point specified by (x2, y2), then the arc segments appended will be segments along the circumference of a circle of the specified radius touching and inscribed into the convex (interior) side of p0->p1->p2. The path will contain a line segment (if needed) to the tangent point between that circle and p0->p1 followed by circular arc segments to reach the tangent point between the circle and p1->p2 and will end with the current point at that tangent point (not at p2). Note that the radius and circularity of the arc segments will be measured or considered relative to the current transform, but the resulting segments that are computed from those untransformed points will then be transformed when they are added to the path. Since all computation is done in untransformed space, but the pre-existing path segments are all transformed, the ability to correctly perform the computation may implicitly depend on being able to inverse transform the current end of the current path back into untransformed coordinates.

        If there is no way to compute and inscribe the indicated circle for any reason then the entire operation will simply append segments to force a line to point p1. Possible reasons that the computation may fail include:

        • The current path is empty.
        • The segments p0->p1->p2 are colinear.
        • the current transform is non-invertible so that the current end point of the current path cannot be untransformed for computation.
        Parameters:
        x1 - the X coordinate of the first point of the arc.
        y1 - the Y coordinate of the first point of the arc.
        x2 - the X coordinate of the second point of the arc.
        y2 - the Y coordinate of the second point of the arc.
        radius - the radius of the arc in the range {0.0-positive infinity}.
      • arc

        public void arc​(double centerX,
                        double centerY,
                        double radiusX,
                        double radiusY,
                        double startAngle,
                        double length)
        Adds path elements to the current path to make an arc that uses Euclidean radians. This Euclidean orientation sweeps from East to North, then West, then South, then back to East. The coordinates are transformed by the current transform as they are added to the path and unaffected by subsequent changes to the transform. The current path is a path attribute used for any of the path methods as specified in the Rendering Attributes Table of GraphicsContext and is not affected by the save() and restore() operations.
        Parameters:
        centerX - the center x position of the arc.
        centerY - the center y position of the arc.
        radiusX - the x radius of the arc.
        radiusY - the y radius of the arc.
        startAngle - the starting angle of the arc in the range 0-2PI
        length - the length of the baseline of the arc.
      • rect

        public void rect​(double x,
                         double y,
                         double width,
                         double height)
        Adds path elements to the current path to make a rectangle. The coordinates are transformed by the current transform as they are added to the path and unaffected by subsequent changes to the transform. The current path is a path attribute used for any of the path methods as specified in the Rendering Attributes Table of GraphicsContext and is not affected by the save() and restore() operations.
        Parameters:
        x - x position of the upper left corner of the rectangle.
        y - y position of the upper left corner of the rectangle.
        width - width of the rectangle.
        height - height of the rectangle.
      • closePath

        public void closePath()
        Closes the path. The current path is a path attribute used for any of the path methods as specified in the Rendering Attributes Table of GraphicsContext and is not affected by the save() and restore() operations.
      • fill

        public void fill()
        Fills the path with the current fill paint.

        This method will be affected by any of the global common, fill, or path attributes as specified in the Rendering Attributes Table of GraphicsContext. Note that the path segments were transformed as they were originally added to the current path so the current transform will not affect those path segments again, but it may affect other attributes in affect at the time of the fill() operation.

      • stroke

        public void stroke()
        Strokes the path with the current stroke paint.

        This method will be affected by any of the global common, stroke, or path attributes as specified in the Rendering Attributes Table of GraphicsContext. Note that the path segments were transformed as they were originally added to the current path so the current transform will not affect those path segments again, but it may affect other attributes in affect at the time of the stroke() operation.

      • clip

        public void clip()
        Intersects the current clip with the current path and applies it to subsequent rendering operation as an anti-aliased mask. The current clip is a common attribute used for nearly all rendering operations as specified in the Rendering Attributes Table of GraphicsContext.

        This method will itself be affected only by the path attributes as specified in the Rendering Attributes Table of GraphicsContext. Note that the path segments were transformed as they were originally added to the current path so the current transform will not affect those path segments again, but it may affect other attributes in affect at the time of the stroke() operation.

      • clearRect

        public void clearRect​(double x,
                              double y,
                              double width,
                              double height)
        Clears a portion of the canvas with a transparent color value.

        This method will be affected only by the current transform, clip, and effect.

        Parameters:
        x - X position of the upper left corner of the rectangle.
        y - Y position of the upper left corner of the rectangle.
        width - width of the rectangle.
        height - height of the rectangle.
      • fillRect

        public void fillRect​(double x,
                             double y,
                             double width,
                             double height)
        Fills a rectangle using the current fill paint.

        This method will be affected by any of the global common or fill attributes as specified in the Rendering Attributes Table of GraphicsContext.

        Parameters:
        x - the X position of the upper left corner of the rectangle.
        y - the Y position of the upper left corner of the rectangle.
        width - the width of the rectangle.
        height - the height of the rectangle.
      • strokeRect

        public void strokeRect​(double x,
                               double y,
                               double width,
                               double height)
        Strokes a rectangle using the current stroke paint.

        This method will be affected by any of the global common or stroke attributes as specified in the Rendering Attributes Table of GraphicsContext.

        Parameters:
        x - the X position of the upper left corner of the rectangle.
        y - the Y position of the upper left corner of the rectangle.
        width - the width of the rectangle.
        height - the height of the rectangle.
      • fillOval

        public void fillOval​(double x,
                             double y,
                             double width,
                             double height)
        Fills an oval using the current fill paint.

        This method will be affected by any of the global common or fill attributes as specified in the Rendering Attributes Table of GraphicsContext.

        Parameters:
        x - the X coordinate of the upper left bound of the oval.
        y - the Y coordinate of the upper left bound of the oval.
        width - the width at the center of the oval.
        height - the height at the center of the oval.
      • strokeOval

        public void strokeOval​(double x,
                               double y,
                               double width,
                               double height)
        Strokes an oval using the current stroke paint.

        This method will be affected by any of the global common or stroke attributes as specified in the Rendering Attributes Table of GraphicsContext.

        Parameters:
        x - the X coordinate of the upper left bound of the oval.
        y - the Y coordinate of the upper left bound of the oval.
        width - the width at the center of the oval.
        height - the height at the center of the oval.
      • fillArc

        public void fillArc​(double x,
                            double y,
                            double width,
                            double height,
                            double startAngle,
                            double arcExtent,
                            javafx.scene.shape.ArcType closure)
        Fills an arc using the current fill paint. A null ArcType or non positive width or height will cause the render command to be ignored.

        This method will be affected by any of the global common or fill attributes as specified in the Rendering Attributes Table of GraphicsContext.

        Parameters:
        x - the X coordinate of the arc.
        y - the Y coordinate of the arc.
        width - the width of the arc.
        height - the height of the arc.
        startAngle - the starting angle of the arc in radians.
        arcExtent - the angular extent of the arc in radians.
        closure - closure type (Round, Chord, Open) or null.
      • strokeArc

        public void strokeArc​(double x,
                              double y,
                              double width,
                              double height,
                              double startAngle,
                              double arcExtent,
                              javafx.scene.shape.ArcType closure)
        Strokes an Arc using the current stroke paint. A null ArcType or non positive width or height will cause the render command to be ignored.

        This method will be affected by any of the global common or stroke attributes as specified in the Rendering Attributes Table of GraphicsContext.

        Parameters:
        x - the X coordinate of the arc.
        y - the Y coordinate of the arc.
        width - the width of the arc.
        height - the height of the arc.
        startAngle - the starting angle of the arc in radians.
        arcExtent - arcExtent the angular extent of the arc in radians.
        closure - closure type (Round, Chord, Open) or null
      • fillRoundRect

        public void fillRoundRect​(double x,
                                  double y,
                                  double width,
                                  double height,
                                  double arcWidth,
                                  double arcHeight)
        Fills a rounded rectangle using the current fill paint.

        This method will be affected by any of the global common or fill attributes as specified in the Rendering Attributes Table of GraphicsContext.

        Parameters:
        x - the X coordinate of the upper left bound of the oval.
        y - the Y coordinate of the upper left bound of the oval.
        width - the width at the center of the oval.
        height - the height at the center of the oval.
        arcWidth - the arc width of the rectangle corners.
        arcHeight - the arc height of the rectangle corners.
      • strokeRoundRect

        public void strokeRoundRect​(double x,
                                    double y,
                                    double width,
                                    double height,
                                    double arcWidth,
                                    double arcHeight)
        Strokes a rounded rectangle using the current stroke paint.

        This method will be affected by any of the global common or stroke attributes as specified in the Rendering Attributes Table of GraphicsContext.

        Parameters:
        x - the X coordinate of the upper left bound of the oval.
        y - the Y coordinate of the upper left bound of the oval.
        width - the width at the center of the oval.
        height - the height at the center of the oval.
        arcWidth - the arc width of the rectangle corners.
        arcHeight - the arc height of the rectangle corners.
      • strokeLine

        public void strokeLine​(double x1,
                               double y1,
                               double x2,
                               double y2)
        Strokes a line using the current stroke paint.

        This method will be affected by any of the global common or stroke attributes as specified in the Rendering Attributes Table of GraphicsContext.

        Parameters:
        x1 - the X coordinate of the starting point of the line.
        y1 - the Y coordinate of the starting point of the line.
        x2 - the X coordinate of the ending point of the line.
        y2 - the Y coordinate of the ending point of the line.
      • drawImage

        public void drawImage​(javafx.scene.image.Image img,
                              double x,
                              double y)
        Draws an image at the given x, y position using the width and height of the given image. A null image value or an image still in progress will be ignored.

        This method will be affected by any of the global common attributes as specified in the Rendering Attributes Table of GraphicsContext.

        Parameters:
        img - the image to be drawn or null.
        x - the X coordinate on the destination for the upper left of the image.
        y - the Y coordinate on the destination for the upper left of the image.
      • drawImage

        public void drawImage​(javafx.scene.image.Image img,
                              double x,
                              double y,
                              double width,
                              double height)
        Draws an image into the given destination rectangle of the canvas. The Image is scaled to fit into the destination rectangle. A null image value or an image still in progress will be ignored.

        This method will be affected by any of the global common attributes as specified in the Rendering Attributes Table of GraphicsContext.

        Parameters:
        img - the image to be drawn or null.
        x - the X coordinate on the destination for the upper left of the image.
        y - the Y coordinate on the destination for the upper left of the image.
        width - the width of the destination rectangle.
        height - the height of the destination rectangle.
      • drawImage

        public void drawImage​(javafx.scene.image.Image img,
                              double sx,
                              double sy,
                              double sw,
                              double sh,
                              double dx,
                              double dy,
                              double dw,
                              double dh)
        Draws the specified source rectangle of the given image to the given destination rectangle of the Canvas. A null image value or an image still in progress will be ignored.

        This method will be affected by any of the global common attributes as specified in the Rendering Attributes Table of GraphicsContext.

        Parameters:
        img - the image to be drawn or null.
        sx - the source rectangle's X coordinate position.
        sy - the source rectangle's Y coordinate position.
        sw - the source rectangle's width.
        sh - the source rectangle's height.
        dx - the destination rectangle's X coordinate position.
        dy - the destination rectangle's Y coordinate position.
        dw - the destination rectangle's width.
        dh - the destination rectangle's height.
      • getPixelWriter

        public javafx.scene.image.PixelWriter getPixelWriter()
        Returns a PixelWriter object that can be used to modify the pixels of the Canvas associated with this GraphicsContext. All coordinates in the PixelWriter methods on the returned object will be in device space since they refer directly to pixels and no other rendering attributes will be applied when modifying pixels using this object.
        Returns:
        the PixelWriter for modifying the pixels of this Canvas
      • setEffect

        public void setEffect​(javafx.scene.effect.Effect effect)
        Sets the effect to be applied after the next draw call, or null to disable effects. The current effect is a common attribute used for nearly all rendering operations as specified in the Rendering Attributes Table of GraphicsContext.
        Parameters:
        effect - the effect to use, or null to disable effects
      • getEffect

        public javafx.scene.effect.Effect getEffect​(javafx.scene.effect.Effect effect)
        Gets a copy of the effect to be applied after the next draw call. A null return value means that no effect will be applied after subsequent rendering calls. The current effect is a common attribute used for nearly all rendering operations as specified in the Rendering Attributes Table of GraphicsContext.
        Parameters:
        effect - an Effect object that may be used to store the copy of the current effect, if it is of a compatible type
        Returns:
        the current effect used for all rendering calls, or null if there is no current effect
      • applyEffect

        public void applyEffect​(javafx.scene.effect.Effect effect)
        Applies the given effect to the entire bounds of the canvas and stores the result back into the same canvas. A null value will be ignored. The effect will be applied without any other rendering attributes and under an Identity coordinate transform. Since the effect is applied to the entire bounds of the canvas, some effects may have a confusing result, such as a Reflection effect that will apply its reflection off of the bottom of the canvas even if only a portion of the canvas has been rendered to and will not be visible unless a negative offset is used to bring the reflection back into view.
        Parameters:
        effect - the effect to apply onto the entire destination or null.