use of com.google.security.zynamics.zylib.gui.zygraph.edges.ZyEdgeData 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.edges.ZyEdgeData 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