-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added #HierarchicalGraphView api and unit tests
- Loading branch information
Showing
14 changed files
with
2,576 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
store/src/main/java/org/gephi/graph/api/HierarchicalGraphView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package org.gephi.graph.api; | ||
|
||
/** | ||
* A hierarchical graph view which allows for collapsible sub-groups. Each node, | ||
* whether it is collapsed or extended, should be in core in view. If a node is | ||
* node is hidden by collapsed parent, it will omitted within | ||
* directed/undirected graph queries. | ||
*/ | ||
public interface HierarchicalGraphView extends GraphView { | ||
/** | ||
* @return Return iterator for each hierarchical node group. | ||
*/ | ||
Iterable<HierarchicalNodeGroup> getGroups(); | ||
|
||
/** | ||
* @return Return root node which first-tier nodes should be attached. | ||
*/ | ||
HierarchicalNodeGroup getRoot(); | ||
|
||
/** | ||
* @param node node within graph graph | ||
* @return Return existing hierarchical group if available; else null. | ||
*/ | ||
HierarchicalNodeGroup getGroup(Node node); | ||
} |
54 changes: 54 additions & 0 deletions
54
store/src/main/java/org/gephi/graph/api/HierarchicalNodeGroup.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package org.gephi.graph.api; | ||
|
||
/** | ||
* A group of nodes within a hierarchical graph view. | ||
*/ | ||
public interface HierarchicalNodeGroup { | ||
/** | ||
* @return Returns true if the group is collapsed, which means the children | ||
* are hidden from visible graph. | ||
*/ | ||
boolean isCollapsed(); | ||
|
||
/** | ||
* @return Returns true if the group is expanded, which means the children | ||
* are visible within visible graph. | ||
*/ | ||
boolean isExpanded(); | ||
|
||
/** | ||
* Expand node, displaying children. | ||
*/ | ||
void expand(); | ||
|
||
/** | ||
* Collapse node, hiding children. | ||
*/ | ||
void collapse(); | ||
|
||
/** | ||
* @return Return iterator containing children nodes (not recursive). | ||
*/ | ||
Iterable<Node> getNodes(); | ||
|
||
/** | ||
* @return Return iterator containing children nodes. | ||
*/ | ||
Iterable<Node> getNodes(boolean recursive); | ||
|
||
/** | ||
* Add node to this group. | ||
* | ||
* @param node child node | ||
* @return Returns child hierarchical group, if created; else null. | ||
*/ | ||
HierarchicalNodeGroup addNode(Node node); | ||
|
||
/** | ||
* Remove node from group. | ||
* | ||
* @param node child node | ||
* @return Returns true if child hierarchical group was remoce; else false. | ||
*/ | ||
boolean removeNode(Node node); | ||
} |
105 changes: 105 additions & 0 deletions
105
store/src/main/java/org/gephi/graph/impl/AbstractGraphView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
package org.gephi.graph.impl; | ||
|
||
import org.gephi.graph.api.DirectedSubgraph; | ||
import org.gephi.graph.api.Graph; | ||
import org.gephi.graph.api.GraphObserver; | ||
import org.gephi.graph.api.GraphView; | ||
import org.gephi.graph.api.Interval; | ||
import org.gephi.graph.api.UndirectedSubgraph; | ||
|
||
abstract public class AbstractGraphView implements GraphView { | ||
protected final GraphStore graphStore; | ||
|
||
protected final GraphAttributesImpl attributes; | ||
|
||
protected final boolean nodeView; | ||
|
||
protected final boolean edgeView; | ||
|
||
private Interval interval; | ||
|
||
private int storeId = GraphViewStore.NULL_VIEW; | ||
|
||
public AbstractGraphView(final GraphStore store, boolean nodes, boolean edges) { | ||
this.graphStore = store; | ||
this.nodeView = nodes; | ||
this.edgeView = edges; | ||
this.interval = Interval.INFINITY_INTERVAL; | ||
this.attributes = new GraphAttributesImpl(); | ||
} | ||
|
||
public AbstractGraphView(final AbstractGraphView view, boolean nodes, boolean edges) { | ||
this.graphStore = view.graphStore; | ||
this.nodeView = nodes; | ||
this.edgeView = edges; | ||
this.interval = view.interval; | ||
this.attributes = new GraphAttributesImpl(); | ||
} | ||
|
||
public int getStoreId() { | ||
return this.storeId; | ||
} | ||
|
||
protected void setStoreId(final int id) { | ||
this.storeId = id; | ||
} | ||
|
||
@Override | ||
public boolean isDestroyed() { | ||
return GraphViewStore.NULL_VIEW == this.storeId; | ||
} | ||
|
||
@Override | ||
public GraphModelImpl getGraphModel() { | ||
return this.graphStore.graphModel; | ||
} | ||
|
||
@Override | ||
public boolean isMainView() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean isNodeView() { | ||
return this.nodeView; | ||
} | ||
|
||
@Override | ||
public boolean isEdgeView() { | ||
return this.edgeView; | ||
} | ||
|
||
public void setTimeInterval(Interval interval) { | ||
if (interval == null) { | ||
interval = Interval.INFINITY_INTERVAL; | ||
} | ||
this.interval = interval; | ||
} | ||
|
||
@Override | ||
public Interval getTimeInterval() { | ||
return this.interval; | ||
} | ||
|
||
abstract public DirectedSubgraph getDirectedGraph(); | ||
|
||
abstract public UndirectedSubgraph getUndirectedGraph(); | ||
|
||
abstract public boolean deepEquals(AbstractGraphView view); | ||
|
||
abstract public int deepHashCode(); | ||
|
||
abstract protected void viewDestroyed(); | ||
|
||
abstract protected void nodeAdded(NodeImpl node); | ||
|
||
abstract protected void nodeRemoved(NodeImpl node); | ||
|
||
abstract protected void edgeAdded(EdgeImpl edge); | ||
|
||
abstract protected void edgeRemoved(EdgeImpl edge); | ||
|
||
abstract protected GraphObserverImpl createGraphObserver(Graph graph, boolean withDiff); | ||
|
||
abstract protected void destroyGraphObserver(GraphObserver graphObserver); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.