use of com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.proximity.ZyProximityNode 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.yfileswrap.gui.zygraph.proximity.ZyProximityNode in project binnavi by google.
the class CDefaultNodeClickedRightAction method execute.
@Override
public void execute(final CNodeClickedRightState<NodeType, EdgeType> state, final MouseEvent event) {
CMouseCursorHelper.setDefaultCursor(state.getGraph());
final AbstractZyGraph<NodeType, EdgeType> graph = state.getGraph();
final Node yNode = state.getNode();
final NodeType node = graph.getNode(yNode);
final double x = graph.getEditMode().translateX(event.getX());
final double y = graph.getEditMode().translateY(event.getY());
if (graph.getEditMode().getLabelEventHandler().isActive() && graph.getEditMode().getLabelEventHandler().hasEmptySelection()) {
CEditNodeHelper.removeCaret(graph);
}
if (node == null) {
// Proximity node was clicked
final ZyProximityNode<?> proximityNode = ProximityHelper.getProximityNode(graph.getGraph(), yNode);
for (final IZyEditModeListener<NodeType, EdgeType> listener : state.getStateFactory().getListeners()) {
try {
listener.proximityBrowserNodeClicked(proximityNode, event, x, y);
} catch (final Exception exception) {
// TODO: (timkornau): implement logging here.
}
}
} else {
for (final IZyEditModeListener<NodeType, EdgeType> listener : state.getStateFactory().getListeners()) {
try {
listener.nodeClicked(node, event, x, y);
} catch (final Exception exception) {
// TODO: (timkornau): implement logging here.
}
}
}
}
use of com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.proximity.ZyProximityNode in project binnavi by google.
the class CSelectionMode method selectionBoxAction.
@Override
protected void selectionBoxAction(final Rectangle rect, final boolean shiftMode) {
m_graph.getGraph().firePreEvent();
final NodeList selectedNodes = new NodeList();
for (final NodeCursor node = m_graph.getGraph().nodes(); node.ok(); node.next()) {
final NodeType zyNode = m_graph.getNode(node.node());
if ((zyNode == null) || (zyNode instanceof ZyProximityNode<?>)) {
continue;
}
if (belongsToSelection(node.node(), rect)) {
selectedNodes.add(node.node());
}
}
if (((getLastDragEvent().getModifiersEx() & InputEvent.CTRL_DOWN_MASK) == 0) && ((getLastDragEvent().getModifiersEx() & InputEvent.SHIFT_DOWN_MASK) == 0)) {
m_graph.getGraph().unselectAll();
}
for (final Object nodeObject : selectedNodes) {
final Node node = (Node) nodeObject;
m_graph.getGraph().setSelected(node, true);
}
for (final EdgeCursor ec = m_graph.getGraph().selectedEdges(); ec.ok(); ec.next()) {
final Edge e = ec.edge();
final Node src = e.source();
final Node dst = e.target();
if (!m_graph.getGraph().getRealizer(src).isSelected() && !m_graph.getGraph().getRealizer(dst).isSelected()) {
m_graph.getGraph().getRealizer(e).setSelected(false);
}
}
m_graph.getGraph().firePostEvent();
m_graph.getGraph().updateViews();
}
Aggregations