Prefuse example graph partly outside of JPanel

限于喜欢 提交于 2019-11-29 14:42:31
trashgod

I'm new to Prefuse, but a number of common errors can contribute to the observed problem. Looking at the example,

  • As discussed here, don't use setSize() on the Display when you really mean to override getPreferredSize().

  • Swing GUI objects should be constructed and manipulated only on the event dispatch thread‌​.

  • The initial clustering is an artifact of the graph's origin falling on the top-left corner of the Display component at the point (0, 0). Having chosen a preferred size, one can pan() to the center.

private static final int W = 640;
private static final int H = 480;
…
Display d = new Display(vis) {

    @Override
    public Dimension getPreferredSize() {
        return new Dimension(W, H);
    }
};
d.pan(W / 2, H / 2);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!