1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
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
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.g2d.example.chassis;
14 import java.applet.Applet;
15 import java.awt.GridLayout;
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;
27 * @author Toni Kalajainen
30 public class AppletExample extends Applet {
32 private static final long serialVersionUID = 8547571658314750189L;
36 // This is an empty content area in the frame
37 AWTChassis chassis = new AWTChassis();
39 // There is a background painter in canvas context (==it is opaque)
40 this.setLayout(new GridLayout(1, 1) );
41 chassis.setOpaque(true);
43 chassis.requestFocus();
44 chassis.setDoubleBuffered(true);
46 IThreadWorkQueue thread = AWTThread.getThreadAccess();
47 CanvasContext ctx = TestCanvas.createDefaultCanvas(thread);
48 IHintContext hintCtx = ctx.getDefaultHintContext();
49 IDiagram diagram = TestCanvas.createDiagram1();
51 hintCtx.setHint(DiagramHints.KEY_DIAGRAM, diagram);
52 chassis.setCanvasContext(ctx);