Canvas is an image that can be drawn on using a set of graphics
commands provided by a GraphicsContext.
A Canvas node is constructed with a width and height that specifies the size
of the image into which the canvas drawing commands are rendered. All drawing
operations are clipped to the bounds of that image.
Example:
import javafx.scene.*; import javafx.scene.paint.*; import javafx.scene.canvas.*; Group root = new Group(); Scene s = new Scene(root, 300, 300, Color.BLACK); final Canvas canvas = new Canvas(250,250); GraphicsContext gc = canvas.getGraphicsContext2D(); gc.setFill(Color.BLUE); gc.fillRect(75,75,100,100); root.getChildren().add(canvas);
GraphicsContext
| Modifier and Type | Field and Description |
|---|---|
| private GrowableDataBuffer | |
| pack-priv static final int | |
| pack-priv static final int | |
| private DoubleProperty | height
Defines the height of the canvas. |
| private int | |
| private int[] | |
| private int[] | |
| private boolean | |
| private static final int | |
| private GraphicsContext | |
| private DoubleProperty | width
Defines the width of the canvas. |
| Access | Constructor and Description |
|---|---|
| public | |
| public | Canvas(double
width of the canvas width, double height of the canvas height)Creates a new instance of Canvas with the given size. |
| Modifier and Type | Method and Description |
|---|---|
| private boolean | |
| private BaseBounds | |
| private NGNode | |
| private void | |
| pack-priv GrowableDataBuffer | |
| public GraphicsContext | Returns: theGraphicsContext associated with this Canvasreturns the |
| public final double | |
| public final double | |
| public final DoubleProperty | |
| pack-priv boolean | |
| private static int | |
| public final void | |
| public final void | |
| public final DoubleProperty |
| current | back to summary |
|---|---|
| private GrowableDataBuffer current | |
| DEFAULT_OBJ_BUF_SIZE | back to summary |
|---|---|
| pack-priv static final int DEFAULT_OBJ_BUF_SIZE | |
| DEFAULT_VAL_BUF_SIZE | back to summary |
|---|---|
| pack-priv static final int DEFAULT_VAL_BUF_SIZE | |
| height | back to summary |
|---|---|
| private DoubleProperty height Defines the height of the canvas.
| |
| lastsizeindex | back to summary |
|---|---|
| private int lastsizeindex | |
| recentobjsizes | back to summary |
|---|---|
| private int[] recentobjsizes | |
| recentvalsizes | back to summary |
|---|---|
| private int[] recentvalsizes | |
| rendererBehind | back to summary |
|---|---|
| private boolean rendererBehind | |
| SIZE_HISTORY | back to summary |
|---|---|
| private static final int SIZE_HISTORY | |
| theContext | back to summary |
|---|---|
| private GraphicsContext theContext | |
| width | back to summary |
|---|---|
| private DoubleProperty width Defines the width of the canvas.
| |
| Canvas | back to summary |
|---|---|
| public Canvas() Creates an empty instance of Canvas. | |
| Canvas | back to summary |
|---|---|
| public Canvas(double width, double height) Creates a new instance of Canvas with the given size.
| |
| doComputeContains | back to summary |
|---|---|
| private boolean doComputeContains(double localX, double localY) | |
| doComputeGeomBounds | back to summary |
|---|---|
| private BaseBounds doComputeGeomBounds(BaseBounds bounds, BaseTransform tx) | |
| doCreatePeer | back to summary |
|---|---|
| private NGNode doCreatePeer() | |
| doUpdatePeer | back to summary |
|---|---|
| private void doUpdatePeer() | |
| getBuffer | back to summary |
|---|---|
| pack-priv GrowableDataBuffer getBuffer() | |
| getGraphicsContext2D | back to summary |
|---|---|
| public GraphicsContext getGraphicsContext2D() returns the
| |
| getHeight | back to summary |
|---|---|
| public final double getHeight() | |
| getWidth | back to summary |
|---|---|
| public final double getWidth() | |
| heightProperty | back to summary |
|---|---|
| public final DoubleProperty heightProperty() | |
| isRendererFallingBehind | back to summary |
|---|---|
| pack-priv boolean isRendererFallingBehind() | |
| max | back to summary |
|---|---|
| private static int max(int[] sizes, int defsize) | |
| setHeight | back to summary |
|---|---|
| public final void setHeight(double value) | |
| setWidth | back to summary |
|---|---|
| public final void setWidth(double value) | |
| widthProperty | back to summary |
|---|---|
| public final DoubleProperty widthProperty() | |