Gephi Toolkit Javadoc

org.gephi.datalab.impl
Class GraphElementsControllerImpl

java.lang.Object
  extended by org.gephi.datalab.impl.GraphElementsControllerImpl
All Implemented Interfaces:
GraphElementsController

public class GraphElementsControllerImpl
extends java.lang.Object
implements GraphElementsController

Implementation of the GraphElementsController interface declared in the Data Laboratory API

Author:
Eduardo Ramos
See Also:
GraphElementsController

Constructor Summary
GraphElementsControllerImpl()
           
 
Method Summary
 boolean areEdgesInGraph(Edge[] edges)
          Checks if an array of edges are contained in the main view graph.
 boolean areNodesInGraph(Node[] nodes)
          Checks if an array of nodes are contained in the main view graph.
 boolean canGroupNodes(Node[] nodes)
          Checks if an array of nodes can form a group.
 boolean canMoveNodeToGroup(Node node, Node group)
          Indicates if a given node can be moved to a group node.
 boolean canUngroupNode(Node node)
          Checks if the node can be ungrouped (it forms a group of nodes).
 Edge createEdge(Node source, Node target, boolean directed)
          Creates and edge between source and target node (if it does not already exist), directed or undirected.
 Edge createEdge(java.lang.String id, Node source, Node target, boolean directed)
          Creates and edge between source and target node (if it does not already exist), directed or undirected.
 void createEdges(Node source, Node[] allNodes, boolean directed)
          Tries to create edges between the source node and all other edges, directed or undirected.
 Node createNode(java.lang.String label)
          Creates a node with default id and the given label.
 Node createNode(java.lang.String label, java.lang.String id)
          Creates a node with the given id and label.
 void deleteEdge(Edge edge)
          Tries to delete an edge checking first if it is on the graph.
 void deleteEdges(Edge[] edges)
          Tries to delete an array of edges checking first if they are on the graph.
 void deleteEdgesWithNodes(Edge[] edges, boolean deleteSource, boolean deleteTarget)
          Tries to delete an array of edges checking first if they are on the graph and also deletes their source and target node if it is indicated.
 void deleteEdgeWithNodes(Edge edge, boolean deleteSource, boolean deleteTarget)
          Tries to delete an edge checking first if it is on the graph and also deletes its source and target node if it is indicated.
 void deleteNode(Node node)
          Tries to delete a node checking first if it is on the graph.
 void deleteNodes(Node[] nodes)
          Tries to delete an array of nodes checking first if they are on the graph.
 Node duplicateNode(Node node)
          Duplicates a node if it is in the graph, and returns the new node.
 void duplicateNodes(Node[] nodes)
          Tries to duplicate an array of nodes with the same behaviour as duplicateNode method.
 Node[] getAvailableGroupsToMoveNodes(Node[] nodes)
          Prepares and returns an array with the groups that the given nodes can be moved to.
 int getEdgesCount()
          Returns the number of edges in the graph.
 Edge[] getNodeEdges(Node node)
          Prepares and returns an array with the edges incident to the specified node.
 Node[] getNodeNeighbours(Node node)
          Prepares and returns an array with the neighbour nodes of the specified node.
 int getNodesCount()
          Returns the number of nodes in the graph.
 boolean groupNodes(Node[] nodes)
          Groups an array of nodes if it is possible.
 boolean isEdgeInGraph(Edge edge)
          Checks if an edge is contained in the main view graph.
 boolean isNodeFixed(Node node)
          Checks the fixed state of a node.
 boolean isNodeInGraph(Node node)
          Checks if a node is contained in the main view graph.
 boolean isNodeInGroup(Node node)
          Checks if the node is in a group (has a parent).
 Node mergeNodes(Node[] nodes, Node selectedNode, AttributeRowsMergeStrategy[] mergeStrategies, boolean deleteMergedNodes)
          Merges 2 or more nodes into a new one node that has all the edges of the merged nodes.
 void moveNodesToGroup(Node[] nodes, Node group)
          Tries to move each node of the nodes array to the group node.
 boolean moveNodeToGroup(Node node, Node group)
          Moves a node to a group of nodes if it is possible.
 boolean removeNodeFromGroup(Node node)
          Removes a node from its group if the node is in a group (has a parent).
 void removeNodesFromGroup(Node[] nodes)
          Tries to remove every node in the array from its group checking first they are in a group.
 void setNodeFixed(Node node, boolean fixed)
          Sets the fixed state of a node to the indicated.
 void setNodesFixed(Node[] nodes, boolean fixed)
          Sets the fixed state of an array of nodes to the indicated.
 boolean ungroupNode(Node node)
          Ungroups a node if it forms a group.
 boolean ungroupNodeRecursively(Node node)
          Ungroups a node if it forms a group and also ungroups all its descendant.
 void ungroupNodes(Node[] nodes)
          Tries to ungroup every node un the array of nodes checking first they form a group.
 void ungroupNodesRecursively(Node[] nodes)
          Tries to ungroup every node un the array of nodes checking first they form a group.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GraphElementsControllerImpl

