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.scenegraph.example;
14 import javax.swing.RepaintManager;
15 import javax.swing.UIManager;
16 import javax.swing.UnsupportedLookAndFeelException;
17 import javax.swing.UIManager.LookAndFeelInfo;
19 import org.eclipse.swt.events.DisposeEvent;
20 import org.eclipse.swt.events.DisposeListener;
21 import org.eclipse.swt.widgets.Composite;
22 import org.eclipse.ui.part.ViewPart;
24 import org.simantics.scenegraph.g2d.nodes.TransformNode;
25 import org.simantics.scenegraph.swing.SliderNode;
27 public class G2DLocalView extends ViewPart {
30 protected boolean rotate = true;
31 protected TransformNode transform = null;
32 protected TransformNode transform2 = null;
33 protected SliderNode sn1 = null;
34 protected SliderNode sn2 = null;
35 protected SampleThread t = new SampleThread() {
36 public void repaint() {
38 RepaintManager rm = RepaintManager.currentManager(c.getCanvas());
39 rm.markCompletelyDirty(c.getCanvas());
45 public void createPartControl(Composite parent) {
47 for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
48 if ("Nimbus".equals(info.getName())) {
49 UIManager.setLookAndFeel(info.getClassName());
53 } catch (UnsupportedLookAndFeelException e) {
55 } catch (ClassNotFoundException e) {
57 } catch (InstantiationException e) {
59 } catch (IllegalAccessException e) {
63 c = new SGComponent(parent, 0);
66 c.addDisposeListener(new DisposeListener(){
68 public void widgetDisposed(DisposeEvent e) {
72 c.getCanvas().setSceneGraph(t.sg);
80 public void setFocus() {