Как использовать пользовательские метки вершин в визуализации графа JUNG ?
Я следую Учебник Jung 2.0 , где я обнаружил, что setVertexLabelTransformer ()
можно использовать для маркировки вершин, но эти метки, насколько мне известно, не могут быть изменены.
Например, приведенный ниже код создает три вершины с метками вершин 1,2,4:
import edu.uci.ics.jung.algorithms.layout.CircleLayout;
import edu.uci.ics.jung.algorithms.layout.Layout;
import edu.uci.ics.jung.graph.Graph;
import edu.uci.ics.jung.graph.SparseMultigraph;
import edu.uci.ics.jung.visualization.BasicVisualizationServer;
import java.awt.Dimension;
import javax.swing.JFrame;
public class SimpleGraphView {
Graph g;
public SimpleGraphView() {
g = new SparseMultigraph();
g.addVertex((Integer)1);
g.addVertex((Integer)2);
g.addVertex((Integer)4);
}
public static void main(String[] args) {
SimpleGraphView sgv = new SimpleGraphView();
Layout layout = new CircleLayout(sgv.g);
layout.setSize(new Dimension(800,800));
BasicVisualizationServer vv =
new BasicVisualizationServer(layout);
vv.setPreferredSize(new Dimension(850,850));
JFrame frame = new JFrame("Simple Graph View");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(vv);
frame.pack();
frame.setVisible(true);
}
}
Как добавить метки типа «q0»?