public GraphElementsControllerImpl()
Method Detail

createNode

public Node createNode(java.lang.String label)
Description copied from interface: GraphElementsController
Creates a node with default id and the given label.

Specified by:
createNode in interface GraphElementsController
Parameters:
label - Label for the node
Returns:
The new created node

createNode

public Node createNode(java.lang.String label,
                       java.lang.String id)
Description copied from interface: GraphElementsController

Creates a node with the given id and label.

If a node with that id already exists, no node will be created

Specified by:
createNode in interface GraphElementsController
Parameters:
label - Label for the node
id - Id for the node
Returns:
The new created node or null if a node with the given id already exists

duplicateNode

public Node duplicateNode(Node node)
Description copied from interface: GraphElementsController

Duplicates a node if it is in the graph, and returns the new node.

If the node has children, they are also copied as children of the new node.

Sets the same properties and attributes for the node as the original node: id, label and AttributeColumns with DATA AttributeOrigin. Does not copy AttributeColumns with COMPUTED AttributeOrigin.

Specified by:
duplicateNode in interface GraphElementsController
Parameters:
node - Node to copy
Returns:
New node

duplicateNodes

public void duplicateNodes(Node[] nodes)
Description copied from interface: GraphElementsController
Tries to duplicate an array of nodes with the same behaviour as duplicateNode method.

Specified by:
duplicateNodes in interface GraphElementsController
Parameters:
nodes - Array of nodes to duplicate

createEdge

public Edge createEdge(Node source,
                       Node target,
                       boolean directed)
Description copied from interface: GraphElementsController

Creates and edge between source and target node (if it does not already exist), directed or undirected.

Specified by:
createEdge in interface GraphElementsController
Parameters:
source - Source node
target - Target node
directed - Indicates if the edge has to be directed
Returns:
New edge if the edge was created succesfully, null otherwise

createEdge

public Edge createEdge(java.lang.String id,
                       Node source,
                       Node target,
                       boolean directed)
Description copied from interface: GraphElementsController

Creates and edge between source and target node (if it does not already exist), directed or undirected.

If a edge with the given id already exists, no edge will be created.

Specified by:
createEdge in interface GraphElementsController
source - Source node
target - Target node
directed - Indicates if the edge has to be directed
Returns:
New edge if the edge was created succesfully, null otherwise

createEdges

public void createEdges(Node source,
                        Node[] allNodes,
                        boolean directed)
Description copied from interface: GraphElementsController

Tries to create edges between the source node and all other edges, directed or undirected.

An edge won't be created if it already exists or is a self-loop.

Specified by:
createEdges in interface GraphElementsController
Parameters:
source - Source node
allNodes - All edges
directed - Indicates if the edges have to be directed

deleteNode

public void deleteNode(Node node)
Description copied from interface: GraphElementsController
Tries to delete a node checking first if it is on the graph.

Specified by:
deleteNode in interface GraphElementsController
Parameters:
node - Node to delete

deleteNodes

public void deleteNodes(Node[] nodes)
Description copied from interface: GraphElementsController
Tries to delete an array of nodes checking first if they are on the graph.

Specified by:
deleteNodes in interface GraphElementsController
Parameters:
nodes - Array of nodes to delete

deleteEdge

public void deleteEdge(Edge edge)
Description copied from interface: GraphElementsController
Tries to delete an edge checking first if it is on the graph.

Specified by:
deleteEdge in interface GraphElementsController
Parameters:
edge - Edge to delete

deleteEdges

public void deleteEdges(Edge[] edges)
Description copied from interface: GraphElementsController
Tries to delete an array of edges checking first if they are on the graph.

Specified by:
deleteEdges in interface GraphElementsController
Parameters:
edges - Array of edges to delete

deleteEdgeWithNodes

public void deleteEdgeWithNodes(Edge edge,
                                boolean deleteSource,
                                boolean deleteTarget)
Description copied from interface: GraphElementsController
Tries to delete an edge checking first if it is on the graph and also deletes its source and target node if it is indicated.

Specified by:
deleteEdgeWithNodes in interface GraphElementsController
Parameters:
edge - Edge to delete
deleteSource - Indicates if the source node has to be deleted
deleteTarget - Indicates if the target node has to be deleted

deleteEdgesWithNodes

public void deleteEdgesWithNodes(Edge[] edges,
                                 boolean deleteSource,
                                 boolean deleteTarget)
