Search in sources :

Example 1 with ZyGraphBuilder

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;
}
Also used : ZyGraphBuilder(com.google.security.zynamics.binnavi.yfileswrap.zygraph.Builders.ZyGraphBuilder) ZyGraphViewSettings(com.google.security.zynamics.binnavi.ZyGraph.ZyGraphViewSettings) ZyGraph(com.google.security.zynamics.binnavi.yfileswrap.zygraph.ZyGraph) ZyGraph2DView(com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.ZyGraph2DView) HashMap(java.util.HashMap) Map(java.util.Map) Graph2D(y.view.Graph2D)

Example 2 with ZyGraphBuilder

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;
    }
}
Also used : ZyGraphBuilder(com.google.security.zynamics.binnavi.yfileswrap.zygraph.Builders.ZyGraphBuilder) MaybeNullException(com.google.security.zynamics.binnavi.Exceptions.MaybeNullException) GradientPaint(java.awt.GradientPaint)

Example 3 with ZyGraphBuilder

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);
        }
    }
}
Also used : ZyGraphBuilder(com.google.security.zynamics.binnavi.yfileswrap.zygraph.Builders.ZyGraphBuilder) MaybeNullException(com.google.security.zynamics.binnavi.Exceptions.MaybeNullException)

Aggregations

ZyGraphBuilder (com.google.security.zynamics.binnavi.yfileswrap.zygraph.Builders.ZyGraphBuilder)3 MaybeNullException (com.google.security.zynamics.binnavi.Exceptions.MaybeNullException)2 ZyGraphViewSettings (com.google.security.zynamics.binnavi.ZyGraph.ZyGraphViewSettings)1 ZyGraph (com.google.security.zynamics.binnavi.yfileswrap.zygraph.ZyGraph)1 ZyGraph2DView (com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.ZyGraph2DView)1 GradientPaint (java.awt.GradientPaint)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Graph2D (y.view.Graph2D)1