- All Implemented Interfaces:
ConnectableFigure,Figure,FillableFigure,PaddableFigure,PathIterableFigure,ShapeableFigure,StrokableFigure,TextFillableFigure,TextFontableFigure,TextLayoutableFigure,TransformCachingFigure,PropertyBean,StyleableBean,StyleablePropertyBean,TreeNode<Figure>
- Direct Known Subclasses:
AbstractLabelConnectionFigure,LabelFigure,PageLabelFigure
Label: The layout bounds of the label are controlled by
FillableFigure, StrokableFigure, ShapeableFigure.
Other figures can get its path with PathIterableFigure. The label
box is connectable by means of ConnectableFigure.
+---------------+ | layout bounds | +---------------+Layout bounds: The layout bounds consist of a content box with padding around it.
+-------------------+ | padding | | +---------------+ | | | content box | | | +---------------+ | +-------------------+Content box: The content is controlled by
ICON_POSITION,
ICON_SIZE, ICON_TEXT_GAP.
+------+ +---------------+ +---------------+ | text | | icon gap text | | text gap icon | +------+ +---------------+ +---------------+
The placement of the label is controlled by ORIGIN,
TextLayoutableFigure.TEXT_VPOS, TEXT_HPOS.
Note that the placement affects the content box.
text-hpos: left; ┆ center; ┆ right;
┆ ┆
x ┆ x ┆ x
+-------------+ ┆ +-------------+ ┆ +-------------+
| content box | ┆ | content box | ┆ | content box |
+-------------+ ┆ +-------------+ ┆ +-------------+
text-vpos: top; ┆ center; ┆ baseline; ┆ bottom;
┆ ┆ ┆
y +---------+ ┆ +---------+ ┆ +---------+ ┆ +---------+
| content | ┆ y | content | ┆ y_| content | ┆ | content |
| box | ┆ | box | ┆ | box | ┆ | box |
+---------+ ┆ +---------+ ┆ +---------+ ┆ y +---------+
- Author:
- Werner Randelshofer
-
Property Summary
Properties inherited from class org.jhotdraw8.draw.figure.AbstractFigure
parentProperties inherited from interface org.jhotdraw8.fxbase.styleable.StyleableBean
id -
Nested Class Summary
Nested classes/interfaces inherited from interface org.jhotdraw8.fxbase.tree.TreeNode
TreeNode.AncestorIterator<T extends TreeNode<T>> -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final NullablePaintableStyleableKeyDefines the paint used for filling the interior of the icon shape.static final NonNullEnumStyleableKey<IconPosition> static final DoubleStyleableKeystatic final NullableFXPathElementsStyleableKeystatic final CssDimension2DStyleableKeystatic final CssSizeStyleableKeystatic final CssPoint2DStyleableMapAccessorThe position relative to the parent (respectively the offset).static final CssSizeStyleableKeystatic final CssSizeStyleableKeystatic final CssPoint2DStyleableMapAccessorstatic final CssSizeStyleableKeystatic final CssSizeStyleableKeystatic final NonNullEnumStyleableKey<javafx.geometry.HPos> The horizontal position of the text.Fields inherited from class org.jhotdraw8.fxbase.styleable.AbstractStyleablePropertyBean
keyMaps, propertiesFields inherited from interface org.jhotdraw8.draw.figure.Figure
declaredAndInheritedKeys, JHOTDRAW_CSS_PREFIX, PARENT_PROPERTYFields inherited from interface org.jhotdraw8.draw.figure.FillableFigure
FILLFields inherited from interface org.jhotdraw8.draw.figure.PaddableFigure
PADDING, PADDING_BOTTOM, PADDING_LEFT, PADDING_RIGHT, PADDING_TOPFields inherited from interface org.jhotdraw8.draw.figure.ShapeableFigure
SHAPE, SHAPE_BOUNDS, SHAPE_BOUNDS_HEIGHT, SHAPE_BOUNDS_WIDTH, SHAPE_BOUNDS_X, SHAPE_BOUNDS_Y, SHAPE_SLICE, SHAPE_SLICE_BOTTOM, SHAPE_SLICE_LEFT, SHAPE_SLICE_RIGHT, SHAPE_SLICE_TOP, SVG_SQUAREFields inherited from interface org.jhotdraw8.draw.figure.StrokableFigure
STROKE, STROKE_DASH_ARRAY, STROKE_DASH_OFFSET, STROKE_LINE_CAP, STROKE_LINE_JOIN, STROKE_MITER_LIMIT, STROKE_STYLE, STROKE_TYPE, STROKE_WIDTHFields inherited from interface org.jhotdraw8.draw.figure.TextFillableFigure
TEXT_FILLFields inherited from interface org.jhotdraw8.draw.figure.TextFontableFigure
FONT, FONT_FAMILY, FONT_SIZE, FONT_STYLE, FONT_WEIGHT, STRIKETHROUGH, UNDERLINEFields inherited from interface org.jhotdraw8.draw.figure.TextLayoutableFigure
LINE_SPACING, TEXT_ALIGNMENT, TEXT_VPOS, WRAPPING_WIDTHFields inherited from interface org.jhotdraw8.draw.figure.TransformCachingFigure
CACHE -
Constructor Summary
ConstructorsConstructorDescriptionAbstractLabelFigure(double x, double y) AbstractLabelFigure(javafx.geometry.Point2D position) -
Method Summary
Modifier and TypeMethodDescriptionjavafx.scene.NodecreateNode(RenderContext ctx) Creates the node for this label.@Nullable ConnectorfindConnector(javafx.geometry.Point2D p, @Nullable Figure prototype, double tolerance) Gets a connector for this figure at the given location.protected @Nullable javafx.geometry.Boundsjavafx.geometry.BoundsThe bounds that should be used for transformations of this figure.getPathIterator(RenderContext ctx, @Nullable AffineTransform tx) protected abstract @Nullable StringgetText(RenderContext ctx) protected booleanhasIcon()Returns true if this figure has an icon.voidlayout(RenderContext ctx) Computes the layout bounds of this figure.voidreshapeInLocal(CssSize x, CssSize y, CssSize width, CssSize height) Attempts to change the local bounds of the figure.protected voidsetCachedLayoutBounds(javafx.geometry.Bounds newValue) voidtranslateInLocal(CssPoint2D delta) Attempts to translate the local bounds of the figure.protected voidupdateGroupNode(RenderContext ctx, javafx.scene.Group node) Updates the group node that holds all other nodes of the label.protected voidupdateIconNode(RenderContext ctx, javafx.scene.Group iconGroupNode) Updates the icon node for rendering.protected voidupdateIconNodeImage(RenderContext ctx, javafx.scene.Group iconGroupNode) Updates the image of the icon node.protected voidupdateIconNodeTransform(RenderContext ctx, javafx.scene.Group iconGroupNode) Updates the transforms (translate, rotate, ...) of the provided icon group node.voidupdateNode(RenderContext ctx, javafx.scene.Node node) Updates the node of the label.protected voidupdatePathNode(RenderContext ctx, javafx.scene.shape.Path node) Updates the path that fills or strokes the visual bounds of the label.protected voidupdateTextNode(RenderContext ctx, javafx.scene.text.Text tn) Updates the given text node with properties from this figure, so that it can be rendered.protected voidupdateTextNodeFontAndText(RenderContext ctx, javafx.scene.text.Text tn) Updates the given text node with properties from this figure that affects the layout of the text node.protected voidupdateTextNodeLayout(RenderContext ctx, javafx.scene.text.Text tn) Updates properties that are relevant for the layout of the given text node with properties from this figure.protected voidupdateTextNodePaint(RenderContext ctx, javafx.scene.text.Text tn) Updates paint properties of the given text node with properties from this figure.Methods inherited from class org.jhotdraw8.draw.figure.AbstractLeafFigure
getChildren, isAllowsChildren, isSuitableChild, isSuitableParentMethods inherited from class org.jhotdraw8.draw.figure.AbstractFigure
addedToDrawing, createKeyMap, doAddedToDrawing, doRemovedFromDrawing, getCachedLocalToParent, getCachedLocalToWorld, getCachedParentToLocal, getCachedParentToWorld, getCachedWorldToLocal, getCachedWorldToParent, getDrawing, getLayoutObservers, getPropertyChangeListeners, getReadOnlyLayoutObservers, getStyledNonNull, hasPropertyChangeListeners, onPropertyChanged, parentProperty, removeAllLayoutSubjects, removedFromDrawing, removeLayoutSubject, setCachedLocalToParent, setCachedLocalToWorld, setCachedParentToLocal, setCachedParentToWorld, setCachedWorldToLocal, setCachedWorldToParent, updateCssMethods inherited from class org.jhotdraw8.fxbase.styleable.AbstractStyleablePropertyBean
callObservers, containsMapAccessor, getProperties, getStyleableMap, getStyled, getStyled, remove, removeAll, resetStyledValues, setStyledMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.jhotdraw8.draw.figure.ConnectableFigure
findConnectorMethods inherited from interface org.jhotdraw8.draw.figure.Figure
addChild, addedToDrawing, createHandles, disconnect, firePropertyChangeEvent, firePropertyChangeEvent, getBoundsInParent, getBoundsInWorld, getCenterInLocal, getCenterInParent, getChildren, getDrawing, getLayer, getLayoutBoundsInParent, getLayoutBoundsInWorld, getLayoutObservers, getLayoutSubjects, getLocalToParent, getParent, getParentToLocal, getPreferredAspectRatio, getPropertyChangeListeners, getReadOnlyLayoutObservers, getRoot, getStyleableParent, getSupportedKeys, getVisualBounds, getVisualBoundsInWorld, hasPropertyChangeListeners, isAllowsChildren, isDecomposable, isDeletable, isDeletWithLastLayoutSubject, isEditable, isEditableKey, isGroupReshapeableWith, isLayoutable, isSelectable, isShowing, isSuitableChild, isSuitableParent, isSupportedKey, isVisible, layoutChanged, layoutObserverChanged, layoutSubjectChanged, localToParent, localToWorld, localToWorld, parentProperty, propertyChanged, removeAllLayoutSubjects, removeChild, removedFromDrawing, removeFromParent, removeLayoutSubject, reshapeInLocal, reshapeInLocal, reshapeInLocal, reshapeInParent, setParent, stylesheetChanged, transformChanged, transformInLocal, transformInParent, translateInParent, updateCss, worldToLocal, worldToLocal, worldToParent, worldToParentMethods inherited from interface org.jhotdraw8.draw.figure.FillableFigure
applyFillableFigurePropertiesMethods inherited from interface org.jhotdraw8.fxbase.beans.PropertyBean
get, getNonNull, getProperties, getProperty, put, remove, set, setNonNull, valueAtMethods inherited from interface org.jhotdraw8.draw.figure.ShapeableFigure
applyShapeableProperties, applyShapeablePropertiesMethods inherited from interface org.jhotdraw8.draw.figure.StrokableFigure
applyStrokableFigureProperties, applyStrokeCapAndJoinProperties, applyStrokeColorProperties, applyStrokeDashProperties, applyStrokeTypeProperties, applyStrokeWidthProperties, getBoundsInLocal, getStyledStrokeMethods inherited from interface org.jhotdraw8.fxbase.styleable.StyleableBean
getId, getPseudoClassStates, getStyle, getStyleClasses, getTypeSelector, idPropertyMethods inherited from interface org.jhotdraw8.fxbase.styleable.StyleablePropertyBean
containsMapAccessor, getStyled, getStyled, getStyledNonNull, remove, removeAll, resetStyledValues, setStyledMethods inherited from interface org.jhotdraw8.draw.figure.TextFillableFigure
applyTextFillableFigureProperties, applyTextFillableFigurePropertiesMethods inherited from interface org.jhotdraw8.draw.figure.TextFontableFigure
applyTextFontableFigureProperties, applyTextFontableFigurePropertiesMethods inherited from interface org.jhotdraw8.draw.figure.TextLayoutableFigure
applyTextLayoutableFigureProperties, applyTextLayoutableFigurePropertiesMethods inherited from interface org.jhotdraw8.draw.figure.TransformCachingFigure
getLocalToWorld, getParentToWorld, getWorldToLocal, getWorldToParent, invalidateTransformsMethods inherited from interface org.jhotdraw8.fxbase.tree.TreeNode
ancestorIterable, breadthFirstIterable, depthFirstIterable, dumpTree, dumpTree, getAncestor, getChild, getDepth, getFirstChild, getLastChild, getMaxDepth, getPath, postorderIterable, preorderIterable, preorderSpliterator
-
Field Details
-
ORIGIN_X
-
ORIGIN_Y
-
ORIGIN
-
ICON_SHAPE
-
ICON_SIZE
-
ICON_TEXT_GAP
-
ICON_POSITION
-
ICON_FILL
Defines the paint used for filling the interior of the icon shape. Default value:Color.BLACK. -
ICON_ROTATE
-
ICON_TRANSLATE_Y
-
ICON_TRANSLATE_X
-
ICON_TRANSLATE
The position relative to the parent (respectively the offset). -
TEXT_HPOS
The horizontal position of the text. Default value:HPos.LEFT. FIXME Move this toTextLayoutableFigure.
-
-
Constructor Details
-
AbstractLabelFigure
public AbstractLabelFigure() -
AbstractLabelFigure
public AbstractLabelFigure(javafx.geometry.Point2D position) -
AbstractLabelFigure
public AbstractLabelFigure(double x, double y)
-
-
Method Details
-
createNode
Creates the node for this label. The node has the following structure:Group holds all other elements of the label . Path the path draws the background and border of the label . Text draws the text of the label . Group draws the icon of the label
- Specified by:
createNodein interfaceFigure- Parameters:
ctx- the render context- Returns:
- the node
-
findConnector
public @Nullable Connector findConnector(javafx.geometry.Point2D p, @Nullable Figure prototype, double tolerance) Description copied from interface:ConnectableFigureGets a connector for this figure at the given location.- Specified by:
findConnectorin interfaceConnectableFigure- Parameters:
p- the location of the connector in local coordinates.prototype- The connecting figure or null if unknown. This allows for specific connectors for different connection figures.tolerance- tolerance in world coordinates- Returns:
- Returns the connector. Returns null if there is no connector at the given location.
-
getCachedLayoutBounds
protected @Nullable javafx.geometry.Bounds getCachedLayoutBounds() -
setCachedLayoutBounds
protected void setCachedLayoutBounds(javafx.geometry.Bounds newValue) -
getLayoutBounds
public javafx.geometry.Bounds getLayoutBounds()Description copied from interface:FigureThe bounds that should be used for transformations of this figure.The bounds are given in the untransformed local coordinate space of the figure.
This method may use caching and return incorrect results if the cache is stale. Invoke
Figure.layout(org.jhotdraw8.draw.render.RenderContext)if you are not sure that the cache is valid.- Specified by:
getLayoutBoundsin interfaceFigure- Returns:
- the local bounds
-
getCssLayoutBounds
- Specified by:
getCssLayoutBoundsin interfaceFigure
-
hasIcon
protected boolean hasIcon()Returns true if this figure has an icon. This method returns true if it has a non-nullICON_SHAPE.Subclasses can override this and
- Returns:
-
getPathIterator
- Specified by:
getPathIteratorin interfacePathIterableFigure
-
getText
-
layout
Computes the layout bounds of this figure. -
reshapeInLocal
Description copied from interface:FigureAttempts to change the local bounds of the figure.See {#link #reshapeInLocal(Transform)} for a description of this method.
This method takes parameters as
CssSizes. This can be used to avoid rounding errors when the figure is reshaped in non-pixel units.This method can forward a call to
Figure.reshapeInLocal(Transform)using the following code:void reshapeInLocal(CssSize x, CssSize y, CssSize width, CssSize height) { Transform tx = Transforms.createReshapeTransform(getCssBoundsInLocal(), x, y, width, height); reshapeInLocal(tx); }- Specified by:
reshapeInLocalin interfaceFigure- Parameters:
x- desired x-position in parent coordinatesy- desired y-position in parent coordinateswidth- desired width in parent coordinates, may be negativeheight- desired height in parent coordinates, may be negative
-
translateInLocal
Description copied from interface:FigureAttempts to translate the local bounds of the figure.- Specified by:
translateInLocalin interfaceFigure- Parameters:
delta- the translation in x and in y direction
-
updateGroupNode
Updates the group node that holds all other nodes of the label.This method is empty. Subclasses may apply properties to the group node.
- Parameters:
ctx- the render contextnode- the group node
-
updateNode
Updates the node of the label.- Specified by:
updateNodein interfaceFigure- Parameters:
ctx- the render contextnode- the node
-
updateIconNode
Updates the icon node for rendering.- Parameters:
ctx- the render contexticonGroupNode- the group node that holds the icon image
-
updateIconNodeImage
Updates the image of the icon node.- Parameters:
ctx- the render contexticonGroupNode- the group node that holds the icon image
-
updateIconNodeTransform
Updates the transforms (translate, rotate, ...) of the provided icon group node.The icon is placed next to the text plus the icon gap. The path for the icon is taken from
ICON_SHAPE.- Parameters:
ctx- the render contexticonGroupNode- the group node that holds the icon image
-
updatePathNode
Updates the path that fills or strokes the visual bounds of the label.- Parameters:
ctx- the render contextnode- the path node
-
updateTextNode
Updates the given text node with properties from this figure, so that it can be rendered.This method calls
updateTextNodeFontAndText(RenderContext, Text),updateTextNodeLayout(RenderContext, Text),updateTextNodePaint(RenderContext, Text).If
hasIcon()returns true, the text is placed next to the icon plus the icon gap.- Parameters:
ctx- the render contexttn- the text node
-
updateTextNodePaint
Updates paint properties of the given text node with properties from this figure.- Parameters:
ctx- the render contexttn- the text node
-
updateTextNodeLayout
Updates properties that are relevant for the layout of the given text node with properties from this figure.- Parameters:
ctx- the render contexttn- the text node
-
updateTextNodeFontAndText
Updates the given text node with properties from this figure that affects the layout of the text node. This includes the text, the font properties, and the text alignment properties.- Parameters:
ctx- the render contexttn- the text node
-