Description copied from interface: GraphElementsController
Tries to delete an array of edges checking first if they are on the graph and also deletes their source and target node if it is indicated.

Specified by:
deleteEdgesWithNodes in interface GraphElementsController
Parameters:
edges - Array of edges to delete
deleteSource - Indicates if the source nodes have to be deleted
deleteTarget - Indicates if the target nodes have to be deleted

groupNodes

public boolean groupNodes(Node[] nodes)
Description copied from interface: GraphElementsController
Groups an array of nodes if it is possible.

Specified by:
groupNodes in interface GraphElementsController
Parameters:
nodes - Array of nodes to group
Returns:
True if the nodes were succesfully grouped, false otherwise

canGroupNodes

public boolean canGroupNodes(Node[] nodes)
Description copied from interface: GraphElementsController
Checks if an array of nodes can form a group.

Specified by:
canGroupNodes in interface GraphElementsController
Parameters:
nodes - Array of nodes to check
Returns:
True if the nodes can form a group, false otherwise

ungroupNode

public boolean ungroupNode(Node node)
Description copied from interface: GraphElementsController
Ungroups a node if it forms a group.

Specified by:
ungroupNode in interface GraphElementsController
Parameters:
node - Node to ungroup
Returns:
True if the node was succesfully ungrouped, false otherwise

ungroupNodes

public void ungroupNodes(Node[] nodes)
Description copied from interface: GraphElementsController
Tries to ungroup every node un the array of nodes checking first they form a group.

Specified by:
ungroupNodes in interface GraphElementsController
Parameters:
nodes - Array of nodes to ungroup

ungroupNodeRecursively

public boolean ungroupNodeRecursively(Node node)
Description copied from interface: GraphElementsController
Ungroups a node if it forms a group and also ungroups all its descendant.

Specified by:
ungroupNodeRecursively in interface GraphElementsController
Parameters:
node - Node to ungroup recursively
Returns:
True if the node was succesfully ungrouped, false otherwise

ungroupNodesRecursively

public void ungroupNodesRecursively(Node[] nodes)
Description copied from interface: GraphElementsController
Tries to ungroup every node un the array of nodes checking first they form a group.

Specified by:
ungroupNodesRecursively in interface GraphElementsController
Parameters:
nodes - Array of nodes to ungroup

canUngroupNode

public boolean canUngroupNode(Node node)
Description copied from interface: GraphElementsController
Checks if the node can be ungrouped (it forms a group of nodes).

Specified by:
canUngroupNode in interface GraphElementsController
Parameters:
node - Node to check
Returns:
True if the node can be ungrouped, false otherwise

mergeNodes

public Node mergeNodes(Node[] nodes,
                       Node selectedNode,
                       AttributeRowsMergeStrategy[] mergeStrategies,
                       boolean deleteMergedNodes)
Description copied from interface: GraphElementsController
Merges 2 or more nodes into a new one node that has all the edges of the merged nodes. An AttributeRowsMergeStrategy must be provided for each column of the nodes.

Specified by:
mergeNodes in interface GraphElementsController
Parameters:
nodes - Nodes to merge (at least 1)
selectedNode - Main selected node of the nodes to merge (or null to use first node)
mergeStrategies - Strategies to merge rows of each column of the nodes
deleteMergedNodes - Indicates if merged nodes should be deleted
Returns:
New resulting node

moveNodeToGroup

public boolean moveNodeToGroup(Node node,
                               Node group)
Description copied from interface: GraphElementsController
Moves a node to a group of nodes if it is possible. To move a node to a group node, they must be different, have the same parent and the node to be the group has to be a group of nodes.

Specified by:
moveNodeToGroup in interface GraphElementsController
Parameters:
node - Node to move to group
group - Group of nodes to move the node
Returns:
True if the node was moved, false otherwise

moveNodesToGroup

public void moveNodesToGroup(Node[] nodes,
                             Node group)
Description copied from interface: GraphElementsController
Tries to move each node of the nodes array to the group node.

Specified by:
moveNodesToGroup in interface GraphElementsController
Parameters:
nodes - Array of nodes to move
group - Group node

getAvailableGroupsToMoveNodes

public Node[] getAvailableGroupsToMoveNodes(Node[] nodes)
Description copied from interface: GraphElementsController

Prepares and returns an array with the groups that the given nodes can be moved to.

These groups are the nodes that have the same parent as the given nodes and are not in the given nodes array.

Specified by:
getAvailableGroupsToMoveNodes in interface GraphElementsController
Parameters:
nodes - Nodes to get available groups to be moved
Returns:
Available groups array of null if the nodes don't all have the same parent

canMoveNodeToGroup

