]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.g2d/src/org/simantics/g2d/example/chassis/AppletExample.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.g2d / src / org / simantics / g2d / example / chassis / AppletExample.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.g2d.example.chassis;
13
14 import java.applet.Applet;
15 import java.awt.GridLayout;
16
17 import org.simantics.g2d.canvas.impl.CanvasContext;
18 import org.simantics.g2d.chassis.AWTChassis;
19 import org.simantics.g2d.diagram.DiagramHints;
20 import org.simantics.g2d.diagram.IDiagram;
21 import org.simantics.g2d.example.TestCanvas;
22 import org.simantics.utils.datastructures.hints.IHintContext;
23 import org.simantics.utils.threads.AWTThread;
24 import org.simantics.utils.threads.IThreadWorkQueue;
25
26 /**
27  * @author Toni Kalajainen
28  *
29  */
30 public class AppletExample extends Applet {
31
32     private static final long serialVersionUID = 8547571658314750189L;
33
34     @Override
35     public void init() {
36         // This is an empty content area in the frame
37         AWTChassis chassis = new AWTChassis();
38
39         // There is a background painter in canvas context (==it is opaque)
40         this.setLayout(new GridLayout(1, 1) );
41         chassis.setOpaque(true);
42         this.add(chassis);
43         chassis.requestFocus();
44         chassis.setDoubleBuffered(true);
45
46         IThreadWorkQueue    thread  = AWTThread.getThreadAccess();
47         CanvasContext       ctx     = TestCanvas.createDefaultCanvas(thread);
48         IHintContext        hintCtx = ctx.getDefaultHintContext();
49         IDiagram            diagram = TestCanvas.createDiagram1();
50
51         hintCtx.setHint(DiagramHints.KEY_DIAGRAM, diagram);
52         chassis.setCanvasContext(ctx);
53     }
54
55     @Override
56     public void start() {
57     }
58
59     @Override
60     public void stop() {
61     }
62
63 }