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

public abstract sealed Class Shape

extends Node
permits AbstractShape, Arc, Circle, CubicCurve, Ellipse, Line, Path, Polygon, Polyline, QuadCurve, Rectangle, SVGPath, Text
Class Inheritance
Known Direct Subclasses
javafx.scene.shape.SVGPath, javafx.scene.text.Text, com.sun.javafx.scene.shape.AbstractShape, javafx.scene.shape.Arc, javafx.scene.shape.Circle, javafx.scene.shape.CubicCurve, javafx.scene.shape.Ellipse, javafx.scene.shape.Line, javafx.scene.shape.Path, javafx.scene.shape.Polygon, javafx.scene.shape.Polyline, javafx.scene.shape.QuadCurve, javafx.scene.shape.Rectangle
Imports
javafx.beans.Observable, javafx.beans.property.BooleanProperty, .DoubleProperty, .ObjectProperty, .Property, javafx.collections.ListChangeListener.Change, .ObservableList, javafx.css.CssMetaData, .Styleable, .StyleableBooleanProperty, .StyleableDoubleProperty, .StyleableObjectProperty, .StyleableProperty, javafx.scene.Node, javafx.scene.paint.Color, .Paint, javafx.scene.text.Text, java.util.ArrayList, .Collections, .List, com.sun.javafx.util.Utils, com.sun.javafx.beans.event.AbstractNotifyListener, com.sun.javafx.collections.TrackableObservableList, javafx.css.converter.BooleanConverter, .EnumConverter, .PaintConverter, .SizeConverter, com.sun.javafx.geom.Area, .BaseBounds, .PathIterator, com.sun.javafx.geom.transform.Affine3D, .BaseTransform, com.sun.javafx.scene.DirtyBits, .NodeHelper, com.sun.javafx.scene.shape.AbstractShape, .ShapeHelper, com.sun.javafx.sg.prism.NGShape, com.sun.javafx.tk.Toolkit, java.lang.ref.Reference, .WeakReference

The Shape class provides definitions of common properties for objects that represent some form of geometric shape. These properties include:

Interaction with coordinate systems

Most nodes tend to have only integer translations applied to them and quite often they are defined using integer coordinates as well. For this common case, fills of shapes with straight line edges tend to be crisp since they line up with the cracks between pixels that fall on integer device coordinates and thus tend to naturally cover entire pixels.

On the other hand, stroking those same shapes can often lead to fuzzy outlines because the default stroking attributes specify both that the default stroke width is 1.0 coordinates which often maps to exactly 1 device pixel and also that the stroke should straddle the border of the shape, falling half on either side of the border. Since the borders in many common shapes tend to fall directly on integer coordinates and those integer coordinates often map precisely to integer device locations, the borders tend to result in 50% coverage over the pixel rows and columns on either side of the border of the shape rather than 100% coverage on one or the other. Thus, fills may typically be crisp, but strokes are often fuzzy.

Two common solutions to avoid these fuzzy outlines are to use wider strokes that cover more pixels completely - typically a stroke width of 2.0 will achieve this if there are no scale transforms in effect - or to specify either the StrokeType#INSIDE or StrokeType#OUTSIDE stroke styles - which will bias the default single unit stroke onto one of the full pixel rows or columns just inside or outside the border of the shape.

Since
JavaFX 2.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
private static class

Field Summary

Modifier and TypeField and Description
private static final float[]
private static final double
private static final StrokeLineCap
private static final StrokeLineJoin
private static final double
private static final StrokeType
private static final double
private ObjectProperty<Paint>
fill

Defines parameters to fill the interior of an Shape using the settings of the Paint context.

private static final double
private static final double
private NGShape.Mode
pack-priv Paint
pack-priv Paint
private final AbstractNotifyListener
private Reference<Runnable>
private BooleanProperty
smooth

Defines whether antialiasing hints are used or not for this Shape.

private ObjectProperty<Paint>
stroke

Defines parameters of a stroke that is drawn around the outline of a Shape using the settings of the specified Paint.

private Shape.StrokeAttributes
private boolean
Inherited from javafx.scene.Node:
BASELINE_OFFSET_SAME_AS_HEIGHT

Constructor Summary

AccessConstructor and Description
public
Shape()

Creates an empty instance of Shape.

Method Summary

Modifier and TypeMethod and Description
private static BaseTransform
private void
pack-priv BaseBounds
computeBounds(BaseBounds bounds, BaseTransform tx, double upad, double dpad, double x, double y, double w, double h)

Helper function for rectangular shapes such as Rectangle and Ellipse for computing their bounds.

private NGShape.Mode
pack-priv BaseBounds
pack-priv boolean
computeShapeContains(double localX, double localY, Shape s)

pack-priv StrokeLineJoin
private static Path
createFromGeomShape(final Shape geomShape)

private static Area
createTransformedArea(final Shape geomShape, final BaseTransform transform)

private boolean
doComputeContains(double localX, double localY)

private BaseBounds
private Paint
private Paint
private void
doMarkDirty(DirtyBits dirtyBits)

Hides javafx.scene.Node.doMarkDirty.

