0

When I'm zooming the graph, half of it disappear. I've tried to modify the ViewPort without any result. This is the code.

public static void printGraph(final Program program) {
    final ViewPanel graphViewNew;
    final Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
    final JFrame mainFrame = new JFrame();
    SCGraph graph = new SCGraph(new SingleGraph("CFG"), pred, succ);
    Viewer viewer;

    program.graphLayout(graph);
    program.printGraph(graph);

    viewer = new Viewer(graph.getGraphForView(), Viewer.ThreadingModel.GRAPH_IN_ANOTHER_THREAD);
    graphViewNew = viewer.addDefaultView(false);
    mainFrame.getContentPane().add(graphViewNew);
    mainFrame.setBounds(0, 0, 1300, 1300);
    mainFrame.setLocation(dim.width / 2 - mainFrame.getSize().width / 2,
     dim.height / 2 - mainFrame.getSize().height / 2);
    mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    mainFrame.setVisible(true);

    graphViewNew.addMouseWheelListener(new MouseWheelListener() {
        @Override
        public void mouseWheelMoved(MouseWheelEvent mwe) {
            zoomGraphMouseWheelMoved(mwe, graphViewNew);
        }
    });

}

and this is the function that handles events:

public static void zoomGraphMouseWheelMoved(MouseWheelEvent mwe, ViewPanel view_panel) {
    if (ALT_MASK != 0) {
        if (mwe.getWheelRotation() > 0) {
            double new_view_percent = view_panel.getCamera().getViewPercent() + 0.05;
            view_panel.getCamera().setViewPercent(new_view_percent);
        } else if (mwe.getWheelRotation() < 0) {
            double current_view_percent = view_panel.getCamera().getViewPercent();
            if (current_view_percent > 0.05) {
                view_panel.getCamera().setViewPercent(current_view_percent - 0.05);
            }
        }
    }
}

Moreover, I have the same problem if I navigate into the view with the built-in key (up.down,left,right, page-down, page-up).

Here the image before I press the right key. Here the same after.

  • Did you search for similar SO questions, like [How to zoom into a GraphStream View?](https://stackoverflow.com/questions/44675827/how-to-zoom-into-a-graphstream-view)? – Abra Feb 07 '20 at 14:27
  • Yes. Actually, the problem exists without zoom. Just pressing the Right key (Implemented by Graphstream), I obtain the results in the images. – Idriss Riouak Feb 07 '20 at 21:28

0 Answers0