JUNG2 测试后发现所有的边线都是弯曲的,但不是直线... Jung2 的边线怎么做直线?
package pkg;
import javax.swing.JFrame;
import edu.uci.ics.jung.algorithms.layout.CircleLayout;
import edu.uci.ics.jung.algorithms.layout.Layout;
import edu.uci.ics.jung.visualization.VisualizationViewer;
import edu.uci.ics.jung.visualization.control.DefaultModalGraphMouse;
import edu.uci.ics.jung.graph.Graph;
import edu.uci.ics.jung.graph.SparseMultigraph;
import edu.uci.ics.jung.visualization.control.ModalGraphMouse;
public class test {
public static void main(String[] args) {
// Graph<V, E> where V is the type of the vertices
// and E is the type of the edges
Graph<Integer, String> g = new SparseMultigraph<Integer, String>();
// Add some vertices. From above we defined these to be type Integer.
g.addVertex((Integer)1);
g.addVertex((Integer)2);
g.addVertex((Integer)3);
// Add some edges. From above we defined these to be of type String
// Note that the default is for undirected edges.
g.addEdge("Edge-A", 1, 2);
g.addEdge("Edge-B", 2, 3);
// Let's see what we have. Note the nice output from the
// SparseMultigraph<V,E> toString() method
// Note that we can use the same nodes and edges in two different graphs.
System.out.println("The graph g = " + g.toString());
Layout<Integer, String> layout = new CircleLayout(g);
VisualizationViewer<Integer,String> vv = new VisualizationViewer<Integer,String>(layout);
DefaultModalGraphMouse gm = new DefaultModalGraphMouse();
gm.setMode(ModalGraphMouse.Mode.PICKING);
vv.setGraphMouse(gm);
JFrame frame = new JFrame("Simple Graph View");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(vv);
frame.pack();
frame.setVisible(true);
}
}
按照输出结果,黑线是默认的,我想得到的红线: http ://www.zhaocs.info/wp-content/uploads/2015/04/test.png