Package dk.gtz.graphedit.viewmodel
Class ViewModelEdge
- All Implemented Interfaces:
IFocusable
,IHoverable
,IInspectable
,ISelectable
,javafx.beans.Observable
,javafx.beans.property.Property<ViewModelEdge>
,javafx.beans.property.ReadOnlyProperty<ViewModelEdge>
,javafx.beans.value.ObservableValue<ViewModelEdge>
,javafx.beans.value.WritableValue<ViewModelEdge>
public class ViewModelEdge
extends AutoProperty<ViewModelEdge>
implements IInspectable, ISelectable, IHoverable, IFocusable
The ViewModel representation of a graph edge.
Edges connects vertices with other vertices.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionViewModelEdge
(UUID uuid, ModelEdge edge) Constructs a new view model edge instance based on a model edge instanceViewModelEdge
(UUID uuid, UUID source, UUID target) Constructs a new view model edge instanceViewModelEdge
(UUID uuid, javafx.beans.property.ObjectProperty<UUID> source, javafx.beans.property.ObjectProperty<UUID> target) Constructs a new view model edge instance -
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 hoverDisplay) Trigger a hover event and display the provided node in the hover effect.id()
Get the id of the edgeboolean
Check if the hover effect is currently showing.boolean
isSourceValid
(UUID source, ViewModelGraph graph) Check if the proposed source vertex is a valid source.boolean
isTargetValid
(UUID target, ViewModelGraph graph) Check if the proposed target vertex is a valid target.void
select()
Select the objectjavafx.beans.property.ObjectProperty<UUID>
source()
Get the source propertyjavafx.beans.property.ObjectProperty<UUID>
target()
Get the target propertytoModel()
Constructs a new model edge 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
-
source
Property pointing to the source vertex id -
target
Property pointing to the target vertex id
-
-
Constructor Details
-
ViewModelEdge
public ViewModelEdge(UUID uuid, javafx.beans.property.ObjectProperty<UUID> source, javafx.beans.property.ObjectProperty<UUID> target) Constructs a new view model edge instance- Parameters:
uuid
- The id of the edgesource
- the syntactic element where the edge originates fromtarget
- the syntactic element where the edge targets
-
ViewModelEdge
Constructs a new view model edge instance based on a model edge instance- Parameters:
uuid
- The id of the edgeedge
- the model edge to convert
-
ViewModelEdge
Constructs a new view model edge instance- Parameters:
uuid
- The id of the edgesource
- the syntactic element where the edge originates fromtarget
- the syntactic element where the edge targets
-
-
Method Details
-
toModel
Constructs a new model edge instance based on the current view model values- Returns:
- a new model edge instance
-
source
Get the source property- Returns:
- the source
UUID
property
-
target
Get the target property- Returns:
- the target
UUID
property
-
id
Get the id of the edge- Returns:
- the unique identifier of the edge
-
isTargetValid
Check if the proposed target vertex is a valid target. Use this in your syntax plugins to limit which vertices can be targeted by edges- Parameters:
target
- The proposed vertex id to targetgraph
- The graph containing this edge and the proposed target vertex- Returns:
- true if the target is a valid target vertex for this edge, false otherwise
-
isSourceValid
Check if the proposed source vertex is a valid source. Use this in your syntax plugins to limit which vertices can have edges- Parameters:
source
- The proposed vertex id to sourcegraph
- The graph containing this edge and the proposed source vertex- Returns:
- true if the source is a valid source vertex for this edge, false otherwise
-
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<ViewModelEdge>
-
getValue
- Specified by:
getValue
in interfacejavafx.beans.value.ObservableValue<ViewModelEdge>
- Specified by:
getValue
in interfacejavafx.beans.value.WritableValue<ViewModelEdge>
-
hover
public void hover(javafx.scene.Node hoverDisplay) Description copied from interface:IHoverable
Trigger a hover event and display the provided node in the hover effect.- Specified by:
hover
in interfaceIHoverable
- Parameters:
hoverDisplay
- The javafx node to show in the hover window.
-
unhover
public void unhover()Description copied from interface:IHoverable
Stop showing the hover effect.- Specified by:
unhover
in interfaceIHoverable
-
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.
-
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.
-
equals
-
hashCode
public int hashCode()
-