use of com.google.security.zynamics.binnavi.ZyGraph.ZyGraphViewSettings in project binnavi by google.
the class CGraphFunctions method showNodes.
/**
* Shows and hides nodes of a graph in one step.
*
* @param parent Parent used for dialogs.
* @param graph The graph where the nodes are shown and hidden.
* @param toShow List of nodes to show.
* @param toHide List of nodes to hide.
*/
public static void showNodes(final JFrame parent, final ZyGraph graph, final Collection<NaviNode> toShow, final Collection<NaviNode> toHide) {
Preconditions.checkNotNull(graph, "IE02120: Graph argument can not be null");
Preconditions.checkNotNull(toShow, "IE02121: toShow argument can not be null");
Preconditions.checkNotNull(toHide, "IE02122: toHide argument can not be null");
final ZyGraphViewSettings settings = graph.getSettings();
final Set<NaviNode> neighbours = ProximityRangeCalculator.getNeighbors(graph, toShow, settings.getProximitySettings().getProximityBrowsingChildren(), settings.getProximitySettings().getProximityBrowsingParents());
neighbours.addAll(toShow);
final int invisibleNodes = countInvisibleNodes(neighbours);
if (userCancelsMakingVisible(parent, graph, invisibleNodes)) {
return;
}
graph.showNodes(toShow, toHide);
}
use of com.google.security.zynamics.binnavi.ZyGraph.ZyGraphViewSettings in project binnavi by google.
the class CGraphFunctions method showNodes.
/**
* Shows or hides nodes of a graph in one step.
*
* @param parent Parent used for dialogs.
* @param graph The graph where the nodes are shown or hidden.
* @param nodes List of nodes to show or hide.
* @param visible True, to show the nodes. False, to hide the nodes.
*/
public static void showNodes(final Window parent, final ZyGraph graph, final Collection<NaviNode> nodes, final boolean visible) {
Preconditions.checkNotNull(parent, "IE02123: Parent argument can not be null");
Preconditions.checkNotNull(graph, "IE02124: Graph argument can not be null");
Preconditions.checkNotNull(nodes, "IE02125: Nodes argument can not be null");
if (visible) {
final ZyGraphViewSettings settings = graph.getSettings();
final Set<NaviNode> neighbours = ProximityRangeCalculator.getNeighbors(graph, nodes, settings.getProximitySettings().getProximityBrowsingChildren(), settings.getProximitySettings().getProximityBrowsingParents());
neighbours.addAll(nodes);
final int invisibleNodes = countInvisibleNodes(neighbours);
if (userCancelsMakingVisible(parent, graph, invisibleNodes)) {
return;
}
}
graph.showNodes(nodes, visible);
}
use of com.google.security.zynamics.binnavi.ZyGraph.ZyGraphViewSettings in project binnavi by google.
the class CGraphBuilder method buildGraph.
/**
* Builds a displayable graph from a view.
*
* @param view The view to be turned into a graph.
*
* @return The generated graph.
* @throws LoadCancelledException Thrown if loading the graph was canceled.
*/
public static ZyGraph buildGraph(final INaviView view) throws LoadCancelledException {
Preconditions.checkNotNull(view, "IE01763: View argument can't be null");
final Pair<Map<String, String>, ZyGraphViewSettings> viewSettings = loadSettings(view);
final Map<String, String> rawSettings = viewSettings.first();
final ZyGraphViewSettings graphSettings = viewSettings.second();
graphSettings.rawSettings = rawSettings;
final ZyGraphBuilder builder = new ZyGraphBuilder();
ZyGraphBuilderManager.instance().setBuilder(view, builder);
final Graph2D graph = builder.convert(view.getGraph().getNodes(), view.getGraph().getEdges(), graphSettings, view.getType() == ViewType.Native);
final ZyGraph2DView graphView = new ZyGraph2DView(graph);
final ZyGraph zyGraph = new ZyGraph(view, builder.getNodeMap(), builder.getEdgeMap(), graphSettings, graphView);
zyGraph.getView().setCenter(CViewSettingsGenerator.createDoubleSetting(rawSettings, "view_center_x", 0), CViewSettingsGenerator.createDoubleSetting(rawSettings, "view_center_y", 0));
zyGraph.getView().setWorldRect(CViewSettingsGenerator.createIntegerSetting(rawSettings, "world_rect_x", 0), CViewSettingsGenerator.createIntegerSetting(rawSettings, "world_rect_y", 0), CViewSettingsGenerator.createIntegerSetting(rawSettings, "world_rect_width", 800), CViewSettingsGenerator.createIntegerSetting(rawSettings, "world_rect_height", 600));
zyGraph.getView().setZoom(CViewSettingsGenerator.createDoubleSetting(rawSettings, "zoom", 1));
ZyGraphBuilderManager.instance().removeBuilder(view);
return zyGraph;
}
use of com.google.security.zynamics.binnavi.ZyGraph.ZyGraphViewSettings in project binnavi by google.
the class CSettingsDialogFunctions method showFlowgraphSettingsDialog.
/**
* Shows the initial flow graph settings dialog.
*
* @param parent Parent window used for dialogs.
*/
public static void showFlowgraphSettingsDialog(final JFrame parent) {
final ZyGraphViewSettings settings = ConfigManager.instance().getDefaultFlowGraphSettings();
final CGraphSettingsDialog dlg = new CGraphSettingsDialog(parent, "Initial Flow graph Settings", settings, true, false);
dlg.setVisible(true);
ConfigManager.instance().updateFlowgraphSettings(settings);
ConfigManager.instance().saveSettings(parent);
}
use of com.google.security.zynamics.binnavi.ZyGraph.ZyGraphViewSettings 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