use of com.google.security.zynamics.binnavi.yfileswrap.zygraph.Builders.ZyGraphBuilder 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.yfileswrap.zygraph.Builders.ZyGraphBuilder in project binnavi by google.
the class CLoadProgressPainter method getLoadPercentage.
/**
* Calculates the load percentage of the rendered view to display a progress bar.
*
* @param view The view to be loaded.
*
* @return The calculated load percentage.
*/
private static double getLoadPercentage(final INaviView view) {
final int totalSteps = ViewLoadEvents.values().length + GraphBuilderEvents.values().length;
final int loadState = view.getLoadState();
if (loadState == IDatabaseLoadProgressReporter.INACTIVE) {
try {
// The view was previously loaded and only needs to be built.
final ZyGraphBuilder builder = ZyGraphBuilderManager.instance().getBuilder(view);
return (1.0 * (ViewLoadEvents.values().length + builder.getBuildStep())) / totalSteps;
} catch (final MaybeNullException exception) {
return 0;
}
} else {
return (1.0 * view.getLoadState()) / totalSteps;
}
}
use of com.google.security.zynamics.binnavi.yfileswrap.zygraph.Builders.ZyGraphBuilder in project binnavi by google.
the class ZyGraphBuilderManager method removeBuilder.
/**
* Removes a builder from the manager.
*
* @param view The view whose builder is removed.
*/
public void removeBuilder(final INaviView view) {
final ZyGraphBuilder builder = m_builders.get(view);
Preconditions.checkNotNull(builder, "IE00704: View was not managed");
m_builders.remove(view);
for (final IGraphBuilderManagerListener listener : m_listeners) {
try {
listener.removedBuilder(view, builder);
} catch (final Exception exception) {
CUtilityFunctions.logException(exception);
}
}
}
Aggregations