コード例 #1
0
  /**
   * @param g
   * @param startup
   * @param layout
   * @param d
   */
  public static void main(String[] s) {
    CircleLayout cl = new CircleLayout();
    Graph g = TestGraphs.getDemoGraph();
    Dimension d = new Dimension(200, 200);
    cl.initializeLocations(d, g);
    VertexRenderer vr = new SimpleVertexRenderer();
    EdgeRenderer er = new SimpleEdgeRenderer();

    GraphLayoutPanel jgp = new GraphLayoutPanel(g, d, vr, er);
    jgp.addClickListener(
        new ClickListener() {

          public void edgeClicked(ClickEvent ece) {
            System.out.println(ece);
          }

          public void vertexClicked(ClickEvent vce) {
            System.out.println(vce);
          }
        });
    jgp.setLayoutDisplay(cl.emit());

    JFrame jf = new JFrame();
    jf.getContentPane().add(jgp);
    jf.pack();
    jf.setVisible(true);
    jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  }