use of com.google.security.zynamics.zylib.gui.zygraph.nodes.IGroupNode in project binnavi by google.
the class CDefaultNodeClickedLeftAction method execute.
@Override
public void execute(final CNodeClickedLeftState<NodeType, EdgeType> state, final MouseEvent event) {
CMouseCursorHelper.setDefaultCursor(state.getGraph());
final AbstractZyGraph<NodeType, EdgeType> graph = state.getGraph();
final Node n = state.getNode();
final NodeType node = graph.getNode(n);
final double x = graph.getEditMode().translateX(event.getX());
final double y = graph.getEditMode().translateY(event.getY());
final CStateFactory<NodeType, EdgeType> factory = state.getStateFactory();
if (ProximityHelper.isProximityNode(state.getGraph().getGraph(), n)) {
CEditNodeHelper.removeCaret(graph);
final ZyProximityNode<?> proximityNode = ProximityHelper.getProximityNode(graph.getGraph(), n);
for (final IZyEditModeListener<NodeType, EdgeType> listener : factory.getListeners()) {
try {
listener.proximityBrowserNodeClicked(proximityNode, event, x, y);
} catch (final Exception exception) {
// TODO: (timkornau): implement logging here.
}
}
} else if ((node != null) && (node.getRawNode() instanceof IGroupNode)) {
CEditNodeHelper.removeCaret(graph);
final GroupNodeRealizer gnr = (GroupNodeRealizer) graph.getGraph().getRealizer(node.getNode());
final NodeLabel handle = gnr.getStateLabel();
if (handle.getBox().contains(x, y)) {
// Clicks on the X in the group node corner
toggleGroup(node);
} else if (SwingUtilities.isLeftMouseButton(event)) {
if ((event.getClickCount() == 2) && event.isControlDown()) {
// CTRL-LEFT-DOUBLECLICK
toggleGroup(node);
} else if (event.getClickCount() == 1) {
CGraphSelector.selectNode(graph, node, event.isShiftDown());
}
}
} else {
if (node != null) {
if (graph.getEditMode().getLabelEventHandler().isActiveLabel(node.getRealizer().getNodeContent())) {
CEditNodeHelper.setCaretEnd(graph, state.getNode(), event);
} else {
if (graph.getEditMode().getLabelEventHandler().isActive()) {
CEditNodeHelper.removeCaret(graph);
}
final Set<NodeType> selectedNodes = graph.getSelectedNodes();
if (event.isShiftDown() && (selectedNodes.size() >= 1)) {
CGraphSelector.selectPath(graph, new ArrayList<NodeType>(selectedNodes), node);
} else if (event.isControlDown()) {
graph.selectNode(node, !node.isSelected());
} else {
final Collection<NodeType> toUnselect = new ArrayList<NodeType>(graph.getNodes());
toUnselect.remove(node);
final Collection<NodeType> toSelect = new ArrayList<NodeType>();
toSelect.add(node);
graph.selectNodes(toSelect, toUnselect);
}
}
for (final IZyEditModeListener<NodeType, EdgeType> listener : factory.getListeners()) {
// ESCA-JAVA0166: Catch Exception because we are calling a listener function
try {
listener.nodeClicked(node, event, x, y);
} catch (final Exception exception) {
// TODO: (timkornau): implement logging here.
}
}
}
}
}
use of com.google.security.zynamics.zylib.gui.zygraph.nodes.IGroupNode in project binnavi by google.
the class ProximityRangeCalculator method getSuccessorsInternal.
private static void getSuccessorsInternal(final ViewNodeAdapter node, final int depth, final Set<ViewNodeAdapter> nodes, final HashSet<ViewNodeAdapter> visited) {
for (final ViewNodeAdapter child : node.getChildren()) {
if (/* visited.contains(child) || */
(depth <= 0) && !(child.getNode() instanceof ITextNode)) {
continue;
} else if (child.getNode().getParentGroup() != null) {
IGroupNode<?, ?> previousNode = child.getNode().getParentGroup();
while (previousNode != null) {
if (!visited(visited, previousNode)) {
final ViewNodeAdapter groupNodeAdapter = new ViewNodeAdapter(previousNode);
visited.add(groupNodeAdapter);
nodes.add(groupNodeAdapter);
previousNode = previousNode.getParentGroup();
} else {
previousNode = null;
}
}
}
if (NodeHelpers.getVisibleNode(child.getNode()) != child.getNode()) {
continue;
}
visited.add(child);
nodes.add(child);
// Silly trick to make attached text nodes visible.
getPredecessorsInternal(child, -1, nodes, new HashSet<ViewNodeAdapter>());
getSuccessorsInternal(child, depth - 1, nodes, visited);
}
}
use of com.google.security.zynamics.zylib.gui.zygraph.nodes.IGroupNode in project binnavi by google.
the class ProximityRangeCalculator method getPredecessorsInternal.
private static void getPredecessorsInternal(final ViewNodeAdapter node, final int depth, final Set<ViewNodeAdapter> nodes, final Set<ViewNodeAdapter> visited) {
for (final ViewNodeAdapter parent : node.getParents()) {
if (/* visited.contains(parent) || */
(depth <= 0) && !(parent.getNode() instanceof ITextNode)) {
// NH: see getSuccessorsInternal for comment
continue;
} else if (parent.getNode().getParentGroup() != null) {
IGroupNode<?, ?> previousNode = parent.getNode().getParentGroup();
while (previousNode != null) {
if (!visited(visited, previousNode)) {
final ViewNodeAdapter groupNodeAdapter = new ViewNodeAdapter(previousNode);
visited.add(groupNodeAdapter);
nodes.add(groupNodeAdapter);
previousNode = previousNode.getParentGroup();
} else {
previousNode = null;
}
}
}
visited.add(parent);
nodes.add(parent);
// Silly trick to make the attached text nodes visible
getSuccessorsInternal(parent, -1, nodes, new HashSet<ViewNodeAdapter>());
getPredecessorsInternal(parent, depth - 1, nodes, visited);
}
}
Aggregations