- All Superinterfaces:
javafx.beans.Observable,ObservableMixin,TreeModel<Figure>
- All Known Implementing Classes:
AbstractDrawingModel,SimpleDrawingModel
DrawingModel provides DrawingModelEvents about a
Drawing.
DrawingModel is used by DrawingView to get change events from
a drawing without having to register listeners on all figures.
The DrawingModelEvents that a DrawingModel fires are based on
assumptions that it makes about the figures contained in the drawing. If the
assumptions are wrong, then the drawing view will not properly update its
view!
DrawingModel invokes addNotify() and removeNotify()
methods on a Figure when it detects that the figure has been added or
removed from a Drawing.
A DrawingView will only be updated properly, if all Tools,
Handles and inspectors update the drawing using the
DrawingModel.
- Author:
- Werner Randelshofer
-
Property Summary
PropertiesTypePropertyDescriptionThe root of the drawing model.javafx.beans.property.ReadOnlyBooleanPropertyThis property returns true if the drawing model is validating its figures. -
Field Summary
FieldsFields inherited from interface org.jhotdraw8.fxbase.tree.TreeModel
ROOT_PROPERTY -
Method Summary
Modifier and TypeMethodDescriptiondefault voidaddChildTo(@NonNull Figure child, @NonNull Figure parent) Adds the specified child to a parent and fires appropriateDrawingModelEvents.default voidaddDrawingModelListener(org.jhotdraw8.base.event.Listener<DrawingModelEvent> l) Adds a listener forDrawingModelEvents.default voidaddListener(javafx.beans.InvalidationListener l) voiddisconnect(Figure f) Invokes the disconnect method of the figure and fires appropriateDrawingModelEvents.The root of the drawing model.default voidFires the specified event.default voidFires an "invalidated" event.default voidFires "node invalidated" event for the specified figure.default voidFires "node invalidated" event for the specified figure.default <T> voidfirePropertyValueChanged(Figure f, Key<T> key, @Nullable T oldValue, @Nullable T newValue, boolean wasAdded, boolean wasRemoved) Fires "node invalidated" event for the specified figure.default voidFires "style invalidated" event for the specified figure.default voidFires "node invalidated" event for the specified figure.default <T> @Nullable Tget(@NonNull Figure figure, @NonNull MapAccessor<T> key) Gets the specified property from the figure.Gets the child at the given index from the parent.default intgetChildCount(@NonNull Figure figure) Gets the child count of the specified figure.getChildren(@NonNull Figure figure) Gets the getChildren of the specified figure.default DrawingGets the root of the tree.@NonNull CopyOnWriteArrayList<org.jhotdraw8.base.event.Listener<DrawingModelEvent>> List of drawing model listeners.@NonNull CopyOnWriteArrayList<javafx.beans.InvalidationListener> List of invalidation listeners.default <T> @NonNull TgetNonNull(@NonNull Figure figure, @NonNull NonNullMapAccessor<T> key) Gets the specified property from the figure.voidinsertChildAt(@NonNull Figure child, @NonNull Figure parent, int index) Adds the specified child to a parent and fires appropriateDrawingModelEvents.booleanReturns true if the drawing model is currently validating its figures.voidlayout(Figure f, RenderContext ctx) Invokes the layout method of the figure and fires appropriate /DrawingModelEvents.<T> @NonNull javafx.beans.property.Property<T> propertyAt(Figure f, Key<T> key) Creates a property for the specified figure and property key.<T> @Nullable Tremove(@NonNull Figure figure, MapAccessor<T> key) <T> @Nullable TRemoves the specified key from the figure.default voidremoveDrawingModelListener(org.jhotdraw8.base.event.Listener<DrawingModelEvent> l) Removes a listener forDrawingModelEvents.voidremoveFromParent(@NonNull Figure child) Removes the specified child from its parent and fires appropriateDrawingModelEvents.removeFromParent(Figure parent, int index) Removes the specified child from its parent and fires appropriateDrawingModelEvents.default voidremoveListener(javafx.beans.InvalidationListener l) voidreshapeInLocal(Figure f, double x, double y, double width, double height) Attempts to change the local bounds of the figure and fires appropriateDrawingModelEvents.voidreshapeInLocal(Figure f, javafx.scene.transform.Transform transform) Attempts to change the local bounds of the figure and fires appropriateDrawingModelEvents.voidvoidreshapeInParent(Figure f, javafx.scene.transform.Transform transform) Attempts to change the parent bounds of the figure and fires appropriateDrawingModelEvents.<T> @Nullable Tset(@NonNull Figure figure, MapAccessor<T> key, @Nullable T newValue) Sets the specified property on the figure and fires appropriateDrawingModelEvents.default voidsetDrawing(Drawing root) Sets the root of the tree and fires appropriateDrawingModelEvents.<T> @NonNull TsetNonNull(@NonNull Figure figure, @NonNull NonNullMapAccessor<T> key, @NonNull T newValue) Sets the specified property on the figure and fires appropriateDrawingModelEvents.voidtransformInLocal(Figure figure, javafx.scene.transform.Transform transform) Invokes "transformInLocal" on the specified figure.voidtransformInParent(Figure figure, javafx.scene.transform.Transform transform) Invokes "transformInParent" on the specified figure.voidtranslateInParent(Figure f, CssPoint2D tx) voidInvokes the updateCss method of the figure and fires appropriateDrawingModelEvents.voidvalidate(RenderContext ctx) Validates the model.javafx.beans.property.ReadOnlyBooleanPropertyThis property returns true if the drawing model is validating its figures.Methods inherited from interface javafx.beans.Observable
subscribeMethods inherited from interface org.jhotdraw8.fxbase.beans.ObservableMixin
fireInvalidated, fireInvalidated, invalidatedMethods inherited from interface org.jhotdraw8.fxbase.tree.TreeModel
addTreeModelListener, fireTreeModelEvent, getRoot, getTreeModelListeners, removeTreeModelListener, rootProperty, setRoot
-
Property Details
-
drawing
The root of the drawing model.- See Also:
-
validating
javafx.beans.property.ReadOnlyBooleanProperty validatingPropertyThis property returns true if the drawing model is validating its figures.- See Also:
-
-
Field Details
-
DRAWING_PROPERTY
Name of the drawing property.- See Also:
-
-
Method Details
-
getDrawingModelListeners
@NonNull CopyOnWriteArrayList<org.jhotdraw8.base.event.Listener<DrawingModelEvent>> getDrawingModelListeners()List of drawing model listeners.- Returns:
- a list of drawing model listeners
-
getInvalidationListeners
@NonNull CopyOnWriteArrayList<javafx.beans.InvalidationListener> getInvalidationListeners()List of invalidation listeners.- Specified by:
getInvalidationListenersin interfaceObservableMixin- Specified by:
getInvalidationListenersin interfaceTreeModel<Figure>- Returns:
- a list of drawing model listeners
-
drawingProperty
The root of the drawing model.- Returns:
- the root
- See Also:
-
addDrawingModelListener
Adds a listener forDrawingModelEvents.- Parameters:
l- the listener
-
removeDrawingModelListener
Removes a listener forDrawingModelEvents.- Parameters:
l- the listener
-
addListener
default void addListener(javafx.beans.InvalidationListener l) - Specified by:
addListenerin interfacejavafx.beans.Observable- Specified by:
addListenerin interfaceObservableMixin
-
removeListener
default void removeListener(javafx.beans.InvalidationListener l) - Specified by:
removeListenerin interfacejavafx.beans.Observable- Specified by:
removeListenerin interfaceObservableMixin
-
getDrawing
Gets the root of the tree.- Returns:
- the drawing
-
setDrawing
Sets the root of the tree and fires appropriateDrawingModelEvents.- Parameters:
root- the new root
-
getChildren
Gets the getChildren of the specified figure.- Specified by:
getChildrenin interfaceTreeModel<Figure>- Parameters:
figure- the figure.- Returns:
- the getChildren.
-
getChildCount
Gets the child count of the specified figure.- Specified by:
getChildCountin interfaceTreeModel<Figure>- Parameters:
figure- the parent.- Returns:
- the number of getChildren
-
getChild
Gets the child at the given index from the parent. -
removeFromParent
Removes the specified child from its parent and fires appropriateDrawingModelEvents.- Specified by:
removeFromParentin interfaceTreeModel<Figure>- Parameters:
child- the figure
-
removeFromParent
Removes the specified child from its parent and fires appropriateDrawingModelEvents.- Parameters:
parent- the parent figureindex- the index
-
insertChildAt
Adds the specified child to a parent and fires appropriateDrawingModelEvents.- Specified by:
insertChildAtin interfaceTreeModel<Figure>- Parameters:
child- the new childparent- the parent.index- the index
-
addChildTo
Adds the specified child to a parent and fires appropriateDrawingModelEvents.- Specified by:
addChildToin interfaceTreeModel<Figure>- Parameters:
child- the new childparent- the parent.
-
set
Sets the specified property on the figure and fires appropriateDrawingModelEvents.- Type Parameters:
T- the value type- Parameters:
figure- the figurekey- the keynewValue- the new value- Returns:
- the old value
-
remove
-
setNonNull
<T> @NonNull T setNonNull(@NonNull Figure figure, @NonNull NonNullMapAccessor<T> key, @NonNull T newValue) Sets the specified property on the figure and fires appropriateDrawingModelEvents.- Type Parameters:
T- the value type- Parameters:
figure- the figurekey- the keynewValue- the new value- Returns:
- the old value
-
get
Gets the specified property from the figure.- Type Parameters:
T- the value type- Parameters:
figure- the figurekey- the key- Returns:
- the value
-
getNonNull
Gets the specified property from the figure.- Type Parameters:
T- the value type- Parameters:
figure- the figurekey- the key- Returns:
- the value
-
reshapeInLocal
Attempts to change the local bounds of the figure and fires appropriateDrawingModelEvents.- Parameters:
f- the figuretransform- the desired transformation in the local coordinate system
-
reshapeInParent
Attempts to change the parent bounds of the figure and fires appropriateDrawingModelEvents.- Parameters:
f- the figuretransform- the desired transformation in the parent coordinate system
-
translateInParent
-
reshapeInLocal
Attempts to change the local bounds of the figure and fires appropriateDrawingModelEvents.- Parameters:
f- the figurex- desired x-position in the local coordinate systemy- desired y-position in the local coordinate systemwidth- desired width in the local coordinate system, may be negativeheight- desired height in the local coordinat system, may be negative
-
reshapeInLocal
-
layout
Invokes the layout method of the figure and fires appropriate /DrawingModelEvents.- Parameters:
f- the figurectx- the render context (optional)
-
disconnect
Invokes the disconnect method of the figure and fires appropriateDrawingModelEvents.- Parameters:
f- the figure
-
isValidating
boolean isValidating()Returns true if the drawing model is currently validating its figures.- Returns:
- true if validation is in progress
-
validatingProperty
javafx.beans.property.ReadOnlyBooleanProperty validatingProperty()This property returns true if the drawing model is validating its figures.- Returns:
- property that returns true if validation is in progress
- See Also:
-
updateCss
Invokes the updateCss method of the figure and fires appropriateDrawingModelEvents.- Parameters:
f- the figure
-
fireDrawingModelEvent
Fires the specified event.- Parameters:
event- the event
-
validate
Validates the model. This method is invoked byDrawingVieweach time before it renders the model.- Parameters:
ctx- the render context (optional)
-
fireNodeInvalidated
Fires "node invalidated" event for the specified figure.- Specified by:
fireNodeInvalidatedin interfaceTreeModel<Figure>- Parameters:
f- the figure
-
firePropertyValueChanged
default <T> void firePropertyValueChanged(Figure f, Key<T> key, @Nullable T oldValue, @Nullable T newValue, boolean wasAdded, boolean wasRemoved) Fires "node invalidated" event for the specified figure.- Type Parameters:
T- the value type- Parameters:
f- the figurekey- the property keyoldValue- the old valuenewValue- the new valuewasAdded-wasRemoved-
-
fireTransformInvalidated
Fires "node invalidated" event for the specified figure.- Parameters:
f- the figure
-
fireLayoutInvalidated
Fires "node invalidated" event for the specified figure.- Parameters:
f- the figure
-
fireStyleInvalidated
Fires "style invalidated" event for the specified figure.- Parameters:
f- the figure
-
fireDrawingModelInvalidated
default void fireDrawingModelInvalidated()Fires an "invalidated" event. -
transformInParent
Invokes "transformInParent" on the specified figure.- Parameters:
figure- a figuretransform- the desired transformation
-
transformInLocal
Invokes "transformInLocal" on the specified figure.- Parameters:
figure- a figuretransform- the desired transformation
-
remove
Removes the specified key from the figure.- Type Parameters:
T- the value type- Parameters:
f- a figureremove- a key- Returns:
- the old value
-
propertyAt
Creates a property for the specified figure and property key.- Type Parameters:
T- the property type- Parameters:
f- a figurekey- a property key- Returns:
- a property
-