Package adams.gui.core
Class DragAndDropTreeNodeCollection<N extends BaseTreeNode>
- java.lang.Object
-
- adams.gui.core.DragAndDropTreeNodeCollection<N>
-
- Type Parameters:
N- the type of node to handle
- All Implemented Interfaces:
Transferable,Serializable,Iterable<N>,Collection<N>
- Direct Known Subclasses:
ClassTreeNodeCollection,TreeNodeCollection
public class DragAndDropTreeNodeCollection<N extends BaseTreeNode> extends Object implements Transferable, Serializable, Collection<N>
Helper class for drag-n-drop in the DragAndDropTree.- Version:
- $Revision$
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description DragAndDropTreeNodeCollection(N[] nodes)Initializes the collection with all the nodes.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(N e)Adds the node.booleanaddAll(Collection<? extends N> c)Adds all the elements of the collection to this one.voidclear()Removes all nodes.booleancontains(Object o)Checks whether the object is stored among the nodes.booleancontainsAll(Collection<?> c)Checks whether all the elements of the specified collection are available in this one.ObjectgetTransferData(DataFlavor flavor)Returns the nodes as transferable object in the requested flavor.DataFlavor[]getTransferDataFlavors()Returns the supported flavors.booleanisDataFlavorSupported(DataFlavor flavor)Returns whether the flavor is supported (only stringFlavor supported).booleanisEmpty()Returns whether the collection is empty.Iterator<N>iterator()Returns an iterator over the nodes.booleanremove(Object o)Removes the object from the collection.booleanremoveAll(Collection<?> c)Removes all the elements from the collection that are also in this one.booleanretainAll(Collection<?> c)Removes all elements but the ones from the specified collection from this one.intsize()Returns the size of the collection.Object[]toArray()Returns the nodes as array.<N> N[]toArray(N[] a)Returns the nodes as array.TransferabletoTransferable()Turns the node/userObject into a transferable string.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Collection
equals, hashCode, parallelStream, removeIf, spliterator, stream, toArray
-
-
-
-
Field Detail
-
m_Nodes
protected ArrayList<N extends BaseTreeNode> m_Nodes
the nodes.
-
-
Constructor Detail
-
DragAndDropTreeNodeCollection
public DragAndDropTreeNodeCollection(N[] nodes)
Initializes the collection with all the nodes.- Parameters:
nodes- the nodes for the collection
-
-
Method Detail
-
size
public int size()
Returns the size of the collection.- Specified by:
sizein interfaceCollection<N extends BaseTreeNode>- Returns:
- the number of nodes stored
-
isEmpty
public boolean isEmpty()
Returns whether the collection is empty.- Specified by:
isEmptyin interfaceCollection<N extends BaseTreeNode>- Returns:
- true if no nodes stored
-
contains
public boolean contains(Object o)
Checks whether the object is stored among the nodes.- Specified by:
containsin interfaceCollection<N extends BaseTreeNode>- Parameters:
o- the object to look for- Returns:
- true if the object can be located
-
iterator
public Iterator<N> iterator()
Returns an iterator over the nodes.- Specified by:
iteratorin interfaceCollection<N extends BaseTreeNode>- Specified by:
iteratorin interfaceIterable<N extends BaseTreeNode>- Returns:
- the node iterator
-
toArray
public Object[] toArray()
Returns the nodes as array.- Specified by:
toArrayin interfaceCollection<N extends BaseTreeNode>- Returns:
- the nodes
-
toArray
public <N> N[] toArray(N[] a)
Returns the nodes as array.- Specified by:
toArrayin interfaceCollection<N extends BaseTreeNode>- Parameters:
a- the array to use- Returns:
- the nodes
-
add
public boolean add(N e)
Adds the node.- Specified by:
addin interfaceCollection<N extends BaseTreeNode>- Parameters:
e- the node to add- Returns:
- true if the collection was modified
-
remove
public boolean remove(Object o)
Removes the object from the collection.- Specified by:
removein interfaceCollection<N extends BaseTreeNode>- Parameters:
o- the object to remove- Returns:
- true if the collection was modified
-
containsAll
public boolean containsAll(Collection<?> c)
Checks whether all the elements of the specified collection are available in this one.- Specified by:
containsAllin interfaceCollection<N extends BaseTreeNode>- Parameters:
c- the collection to use for checking
-
addAll
public boolean addAll(Collection<? extends N> c)
Adds all the elements of the collection to this one.- Specified by:
addAllin interfaceCollection<N extends BaseTreeNode>- Parameters:
c- the collection to add- Returns:
- true if the collection was modified
-
removeAll
public boolean removeAll(Collection<?> c)
Removes all the elements from the collection that are also in this one.- Specified by:
removeAllin interfaceCollection<N extends BaseTreeNode>- Parameters:
c- the collection to remove- Returns:
- true if the collection was modified
-
retainAll
public boolean retainAll(Collection<?> c)
Removes all elements but the ones from the specified collection from this one.- Specified by:
retainAllin interfaceCollection<N extends BaseTreeNode>- Parameters:
c- the collection to retain- Returns:
- true if the collection was modified
-
clear
public void clear()
Removes all nodes.- Specified by:
clearin interfaceCollection<N extends BaseTreeNode>
-
getTransferDataFlavors
public DataFlavor[] getTransferDataFlavors()
Returns the supported flavors.- Specified by:
getTransferDataFlavorsin interfaceTransferable- Returns:
- the flavors
-
isDataFlavorSupported
public boolean isDataFlavorSupported(DataFlavor flavor)
Returns whether the flavor is supported (only stringFlavor supported).- Specified by:
isDataFlavorSupportedin interfaceTransferable- Parameters:
flavor- the flavor to check- Returns:
- true if supported
-
getTransferData
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException
Returns the nodes as transferable object in the requested flavor.- Specified by:
getTransferDatain interfaceTransferable- Parameters:
flavor- the requested flavor- Returns:
- the converted nodes
- Throws:
UnsupportedFlavorException- if the flavor is not supportedIOException- if an IO operation fails
-
toTransferable
public Transferable toTransferable()
Turns the node/userObject into a transferable string. One node per line, separated by "\n", string representation obtained via the node's toString() method.- Returns:
- the generated string
-
-