public class LayoutGraphHider extends Object
This class can be used to temporarily hide away certain elements of a graph and to unhide that parts at a later time again. Instances of this class keep track of graph elements that were hidden from a graph in order to make them visible again at a later time.
Note that this class should not be used to hide elements from a Graph2D for pure hiding purposes. Since this class will by default prevent the graph instance from firing events, other code might cease to work correctly. Use this class for short term removal of nodes and edges, only.
Modifier and Type | Field and Description |
---|---|
protected EdgeList |
hiddenEdges
holds the list of the hidden edges in stack order.
|
protected NodeList |
hiddenNodes
holds the list of the hidden nodes in stack order.
|
Constructor and Description |
---|
LayoutGraphHider(Graph g)
Instantiates a new GraphHider for the given graph.
|
Modifier and Type | Method and Description |
---|---|
Graph |
getGraph()
Gets the
Graph for which this GraphHider was created. |
IEdgeCursor |
getHiddenEdgeCursor()
The edges that are currently hidden.
|
INodeCursor |
getHiddenNodeCursor()
The nodes that are currently hidden.
|
void |
hide(Edge e)
Hides the given edge from the graph.
|
void |
hide(EdgeList el)
Hides the given list of edges from the graph.
|
void |
hide(ICursor cursor)
Hides the given elements from the graph.
|
void |
hide(IEdgeCursor ec)
Hides the given edges from the graph.
|
void |
hide(INodeCursor nc)
Hides the given nodes from the graph.
|
void |
hide(Node v)
Hides the given node and all it's adjacent edges from the graph.
|
void |
hide(NodeList nl)
Hides the given list of nodes from the graph.
|
void |
hideAll()
Hides all nodes and edges from this graph.
|
void |
hideEdges()
Hides all edges from this graph.
|
void |
hideMultipleEdges()
Hides multiple edges from the graph.
|
void |
hideSelfLoops()
Hides all self-loop edges from this graph.
|
static void |
hideSubgraph(Graph graph,
IEdgeCursor ec)
Hides the subgraph induced by the given edges from the given graph.
|
boolean |
isFiringGraphEventsEnabled()
Gets whether or not this hider should fire graph events.
|
void |
setFiringGraphEventsEnabled(boolean value)
Sets whether or not this hider should fire graph events.
|
void |
simplifyGraph()
Hides all self-loops and multiple edges from the graph.
|
protected void |
unhide(Edge e)
This method will be called whenever the hider is requested to unhide the given edge from the graph.
|
protected void |
unhide(Node v)
This method will be called whenever the hider is requested to unhide the given node from the graph.
|
void |
unhideAll()
Unhides all formerly hidden elements in the graph.
|
void |
unhideEdge(Edge e)
Unhides the given edge.
|
void |
unhideEdges()
Unhides all formerly hidden edges in the graph.
|
void |
unhideEdges(EdgeList edges)
Unhides the given edges.
|
void |
unhideNode(Node v,
boolean unhideAdjacentEdges)
Unhides the given node and if requested its adjacent edges.
|
void |
unhideNodes()
Unhides all formerly hidden nodes in the graph.
|
void |
unhideNodes(NodeList nodes,
boolean unhideAdjacentEdges)
Unhides the given nodes and if requested its adjacent edges.
|
static void |
unhideSubgraph(Graph graph,
IEdgeCursor ec)
Unhides the subgraph induced by the given edges in the given graph.
|
protected EdgeList hiddenEdges
protected NodeList hiddenNodes
public LayoutGraphHider(Graph g)
All non-static hiding and unhiding methods will refer to the given graph.
public Graph getGraph()
Graph
for which this GraphHider
was created.Graph
for which this GraphHider
was created.public IEdgeCursor getHiddenEdgeCursor()
public INodeCursor getHiddenNodeCursor()
public void hide(Edge e)
The hidden edge will be stored so that they can be unhidden again at a later time.
public void hide(EdgeList el)
The hidden edges will be stored so that they can be unhidden again at a later time.
public void hide(ICursor cursor)
The hidden nodes and adjacent edges will be stored so that they can be unhidden again at a later time.
public void hide(IEdgeCursor ec)
The hidden edges will be stored so that they can be unhidden again at a later time.
public void hide(INodeCursor nc)
The hidden nodes and adjacent edges will be stored so that they can be unhidden again at a later time.
public void hide(Node v)
The hidden elements will be stored so that they can be unhidden again at a later time.
public void hide(NodeList nl)
The hidden nodes and adjacent edges will be stored so that they can be unhidden again at a later time.
public void hideAll()
The hidden elements will be stored so that they can be unhidden again at a later time.
public void hideEdges()
The hidden edges will be stored so that they can be unhidden again at a later time.
public void hideMultipleEdges()
If there are multiple edges connecting two nodes then all but one (representative) of these edges will be hidden. The hidden edges will be stored so that they can be unhidden again at a later time.
public void hideSelfLoops()
The hidden edges will be stored so that they can be unhidden again at a later time.
public static final void hideSubgraph(Graph graph, IEdgeCursor ec)
The induced subgraph defined by the given edges consists of the given edges and all nodes that are solely connected to the rest of the graph by the given edges.
public boolean isFiringGraphEventsEnabled()
By default the hider does not fire graph events.
setFiringGraphEventsEnabled(boolean)
public void setFiringGraphEventsEnabled(boolean value)
By default the hider does not fire graph events.
value
- The FiringGraphEventsEnabled to set.isFiringGraphEventsEnabled()
public void simplifyGraph()
The overall effect of this method is that the minimum number of edges are hidden from the graph such that it contains no self-loops and no multiple edges anymore. The hidden edges will be stored so that they can be unhidden again at a later time.
protected void unhide(Edge e)
protected void unhide(Node v)
public void unhideAll()
public void unhideEdge(Edge e)
Also updates hiddenEdges
.
Note that unhiding an edge whose source/target is not in the graph (e.g., because it's currently hidden/removed) causes an exception. Hence, in such cases, you first have to unhide/reinsert the corresponding endpoints.
e
- the edge that will be unhiddenpublic void unhideEdges()
public void unhideEdges(EdgeList edges)
Also updates hiddenEdges
.
Note that unhiding an edge whose source/target is not in the graph (e.g., because it's currently hidden/removed) causes an exception. Hence, in such cases, you first have to unhide/reinsert the corresponding endpoints.
edges
- the edges that will be unhiddenpublic void unhideNode(Node v, boolean unhideAdjacentEdges)
Also updates hiddenNodes
and hiddenEdges
.
v
- the node that will be unhiddenunhideAdjacentEdges
- whether of not to unhide previously hidden edges connected at v
whose other end point is not hidden, i.e. it is
part of the graph.public void unhideNodes()
Note that this method does not unhide hidden edges.
public void unhideNodes(NodeList nodes, boolean unhideAdjacentEdges)
Also updates hiddenNodes
and hiddenEdges
.
nodes
- the nodes that will be unhiddenunhideAdjacentEdges
- whether of not to unhide previously hidden edges connected at the given nodes whose other end point is not hidden, i.e.
it is part of the graph.public static final void unhideSubgraph(Graph graph, IEdgeCursor ec)
The induced subgraph defined by the given edges consists of the given edges and all nodes that are either source or target of at least one of the given edges.
Parts of the subgraph that are already contained in the given graph will not be unhidden and pose no problem to this method.