T
- The type of managed items.public class ItemModelManager<T> extends Object
Constructor and Description |
---|
ItemModelManager(Class<T> itemType) |
Modifier and Type | Method and Description |
---|---|
void |
addItem(T item)
Registers and
installs the given item into the canvas. |
void |
addItems(Iterable<T> items)
Adds all items to the canvas. |
ICanvasObject |
getCanvasObject(T item)
Retrieves the canvas object that has been registered for the given item or
null . |
ICanvasObjectGroup |
getCanvasObjectGroup()
Gets the canvas object group used by
install(Object) . |
protected ICanvasObjectGroup |
getCanvasObjectGroup(T item)
|
Comparator<T> |
getComparator()
Gets a comparer that compares the items so that they are put into the correct order in the canvas tree.
|
ICanvasObjectDescriptor |
getDescriptor()
Gets the canvas object descriptor used by
install(Object) when an item is added
to an canvas object group. |
protected ICanvasObjectDescriptor |
getDescriptor(T item)
|
T |
getItem(ICanvasObject canvasObject)
Tries to find the item managed by this instance that is associated with the given canvas object.
|
protected ICanvasObject |
install(T item)
Installs a member of the collection into the canvas using the
Descriptor . |
void |
itemAddedHandler(Object source,
ItemEventArgs<T> args)
Event handler for item creation events that adds the item to this manager.
|
void |
itemChangedHandler(Object source,
ItemEventArgs<T> args)
Event handler for item change events that updates the visual representation for that item.
|
void |
itemRemovedHandler(Object source,
ItemEventArgs<T> args)
Event handler for item removal events that removes the item from this manager.
|
void |
removeItem(T item)
Deregisters and uninstalls the given
item from the canvas. |
void |
removeItems(Iterable<T> items)
Removes all items from the canvas. |
void |
setCanvasObjectGroup(ICanvasObjectGroup value)
Sets the canvas object group used by
install(Object) . |
void |
setComparator(Comparator<T> value)
Sets a comparer that compares the items so that they are put into the correct order in the canvas tree.
|
void |
setDescriptor(ICanvasObjectDescriptor value)
Sets the canvas object descriptor used by
install(Object) when an item is added
to an canvas object group. |
void |
update(T item)
This method may be called to update the visual representation of the given item in the canvas.
|
public void addItem(T item)
installs
the given item
into the canvas.item
- The item to install.public void addItems(Iterable<T> items)
Adds
all items to the canvas.
This is useful to initialize this manager with an existing collection of items.
items
- The items to add.public ICanvasObject getCanvasObject(T item)
null
.item
- The item to retrieve the canvas object for.null
.install(Object)
public final ICanvasObjectGroup getCanvasObjectGroup()
install(Object)
.
Setting this property to null
will prevent this manager from installing new items.
setCanvasObjectGroup(ICanvasObjectGroup)
protected ICanvasObjectGroup getCanvasObjectGroup(T item)
ICanvasObjectGroup
used to install(Object)
the item
in the canvas.
The default implementation simply returns the value of CanvasObjectGroup
.
item
- The item to get the group for.ICanvasObjectGroup
used to install(Object)
an item in the canvas.public final Comparator<T> getComparator()
If this instance is set to null
this feature is effectively turned off.
setComparator(Comparator)
public final ICanvasObjectDescriptor getDescriptor()
install(Object)
when an item is added
to an canvas object group.
Setting the descriptor to null
will prevent this manager from installing new items.
install(Object)
.setDescriptor(ICanvasObjectDescriptor)
protected ICanvasObjectDescriptor getDescriptor(T item)
ICanvasObjectDescriptor
used to install(Object)
the item
in the canvas.
The default implementation simply returns the value of Descriptor
.
item
- The item to get the descriptor for.ICanvasObjectDescriptor
used to install(Object)
an item in the canvas.public T getItem(ICanvasObject canvasObject)
canvasObject
- The canvas object to query the corresponding model item for.null
if no such item could be found.protected ICanvasObject install(T item)
Descriptor
.item
- The member to install.public void itemAddedHandler(Object source, ItemEventArgs<T> args)
This method is intended to be used to delegate item creation events from observable collections:
This method calls addItem(Object)
with Item
.
source
- The instance that raised the event.args
- The event arguments.public void itemChangedHandler(Object source, ItemEventArgs<T> args)
This method is intended to be used to delegate item change events from observable collections:
This is necessary if the group the canvas object should be added to might change after the item change. This might happen, e.g. after changing an edge's port in a grouped graph.
source
- The event source.args
- The item event args which indicate the change.public void itemRemovedHandler(Object source, ItemEventArgs<T> args)
This method is intended to be used to delegate item removal events from observable collections:
This method calls removeItem(Object)
with Item
.
source
- The instance that raised the event.args
- The event arguments.public void removeItem(T item)
item
from the canvas.item
- The item to uninstall.public void removeItems(Iterable<T> items)
Removes
all items from the canvas.
This method can be used to clean up this manager before disposing it.
items
- The items to remove.public final void setCanvasObjectGroup(ICanvasObjectGroup value)
install(Object)
.
Setting this property to null
will prevent this manager from installing new items.
value
- The CanvasObjectGroup to set.getCanvasObjectGroup()
public final void setComparator(Comparator<T> value)
If this instance is set to null
this feature is effectively turned off.
value
- The Comparator to set.getComparator()
public final void setDescriptor(ICanvasObjectDescriptor value)
install(Object)
when an item is added
to an canvas object group.
Setting the descriptor to null
will prevent this manager from installing new items.
value
- The canvas object descriptor used by install(Object)
.getDescriptor()
public void update(T item)
If no visual representation is registered, yet, install(Object)
will be called.
item
- The item to update.