- All Superinterfaces:
PropertyBean,StyleableBean,StyleablePropertyBean,TreeNode<Figure>
- All Known Subinterfaces:
AnchorableFigure,ChildLayoutingFigure,Clipping,CompositableFigure,ConnectableFigure,ConnectingFigure,DefaultableFigure,Drawing,ElbowableLineFigure,FillableFigure,FillRulableFigure,Grouping,HideableFigure,ImageableFigure,LabelConnectionFigure,Layer,LayeredDrawing,LineConnectingFigure,LockableFigure,LockedFigure,MarkerEndableFigure,MarkerFillableFigure,MarkerMidableFigure,MarkerSegmentableFigure,MarkerStartableFigure,MarkerStrokableFigure,NonTransformableFigure,PaddableFigure,Page,PathIterableFigure,PatternStrokableFigure,RectangularFigure,ResizableFigure,SecondStrokableFigure,SecondStrokeCuttableFigure,ShapeableFigure,Slice,StrokableFigure,StrokeCuttableFigure,StyleableFigure,TextableFigure,TextEditableFigure,TextFillableFigure,TextFontableFigure,TextLayoutableFigure,TextStrokeableFigure,TransformableFigure,TransformCachingFigure,ViewBoxableDrawing
- All Known Implementing Classes:
AbstractCompositeFigure,AbstractDrawing,AbstractElbowLineConnectionWithMarkersFigure,AbstractFigure,AbstractLabelConnectionFigure,AbstractLabelFigure,AbstractLeafFigure,AbstractLineConnectionFigure,AbstractPathConnectionWithMarkersFigure,AbstractRegionFigure,AbstractStraightLineConnectionWithMarkersFigure,AbstractViewBoxDrawing,ArcFigure,BezierPathFigure,ClippingFigure,CombinedPathFigure,EllipseFigure,GroupFigure,ImageFigure,LabelFigure,LayerFigure,LineConnectionFigure,LineConnectionWithMarkersFigure,LineFigure,PageFigure,PageLabelFigure,PolygonFigure,PolylineFigure,RectangleFigure,RegionFigure,SimpleDrawing,SimpleLabelConnectionFigure,SimpleLayeredDrawing,SliceFigure,TextAreaFigure,TextFigure
Drawing.
Rendering. A figure can render a JavaFX scene graph (see Node)
with the help of a RenderContext. The contents of the scene graph
depends on the class of the figure, the state of the figure, and the state of
the render context.
State. The state of a figure is defined by its property values. The
state consists of genuine property values and of computed property
values.
Genuine property values typically describe the shape and the style of a
figure.
Computed property values typically describe the layout of the figure or
cached values. Such as cached CSS properties and cached transformation
matrices. Computed property values often depend on the state of other
figures.
Tree Structure. A figure can be composed of other figures in a tree
structure. The composition is implemented with the children property
and the parent property.
The composition can be restricted. Typically the parent of Layer
objects is restricted to instances of Drawing, and the parent of all
other figures is restricted to non-instances of Drawing.
Local Coordinate Systems. A figure may introduce a local coordinate
system which affects the graphical representation of itself and of its
descendants.
The Figure interface provides methods which allow to transform between the
local coordinate system of a figure, the coordinate system of its parent, and
the world coordinate system.
Dependent Figures. The state of a figure may depend on the state of
other figures. These dependencies are made explicit by parent/child
relationships and provider/dependant relationships.
The parent/child relationships are strictly hierarchical, the
provider/dependant relationships may include cycles.
The parent/child relationships are typically used for grouping figures into
Layers, Groups and into layout hierarchies.
The provider/dependant relationships are typically used for the creation of
line connections between figures, such as with
LineConnectionFigure. The strategy for updating the state of
dependent figures is implement in DrawingModel.
Handles. A figure can produce Handles which allow to
graphically change the state of the figure in a drawing view.
Map Accessors. A figure has an open ended set of property values. The
property values are accessed using FigureMapAccessors.
Styling. Some property values of a figure can be styled using CSS. The
corresponding property key must implement the interface
WritableStyleableMapAccessor.
Update Strategy. A figure does not automatically update its computed
property values. The update strategy is factored out into
DrawingModel.
- Author:
- Werner Randelshofer
-
Property Summary
PropertiesTypePropertyDescriptionThe parent figure.Properties 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 Map<Class<?>, ImmutableSet<MapAccessor<?>>> FIXME should be private!static final StringTo avoid name clashes in the stylesheet, all styleable JHotDraw getProperties use the prefix"-jhotdraw-".static final StringThe name of the parent property. -
Method Summary
Modifier and TypeMethodDescriptiondefault booleanAdds a new child to the figure if it is a suitable child and this figure is a suitable parent.default voidaddedToDrawing(@NonNull Drawing drawing) Invoked byDrawingModelwhen the figure was added to a drawing.static @NonNull javafx.geometry.Boundsbounds(@NonNull Collection<? extends Figure> selection) Computes the union of the bounds of the provided figures in world coordinates.default voidcreateHandles(@NonNull HandleType handleType, @NonNull List<Handle> list) Creates handles of the specified level and adds them to the provided list.@NonNull javafx.scene.NodeThis method is invoked by aRenderContext, when it needs a node to create a JavaFX scene graph for a figure.default voidDisconnects all layout subjects and layout observers from this figure.default voidFires a property change event.default <T> voidfirePropertyChangeEvent(Figure source, Key<T> key, @Nullable T oldValue, @Nullable T newValue, boolean wasAdded, boolean wasRemoved) Fires a property change event.@NonNull javafx.geometry.BoundsThe bounds of this figure in local coordinates, including space required for a non-zero stroke.default @NonNull javafx.geometry.BoundsThe bounds of this figure in parent coordinates including space required for a non-zero stroke.default @NonNull javafx.geometry.BoundsThe bounds of this figure in world coordinates including space required for a non-zero stroke.default @NonNull javafx.geometry.Point2DReturns the center of the figure in the local coordinates of the figure.default @NonNull javafx.geometry.Point2DReturns the center of the figure in the local coordinates of the figure.The child figures.static ImmutableSet<MapAccessor<?>> getDeclaredAndInheritedMapAccessors(Class<?> clazz) Returns all keys declared in this class and inherited from parent classes.static voidgetDeclaredKeys(@NonNull Class<?> clazz, @NonNull Collection<Key<?>> keys) static ImmutableSet<MapAccessor<?>> getDeclaredMapAccessors(@NonNull Class<?> clazz, @NonNull ImmutableSet<MapAccessor<?>> keys) Returns the ancestor Drawing.getLayer()Returns the ancestor Layer.default @NonNull javafx.geometry.BoundsThe bounds that should be used for transformations of this figure.default @NonNull javafx.geometry.BoundsThe layout bounds of this figure in parent coordinates.default @NonNull javafx.geometry.BoundsReturns the layout bounds of the figure in world coordinates, including space required for non-zero strokkes.Returns all figures which observe the layout of this figure.default @NonNull ReadOnlySet<Figure> Returns all figures which are subject to the layout of this figure.@NonNull javafx.scene.transform.TransformReturns the transformation from local coordinates into parent coordinates.@NonNull javafx.scene.transform.TransformReturns the transformation from local coordinates into world coordinates.Gets the value of theparentproperty.@NonNull javafx.scene.transform.TransformReturns the transformation from parent coordinates into local coordinates.@NonNull javafx.scene.transform.TransformReturns the transformation from world coordinates into drawing coordinates.default doubleReturns the preferred aspect ratio of the figure.CopyOnWriteArrayList<org.jhotdraw8.base.event.Listener<FigurePropertyChangeEvent>> List of property change listeners.getRoot()Returns the root.default @Nullable StyleableBeandefault @NonNull ImmutableSet<MapAccessor<?>> Returns all supported map accessors of the figure.default @NonNull javafx.geometry.BoundsThe bounds that should be used for clipping and intersection tests of this figure.default @NonNull javafx.geometry.BoundsReturns the visal bounds of the figure in world coordinates, including space required for non-zero strokkes.@NonNull javafx.scene.transform.TransformReturns the transformation from world coordinates into local coordinates.@NonNull javafx.scene.transform.TransformReturns the transformation from world coordinates into parent coordinates.booleanWhether this figure has property change listeners.voidInvalidates the transformation matrices of this figure.booleanWhether children may be added to this figure.default booleanWhether the figure is decomposable by the user.booleanWhether the figure is deletable by the user.default booleanReturns true if this figure should be deleted if its last layout subject is deleted.booleanWhether the figure is editable by the user.default booleanisEditableKey(MapAccessor<?> key) Returns true if the specified key is user editable.default booleanisGroupReshapeableWith(@NonNull Set<Figure> others) Whether the figure can be reshaped as a group together with other figures.default booleanWhether thelayoutmethod of this figure does anything.booleanWhether the figure is selectable by the user.default booleanWhether the figure and all its ancestors are visible.booleanisSuitableChild(@NonNull Figure newChild) This method returns whether the provided figure is a suitable child for this figure.booleanisSuitableParent(@NonNull Figure newParent) This method returns whether the provided figure is a suitable parent for this figure.default booleanisSupportedKey(MapAccessor<?> key) Returns true if the specified key is supported by this figure.default booleanWhether the figure is visible.default voidlayout(@NonNull RenderContext ctx) Updates the layout of this figure, based on the layout of its children and the layout of observed layout subjects.default voidThis method is invoked on a figure byDrawingModelwhen it determines that the figure needs to be laid out.default voidThis method is invoked on a figure byDrawingModelwhen it determines that one or more layout observers have been added or removed.default voidThis method is invoked on a figure byDrawingModelwhen it determines that one or more layout subjects have been added or removed.default @NonNull javafx.geometry.BoundslocalToParent(@NonNull javafx.geometry.Bounds p) Transforms the specified bounds from local coordinates into parent coordinates.default @NonNull javafx.geometry.BoundslocalToWorld(@NonNull javafx.geometry.Bounds p) Transforms the specified bounds from local coordinates into world coordinates.default @NonNull javafx.geometry.Point2DlocalToWorld(@NonNull javafx.geometry.Point2D p) Transforms the specified point from local coordinates into world coordinates.The parent figure.default <T> voidpropertyChanged(Key<T> key, @Nullable T oldValue, @Nullable T newValue) This method is invoked on a figure byDrawingModelwhen it determines that a property has been changed.voidRequests to removeChild all connection targets.default voidremoveChild(Figure child) Removes a child from the figure.default voidremovedFromDrawing(Drawing drawing) Invoked byDrawingModelwhen the figure is removed from a drawing.voidremoveLayoutSubject(Figure targetFigure) Removes the specified connection target.default voidreshapeInLocal(double x, double y, double width, double height) Attempts to change the local bounds of the figure.default voidreshapeInLocal(@NonNull javafx.geometry.Bounds bounds) Attempts to change the local bounds of the figure.voidreshapeInLocal(javafx.scene.transform.Transform transform) Attempts to change the local bounds of the figure.voidreshapeInLocal(@NonNull CssSize x, @NonNull CssSize y, @NonNull CssSize width, @NonNull CssSize height) Attempts to change the local bounds of the figure.voidreshapeInParent(@NonNull javafx.scene.transform.Transform transform) Attempts to change the parent bounds of the figure.default voidSets the value of theparentproperty.default voidThis method is invoked on a figure byDrawingModelwhen it determines that the figure needs to apply its stylesheet again.default voidThis method is invoked on a figure and all its descendants byDrawingModelwhen it determines that the transformation of the figure has changed.voidtransformInLocal(@NonNull javafx.scene.transform.Transform transform) Attempts to transform the figure.voidtransformInParent(@NonNull javafx.scene.transform.Transform transform) Attempts to transform the figure.default voidAttempts to translate the local bounds of the figure.default voidAttempts to translate the parent bounds of the figure.voidupdateCss(RenderContext ctx) Updates the stylesheet cache of this figure depending on its property values and on the and the property values of its ancestors.voidupdateNode(@NonNull RenderContext ctx, @NonNull javafx.scene.Node node) This method is invoked by aRenderContext, when it needs to update the node which represents the scene graph in the figure.static @Nullable javafx.geometry.BoundsvisualBounds(@NonNull Collection<Figure> selection) Computes the union of the visual bounds of the provided figures in world coordinates.default @NonNull javafx.geometry.Point2DworldToLocal(@NonNull javafx.geometry.Point2D pointInWorld) Transforms the specified point from world coordinates into local coordinates.default @NonNull CssPoint2DworldToLocal(@NonNull CssPoint2D pointInWorld) default @NonNull javafx.geometry.Point2DworldToParent(double x, double y) default @NonNull javafx.geometry.Point2DworldToParent(@NonNull javafx.geometry.Point2D pointInWorld) Transforms the specified point from world coordinates into parent coordinates.Methods inherited from interface org.jhotdraw8.fxbase.beans.PropertyBean
get, getNonNull, getProperties, getProperty, put, remove, set, setNonNull, valueAtMethods 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.fxbase.tree.TreeNode
ancestorIterable, breadthFirstIterable, depthFirstIterable, dumpTree, dumpTree, getAncestor, getChild, getDepth, getFirstChild, getLastChild, getMaxDepth, getPath, postorderIterable, preorderIterable, preorderSpliterator
-
Property Details
-
parent
The parent figure.If this figure has not been added as a child to another figure, then this variable will be null.
By convention the parent is set exclusively by a composite figure on its child figures. The composite figure sets parent to itself on a child immediately after the child figure has been added to the composite figure. The composite figure sets parent tonullon a child immediately after the child figure has been removed from the composite figure.- See Also:
-
-
Field Details
-
JHOTDRAW_CSS_PREFIX
To avoid name clashes in the stylesheet, all styleable JHotDraw getProperties use the prefix"-jhotdraw-".XXX mapping of css attribute names to keys should be done elsewhere!
- See Also:
-
PARENT_PROPERTY
The name of the parent property.- See Also:
-
declaredAndInheritedKeys
FIXME should be private!
-
-
Method Details
-
bounds
Computes the union of the bounds of the provided figures in world coordinates.- Parameters:
selection- a set of figures- Returns:
- bounds
-
getDeclaredMapAccessors
static ImmutableSet<MapAccessor<?>> getDeclaredMapAccessors(@NonNull Class<?> clazz, @NonNull ImmutableSet<MapAccessor<?>> keys) -
getDeclaredKeys
-
getDeclaredAndInheritedMapAccessors
Returns all keys declared in this class and inherited from parent classes.- Parameters:
clazz- A figure class.- Returns:
- an unmodifiable set of the keys
-
visualBounds
Computes the union of the visual bounds of the provided figures in world coordinates.- Parameters:
selection- a set of figures- Returns:
- bounds
-
addChild
Adds a new child to the figure if it is a suitable child and this figure is a suitable parent.- Parameters:
newChild- the new child- Returns:
- whether the child was added
-
addedToDrawing
Invoked byDrawingModelwhen the figure was added to a drawing.- Parameters:
drawing- the drawing to which this figure has been added
-
createHandles
Creates handles of the specified level and adds them to the provided list.- Parameters:
handleType- The desired handle typelist- The handles.
-
createNode
This method is invoked by aRenderContext, when it needs a node to create a JavaFX scene graph for a figure.A typical implementation should look like this:
public Node createNode(RenderContext v) { return new ...desired subclass of Node...(); }A figure may be rendered with multiple
RenderContexts simultaneously. EachRenderContextuses this method to instantiate a JavaFX node for the figure and associate it to the figure.This method must create a new instance because returning an already existing instance may cause undesired side effects on other
RenderContexts.Note that by convention this method may only be invoked by a
RenderContextobject.- Parameters:
ctx- the renderer which will use the node- Returns:
- the newly created node
-
layoutSubjectChanged
default void layoutSubjectChanged()This method is invoked on a figure byDrawingModelwhen it determines that one or more layout subjects have been added or removed.The default implementation of this method is empty.
-
propertyChanged
This method is invoked on a figure byDrawingModelwhen it determines that a property has been changed.The default implementation of this method is empty.
- Type Parameters:
T- the value type- Parameters:
key- the keyoldValue- the old valuenewValue- the new value
-
layoutObserverChanged
default void layoutObserverChanged()This method is invoked on a figure byDrawingModelwhen it determines that one or more layout observers have been added or removed.The default implementation of this method is empty.
-
disconnect
default void disconnect()Disconnects all layout subjects and layout observers from this figure.This method is called, when the figure is about to be removed from a drawing.
-
firePropertyChangeEvent
default <T> void firePropertyChangeEvent(Figure source, Key<T> key, @Nullable T oldValue, @Nullable T newValue, boolean wasAdded, boolean wasRemoved) Fires a property change event.- Type Parameters:
T- the value type- Parameters:
source- the event sourcekey- the property keyoldValue- the old property valuenewValue- the new property valuewasAdded- true if the new property value was addedwasRemoved- true if the old property value was removed
-
firePropertyChangeEvent
Fires a property change event.- Parameters:
event- the event
-
getLayoutBounds
The 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
layout(org.jhotdraw8.draw.render.RenderContext)if you are not sure that the cache is valid.- Returns:
- the local bounds
-
getVisualBounds
The bounds that should be used for clipping and intersection tests of this figure.- Returns:
- the visual bounds
-
getBoundsInLocal
@NonNull javafx.geometry.Bounds getBoundsInLocal()The bounds of this figure in local coordinates, including space required for a non-zero stroke.- Returns:
- the local bounds
-
getCssLayoutBounds
@NonNull CssRectangle2D getCssLayoutBounds() -
getLayoutBoundsInParent
The layout bounds of this figure in parent coordinates.The bounds are given in the coordinate space of the parent figure.
This method may use caching and return incorrect results if the caches are stale. Invoke
invalidateTransforms()andlayout(org.jhotdraw8.draw.render.RenderContext)if you are not sure that the cache is valid.- Returns:
- the local bounds
-
getBoundsInParent
The bounds of this figure in parent coordinates including space required for a non-zero stroke.The bounds are given in the coordinate space of the parent figure.
This method may use caching and return incorrect results if the caches are stale. Invoke
invalidateTransforms()andlayout(org.jhotdraw8.draw.render.RenderContext)if you are not sure that the cache is valid.- Returns:
- the bounds in parent coordinates
-
getBoundsInWorld
The bounds of this figure in world coordinates including space required for a non-zero stroke.The bounds are given in the coordinate space of the world.
This method may use caching and return incorrect results if the caches are stale. Invoke
invalidateTransforms()andlayout(org.jhotdraw8.draw.render.RenderContext)if you are not sure that the cache is valid.- Returns:
- the bounds in world coordinates
-
getLayoutBoundsInWorld
Returns the layout bounds of the figure in world coordinates, including space required for non-zero strokkes.- Returns:
- the bounds in world coordinates
-
getVisualBoundsInWorld
Returns the visal bounds of the figure in world coordinates, including space required for non-zero strokkes.- Returns:
- the bounds in world coordinates
-
getCenterInLocal
Returns the center of the figure in the local coordinates of the figure.- Returns:
- The center of the figure
-
getCenterInParent
Returns the center of the figure in the local coordinates of the figure.- Returns:
- The center of the figure
-
getChildren
The child figures.All changes on this list causes this figure to fire an invalidation event.
If a child is added to this list, then this figure removes the child from its former parent, and then sets itself as the parent of the child.
If a child is removed from this list, then this figure sets the parent of the child to null.
- Specified by:
getChildrenin interfaceTreeNode<Figure>- Returns:
- the children
-
getLayoutObservers
Returns all figures which observe the layout of this figure.When the layout of this figure changes, then the layout of the observers figures must be updated.
The update strategy is implemented in
DrawingModel.DrawingModeobserves state changes in figures and updates dependent figures.DrawingModelcan coalesce multiple state changes of an observed figure into a smaller number of layout calls on the observers.DrawingModelcan also detect cyclic layout dependencies and prevent endless update loops.This set must be synchronized, because it is accessed by other figures, when there properties are changed.
- Returns:
- a list of dependent figures
-
getReadOnlyLayoutObservers
@NonNull ReadOnlySet<Figure> getReadOnlyLayoutObservers() -
getDrawing
Returns the ancestor Drawing.- Returns:
- the drawing or null if no ancestor is a drawing. Returns this, if this figure is a drawing.
-
getLayer
Returns the ancestor Layer.- Returns:
- the drawing or null if no ancestor is a layer. Returns this, if this figure is a layer.
-
getLocalToParent
@NonNull javafx.scene.transform.Transform getLocalToParent()Returns the transformation from local coordinates into parent coordinates.This method may use caching and return incorrect results if the cache is stale.
- Returns:
- the transformation
-
getLocalToWorld
@NonNull javafx.scene.transform.Transform getLocalToWorld()Returns the transformation from local coordinates into world coordinates.This method may use caching and return incorrect results if the cache is stale.
- Returns:
- the transformation
-
getParent
Gets the value of theparentproperty.- Specified by:
getParentin interfaceTreeNode<Figure>- Property description:
- The parent figure.
If this figure has not been added as a child to another figure, then this variable will be null.
By convention the parent is set exclusively by a composite figure on its child figures. The composite figure sets parent to itself on a child immediately after the child figure has been added to the composite figure. The composite figure sets parent tonullon a child immediately after the child figure has been removed from the composite figure. - Returns:
- the value of the
parentproperty - See Also:
-
setParent
Sets the value of theparentproperty.- Specified by:
setParentin interfaceTreeNode<Figure>- Property description:
- The parent figure.
If this figure has not been added as a child to another figure, then this variable will be null.
By convention the parent is set exclusively by a composite figure on its child figures. The composite figure sets parent to itself on a child immediately after the child figure has been added to the composite figure. The composite figure sets parent tonullon a child immediately after the child figure has been removed from the composite figure. - Parameters:
newValue- the value for theparentproperty- See Also:
-
getParentToLocal
@NonNull javafx.scene.transform.Transform getParentToLocal()Returns the transformation from parent coordinates into local coordinates.This method may use caching and return incorrect results if the cache is stale.
- Returns:
- the transformation
-
getParentToWorld
@NonNull javafx.scene.transform.Transform getParentToWorld()Returns the transformation from world coordinates into drawing coordinates.This method may use caching and return incorrect results if the cache is stale.
- Returns:
- the transformation
-
getPreferredAspectRatio
default double getPreferredAspectRatio()Returns the preferred aspect ratio of the figure. The aspect ratio is defined as the height divided by the width of the figure. If a figure does not have a preference it should return its current aspect ratio.- Returns:
- the preferred aspect ratio of the figure.
-
getPropertyChangeListeners
CopyOnWriteArrayList<org.jhotdraw8.base.event.Listener<FigurePropertyChangeEvent>> getPropertyChangeListeners()List of property change listeners.- Returns:
- a list of property change listeners
-
getLayoutSubjects
Returns all figures which are subject to the layout of this figure.When the layout of a layout subject changes, then the layout of this figure needs to be updated.
See
getLayoutObservers()for a description of the update strategy.This default implementation returns an unmodifiable empty set.
- Returns:
- a list of layout subjects
-
getRoot
Returns the root.- Returns:
- the root
-
getStyleableParent
- Specified by:
getStyleableParentin interfaceStyleableBean
-
getSupportedKeys
Returns all supported map accessors of the figure.The default implementation returns all declared and inherited map accessors.
- Returns:
- an unmodifiable set of keys
-
getWorldToLocal
@NonNull javafx.scene.transform.Transform getWorldToLocal()Returns the transformation from world coordinates into local coordinates.This method may use caching and return incorrect results if the cache is stale.
- Returns:
- the transformation
-
getWorldToParent
@NonNull javafx.scene.transform.Transform getWorldToParent()Returns the transformation from world coordinates into parent coordinates.This method may use caching and return incorrect results if the cache is stale.
- Returns:
- the transformation
-
hasPropertyChangeListeners
boolean hasPropertyChangeListeners()Whether this figure has property change listeners.- Returns:
- true if this figure has property change listeners
-
invalidateTransforms
void invalidateTransforms()Invalidates the transformation matrices of this figure.This figure does not keep track of changes that cause the invalidation of its transformation matrices. Use a
DrawingModelto manage the transformation matrices of the figures in a drawing. Or call this method on a figure and all its descendants, after you have performed a change which invalidated the transform matrices of the figure. -
isAllowsChildren
boolean isAllowsChildren()Whether children may be added to this figure.- Returns:
- true if getChildren are allowed
-
isDecomposable
default boolean isDecomposable()Whether the figure is decomposable by the user.- Returns:
- true if the figure is decomposable
-
isDeletable
boolean isDeletable()Whether the figure is deletable by the user.- Returns:
- true if the user may delete the figure
-
isEditable
boolean isEditable()Whether the figure is editable by the user.- Returns:
- true if the user may edit the figure.
-
isGroupReshapeableWith
Whether the figure can be reshaped as a group together with other figures.If this figure uses one of the other figures for computing its position or its layout, then it will return false.
The default implementation always returns true.
- Parameters:
others- A set of figures.- Returns:
- true if the user may svgStringReshapeToBuilder this figure together with those in the set.
-
isLayoutable
default boolean isLayoutable()Whether thelayoutmethod of this figure does anything.The default implementation returns false.
- Returns:
- true if the
layoutmethod is not empty.
-
isSelectable
boolean isSelectable()Whether the figure is selectable by the user.- Returns:
- true if the user may select the figure
-
isSuitableParent
This method returns whether the provided figure is a suitable parent for this figure.- Specified by:
isSuitableParentin interfaceTreeNode<Figure>- Parameters:
newParent- The new parent figure.- Returns:
- true if
newParentis an acceptable parent
-
isSuitableChild
This method returns whether the provided figure is a suitable child for this figure.- Specified by:
isSuitableChildin interfaceTreeNode<Figure>- Parameters:
newChild- The new child figure.- Returns:
- true if
newChildis an acceptable child
-
isSupportedKey
Returns true if the specified key is supported by this figure.The default implementation returns all declared and inherited map accessors.
- Parameters:
key- a key- Returns:
- whether the key is supported
-
isEditableKey
Returns true if the specified key is user editable.- Parameters:
key- a key- Returns:
- whether the key is user edtiable
-
isShowing
default boolean isShowing()Whether the figure and all its ancestors are visible.- Returns:
- true if the user can see the figure
-
isVisible
default boolean isVisible()Whether the figure is visible.- Returns:
- true if the user can see the figure
-
layout
Updates the layout of this figure, based on the layout of its children and the layout of observed layout subjects.If the layout of this figure depends on the layout of other figures, then calling layout on this figure will only result in the correct result, if layout of the other figures has been performed first.
A figure does not keep track of changes that require layout updates. Use
DrawingModelto manage layout updates.The default implementation is empty.
To layout a drawing use
Drawing.layoutAll(RenderContext).- Parameters:
ctx- the render context (optional)
-
layoutChanged
This method is invoked on a figure byDrawingModelwhen it determines that the figure needs to be laid out.The default implementation of this method calls
layout(org.jhotdraw8.draw.render.RenderContext).- Parameters:
ctx- the render context (optional)
-
localToWorld
Transforms the specified point from local coordinates into world coordinates.This method may use caching and return incorrect results if the cache is stale.
- Parameters:
p- point in local coordinates- Returns:
- point in world coordinates
-
localToParent
Transforms the specified bounds from local coordinates into parent coordinates.This method may use caching and return incorrect results if the cache is stale.
- Parameters:
p- bounds in local coordinates- Returns:
- bounds in parent coordinates
-
localToWorld
Transforms the specified bounds from local coordinates into world coordinates.This method may use caching and return incorrect results if the cache is stale.
- Parameters:
p- bounds in local coordinates- Returns:
- bounds in world coordinates
-
parentProperty
The parent figure.If this figure has not been added as a child to another figure, then this variable will be null.
By convention the parent is set exclusively by a composite figure on its child figures. The composite figure sets parent to itself on a child immediately after the child figure has been added to the composite figure. The composite figure sets parent tonullon a child immediately after the child figure has been removed from the composite figure.- Returns:
- the parent property, with
getBean()returning this figure, andgetName()returningPARENT_PROPERTY. - See Also:
-
removeChild
Removes a child from the figure.- Parameters:
child- a child of the figure
-
removeAllLayoutSubjects
void removeAllLayoutSubjects()Requests to removeChild all connection targets. -
removeLayoutSubject
Removes the specified connection target.- Parameters:
targetFigure- a Figure which is a connection target.
-
removedFromDrawing
Invoked byDrawingModelwhen the figure is removed from a drawing.- Parameters:
drawing- the drawing from which this figure has been removed
-
reshapeInLocal
void reshapeInLocal(javafx.scene.transform.Transform transform) Attempts to change the local bounds of the figure.The figure may choose to only partially change its local bounds.
- Parameters:
transform- the desired transformation in local coordinates
-
reshapeInLocal
Attempts to change the local bounds of the figure.See
reshapeInLocal(CssSize, CssSize, CssSize, CssSize)for a description of this method.- Parameters:
bounds- the desired bounds
-
reshapeInLocal
default void reshapeInLocal(double x, double y, double width, double height) Attempts to change the local bounds of the figure.See {#link #reshapeInLocal(Transform)} for a description of this method.
This is a convenience method which takes all parameters in pixel units.
- 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
-
reshapeInLocal
void reshapeInLocal(@NonNull CssSize x, @NonNull CssSize y, @NonNull CssSize width, @NonNull CssSize height) Attempts 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
reshapeInLocal(Transform)using the following code:void reshapeInLocal(@NonNull CssSize x, @NonNull CssSize y, @NonNull CssSize width, @NonNull CssSize height) { Transform tx = Transforms.createReshapeTransform(getCssBoundsInLocal(), x, y, width, height); reshapeInLocal(tx); }- 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
-
reshapeInParent
Attempts to change the parent bounds of the figure.The figure may choose to only partially change its parent bounds.
This method may also call
reshapeInLocalon child figures.- Parameters:
transform- the desired transformation in parent coordinates
-
translateInParent
Attempts to translate the parent bounds of the figure.- Parameters:
t- the translation in x and in y direction
-
translateInLocal
Attempts to translate the local bounds of the figure.- Parameters:
t- the translation in x and in y direction
-
stylesheetChanged
This method is invoked on a figure byDrawingModelwhen it determines that the figure needs to apply its stylesheet again.The default implementation of this method calls
updateCss(org.jhotdraw8.draw.render.RenderContext).- Parameters:
ctx- the render context (optional)
-
transformInLocal
Attempts to transform the figure.The figure may choose to only partially change its transformation.
- Parameters:
transform- the desired transformation in local coordinates
-
transformInParent
Attempts to transform the figure.The figure may choose to only partially change its transformation.
- Parameters:
transform- the desired transformation in parent coordinates
-
transformChanged
default void transformChanged()This method is invoked on a figure and all its descendants byDrawingModelwhen it determines that the transformation of the figure has changed.The default implementation of this method calls
invalidateTransforms(). -
updateCss
Updates the stylesheet cache of this figure depending on its property values and on the and the property values of its ancestors.This figure does not keep track of changes that require CSS updates. Use a
DrawingModelto manage CSS updates.- Parameters:
ctx- the render context
-
updateNode
This method is invoked by aRenderContext, when it needs to update the node which represents the scene graph in the figure.A figure which is composed from child figures, must addChild the nodes of its getChildren to its node. This ensures that coordinate space transformations of the composed figure are properly propagated to its getChildren.
public void updateNode(RenderContext rc, Node n) { ObservableList<Node> group = ((Group) n).getChildren(); group.clear(); for (Figure child : children()) { group.addChild(rc.getNode(child)); }A figure may be shown in multiple
RenderContexts. EachRenderContextuses this method to update the a JavaFX node for the figure.Note that the figure must retrieve the JavaFX node from other figures from the render context by invoking
rc.getNode(child)rather than creating new nodes usingchild.createNode(rc). This convention allows to implement a cache in the render context for the Java FX node. Also, render contexts like a drawing view need to associate input events on Java FX nodes to the corresponding figure.This figure does not keep track of changes that require node updates.
DrawingModelto manage node updates.- Parameters:
ctx- the render contextnode- the node which was created withcreateNode(org.jhotdraw8.draw.render.RenderContext)
-
worldToLocal
default @NonNull javafx.geometry.Point2D worldToLocal(@NonNull javafx.geometry.Point2D pointInWorld) Transforms the specified point from world coordinates into local coordinates.This method may use caching and return incorrect results if the cache is stale.
- Parameters:
pointInWorld- point in drawing coordinates- Returns:
- point in local coordinates
-
worldToLocal
-
worldToParent
default @NonNull javafx.geometry.Point2D worldToParent(@NonNull javafx.geometry.Point2D pointInWorld) Transforms the specified point from world coordinates into parent coordinates.This method may use caching and return incorrect results if the cache is stale.
- Parameters:
pointInWorld- point in drawing coordinates- Returns:
- point in local coordinates
-
worldToParent
-
isDeletWithLastLayoutSubject
default boolean isDeletWithLastLayoutSubject()Returns true if this figure should be deleted if its last layout subject is deleted.- Returns:
- if the deletion of the layout subject should lead to a cascaded delete
-