APIdia Launch Partner
Top Description Inners Fields Constructors Methods
javafx.scene.shape

public non-sealed Class Rectangle

extends Shape
Class Inheritance
Imports
javafx.beans.property.DoubleProperty, .DoublePropertyBase, javafx.css.CssMetaData, .Styleable, .StyleableDoubleProperty, .StyleableProperty, javafx.scene.paint.Paint, java.util.ArrayList, .Collections, .List, javafx.css.converter.SizeConverter, com.sun.javafx.geom.BaseBounds, .RoundRectangle2D, com.sun.javafx.geom.transform.BaseTransform, com.sun.javafx.scene.DirtyBits, .NodeHelper, com.sun.javafx.scene.shape.RectangleHelper, .ShapeHelper, com.sun.javafx.sg.prism.NGNode, .NGRectangle, .NGShape, javafx.scene.Node

The Rectangle class defines a rectangle with the specified size and location. By default the rectangle has sharp corners. Rounded corners can be specified by setting both of the arcWidth and arcHeight properties to positive values (> 0.0).

Example code: the following code creates a rectangle with 20 pixel rounded corners.

import javafx.scene.shape.*;

Rectangle r = new Rectangle();
r.setX(50);
r.setY(50);
r.setWidth(200);
r.setHeight(100);
r.setArcWidth(20);
r.setArcHeight(20);
Since
JavaFX 2.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private DoubleProperty
arcHeight

Defines the vertical diameter of the arc at the four corners of the rectangle.

private DoubleProperty
arcWidth

Defines the horizontal diameter of the arc at the four corners of the rectangle.

private final DoubleProperty
height

Defines the height of the rectangle.

private static final int
private final RoundRectangle2D
private final DoubleProperty
width

Defines the width of the rectangle.

private DoubleProperty
x

Defines the X coordinate of the upper-left corner of the rectangle.

private DoubleProperty
y

Defines the Y coordinate of the upper-left corner of the rectangle.

Inherited from javafx.scene.shape.Shape:
old_fillold_stroke

Constructor Summary

AccessConstructor and Description
public
Rectangle()

Creates an empty instance of Rectangle.

public
Rectangle(double
width of the rectangle
width
,
double
height of the rectangle
height
)

Creates a new instance of Rectangle with the given size.

public
Rectangle(double
width of the rectangle
width
,
double
height of the rectangle
height
,
Paint
determines how to fill the interior of the rectangle
fill
)

Creates a new instance of Rectangle with the given size and fill.

public
Rectangle(double
horizontal position of the rectangle
x
,
double
vertical position of the rectangle
y
,
double
width of the rectangle
width
,
double
height of the rectangle
height
)

Creates a new instance of Rectangle with the given position and size.

Method Summary

Modifier and TypeMethod and Description
public final DoubleProperty
public final DoubleProperty
pack-priv StrokeLineJoin
private BaseBounds
private RoundRectangle2D
private NGNode
private void
public final double
public final double
public static List<CssMetaData<? extends Styleable, ?>>

Returns:

the CssMetaData
getClassCssMetaData
()

Hides javafx.scene.shape.Shape.getClassCssMetaData.

Gets the CssMetaData associated with this class, which may include the CssMetaData of its superclasses.

public List<CssMetaData<? extends Styleable, ?>>
getCssMetaData()

Overrides javafx.scene.shape.Shape.getCssMetaData.

Implements javafx.css.Styleable.getCssMetaData.

This method should delegate to Node#getClassCssMetaData() so that a Node's CssMetaData can be accessed without the need for reflection.

public final double
public final double
public final double
getX()

public final double
getY()

public final DoubleProperty
public final void
setArcHeight(double value)

public final void
setArcWidth(double value)

public final void
setHeight(double value)

public final void
setWidth(double value)

public final void
setX(double value)

public final void
setY(double value)

public String

Returns:

a string representation of this Rectangle object.
toString
()

Overrides javafx.scene.Node.toString.

Returns a string representation of this Rectangle object.

public final DoubleProperty
public final DoubleProperty
public final DoubleProperty
Inherited from javafx.scene.shape.Shape:
computeBoundscomputeShapeBoundscomputeShapeContainsfillPropertygetFillgetModegetStrokegetStrokeDashArraygetStrokeDashOffsetgetStrokeLineCapgetStrokeLineJoingetStrokeMiterLimitgetStrokeTypegetStrokeWidthintersectisSmoothsetFillsetShapeChangeListenersetSmoothsetStrokesetStrokeDashOffsetsetStrokeLineCapsetStrokeLineJoinsetStrokeMiterLimitsetStrokeTypesetStrokeWidthsmoothPropertystrokeDashOffsetPropertystrokeLineCapPropertystrokeLineJoinPropertystrokeMiterLimitPropertystrokePropertystrokeTypePropertystrokeWidthPropertysubtractunion

Field Detail

arcHeightback to summary
private DoubleProperty arcHeight

Defines the vertical diameter of the arc at the four corners of the rectangle. The rectangle will have rounded corners if and only if both of the arc width and arc height properties are greater than 0.0.

Default Value
0.0
arcWidthback to summary
private DoubleProperty arcWidth

