public class VectorGraphicsPainter extends Object
Modifier and Type | Class and Description |
---|---|
static class |
VectorGraphicsPainter.Direction
Enum for specifying the direction in which a rotation can occur.
|
static class |
VectorGraphicsPainter.FillType
Enum for the ways a path may be filled.
|
Modifier and Type | Method and Description |
---|---|
static void |
drawAnimatedImage(GraphicsContext g,
VectorImage image,
float x,
float y,
long elapsedTime)
Draws an animated vector image at a specific time.
|
static void |
drawAnimatedImage(GraphicsContext g,
VectorImage image,
Matrix matrix,
long elapsedTime)
Draws an animated vector image at a specific time.
|
static void |
drawAnimatedImage(GraphicsContext g,
VectorImage image,
Matrix matrix,
long elapsedTime,
int alpha)
Draws an animated vector image at a specific time.
|
static void |
drawFilteredAnimatedImage(GraphicsContext g,
VectorImage image,
Matrix matrix,
long elapsedTime,
float[] colorMatrix)
Draws an animated vector image at a specific time with a color filter.
|
static void |
drawFilteredImage(GraphicsContext g,
VectorImage image,
Matrix matrix,
float[] colorMatrix)
Draws a vector image with a color filter.
|
static void |
drawGradientString(GraphicsContext g,
String string,
VectorFont font,
float size,
Matrix matrix,
LinearGradient gradient,
int alpha,
BlendMode blendMode,
float letterSpacing)
Draws a text with a gradient.
|
static void |
drawGradientStringOnCircle(GraphicsContext g,
String string,
VectorFont font,
float size,
Matrix matrix,
LinearGradient gradient,
float radius,
VectorGraphicsPainter.Direction direction,
int alpha,
BlendMode blendMode,
float letterSpacing)
Draws a text with a gradient along a circle.
|
static void |
drawImage(GraphicsContext g,
VectorImage image,
float x,
float y)
Draws a vector image.
|
static void |
drawImage(GraphicsContext g,
VectorImage image,
Matrix matrix)
Draws a vector image.
|
static void |
drawImage(GraphicsContext g,
VectorImage image,
Matrix matrix,
int alpha)
Draws a vector image.
|
static void |
drawString(GraphicsContext g,
String string,
VectorFont font,
float size,
float x,
float y)
Draws a text.
|
static void |
drawString(GraphicsContext g,
String string,
VectorFont font,
float size,
Matrix matrix,
int alpha,
BlendMode blendMode,
float letterSpacing)
Draws a text.
|
static void |
drawStringOnCircle(GraphicsContext g,
String string,
VectorFont font,
float size,
Matrix matrix,
float radius,
VectorGraphicsPainter.Direction direction)
Draws a text along a circle.
|
static void |
drawStringOnCircle(GraphicsContext g,
String string,
VectorFont font,
float size,
Matrix matrix,
float radius,
VectorGraphicsPainter.Direction direction,
int alpha,
BlendMode blendMode,
float letterSpacing)
Draws a text along a circle.
|
static void |
fillGradientPath(GraphicsContext g,
Path path,
Matrix matrix,
LinearGradient gradient)
Draws a path filled with a linear gradient and winding fill type and source over blending.
|
static void |
fillGradientPath(GraphicsContext g,
Path path,
Matrix matrix,
LinearGradient gradient,
VectorGraphicsPainter.FillType fillType,
int alpha,
BlendMode blendMode)
Draws a path filled with a linear gradient.
|
static void |
fillPath(GraphicsContext g,
Path path,
float x,
float y)
Draws a path filled with the color of the graphics context and winding fill type and source over blending.
|
static void |
fillPath(GraphicsContext g,
Path path,
Matrix matrix)
Draws a path filled with the color of the graphics context and winding fill type and source over blending.
|
static void |
fillPath(GraphicsContext g,
Path path,
Matrix matrix,
VectorGraphicsPainter.FillType fillType,
int alpha,
BlendMode blendMode)
Draws a path filled with the color of the graphics context.
|
public static void drawAnimatedImage(GraphicsContext g, VectorImage image, float x, float y, long elapsedTime)
The given elapsed time is cropped between 0 and the image duration.
Equivalent to:
Matrix matrix = new Matrix(); matrix.setTranslate(x, y); drawAnimatedImage(g, image, matrix, elapsedTime, GraphicsContext.OPAQUE);
g
- the graphics context to draw onimage
- the image to drawx
- the x coordinate of the imagey
- the y coordinate of the imageelapsedTime
- the elapsed time since the beginning of the animation, in millisecondsVectorGraphicsException
- if the image could not be drawn for any reason (see VectorGraphicsException.getErrorCode()
)public static void drawAnimatedImage(GraphicsContext g, VectorImage image, Matrix matrix, long elapsedTime)
The given elapsed time is cropped between 0 and the image duration.
Equivalent to:
drawAnimatedImage(g, image, matrix, elapsedTime, GraphicsContext.OPAQUE);
g
- the graphics context to draw onimage
- the image to drawmatrix
- the matrix to applyelapsedTime
- the elapsed time since the beginning of the animation, in millisecondsVectorGraphicsException
- if the image could not be drawn for any reason (see VectorGraphicsException.getErrorCode()
)public static void drawAnimatedImage(GraphicsContext g, VectorImage image, Matrix matrix, long elapsedTime, int alpha)
The given elapsed time is cropped between 0 and the image duration.
g
- the graphics context to draw onimage
- the image to drawmatrix
- the matrix to applyelapsedTime
- the elapsed time since the beginning of the animation, in millisecondsalpha
- the global opacity rendering value, between 0 (transparent) and 255 (opaque)VectorGraphicsException
- if the image could not be drawn for any reason (see VectorGraphicsException.getErrorCode()
)GraphicsContext.getAlpha(int)
public static void drawFilteredAnimatedImage(GraphicsContext g, VectorImage image, Matrix matrix, long elapsedTime, float[] colorMatrix)
g
- the graphics context to draw onimage
- the image to drawmatrix
- the matrix to applyelapsedTime
- the elapsed time since the beginning of the animation, in millisecondscolorMatrix
- the color matrix used to transform colorsVectorGraphicsException
- if the image could not be drawn for any reason (see VectorGraphicsException.getErrorCode()
)ArrayIndexOutOfBoundsException
- if the given color matrix is shorter than 20 entriesVectorImage.filterImage(float[])
public static void drawFilteredImage(GraphicsContext g, VectorImage image, Matrix matrix, float[] colorMatrix)
g
- the graphics context to draw onimage
- the image to drawmatrix
- the matrix to applycolorMatrix
- the color matrix used to transform colorsVectorGraphicsException
- if the image could not be drawn for any reason (see VectorGraphicsException.getErrorCode()
)ArrayIndexOutOfBoundsException
- if the given color matrix is shorter than 20 entriesVectorImage.filterImage(float[])
public static void drawGradientString(GraphicsContext g, String string, VectorFont font, float size, Matrix matrix, LinearGradient gradient, int alpha, BlendMode blendMode, float letterSpacing)
This method uses the given gradient for the font coloring. The color of the graphics context is not used by this drawing.
The anchor point is the top left corner of the text render box (related to font height; different from the text
bounding box, which is related to font size; see class comment VectorFont
). The matrix defines the
transformations to apply to the text (translation, scale, rotation). For example, passing the identity matrix to
this method will draw an horizontal text whose top-left corner is aligned with the origin of the graphics
context.
The font size must be positive. If it is less than or equal to 0, nothing is drawn.
This method allows to specify the global opacity value to apply during the rendering. The alpha must be a value between and . If the specified alpha is outside this range, nothing is drawn.
The blend mode specifies the algorithm to use when blending the pixels of the source and destination.
The letter spacing argument specifies the extra space to add between the characters. A positive value will move the characters apart, a negative value will move them together. The default value is 0.
g
- the graphics context to draw onstring
- the text to drawfont
- the font to usesize
- the font size, in pixelsmatrix
- the transformation matrix to applygradient
- the gradient to color the text withalpha
- the global opacity rendering valueblendMode
- the blend modeletterSpacing
- the extra letter spacing to use, in pixelsVectorGraphicsException
- if the text could not be drawn for any reason (see VectorGraphicsException.getErrorCode()
)GraphicsContext.getAlpha(int)
,
BlendMode
public static void drawGradientStringOnCircle(GraphicsContext g, String string, VectorFont font, float size, Matrix matrix, LinearGradient gradient, float radius, VectorGraphicsPainter.Direction direction, int alpha, BlendMode blendMode, float letterSpacing)
This method uses the given gradient for the font coloring. The color of the graphics context is not used by this drawing.
The anchor point is the center of the circle. The matrix defines the transformations to apply to the text (translation, scale, rotation). For example, passing the identity matrix to this method will align the center of the circle with the origin of the graphics context.
The position where the text starts along the circle is the 3 o'clock position (positive X axis). This starting position can be modified by specifying a rotation into the transformation matrix.
The text winds along the circle in the specified direction (clockwise or counter-clockwise). The radius of the circle must be positive. If it is less than or equal to 0, nothing is drawn.
The font size must be positive. If it is less than or equal to 0, nothing is drawn.
This method allows to specify the global opacity value to apply during the rendering. The alpha must be a value between and . If the specified alpha is outside this range, nothing is drawn.
The blend mode specifies the algorithm to use when blending the pixels of the source and destination.
The letter spacing argument specifies the extra space to add between the characters. A positive value will move the characters apart, a negative value will move them together. The default value is 0.
g
- the graphics context to draw onstring
- the string to drawfont
- the font to usesize
- the font size, in pixelsmatrix
- the matrix to applygradient
- the gradient to color the string withalpha
- the global opacity rendering valueblendMode
- the blend modeletterSpacing
- the extra letter spacing to use, in pixelsradius
- the radius of the circle, in pixelsdirection
- the winding direction of the text along the circleVectorGraphicsException
- if the text could not be drawn for any reason (see VectorGraphicsException.getErrorCode()
)GraphicsContext.getAlpha(int)
,
BlendMode
,
VectorGraphicsPainter.Direction
public static void drawImage(GraphicsContext g, VectorImage image, float x, float y)
Equivalent to:
Matrix matrix = new Matrix(); matrix.setTranslate(x, y); drawImage(g, image, matrix, GraphicsContext.OPAQUE);
g
- the graphics context to draw onimage
- the image to drawx
- the x coordinate of the imagey
- the y coordinate of the imageVectorGraphicsException
- if the image could not be drawn for any reason (see VectorGraphicsException.getErrorCode()
)public static void drawImage(GraphicsContext g, VectorImage image, Matrix matrix)
Equivalent to:
drawImage(g, image, matrix, GraphicsContext.OPAQUE);
g
- the graphics context to draw onimage
- the image to drawmatrix
- the matrix to applyVectorGraphicsException
- if the image could not be drawn for any reason (see VectorGraphicsException.getErrorCode()
)public static void drawImage(GraphicsContext g, VectorImage image, Matrix matrix, int alpha)
g
- the graphics context to draw onimage
- the image to drawmatrix
- the matrix to applyalpha
- the global opacity rendering value, between 0 (transparent) and 255 (opaque)VectorGraphicsException
- if the image could not be drawn for any reason (see VectorGraphicsException.getErrorCode()
)GraphicsContext.getAlpha(int)
public static void drawString(GraphicsContext g, String string, VectorFont font, float size, float x, float y)
This method uses the color of the graphics context as font color.
The anchor point is the top left corner of the text render box (related to font height; different from the text
bounding box, which is related to font size; see class comment VectorFont
). The position of this anchor
point within the graphics context is defined by the (x,y)
coordinates.
For example, to draw a text where yBaseline
defines the y coordinate of the text baseline, use
yBaseline - font.getBaselinePosition()
as argument of this method (see
VectorFont.getBaselinePosition(float)
).
The font size must be positive. If it is less than or equal to 0, nothing is drawn.
Equivalent to:
Matrix matrix = new Matrix(); matrix.setTranslate(x, y); drawString(g, string font, size, matrix, GraphicsContext.OPAQUE, BlendMode.SRC_OVER, 0);
g
- the graphics context to draw onstring
- the text to drawfont
- the font to usesize
- the font size, in pixelsx
- the x coordinate of the stringy
- the y coordinate of the stringVectorGraphicsException
- if the text could not be drawn for any reason (see VectorGraphicsException.getErrorCode()
)public static void drawString(GraphicsContext g, String string, VectorFont font, float size, Matrix matrix, int alpha, BlendMode blendMode, float letterSpacing)
This method uses the color of the graphics context as font color.
The anchor point is the top left corner of the text render box (related to font height; different from the text
bounding box, which is related to font size; see class comment VectorFont
). The matrix defines the
transformations to apply to the text (translation, scale, rotation). For example, passing the identity matrix to
this method will draw an horizontal text whose top-left corner is aligned with the origin of the graphics
context.
The font size must be positive. If it is less than or equal to 0, nothing is drawn.
This method allows to specify the global opacity value to apply during the rendering. The alpha must be a value between and . If the specified alpha is outside this range, nothing is drawn.
The blend mode specifies the algorithm to use when blending the pixels of the source and destination.
The letter spacing argument specifies the extra space to add between the characters. A positive value will move the characters apart, a negative value will move them together. The default value is 0.
g
- the graphics context to draw onstring
- the text to drawfont
- the font to usesize
- the font size, in pixelsmatrix
- the transformation matrix to applyalpha
- the global opacity rendering valueblendMode
- the blend mode to useletterSpacing
- the extra letter spacing to use, in pixelsVectorGraphicsException
- if the text could not be drawn for any reason (see VectorGraphicsException.getErrorCode()
)GraphicsContext.getAlpha(int)
,
BlendMode
public static void drawStringOnCircle(GraphicsContext g, String string, VectorFont font, float size, Matrix matrix, float radius, VectorGraphicsPainter.Direction direction)
This method uses the color of the graphics context as font color.
The anchor point is the center of the circle. The matrix defines the transformations to apply to the text (translation, scale, rotation). For example, passing the identity matrix to this method will align the center of the circle with the origin of the graphics context.
The position where the text starts along the circle is the 3 o'clock position (positive X axis). This starting position can be modified by specifying a rotation into the transformation matrix.
The text winds along the circle in the specified direction (clockwise or counter-clockwise). The radius of the circle must be positive. If it is less than or equal to 0, nothing is drawn.
The font size must be positive. If it is less than or equal to 0, nothing is drawn.
Equivalent to:
drawStringOnCircle(g, string font, size, matrix, radius, direction, GraphicsContext.OPAQUE, BlendMode.SRC_OVER, 0);
g
- the graphics context to draw onstring
- the string to drawfont
- the font to usesize
- the font size, in pixelsmatrix
- the matrix to applyradius
- the radius of the circle, in pixelsdirection
- the winding direction of the text along the circle.VectorGraphicsException
- if the text could not be drawn for any reason (see VectorGraphicsException.getErrorCode()
)VectorGraphicsPainter.Direction
public static void drawStringOnCircle(GraphicsContext g, String string, VectorFont font, float size, Matrix matrix, float radius, VectorGraphicsPainter.Direction direction, int alpha, BlendMode blendMode, float letterSpacing)
This method uses the color of the graphics context as font color.
The anchor point is the center of the circle. The matrix defines the transformations to apply to the text (translation, scale, rotation). For example, passing the identity matrix to this method will align the center of the circle with the origin of the graphics context.
The position where the text starts along the circle is the 3 o'clock position (positive X axis). This starting position can be modified by specifying a rotation into the transformation matrix.
The text winds along the circle in the specified direction (clockwise or counter-clockwise). The radius of the circle must be positive. If it is less than or equal to 0, nothing is drawn.
The font size must be positive. If it is less than or equal to 0, nothing is drawn.
This method allows to specify the global opacity value to apply during the rendering. The alpha must be a value between and . If the specified alpha is outside this range, nothing is drawn.
The blend mode specifies the algorithm to use when blending the pixels of the source and destination.
The letter spacing argument specifies the extra space to add between the characters. A positive value will move the characters apart, a negative value will move them together. The default value is 0.
g
- the graphics context to draw onstring
- the string to drawfont
- the font to usesize
- the font size, in pixelsmatrix
- the matrix to applyradius
- the radius of the circle, in pixelsdirection
- the winding direction of the text along the circlealpha
- the global opacity rendering valueblendMode
- the blend modeletterSpacing
- the extra letter spacing to use, in pixelsVectorGraphicsException
- if the text could not be drawn for any reason (see VectorGraphicsException.getErrorCode()
)GraphicsContext.getAlpha(int)
,
BlendMode
,
VectorGraphicsPainter.Direction
public static void fillGradientPath(GraphicsContext g, Path path, Matrix matrix, LinearGradient gradient)
The color of the graphics context is not used by this drawing.
Equivalent to:
fillGradientPath(g, path, matrix, gradient, FillType.WINDING, GraphicsContext.OPAQUE, BlendMode.SRC_OVER);
g
- the graphics context to draw onpath
- the path to drawmatrix
- the matrix to applygradient
- the gradient to fill withpublic static void fillGradientPath(GraphicsContext g, Path path, Matrix matrix, LinearGradient gradient, VectorGraphicsPainter.FillType fillType, int alpha, BlendMode blendMode)
The color of the graphics context is not used by this drawing.
g
- the graphics context to draw onpath
- the path to drawmatrix
- the matrix to applygradient
- the gradient to fill withfillType
- the fill typealpha
- the global opacity rendering value, between 0 (transparent) and 255 (opaque)blendMode
- the blend modeGraphicsContext.getAlpha(int)
public static void fillPath(GraphicsContext g, Path path, float x, float y)
Equivalent to:
Matrix matrix = new Matrix(); matrix.setTranslate(x, y); fillPath(g, path, matrix, FillType.WINDING, GraphicsContext.OPAQUE, BlendMode.SRC_OVER);
g
- the graphics context to draw onpath
- the path to drawx
- the x coordinate of the pathy
- the y coordinate of the pathpublic static void fillPath(GraphicsContext g, Path path, Matrix matrix)
Equivalent to:
fillPath(g, path, matrix, FillType.WINDING, GraphicsContext.OPAQUE, BlendMode.SRC_OVER);
g
- the graphics context to draw onpath
- the path to drawmatrix
- the matrix to applypublic static void fillPath(GraphicsContext g, Path path, Matrix matrix, VectorGraphicsPainter.FillType fillType, int alpha, BlendMode blendMode)
g
- the graphics context to draw onpath
- the path to drawmatrix
- the matrix to applyfillType
- the fill typealpha
- the global opacity rendering value, between 0 (transparent) and 255 (opaque)blendMode
- the blend modeGraphicsContext.getAlpha(int)