use of com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLabelContent in project binnavi by google.
the class CSearchResultsDialog method setResults.
/**
* Fills the search results table model with search results data.
*
* @param results The search results data.
*/
private void setResults(final List<SearchResult> results) {
final Object[][] data = new Object[results.size()][1];
int counter = 0;
for (final SearchResult result : results) {
if (result.getObject() instanceof NaviNode) {
final NaviNode node = (NaviNode) result.getObject();
final ZyLabelContent labelContent = node.getRealizer().getNodeContent();
final String lineText = labelContent.getLineContent(result.getLine()).getText();
data[counter++][0] = lineText;
} else if (result.getObject() instanceof NaviEdge) {
final NaviEdge edge = (NaviEdge) result.getObject();
final ZyLabelContent labelContent = edge.getLabelContent();
final String lineText = labelContent.getLineContent(result.getLine()).getText();
data[counter++][0] = lineText;
}
}
m_table.setModel(new CResultsTableModel(data, new String[] { "Result" }));
m_resultsLabel.setText(String.format("%d search results", data.length));
}
use of com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLabelContent in project binnavi by google.
the class ZyEdgeBuilder method convertEdge.
/**
* Creates a graph node from a raw edge.
*
* @param edge The raw edge that provides the underlying data.
* @param sourceNode Source node of the edge.
* @param targetNode Target node of the edge.
* @param graph2D The graph object where the edge is created.
* @param adjustColors Flag that indicates whether the initial color of all edges should be
* recalculated according to their type.
*
* @return The created YNode/NaviNode pair.
*/
public static Pair<Edge, NaviEdge> convertEdge(final INaviEdge edge, final NaviNode sourceNode, final NaviNode targetNode, final Graph2D graph2D, final boolean adjustColors) {
// Build the edge label if necessary
final ZyLabelContent content = ZyEdgeBuilder.buildContent(edge);
// Create the edge realizer of the new edge
final ZyEdgeRealizer<NaviEdge> realizer = new ZyEdgeRealizer<NaviEdge>(content, new CEdgeUpdater(edge));
// Create the edge
final Edge g2dEdge = graph2D.createEdge(sourceNode.getNode(), targetNode.getNode(), realizer);
if (adjustColors) {
EdgeInitializer.adjustColor(edge);
}
EdgeInitializer.initializeEdgeType(edge, realizer);
graph2D.getRealizer(g2dEdge).setLineColor(edge.getColor());
// Associate user data with the edge
final NaviEdge zyEdge = new NaviEdge(sourceNode, targetNode, g2dEdge, realizer, edge);
NaviNode.link(sourceNode, targetNode);
final ZyEdgeData<NaviEdge> data = new ZyEdgeData<NaviEdge>(zyEdge);
realizer.setUserData(data);
return new Pair<Edge, NaviEdge>(g2dEdge, zyEdge);
}
use of com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLabelContent in project binnavi by google.
the class CAbstractKeyBehavior method updateLabelSize.
private void updateLabelSize() {
final ZyLabelContent labelContent = getLabelContent();
final IZyEditableObject labelModel = labelContent.getModel();
labelContent.getLineEditor().recreateLabelLines(labelContent, labelModel);
}
use of com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLabelContent in project binnavi by google.
the class CCursorKeyBehavior method handleNotShiftAndNotCtrl.
protected void handleNotShiftAndNotCtrl(final int xdelta, final int ydelta) {
final ZyLabelContent labelContent = getLabelContent();
int caretStartPos_X = getCaretStartPosX();
int mousePressed_X = getCaretMousePressedX();
int mousePressed_Y = getCaretMousePressedY();
int caretEndPos_X = getCaretEndPosX();
int mouseReleased_X = getCaretMouseReleasedX();
int mouseReleased_Y = getCaretMouseReleasedY();
if (isSelection() && (xdelta != 0) && (ydelta == 0)) {
if ((mousePressed_Y <= mouseReleased_Y) && (mousePressed_X <= mouseReleased_X)) {
if (xdelta < 0) {
mouseReleased_X = mousePressed_X;
caretEndPos_X = caretStartPos_X;
mouseReleased_Y = mousePressed_Y;
} else {
mousePressed_X = mouseReleased_X;
caretStartPos_X = mouseReleased_X;
mousePressed_Y = mouseReleased_Y;
}
} else {
if (xdelta > 0) {
mouseReleased_X = mousePressed_X;
caretEndPos_X = caretStartPos_X;
mouseReleased_Y = mousePressed_Y;
} else {
mousePressed_X = mouseReleased_X;
caretStartPos_X = mouseReleased_X;
mousePressed_Y = mouseReleased_Y;
}
}
} else {
mousePressed_X = mouseReleased_X;
mousePressed_Y = mouseReleased_Y;
mousePressed_Y += ydelta;
if (mousePressed_Y < 0) {
mousePressed_Y = 0;
}
if (mousePressed_Y > (labelContent.getLineCount() - 1)) {
mousePressed_Y = labelContent.getLineCount() - 1;
}
mouseReleased_Y = mousePressed_Y;
mousePressed_X += xdelta;
if (mousePressed_X < 0) {
mousePressed_X = 0;
}
if (mousePressed_X > (labelContent.getLineContent(mouseReleased_Y).getTextLayout().getCharacterCount() - 1)) {
mousePressed_X = labelContent.getLineContent(mouseReleased_Y).getTextLayout().getCharacterCount();
}
caretEndPos_X = mousePressed_X;
mouseReleased_X = mousePressed_X;
caretStartPos_X = caretEndPos_X;
}
mouseReleased_X = correctMouseReleasedX(mouseReleased_X, mouseReleased_Y, mousePressed_Y);
setCaret(caretStartPos_X, mousePressed_X, mousePressed_Y, caretEndPos_X, mouseReleased_X, mouseReleased_Y);
}
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);
}
}
Aggregations