| SimpleDemo.java |
1 /****************************************************************************
2 **
3 ** This file is part of yFiles-2.9.
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-2011 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 * @see <a href="http://docs.yworks.com/yfiles/doc/developers-guide/mvc_view.html">Section View Implementations</a> in the yFiles for Java Developer's Guide
30 */
31 public class SimpleDemo extends JPanel
32 {
33 Graph2DView view;
34
35 public SimpleDemo()
36 {
37 setLayout(new BorderLayout());
38 view = new Graph2DView();
39 EditMode mode = new EditMode();
40 view.addViewMode(mode);
41 add(view);
42 }
43
44 public void start()
45 {
46 JFrame frame = new JFrame(getClass().getName());
47 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
48 addContentTo(frame.getRootPane());
49 frame.pack();
50 frame.setLocationRelativeTo(null);
51 frame.setVisible(true);
52 }
53
54 public final void addContentTo( final JRootPane rootPane )
55 {
56 rootPane.setContentPane(this);
57 }
58
59 public static void main(String[] args) {
60 EventQueue.invokeLater(new Runnable() {
61 public void run() {
62 (new SimpleDemo()).start();
63 }
64 });
65 }
66 }
67
68
69
70