1   /****************************************************************************
2    **
3    ** This file is part of yFiles-2.6. 
4    ** 
5    ** yWorks proprietary/confidential. Use is subject to license terms.
6    **
7    ** Redistribution of this file or of an unauthorized byte-code version
8    ** of this file is strictly forbidden.
9    **
10   ** Copyright (c) 2000-2008 by yWorks GmbH, Vor dem Kreuzberg 28, 
11   ** 72070 Tuebingen, Germany. All rights reserved.
12   **
13   ***************************************************************************/
14  package demo.view;
15  
16  import java.awt.*;
17  import javax.swing.*;
18  
19  import y.view.Graph2DView;
20  import y.view.EditMode;
21  
22  /**
23   * The yFiles view says "Hello World."
24   * <br>
25   * Demonstrates basic usage of {@link y.view.Graph2DView}, the yFiles graph
26   * viewer component, and shows how to provide editing support through
27   * {@link y.view.EditMode}.
28   */
29  public class SimpleDemo extends JPanel 
30  {
31    Graph2DView view;
32    
33    public SimpleDemo()
34    {
35      setLayout(new BorderLayout());  
36      view = new Graph2DView();
37      EditMode mode = new EditMode();
38      view.addViewMode(mode);
39      add(view);
40    }
41  
42    public void start()
43    {
44      JFrame frame = new JFrame(getClass().getName());
45      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
46      addContentTo(frame.getRootPane());
47      frame.pack();
48      frame.setLocationRelativeTo(null);
49      frame.setVisible(true);
50    }
51  
52    public final void addContentTo( final JRootPane rootPane )
53    {
54      rootPane.setContentPane(this);
55    }
56  
57    public static void main(String args[])
58    {
59      final SimpleDemo demo = new SimpleDemo();
60      demo.start();
61    }
62  }
63  
64  
65        
66