Package dk.gtz.graphedit.viewmodel
Class ViewModelVertex
- All Implemented Interfaces:
IFocusable
,IHoverable
,IInspectable
,ISelectable
,javafx.beans.Observable
,javafx.beans.property.Property<ViewModelVertex>
,javafx.beans.property.ReadOnlyProperty<ViewModelVertex>
,javafx.beans.value.ObservableValue<ViewModelVertex>
,javafx.beans.value.WritableValue<ViewModelVertex>
public class ViewModelVertex
extends AutoProperty<ViewModelVertex>
implements IInspectable, IHoverable, ISelectable, IFocusable
Viewmodel representation of a
ModelVertex
.
A vertex is the most basic part of a graph. It can be connected with other vertices via ModelEdge
s.-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionViewModelVertex
(UUID uuid, ModelVertex vertex) Constructs a new view model vertex based on a model vertexViewModelVertex
(UUID uuid, ModelVertex vertex, ViewModelVertexShape shape) Constructs a new view model vertex based on a model vertex and a shapeViewModelVertex
(UUID uuid, ViewModelPoint position, ViewModelVertexShape shape) Constructs a new view model vertex based on a position and a shape -
Method Summary
Modifier and TypeMethodDescriptionvoid
addFocusListener
(Runnable focusEventHandler) Add an event listener for when the focus is stolenvoid
addHoverListener
(javafx.beans.value.ChangeListener<javafx.scene.Node> consumer) Add a changelistener that will be invoked whenIHoverable.hover(javafx.scene.Node)
is being called.void
deselect()
Deselect the objectboolean
void
focus()
Steal the focusGets a list of objects that should be inspectable by anInspectorController
viewjavafx.beans.property.BooleanProperty
Get the observable property that determines if the object is selected or not.getName()
getValue()
int
hashCode()
void
hover
(javafx.scene.Node node) Trigger a hover event and display the provided node in the hover effect.id()
Get the id of the vertexboolean
Check if the hover effect is currently showing.position()
Get the position of the vertexvoid
select()
Select the objectshape()
Get the shape of the vertextoModel()
Constructs a new model vertex instance based on the current view model valuesvoid
unhover()
Stop showing the hover effect.Methods inherited from class dk.gtz.graphedit.viewmodel.AutoProperty
addListener, addListener, bind, bindBidirectional, getBean, isBound, loadFields, removeListener, removeListener, setValue, unbind, unbindBidirectional
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface javafx.beans.value.ObservableValue
flatMap, map, orElse, when
-
Field Details
-
position
The position of the vertex
-
-
Constructor Details
-
ViewModelVertex
Constructs a new view model vertex based on a position and a shape- Parameters:
uuid
- The id of the vertexposition
- The point at which the vertex is locatedshape
- The shape at which edges should follow
-
ViewModelVertex
Constructs a new view model vertex based on a model vertex and a shape- Parameters:
uuid
- The id of the vertexvertex
- The model vertex to base onshape
- The shape at which edges should follow
-
ViewModelVertex
Constructs a new view model vertex based on a model vertex- Parameters:
uuid
- The id of the vertexvertex
- The model vertex to base on
-
-
Method Details
-
toModel
Constructs a new model vertex instance based on the current view model values- Returns:
- A new model vertex instance
-
position
Get the position of the vertex- Returns:
- A view model point
-
shape
Get the shape of the vertex- Returns:
- A view model shape
-
id
Get the id of the vertex- Returns:
- The unique identifier of the vertex
-
getIsSelected
public javafx.beans.property.BooleanProperty getIsSelected()Description copied from interface:ISelectable
Get the observable property that determines if the object is selected or not. This is useful if you want to add event listeners to handle when the property changes.- Specified by:
getIsSelected
in interfaceISelectable
- Returns:
true
if the object is currently selected, otherwisefalse
-
select
public void select()Description copied from interface:ISelectable
Select the object- Specified by:
select
in interfaceISelectable
-
deselect
public void deselect()Description copied from interface:ISelectable
Deselect the object- Specified by:
deselect
in interfaceISelectable
-
addFocusListener
Description copied from interface:IFocusable
Add an event listener for when the focus is stolen- Specified by:
addFocusListener
in interfaceIFocusable
- Parameters:
focusEventHandler
- the handler to call
-
focus
public void focus()Description copied from interface:IFocusable
Steal the focus- Specified by:
focus
in interfaceIFocusable
-
getInspectableObjects
Gets a list of objects that should be inspectable by anInspectorController
view- Specified by:
getInspectableObjects
in interfaceIInspectable
- Returns:
- An unmodifiable list of inspectable objects
-
getName
- Specified by:
getName
in interfacejavafx.beans.property.ReadOnlyProperty<ViewModelVertex>
-
getValue
- Specified by:
getValue
in interfacejavafx.beans.value.ObservableValue<ViewModelVertex>
- Specified by:
getValue
in interfacejavafx.beans.value.WritableValue<ViewModelVertex>
-
hover
public void hover(javafx.scene.Node node) Description copied from interface:IHoverable
Trigger a hover event and display the provided node in the hover effect.- Specified by:
hover
in interfaceIHoverable
- Parameters:
node
- The javafx node to show in the hover window.
-
addHoverListener
public void addHoverListener(javafx.beans.value.ChangeListener<javafx.scene.Node> consumer) Description copied from interface:IHoverable
Add a changelistener that will be invoked whenIHoverable.hover(javafx.scene.Node)
is being called.- Specified by:
addHoverListener
in interfaceIHoverable
- Parameters:
consumer
- The changelistener to add.
-
isHovering
public boolean isHovering()Description copied from interface:IHoverable
Check if the hover effect is currently showing.- Specified by:
isHovering
in interfaceIHoverable
- Returns:
- True if the hover effect is currently being shown, false otherwise.
-
unhover
public void unhover()Description copied from interface:IHoverable
Stop showing the hover effect.- Specified by:
unhover
in interfaceIHoverable
-
equals
-
hashCode
public int hashCode()
-