public abstract class NodeController extends Object
Node controllers assume that each node is represented by a single Figure on the canvas. (If the node is composite, then of course it's Figure also has child figures, corresponding to each child node.) The mapping between figures and node objects is set up in two ways:
The binding between a node and its figure is exposed by the methods bind() and unbind(), which add and remove a binding. These methods are fairly low-level and not really intended for general use. The method getFigure() looks up a binding ie gets the figure representing a node, and is what clients should use anytime they need to get the visual representation of a node.
This class has one abstract method which must be implemented by application-specific subclasses, renderNode(). This method creates a Figure given a node. A second method, drawNodeChildren(), should be overridden by any subclass that manages composite nodes.
Finally, concrete subclasses that want to change the default interactor will do so in the subclass' constructor. Subclass constructors must always call super() to ensure that the controller is properly initialized.
Constructor and Description |
---|
NodeController(GraphController controller)
Create a new node controller with a default node interactor.
|
Modifier and Type | Method and Description |
---|---|
void |
addNode(Object node,
Object parent,
double x,
double y)
Add the given node to this graph editor, inside the given parent node
and render it at the given location relative to its parent.
|
void |
bind(Object node,
Figure figure)
Create or overwrite a binding from a node to a figure.
|
void |
drawNode(Object node,
Object parent,
double x,
double y)
Draw the given node at the specified location.
|
void |
drawNodeChildren(Object parent,
Figure container)
Draw the children of the given node.
|
GraphController |
getController()
Return the graph controller containing this controller.
|
Figure |
getFigure(Object node)
Get the figure corresponding to the given node.
|
Interactor |
getNodeInteractor()
Return the node interactor associated with this controller.
|
void |
removeNode(Object node)
Remove the node and its associated figure.
|
abstract Figure |
renderNode(Object node,
Object parent,
FigureContainer container,
double x,
double y)
Render a visual representation of the given node, at the given
location, and add it to the given figure container.
|
void |
setNodeInteractor(Interactor interactor)
Set the node interactor for this controller
|
void |
unbind(Object node,
Figure figure)
Remove a binding from a node to a figure.
|
void |
undrawNode(Object node)
Remove the figure for the given node.
|
abstract void |
unrenderNode(Object node,
Figure figure)
Remove the visual representation of the given node.
|
public NodeController(GraphController controller)
public void bind(Object node, Figure figure)
public void addNode(Object node, Object parent, double x, double y)
public void drawNode(Object node, Object parent, double x, double y)
public void drawNodeChildren(Object parent, Figure container)
public GraphController getController()
public Figure getFigure(Object node)
public Interactor getNodeInteractor()
public void removeNode(Object node)
public abstract Figure renderNode(Object node, Object parent, FigureContainer container, double x, double y)
public void setNodeInteractor(Interactor interactor)
public void unbind(Object node, Figure figure)
public void undrawNode(Object node)
GraphController#rerenderSubgraph(Iterator);
Copyright © 2024 Central Laboratory of the Research Councils. All Rights Reserved.