use of com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLabelContent in project binnavi by google.
the class CCursorKeyBehavior method handleNotShiftAndCtrl.
protected void handleNotShiftAndCtrl(final int xdelta, final int ydelta) {
final ZyLabelContent labelContent = getLabelContent();
int caretStartPos_X = getCaretStartPosX();
int mousePressed_X = getCaretMousePressedX();
final int mousePressed_Y = getCaretMousePressedY();
int caretEndPos_X = getCaretEndPosX();
int mouseReleased_X = getCaretMouseReleasedX();
final int mouseReleased_Y = getCaretMouseReleasedY();
if (xdelta != 0) {
final ZyLineContent lineContent = labelContent.getLineContent(mouseReleased_Y);
final String s = lineContent.getText() + " ";
if (xdelta > 0) {
final boolean firstIsSpace = s.charAt(caretEndPos_X) == ' ';
int endindex = 0;
for (int i = caretEndPos_X; i < s.length(); ++i) {
endindex = i;
if (firstIsSpace) {
if (s.charAt(i) != ' ') {
break;
}
} else {
if (s.charAt(i) == ' ') {
break;
}
}
}
if ((lineContent.getText().endsWith("\n") || lineContent.getText().endsWith("\r")) && (lineContent.getText().length() == endindex)) {
endindex -= 1;
}
caretStartPos_X = endindex;
mousePressed_X = endindex;
mouseReleased_X = endindex;
caretEndPos_X = endindex;
} else if (xdelta < 0) {
if (caretEndPos_X == 0) {
return;
}
final boolean firstIsSpace = s.charAt(caretEndPos_X - 1) == ' ';
int startindex = caretEndPos_X - 1;
for (int i = caretEndPos_X - 1; i >= 0; --i) {
if (firstIsSpace) {
if (s.charAt(i) != ' ') {
break;
}
} else {
if (s.charAt(i) == ' ') {
break;
}
}
startindex = i;
}
caretStartPos_X = startindex;
mousePressed_X = startindex;
mouseReleased_X = startindex;
caretEndPos_X = startindex;
}
mouseReleased_X = correctMouseReleasedX(mouseReleased_X, mouseReleased_Y, mousePressed_Y);
setCaret(caretStartPos_X, mousePressed_X, mousePressed_Y, caretEndPos_X, mouseReleased_X, mouseReleased_Y);
} else if (ydelta != 0) {
handleNotShiftAndNotCtrl(0, ydelta);
}
}
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);
}
Aggregations