use of com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLabelContent in project binnavi by google.
the class CDefaultNodePressedLeftAction method execute.
@Override
public void execute(final CNodePressedLeftState<NodeType, EdgeType> state, final MouseEvent event) {
final AbstractZyGraph<NodeType, EdgeType> graph = state.getGraph();
final NodeType draggedNode = graph.getNode(state.getNode());
if (draggedNode != null) {
final ZyLabelContent labelContent = draggedNode.getRealizer().getNodeContent();
if (graph.getEditMode().getLabelEventHandler().isActiveLabel(labelContent)) {
CEditNodeHelper.setCaretStart(graph, state.getNode(), event);
CEditNodeHelper.setCaretEnd(graph, state.getNode(), event);
} else {
CEditNodeHelper.removeCaret(graph);
}
} else {
CEditNodeHelper.removeCaret(graph);
}
}
use of com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLabelContent in project binnavi by google.
the class ClipboardCopier method copyToClipboard.
/**
* Copies the text content of a node to the clip board.
*
* @param node The node to copy to the clip board.
*/
public static void copyToClipboard(final ZyGraphNode<?> node) {
Preconditions.checkNotNull(node, "Error: Node argument can not be null");
final IZyNodeRealizer realizer = node.getRealizer();
final ZyLabelContent content = realizer.getNodeContent();
if (content.isSelectable()) {
final ZyLabelContent zyContent = content;
final StringBuilder textBuilder = new StringBuilder();
for (final ZyLineContent zyLineContent : zyContent) {
textBuilder.append(zyLineContent.getText());
//$NON-NLS-1$
textBuilder.append("\n");
}
ClipboardHelpers.copyToClipboard(textBuilder.toString());
}
}
use of com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLabelContent in project binnavi by google.
the class CEndKeyBehavior method updateCaret.
@Override
protected void updateCaret() {
if (!isShiftPressed() && !isCtrlPressed()) {
final int yPos = getCaretMouseReleasedY();
final int lastXPos = getLastLineXPos(yPos);
setCaret(lastXPos, lastXPos, yPos, lastXPos, lastXPos, yPos);
} else if (isShiftPressed() && !isCtrlPressed()) {
final int ypos = getCaretMouseReleasedY();
final int lastXPos = getLineContent(ypos).getTextLayout().getCharacterCount();
int mouseReleased_X = lastXPos;
final ZyLineContent lineContent = getLineContent(getCaretMouseReleasedY());
final boolean noReturn = getCaretEndPosX() == lineContent.getText().length();
final boolean withReturn = lineContent.getText().endsWith("\n") && (getCaretEndPosX() == (lineContent.getText().length() - 1));
final boolean withCReturn = lineContent.getText().endsWith("\r") && (getCaretEndPosX() == (lineContent.getText().length() - 1));
if (noReturn || withReturn || withCReturn) {
mouseReleased_X = getMaxLineLength(getCaretMousePressedY(), getCaretMouseReleasedY());
}
if ((lineContent.getText().endsWith("\n") || lineContent.getText().endsWith("\r")) && (mouseReleased_X > 0)) {
mouseReleased_X -= 1;
}
setCaret(getCaretStartPosX(), getCaretMousePressedX(), getCaretMousePressedY(), lastXPos, mouseReleased_X, ypos);
} else if (!isShiftPressed() && isCtrlPressed()) {
final ZyLabelContent labelContent = getLabelContent();
final int lastXPos = labelContent.getLineContent(labelContent.getLineCount() - 1).getText().length();
final int lastYPos = labelContent.getLineCount() - 1;
setCaret(lastXPos, lastXPos, lastYPos, lastXPos, lastXPos, lastYPos);
} else if (isShiftPressed() && isCtrlPressed()) {
final int lastYPos = getLabelContent().getLineCount() - 1;
final int lastXPos = getLabelContent().getLineContent(lastYPos).getText().length();
setCaret(getCaretStartPosX(), getCaretMousePressedX(), getCaretMousePressedY(), lastXPos, lastXPos, lastYPos);
}
}
use of com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLabelContent in project binnavi by google.
the class View2DTest method setUp.
@Before
public void setUp() throws CouldntLoadDataException, LoadCancelledException, FileReadException {
ConfigManager.instance().read();
final MockDatabase database = new MockDatabase();
final CModule module = new CModule(1, "", "", new Date(), new Date(), "00000000000000000000000000000000", "0000000000000000000000000000000000000000", 0, 0, new CAddress(0), new CAddress(0), null, null, Integer.MAX_VALUE, false, new MockSqlProvider());
database.getContent().addModule(module);
manager.addDatabase(database);
module.load();
m_view = module.getContent().getViewContainer().createView("name", "description");
final ZyGraphViewSettings settings = new ZyGraphViewSettings(new CallGraphSettingsConfigItem());
settings.getLayoutSettings().setDefaultGraphLayout(LayoutStyle.CIRCULAR);
final ZyGraph2DView g2dView = new ZyGraph2DView();
final LinkedHashMap<Node, NaviNode> nodeMap = new LinkedHashMap<Node, NaviNode>();
final LinkedHashMap<Edge, NaviEdge> edgeMap = new LinkedHashMap<Edge, NaviEdge>();
final Node node1 = g2dView.getGraph2D().createNode();
final CTextNode rawNode1 = m_view.getContent().createTextNode(Lists.<IComment>newArrayList(new CComment(null, CommonTestObjects.TEST_USER_1, null, " TEXT NODE ")));
nodeMap.put(node1, new NaviNode(node1, new ZyNormalNodeRealizer<NaviNode>(new ZyLabelContent(null)), rawNode1));
final Node node2 = g2dView.getGraph2D().createNode();
final CTextNode rawNode2 = m_view.getContent().createTextNode(Lists.<IComment>newArrayList(new CComment(null, CommonTestObjects.TEST_USER_1, null, " TEXT COMMENT ")));
nodeMap.put(node2, new NaviNode(node2, new ZyNormalNodeRealizer<NaviNode>(new ZyLabelContent(null)), rawNode2));
final Edge edge = g2dView.getGraph2D().createEdge(node1, node2);
final INaviEdge rawEdge = m_view.getContent().createEdge(rawNode1, rawNode2, com.google.security.zynamics.zylib.gui.zygraph.edges.EdgeType.JUMP_CONDITIONAL_FALSE);
edgeMap.put(edge, new NaviEdge(nodeMap.get(node1), nodeMap.get(node2), edge, new ZyEdgeRealizer<NaviEdge>(new ZyLabelContent(null), null), rawEdge));
final ZyGraph graph = new ZyGraph(m_view, nodeMap, edgeMap, settings, g2dView);
m_view2d = new View2D(database, new CModuleContainer(database, module), graph, pluginInterface);
}
use of com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLabelContent in project binnavi by google.
the class ProximityNodeCreator method insertProximityEdge.
/**
* Inserts a proximity edge between two nodes. One of the two input nodes must be a proximity
* browsing node or an exception is thrown.
*
* @param graph The graph where the node is inserted.
* @param sourceNode The source node of the edge.
* @param targetNode The target node of the edge.
*
* @return The inserted edge.
*/
public static ZyInfoEdge insertProximityEdge(final Graph2D graph, final ZyGraphNode<?> sourceNode, final ZyGraphNode<?> targetNode) {
Preconditions.checkNotNull(graph, "Graph argument can not be null");
Preconditions.checkNotNull(sourceNode, "Source node argument can not be null");
Preconditions.checkNotNull(targetNode, "Target node argument can not be null");
Preconditions.checkArgument((sourceNode instanceof ZyProximityNode<?>) || (targetNode instanceof ZyProximityNode<?>), "One of the two arguments must be a proximity browsing node");
final ZyEdgeRealizer<ZyInfoEdge> r = new ZyEdgeRealizer<ZyInfoEdge>(new ZyLabelContent(null), null);
r.setLineType(LineType.LINE_2);
final Edge edge = graph.createEdge(sourceNode.getNode(), targetNode.getNode(), r);
final ZyInfoEdge infoEdge = new ZyInfoEdge(sourceNode, targetNode, edge, r);
final ZyEdgeData<ZyInfoEdge> data = new ZyEdgeData<ZyInfoEdge>(infoEdge);
r.setUserData(data);
return infoEdge;
}
Aggregations