public boolean canMoveNodeToGroup(Node node,
                                  Node group)
Description copied from interface: GraphElementsController
Indicates if a given node can be moved to a group node. To move a node to a group, they must have the same parent and the group node has to be a group of nodes.

Specified by:
canMoveNodeToGroup in interface GraphElementsController
Parameters:
node - Node to check if can be moved
group - Group node
Returns:
True if it can be moved, false otherwise

removeNodeFromGroup

public boolean removeNodeFromGroup(Node node)
Description copied from interface: GraphElementsController
Removes a node from its group if the node is in a group (has a parent). Also breaks the group if the last node is removed.

Specified by:
removeNodeFromGroup in interface GraphElementsController
Parameters:
node - Node to remove from its group
Returns:
True if the node was removed from a group, false otherwise

removeNodesFromGroup

public void removeNodesFromGroup(Node[] nodes)
Description copied from interface: GraphElementsController
Tries to remove every node in the array from its group checking first they are in a group. Also breaks groups when the last node is removed.

Specified by:
removeNodesFromGroup in interface GraphElementsController
Parameters:
nodes - Arrays of nodes to remove from its group

isNodeInGroup

public boolean isNodeInGroup(Node node)
Description copied from interface: GraphElementsController
Checks if the node is in a group (has a parent).

Specified by:
isNodeInGroup in interface GraphElementsController
Returns:
True if the node is in a group, false otherwise

setNodeFixed

public void setNodeFixed(Node node,
                         boolean fixed)
Description copied from interface: GraphElementsController
Sets the fixed state of a node to the indicated.

Specified by:
setNodeFixed in interface GraphElementsController
Parameters:
node - Node to set fixed state
fixed - Fixed state for the node

setNodesFixed

public void setNodesFixed(Node[] nodes,
                          boolean fixed)
Description copied from interface: GraphElementsController
Sets the fixed state of an array of nodes to the indicated.

Specified by:
setNodesFixed in interface GraphElementsController
Parameters:
nodes - Array of nodes to set fixed state
fixed - Fixed state for the nodes

isNodeFixed

public boolean isNodeFixed(Node node)
Description copied from interface: GraphElementsController
Checks the fixed state of a node.

Specified by:
isNodeFixed in interface GraphElementsController
Parameters:
node - Node to check
Returns:
Fixed state of the node

getNodeNeighbours

public Node[] getNodeNeighbours(Node node)
Description copied from interface: GraphElementsController
Prepares and returns an array with the neighbour nodes of the specified node.

Specified by:
getNodeNeighbours in interface GraphElementsController
Parameters:
node - Node to get neighbours
Returns:
Array of neighbour nodes

getNodeEdges

public Edge[] getNodeEdges(Node node)
Description copied from interface: GraphElementsController
Prepares and returns an array with the edges incident to the specified node.

Specified by:
getNodeEdges in interface GraphElementsController
Parameters:
node - Node to get edges
Returns:
Array of incident edges

getNodesCount

public int getNodesCount()
Description copied from interface: GraphElementsController
Returns the number of nodes in the graph.

Specified by:
getNodesCount in interface GraphElementsController
Returns:
Nodes count

getEdgesCount

public int getEdgesCount()
Description copied from interface: GraphElementsController
Returns the number of edges in the graph.

Specified by:
getEdgesCount in interface GraphElementsController
Returns:
Edges count

isNodeInGraph

public boolean isNodeInGraph(Node node)
Description copied from interface: GraphElementsController
Checks if a node is contained in the main view graph.

Specified by:
isNodeInGraph in interface GraphElementsController
Parameters:
node - Node to check
Returns:
True if the node is in the graph, false otherwise

areNodesInGraph

public boolean areNodesInGraph(Node[] nodes)
Description copied from interface: GraphElementsController
Checks if an array of nodes are contained in the main view graph.

Specified by:
areNodesInGraph in interface GraphElementsController
Parameters:
nodes - Array of nodes to check
Returns:
True if all the nodes are in the graph, false otherwise

isEdgeInGraph

public boolean isEdgeInGraph(Edge edge)
Description copied from interface: GraphElementsController
Checks if an edge is contained in the main view graph.

Specified by:
isEdgeInGraph in interface GraphElementsController
Parameters:
edge - Edge to check
Returns:
True if the edge is in the graph, false otherwise

areEdgesInGraph

public boolean areEdgesInGraph(Edge[] edges)
Description copied from interface: GraphElementsController
Checks if an array of edges are contained in the main view graph.

Specified by:
areEdgesInGraph in interface GraphElementsController
Parameters:
edges - Edges to check
Returns:
True if all the edges are in the graph, false otherwise

Gephi Toolkit Javadoc