Defines the horizontal diameter of the arc at the four corners of the rectangle. The rectangle will have rounded corners if and only if both of the arc width and arc height properties are greater than 0.0.

Default Value
0.0
heightback to summary
private final DoubleProperty height

Defines the height of the rectangle.

Default Value
0.0
NON_RECTILINEAR_TYPE_MASKback to summary
private static final int NON_RECTILINEAR_TYPE_MASK
shapeback to summary
private final RoundRectangle2D shape
widthback to summary
private final DoubleProperty width

Defines the width of the rectangle.

Default Value
0.0
xback to summary
private DoubleProperty x

Defines the X coordinate of the upper-left corner of the rectangle.

Default Value
0.0
yback to summary
private DoubleProperty y

Defines the Y coordinate of the upper-left corner of the rectangle.

Default Value
0.0

Constructor Detail

Rectangleback to summary
public Rectangle()

Creates an empty instance of Rectangle.

Rectangleback to summary
public Rectangle(double width, double height)

Creates a new instance of Rectangle with the given size.

Parameters
width:double

width of the rectangle

height:double

height of the rectangle

Rectangleback to summary
public Rectangle(double width, double height, Paint fill)

Creates a new instance of Rectangle with the given size and fill.

Parameters
width:double

width of the rectangle

height:double

height of the rectangle

fill:Paint

determines how to fill the interior of the rectangle

Rectangleback to summary
public Rectangle(double x, double y, double width, double height)

Creates a new instance of Rectangle with the given position and size.

Parameters
x:double

horizontal position of the rectangle

y:double

vertical position of the rectangle

width:double

width of the rectangle

height:double

height of the rectangle

Method Detail

arcHeightPropertyback to summary
public final DoubleProperty arcHeightProperty()
arcWidthPropertyback to summary
public final DoubleProperty arcWidthProperty()
convertLineJoinback to summary
pack-priv StrokeLineJoin convertLineJoin(StrokeLineJoin t)

Overrides javafx.scene.shape.Shape.convertLineJoin.

Annotations
@Override
doComputeGeomBoundsback to summary
private BaseBounds doComputeGeomBounds(BaseBounds bounds, BaseTransform tx)

Hides javafx.scene.shape.Shape.doComputeGeomBounds.

doConfigShapeback to summary
private RoundRectangle2D doConfigShape()
doCreatePeerback to summary
private NGNode doCreatePeer()
doUpdatePeerback to summary
private void doUpdatePeer()

Hides javafx.scene.shape.Shape.doUpdatePeer.

getArcHeightback to summary
public final double getArcHeight()
getArcWidthback to summary
public final double getArcWidth()
getClassCssMetaDataback to summary
public static List<CssMetaData<? extends Styleable, ?>> getClassCssMetaData()

Hides javafx.scene.shape.Shape.getClassCssMetaData.

Gets the CssMetaData associated with this class, which may include the CssMetaData of its superclasses.

Returns:List<CssMetaData<? extends Styleable, ?>>

the CssMetaData

Since
JavaFX 8.0
getCssMetaDataback to summary
public List<CssMetaData<? extends Styleable, ?>> getCssMetaData()

Overrides javafx.scene.shape.Shape.getCssMetaData.

Implements javafx.css.Styleable.getCssMetaData.

Doc from javafx.scene.shape.Shape.getCssMetaData.

This method should delegate to Node#getClassCssMetaData() so that a Node's CssMetaData can be accessed without the need for reflection.

Annotations
@Override
Since
JavaFX 8.0
getHeightback to summary
public final double getHeight()
getWidthback to summary
public final double getWidth()
getXback to summary
public final double getX()
getYback to summary
public final double getY()
heightPropertyback to summary
public final DoubleProperty heightProperty()
setArcHeightback to summary
public final void setArcHeight(double value)
setArcWidthback to summary
public final void setArcWidth(double value)
setHeightback to summary
public final void setHeight(double value)
setWidthback to summary
public final void setWidth(double value)
setXback to summary
public final void setX(double value)
setYback to summary
public final void setY(double value)
toStringback to summary
public String toString()

Overrides javafx.scene.Node.toString.

Returns a string representation of this Rectangle object.

Returns:String

a string representation of this Rectangle object.

Annotations
@Override
widthPropertyback to summary
public final DoubleProperty widthProperty()
xPropertyback to summary
public final DoubleProperty xProperty()
yPropertyback to summary
public final DoubleProperty yProperty()
javafx.scene.shape back to summary

private Class Rectangle.StyleableProperties

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private static final CssMetaData<Rectangle, Number>
private static final CssMetaData<Rectangle, Number>
private static final List<CssMetaData<? extends Styleable, ?>>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ARC_HEIGHTback to summary
private static final CssMetaData<Rectangle, Number> ARC_HEIGHT
ARC_WIDTHback to summary
private static final CssMetaData<Rectangle, Number> ARC_WIDTH
STYLEABLESback to summary
private static final List<CssMetaData<? extends Styleable, ?>> STYLEABLES

Constructor Detail

StyleablePropertiesback to summary
private StyleableProperties()