Mark the specified bit as dirty, and add this node to the scene's dirty list.

private void
public final ObjectProperty<Paint>
public static List<CssMetaData<? extends Styleable, ?>>

Returns:

the CssMetaData
getClassCssMetaData
()

Hides javafx.scene.Node.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.Node.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 Paint
pack-priv NGShape.Mode
public final Paint
private Shape.StrokeAttributes
public final ObservableList<Double>

Returns:

the array representing the lengths of the dash segments
getStrokeDashArray
()

Defines the array representing the lengths of the dash segments.

public final double
public final StrokeLineCap
public final StrokeLineJoin
public final double
public final StrokeType
public final double
private Area
private Area
private boolean
public static Shape

Returns:

the created Shape
intersect
(final Shape
the first shape
shape1
,
final Shape
the second shape
shape2
)

Returns a new Shape which is created as an intersection of the specified input shapes.

public final boolean
public final void
setFill(Paint value)

pack-priv void
public final void
setSmooth(boolean value)

public final void
public final void
setStrokeDashOffset(double value)

public final void
public final void
public final void
setStrokeMiterLimit(double value)

public final void
public final void
setStrokeWidth(double value)

public final BooleanProperty
public final DoubleProperty

Returns:

the distance specified in user coordinates that represents an offset into the dashing pattern
strokeDashOffsetProperty
()

Defines a distance specified in user coordinates that represents an offset into the dashing pattern.

public final ObjectProperty<StrokeLineCap>

Returns:

the end cap style of this shape
strokeLineCapProperty
()

The end cap style of this Shape as one of the following values that define possible end cap styles: StrokeLineCap.BUTT, StrokeLineCap.ROUND, and StrokeLineCap.SQUARE.

public final ObjectProperty<StrokeLineJoin>

Returns:

the decoration applied where path segments meet
strokeLineJoinProperty
()

Defines the decoration applied where path segments meet.

public final DoubleProperty

Returns:

the limit for the StrokeLineJoin.MITER line join style
strokeMiterLimitProperty
()

Defines the limit for the StrokeLineJoin.MITER line join style.

public final ObjectProperty<Paint>
public final ObjectProperty<StrokeType>

Returns:

the direction that the strokeWidth is applied to the boundary of the shape
strokeTypeProperty
()

Defines the direction (inside, centered, or outside) that the strokeWidth is applied to the boundary of the shape.

public final DoubleProperty

Returns:

the square pen line width
strokeWidthProperty
()

Defines a square pen line width.

public static Shape

Returns:

the created Shape
subtract
(final Shape
the first shape
shape1
,
final Shape
the second shape
shape2
)

Returns a new Shape which is created by subtracting the specified second shape from the first shape.

private static float[]
toPGDashArray(final List<Double> dashArray)

public static Shape

Returns:

the created Shape
union
(final Shape
the first shape
shape1
,
final Shape
the second shape
shape2
)

Returns a new Shape which is created as a union of the specified input shapes.

