use of y.base.Node in project binnavi by google.
the class CNodeEditState method mouseReleased.
@Override
public IMouseStateChange mouseReleased(final MouseEvent event, final AbstractZyGraph<?, ?> graph) {
final double x = graph.getEditMode().translateX(event.getX());
final double y = graph.getEditMode().translateY(event.getY());
final HitInfo hitInfo = graph.getGraph().getHitInfo(x, y);
if (hitInfo.hasHitNodes()) {
final Node n = hitInfo.getHitNode();
if (SwingUtilities.isLeftMouseButton(event) && !event.isAltDown()) {
if (n == m_node) {
if (!m_isDragging) {
// Change caret
CEditNodeHelper.setCaretEnd(graph, n, event);
} else {
m_isDragging = false;
}
return new CStateChange(this, false);
} else {
m_factory.createNodeEditExitState(m_node, event);
return new CStateChange(m_factory.createNodePressedLeftState(n, event), true);
}
} else if (SwingUtilities.isRightMouseButton(event)) {
if (n == m_node) {
return new CStateChange(this, false);
} else {
m_factory.createNodeEditExitState(m_node, event);
return new CStateChange(m_factory.createNodePressedRightState(n, event), true);
}
} else if (SwingUtilities.isMiddleMouseButton(event) || (event.isAltDown() && SwingUtilities.isLeftMouseButton(event))) {
if (n == m_node) {
if (!m_isDragging) {
// Change caret
CEditNodeHelper.setCaretEnd(graph, n, event);
} else {
m_isDragging = false;
}
return new CStateChange(this, false);
} else {
m_factory.createNodeEditExitState(m_node, event);
return new CStateChange(m_factory.createNodePressedMiddleState(n, event), true);
}
} else {
return new CStateChange(this, false);
}
} else if (hitInfo.hasHitNodeLabels()) {
throw new IllegalStateException();
} else if (hitInfo.hasHitEdges()) {
m_factory.createNodeEditExitState(m_node, event);
return new CStateChange(m_factory.createEdgePressedLeftState(hitInfo.getHitEdge(), event), true);
} else if (hitInfo.hasHitEdgeLabels()) {
m_factory.createNodeEditExitState(m_node, event);
return new CStateChange(m_factory.createEdgePressedLeftState(hitInfo.getHitEdgeLabel().getEdge(), event), true);
} else if (hitInfo.hasHitBends()) {
m_factory.createNodeEditExitState(m_node, event);
return new CStateChange(m_factory.createBendPressedLeftState(hitInfo.getHitBend(), event), true);
} else if (hitInfo.hasHitPorts()) {
m_factory.createNodeEditExitState(m_node, event);
return new CStateChange(m_factory.createDefaultState(), true);
} else {
// User left-pressed the background.
m_factory.createNodeEditExitState(m_node, event);
return new CStateChange(m_factory.createBackgroundPressedLeftState(event), true);
}
}
use of y.base.Node in project binnavi by google.
the class CReilInstructionGraph method createInstructionNode.
/**
* Creates an instruction graph node
*
* @param reilInstruction The REIL instruction which will be contained in the node.
*
* @return The yfiles node which has been created and inserted in the graph.
*/
private Node createInstructionNode(final ReilInstruction reilInstruction) {
final Node node = m_internalGraph.createNode();
m_nodesMap.put(node, new ReilInstructionGraphNode(reilInstruction));
return node;
}
use of y.base.Node in project binnavi by google.
the class ZyDefaultProximityBrowser method deleteProximityBrowsingNodes.
/**
* Removes all proximity browsing nodes from the graph.
*/
protected void deleteProximityBrowsingNodes() {
// each node deletion triggers the selection state listener
// which updates proximity browsing automatically
// this is suppressed here by setting m_isActive temporarily to false
m_internallyDisabled = true;
for (final Node node : m_proximityMap.keySet()) {
m_graph.getGraph().removeNode(node);
}
m_proximityMap.clear();
for (final Entry<ZyProximityNode<?>, InternalNodeListener> entry : m_nodeListeners.entrySet()) {
((IViewNode<?>) entry.getKey().getRawNode().getAttachedNode()).removeListener(entry.getValue());
}
m_nodeListeners.clear();
m_internallyDisabled = false;
}
use of y.base.Node in project binnavi by google.
the class CBreakpointTableTest method testAddedDebugger.
/**
* This test is making sure that listeners are correctly attached to new debuggers.
*
* @throws CouldntSaveDataException
* @throws FileReadException
*/
@Test
public void testAddedDebugger() throws CouldntSaveDataException, FileReadException {
ConfigManager.instance().read();
final INaviModule mockModule = new MockModule();
final DebugTargetSettings target = new ModuleTargetSettings(mockModule);
final DebuggerProvider debuggerProvider = new DebuggerProvider(target);
final ZyGraphViewSettings settings = new ZyGraphViewSettings(new FlowGraphSettingsConfigItem());
settings.getLayoutSettings().setDefaultGraphLayout(LayoutStyle.CIRCULAR);
final ZyGraph graph = new ZyGraph(new MockView(), new LinkedHashMap<Node, NaviNode>(), new LinkedHashMap<Edge, NaviEdge>(), settings, new ZyGraph2DView());
final IViewContainer viewContainer = new MockViewContainer();
final CBreakpointTable table = new CBreakpointTable(debuggerProvider, graph, viewContainer);
final MockDebugger debugger = new MockDebugger(new ModuleTargetSettings(mockModule));
final MockModule module = new MockModule();
debugger.getBreakpointManager().addBreakpoints(BreakpointType.REGULAR, Sets.newHashSet(new BreakpointAddress(module, new UnrelocatedAddress(new CAddress(0)))));
debuggerProvider.addDebugger(debugger);
table.dispose();
}
use of y.base.Node 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;
}
Aggregations