| SimpleDemo.java |
1 /****************************************************************************
2 * This demo file is part of yFiles for Java 2.14.
3 * Copyright (c) 2000-2017 by yWorks GmbH, Vor dem Kreuzberg 28,
4 * 72070 Tuebingen, Germany. All rights reserved.
5 *
6 * yFiles demo files exhibit yFiles for Java functionalities. Any redistribution
7 * of demo files in source code or binary form, with or without
8 * modification, is not permitted.
9 *
10 * Owners of a valid software license for a yFiles for Java version that this
11 * demo is shipped with are allowed to use the demo source code as basis
12 * for their own yFiles for Java powered applications. Use of such programs is
13 * governed by the rights and conditions as set out in the yFiles for Java
14 * license agreement.
15 *
16 * THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
19 * NO EVENT SHALL yWorks BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
21 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 *
27 ***************************************************************************/
28 package demo.view;
29
30 import java.awt.*;
31 import javax.swing.*;
32
33 import y.view.Graph2DView;
34 import y.view.EditMode;
35
36 /**
37 * The yFiles view says "Hello World."
38 * <br>
39 * Demonstrates basic usage of {@link y.view.Graph2DView}, the yFiles graph
40 * viewer component, and shows how to provide editing support through
41 * {@link y.view.EditMode}.
42 *
43 * @see <a href="http://docs.yworks.com/yfiles/doc/api/index.html#/dguide/mvc_view" target="_blank">Section View Implementations</a> in the yFiles for Java Developer's Guide
44 */
45 public class SimpleDemo extends JPanel
46 {
47 Graph2DView view;
48
49 public SimpleDemo()
50 {
51 setLayout(new BorderLayout());
52 view = new Graph2DView();
53 EditMode mode = new EditMode();
54 view.addViewMode(mode);
55 add(view);
56 }
57
58 public void start()
59 {
60 JFrame frame = new JFrame(getClass().getName());
61 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
62 addContentTo(frame.getRootPane());
63 frame.pack();
64 frame.setLocationRelativeTo(null);
65 frame.setVisible(true);
66 }
67
68 public final void addContentTo( final JRootPane rootPane )
69 {
70 rootPane.setContentPane(this);
71 }
72
73 public static void main(String[] args) {
74 EventQueue.invokeLater(new Runnable() {
75 public void run() {
76 (new SimpleDemo()).start();
77 }
78 });
79 }
80 }
81
82
83
84