private void
Inherited from javafx.scene.Node:
accessibleHelpPropertyaccessibleRoleDescriptionPropertyaccessibleRolePropertyaccessibleTextPropertyaddEventFilteraddEventHandlerapplyCssautosizeblendModePropertyboundsInLocalPropertyboundsInParentPropertybuildEventDispatchChaincacheHintPropertycachePropertyclipPropertycomputeAreaInScreencontainscontainscursorPropertydepthTestPropertydisabledPropertydisablePropertyeffectiveNodeOrientationPropertyeffectPropertyeventDispatcherPropertyexecuteAccessibleActionfireEventfocusedPropertyfocusTraversablePropertyfocusVisiblePropertyfocusWithinPropertygetAccessibleHelpgetAccessibleRolegetAccessibleRoleDescriptiongetAccessibleTextgetBaselineOffsetgetBlendModegetBoundsInLocalgetBoundsInParentgetCacheHintgetClipgetContentBiasgetCursorgetDepthTestgetEffectgetEffectiveNodeOrientationgetEventDispatchergetIdgetInitialCursorgetInitialFocusTraversablegetInputMethodRequestsgetLayoutBoundsgetLayoutXgetLayoutYgetLocalToParentTransformgetLocalToSceneTransformgetNodeOrientationgetOnContextMenuRequestedgetOnDragDetectedgetOnDragDonegetOnDragDroppedgetOnDragEnteredgetOnDragExitedgetOnDragOvergetOnInputMethodTextChangedgetOnKeyPressedgetOnKeyReleasedgetOnKeyTypedgetOnMouseClickedgetOnMouseDragDonegetOnMouseDragEnteredgetOnMouseDragExitedgetOnMouseDraggedgetOnMouseDragOvergetOnMouseDragReleasedgetOnMouseEnteredgetOnMouseExitedgetOnMouseMovedgetOnMousePressedgetOnMouseReleasedgetOnRotategetOnRotationFinishedgetOnRotationStartedgetOnScrollgetOnScrollFinishedgetOnScrollStartedgetOnSwipeDowngetOnSwipeLeftgetOnSwipeRightgetOnSwipeUpgetOnTouchMovedgetOnTouchPressedgetOnTouchReleasedgetOnTouchStationarygetOnZoomgetOnZoomFinishedgetOnZoomStartedgetOpacitygetParentgetPropertiesgetPseudoClassStatesgetRotategetRotationAxisgetScaleXgetScaleYgetScaleZgetScenegetStylegetStyleableParentgetStyleClassgetTransformsgetTranslateXgetTranslateYgetTranslateZgetTypeSelectorgetUserDatagetViewOrderhasPropertieshoverPropertyidPropertyinputMethodRequestsPropertyintersectsintersectsisCacheisDisableisDisabledisFocusedisFocusTraversableisFocusVisibleisFocusWithinisHoverisManagedisMouseTransparentisPickOnBoundsisPressedisResizableisVisiblelayoutBoundsPropertylayoutXPropertylayoutYPropertylocalToParentlocalToParentlocalToParentlocalToParentlocalToParentlocalToParentTransformPropertylocalToScenelocalToScenelocalToScenelocalToScenelocalToScenelocalToScenelocalToScenelocalToScenelocalToScenelocalToScenelocalToSceneTransformPropertylocalToScreenlocalToScreenlocalToScreenlocalToScreenlocalToScreenlookuplookupAllmanagedPropertymaxHeightmaxWidthminHeightminWidthmouseTransparentPropertynodeOrientationPropertynotifyAccessibleAttributeChangedonContextMenuRequestedPropertyonDragDetectedPropertyonDragDonePropertyonDragDroppedPropertyonDragEnteredPropertyonDragExitedPropertyonDragOverPropertyonInputMethodTextChangedPropertyonKeyPressedPropertyonKeyReleasedPropertyonKeyTypedPropertyonMouseClickedPropertyonMouseDragDonePropertyonMouseDragEnteredPropertyonMouseDragExitedPropertyonMouseDraggedPropertyonMouseDragOverPropertyonMouseDragReleasedPropertyonMouseEnteredPropertyonMouseExitedPropertyonMouseMovedPropertyonMousePressedPropertyonMouseReleasedPropertyonRotatePropertyonRotationFinishedPropertyonRotationStartedPropertyonScrollFinishedPropertyonScrollPropertyonScrollStartedPropertyonSwipeDownPropertyonSwipeLeftPropertyonSwipeRightPropertyonSwipeUpPropertyonTouchMovedPropertyonTouchPressedPropertyonTouchReleasedPropertyonTouchStationaryPropertyonZoomFinishedPropertyonZoomPropertyonZoomStartedPropertyopacityPropertyparentPropertyparentToLocalparentToLocalparentToLocalparentToLocalparentToLocalpickOnBoundsPropertyprefHeightprefWidthpressedPropertypseudoClassStateChangedqueryAccessibleAttributerelocateremoveEventFilterremoveEventHandlerrequestFocusrequestFocusTraversalresizeresizeRelocaterotatePropertyrotationAxisPropertyscaleXPropertyscaleYPropertyscaleZPropertyscenePropertysceneToLocalsceneToLocalsceneToLocalsceneToLocalsceneToLocalsceneToLocalsceneToLocalsceneToLocalscreenToLocalscreenToLocalscreenToLocalsetAccessibleHelpsetAccessibleRolesetAccessibleRoleDescriptionsetAccessibleTextsetBlendModesetCachesetCacheHintsetClipsetCursorsetDepthTestsetDisablesetDisabledsetEffectsetEventDispatchersetEventHandlersetFocusedsetFocusTraversablesetHoversetIdsetInputMethodRequestssetLayoutXsetLayoutYsetManagedsetMouseTransparentsetNodeOrientationsetOnContextMenuRequestedsetOnDragDetectedsetOnDragDonesetOnDragDroppedsetOnDragEnteredsetOnDragExitedsetOnDragOversetOnInputMethodTextChangedsetOnKeyPressedsetOnKeyReleasedsetOnKeyTypedsetOnMouseClickedsetOnMouseDragDonesetOnMouseDragEnteredsetOnMouseDragExitedsetOnMouseDraggedsetOnMouseDragOversetOnMouseDragReleasedsetOnMouseEnteredsetOnMouseExitedsetOnMouseMovedsetOnMousePressedsetOnMouseReleasedsetOnRotatesetOnRotationFinishedsetOnRotationStartedsetOnScrollsetOnScrollFinishedsetOnScrollStartedsetOnSwipeDownsetOnSwipeLeftsetOnSwipeRightsetOnSwipeUpsetOnTouchMovedsetOnTouchPressedsetOnTouchReleasedsetOnTouchStationarysetOnZoomsetOnZoomFinishedsetOnZoomStartedsetOpacitysetPickOnBoundssetPressedsetRotatesetRotationAxissetScaleXsetScaleYsetScaleZsetStylesetTranslateXsetTranslateYsetTranslateZsetUserDatasetViewOrdersetVisiblesnapshotsnapshotstartDragAndDropstartFullDragstylePropertytoBacktoFronttoStringtranslateXPropertytranslateYPropertytranslateZPropertyusesMirroringviewOrderPropertyvisibleProperty