use of com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent in project binnavi by google.
the class ZyGraphNode method setBackgroundColor.
/**
* Colorizes a complete line of the node in a given color.
*
* @param line The index of the line.
* @param color The color of the line.
*/
public void setBackgroundColor(final int line, final Color color) {
final ZyLineContent lineContent = m_realizer.getNodeContent().getLineContent(line);
lineContent.setBackgroundColor(color);
updateViews();
}
use of com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent in project binnavi by google.
the class ProximityNodeCreator method createProximityNode.
/**
* Creates a proximity browsing node.
*
* @param graph The graph where the proximity node is added to.
* @param attachedNode The graph node the proximity node is attached to.
* @param degree The edge degree of the attached node (this is the number shown in the proximity
* node).
* @param isIncoming True, to signal that the proximity node is incoming. False, if it is
* outcoming.
*
* @param <NodeType> Raw node type of the real (e.g. not proximity nodes) nodes in the graph.
*
* @return The created proximity node.
*/
public static <NodeType extends IViewNode<?>> ZyProximityNode<?> createProximityNode(final Graph2D graph, final ZyGraphNode<?> attachedNode, final int degree, final boolean isIncoming) {
Preconditions.checkNotNull(graph, "Graph argument can not be null");
Preconditions.checkNotNull(attachedNode, "Target node argument can not be null");
final ZyLabelContent labelcontent = new ZyLabelContent(null);
labelcontent.addLineContent(new ZyLineContent(String.valueOf(degree), new Font("New Courier", Font.PLAIN, 12), null));
final ZyProximityNodeRealizer<NodeType> r = new ZyProximityNodeRealizer<NodeType>(labelcontent);
final Node node = graph.createNode(r);
@SuppressWarnings("unchecked") final ZyProximityNode<NodeType> infoNode = new ZyProximityNode<NodeType>(node, r, (ZyGraphNode<NodeType>) attachedNode, isIncoming);
final ZyNodeData<ZyProximityNode<NodeType>> data = new ZyNodeData<ZyProximityNode<NodeType>>(infoNode);
r.setUserData(data);
return infoNode;
}
use of com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent in project binnavi by google.
the class CElementSearcher method search.
/**
* Performs a search on a label content.
*
* @param element The element to search through.
* @param content The label content to search through.
* @param searchString The string to search for.
* @param regEx True, if regular expression search.
* @param caseSensitive True, to signal case sensitive search.
*
* @return The start position for the next iteration or -1 if nothing was found.
*/
public static List<SearchResult> search(final Object element, final ZyLabelContent content, final String searchString, final boolean regEx, final boolean caseSensitive) {
final ArrayList<SearchResult> results = new ArrayList<SearchResult>();
if ("".equals(searchString)) {
return results;
}
int lineCounter = 0;
for (final ZyLineContent lineContent : content) {
final String lineText = caseSensitive ? lineContent.getText() : lineContent.getText().toLowerCase();
int startPosition = 0;
do {
startPosition = regEx ? CElementSearcher.doRegexSearch(element, lineText, lineCounter, searchString, startPosition, caseSensitive, results) : CElementSearcher.doTextSearch(element, lineText, lineCounter, searchString, startPosition, caseSensitive, results);
} while (startPosition != -1);
++lineCounter;
}
return results;
}
use of com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent in project binnavi by google.
the class ZyCodeNodeBuilder method buildFunctionLine.
/**
* Builds the function line of a code node. This line gives information about the function from
* where the code node originally came from.
*
* @param node The node that provides the raw data.
* @param content The node content where the function line is added.
* @param modifier Calculates the address strings. This argument can be null.
*/
private static void buildFunctionLine(final INaviCodeNode node, final ZyLabelContent content, final INodeModifier modifier) {
try {
final INaviFunction parentFunction = node.getParentFunction();
final String address = modifier == null ? parentFunction.getAddress().toHexString() : modifier.getAddress(parentFunction.getModule(), new UnrelocatedAddress(parentFunction.getAddress()), true);
final String name = parentFunction.getName();
content.addLineContent(new ZyLineContent(address + PADDING_AFTER_FUNCTION_ADDRESS + parentFunction.getModule().getConfiguration().getName() + "::" + name, BOLD_FONT, Lists.newArrayList(new CStyleRunData(0, -1, Color.BLACK)), null));
} catch (final MaybeNullException exception) {
// If there is no parent function, the parent function is not shown in the code node.
}
}
use of com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent in project binnavi by google.
the class GraphSearcherTest method testSimpleNoResult.
@Test
public void testSimpleNoResult() {
final ZyNodeRealizer<NaviNode> r = new ZyNormalNodeRealizer<NaviNode>(m_content);
final NaviNode m_node1 = new NaviNode(m_ynode, r, m_codeNode1);
final GraphSearcher searcher = new GraphSearcher();
m_content.addLineContent(new ZyLineContent("Hello my Test", null));
searcher.search(Lists.newArrayList(m_node1), new ArrayList<NaviEdge>(), "mx");
searcher.getCursor().next();
assertNull(searcher.getCursor().current());
}
Aggregations