我的问题是用jgraph绘图后,拖动cell后edge显示有问题,edge折断了一样。
  我用的是netBeans开发平台,如果将cells insert到GraphLayoutCache视图里面,之后再将graph加到frame里面显示出来是没有以上所说问题的。但是如果先将jgraph作为组件添加到frame上面,然后试图通过按键事件去动态地生成拓扑图,虽然生成是成功的,但是拖动cell后edge显示就有问题,edge折断了一样。

解决方案 »

  1.   

    自己已经解决,在此贴上解决的方法,希望对后面学习的有用:
    I make some investigation: 
    - I tried older version of jgraph (5.10.2.0) and it worked fine there, it doesn't work in version 5.11 
    - I realised, that graph is repainted well everytime after I call (I made button action with only this line): 
    graph.getSelectionModel().clearSelection(); I finally found "not nice" solution   
    I overrided applyMap method in AttributeMap (this method is called everytime object is dropped, label is changed, edge is moved, ..) and repainted the graph before If somebody knows of better (nicer) solution or have some idea, let me know, for now it works well  
    public AttributeMap applyMap(Map change) { 
    // these 3 lines solve repaint graph problems 
    WD.INSTANCE.getCurrentGraph().clearSelection(); 
    WD.INSTANCE.getCurrentGraph().getGraphLayoutCache().reload(); 
    WD.INSTANCE.getCurrentGraph().repaint(); if (!change.containsKey(GraphConstants.VALUE)) { 
    ... 
    ... 
    }
    解决方法参考自http://www.jgraph.com/forum/viewtopic.php?t=3985&highlight=drag+cell