use of y.view.hierarchy.HierarchyManager in project binnavi by google.
the class ZyGraphLayeredRenderer method isAnyParentNodeSelected.
/**
* Determines whether any of the parent nodes of the given node is selected.
*/
private boolean isAnyParentNodeSelected(final Node n) {
final Graph2D graph = (Graph2D) n.getGraph();
final HierarchyManager hierarchy = graph.getHierarchyManager();
if (hierarchy == null) {
return false;
}
boolean result = false;
Node parent = hierarchy.getParentNode(n);
while (parent != null) {
if (graph.isSelected(parent)) {
result = true;
break;
}
parent = hierarchy.getParentNode(parent);
}
return result;
}
use of y.view.hierarchy.HierarchyManager in project binnavi by google.
the class AbstractZyGraph method removeNode.
protected void removeNode(final NodeType node) {
if (node.getNode().getGraph() == null) {
m_graph.reInsertNode(node.getNode());
}
final HierarchyManager manager = m_graph.getHierarchyManager();
final Node n = node.getNode();
if (manager.isNormalNode(n)) {
m_graph.removeNode(node.getNode());
} else if (getGraph().getHierarchyManager().isFolderNode(node.getNode())) {
GroupHelpers.extractFolder(m_graph, node.getNode());
m_graph.removeNode(node.getNode());
} else if (getGraph().getHierarchyManager().isGroupNode(node.getNode())) {
GroupHelpers.extractGroup(m_graph, node.getNode());
m_graph.removeNode(node.getNode());
}
m_mappings.removeNode(node);
}
use of y.view.hierarchy.HierarchyManager in project binnavi by google.
the class GraphSearcherTest method testSearchVisible.
@Test
public void testSearchVisible() throws CouldntLoadDataException, CPartialLoadException, LoadCancelledException {
final MockSqlProvider sql = new MockSqlProvider();
final CModule module = MockCreator.createModule(sql);
module.load();
final CFunction function = MockCreator.createFunction(module, sql);
final CView m_view = MockCreator.createView(sql, module);
final CInstruction instruction1 = MockCreator.createInstruction(module, sql);
final CInstruction instruction2 = MockCreator.createInstruction(module, sql);
final CInstruction instruction3 = MockCreator.createInstruction(module, sql);
m_view.load();
final CCodeNode node1 = m_view.getContent().createCodeNode(function, Lists.newArrayList(instruction1, instruction2, instruction3));
final CCodeNode node2 = m_view.getContent().createCodeNode(function, Lists.newArrayList(instruction1, instruction2, instruction3));
final CCodeNode node3 = m_view.getContent().createCodeNode(function, Lists.newArrayList(instruction1, instruction2, instruction3));
final ZyNodeRealizer<NaviNode> r1 = new ZyNormalNodeRealizer<NaviNode>(m_content);
final ZyNodeRealizer<NaviNode> r2 = new ZyNormalNodeRealizer<NaviNode>(m_content);
final ZyNodeRealizer<NaviNode> r3 = new ZyNormalNodeRealizer<NaviNode>(m_content);
final Graph2D g = new Graph2D();
g.setHierarchyManager(new HierarchyManager(g));
final NaviNode m_node1 = new NaviNode(g.createNode(), r1, node1);
final NaviNode m_node2 = new NaviNode(g.createNode(), r2, node2);
final NaviNode m_node3 = new NaviNode(g.createNode(), r3, node3);
assertTrue(m_node1.isVisible());
final GraphSearcher searcher = new GraphSearcher();
searcher.getSettings().setOnlyVisible(true);
m_content.addLineContent(new ZyLineContent("Hello my Test", null));
searcher.search(Lists.newArrayList(m_node1, m_node2, m_node3), new ArrayList<NaviEdge>(), "my");
assertEquals(m_node1, searcher.getCursor().current().getObject());
assertEquals(0, searcher.getCursor().current().getLine());
assertEquals(6, searcher.getCursor().current().getPosition());
assertEquals(2, searcher.getCursor().current().getLength());
searcher.getCursor().next();
assertEquals(m_node2, searcher.getCursor().current().getObject());
assertEquals(0, searcher.getCursor().current().getLine());
assertEquals(6, searcher.getCursor().current().getPosition());
assertEquals(2, searcher.getCursor().current().getLength());
searcher.getCursor().next();
assertEquals(m_node3, searcher.getCursor().current().getObject());
assertEquals(0, searcher.getCursor().current().getLine());
assertEquals(6, searcher.getCursor().current().getPosition());
assertEquals(2, searcher.getCursor().current().getLength());
m_node2.getRawNode().setVisible(false);
searcher.search(Lists.newArrayList(m_node1, m_node2, m_node3), new ArrayList<NaviEdge>(), "my");
assertEquals(m_node1, searcher.getCursor().current().getObject());
assertEquals(0, searcher.getCursor().current().getLine());
assertEquals(6, searcher.getCursor().current().getPosition());
assertEquals(2, searcher.getCursor().current().getLength());
searcher.getCursor().next();
assertEquals(m_node3, searcher.getCursor().current().getObject());
assertEquals(0, searcher.getCursor().current().getLine());
assertEquals(6, searcher.getCursor().current().getPosition());
assertEquals(2, searcher.getCursor().current().getLength());
}
Aggregations