use of com.google.security.zynamics.binnavi.ZyGraph.Updaters.CEdgeUpdater 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.binnavi.ZyGraph.Updaters.CEdgeUpdater in project binnavi by google.
the class ZyGraph method saveAs.
/**
* Creates a copy of the current native view and transfers the copied native view into the graph
* object. That means that the graph object changes its underlying raw view when this function is
* called.
*
* @param container The view container where the view is copied to.
* @param name The new name of the raw view.
* @param description The new description of the raw view.
*
* @return The new raw view.
*
* @throws CouldntSaveDataException Thrown if the view could not be saved.
*/
public INaviView saveAs(final IViewContainer container, final String name, final String description) throws CouldntSaveDataException {
Preconditions.checkNotNull(container, "IE00871: Container argument can not be null");
Preconditions.checkNotNull(name, "IE00872: Name argument can not be null");
Preconditions.checkNotNull(description, "IE00899: Description argument can not be null");
final INaviView oldView = m_rawView;
final INaviView newView = container.createView(name, description);
CViewInserter.insertView(oldView, newView);
final List<INaviViewNode> oldNodes = oldView.getGraph().getNodes();
final List<INaviViewNode> newNodes = newView.getGraph().getNodes();
for (int i = 0; i < oldNodes.size(); i++) {
final INaviViewNode newNode = newNodes.get(i);
final NaviNode oldNode = getMappings().getNode(oldNodes.get(i));
getMappings().setNode(newNode, oldNode);
oldNode.setRawNode(newNode);
for (final INaviGraphListener listener : m_listeners) {
try {
listener.changedModel(this, oldNode);
} catch (final Exception exception) {
CUtilityFunctions.logException(exception);
}
}
}
final List<INaviEdge> oldEdges = oldView.getGraph().getEdges();
final List<INaviEdge> newEdges = newView.getGraph().getEdges();
for (int i = 0; i < oldEdges.size(); i++) {
final INaviEdge newEdge = newEdges.get(i);
final NaviEdge oldEdge = getMappings().getEdge(oldEdges.get(i));
assert oldEdge != null;
getMappings().setEdge(newEdge, oldEdge);
final ZyEdgeRealizer<NaviEdge> realizer = oldEdge.getRealizer();
realizer.setUpdater(new CEdgeUpdater(newEdge));
oldEdge.setRawEdge(newEdge);
}
removeListeners();
newView.save();
CSettingsFunctions.saveSettings(newView, getView(), m_settings);
m_rawView = newView;
initializeListeners();
m_synchronizer.reset();
for (final INaviGraphListener listener : m_listeners) {
// ESCA-JAVA0166: Catch Exception here because we are calling a listener function.
try {
listener.changedView(oldView, newView);
} catch (final Exception exception) {
CUtilityFunctions.logException(exception);
}
}
oldView.close();
return m_rawView;
}
Aggregations