-/*******************************************************************************\r
- * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
- * in Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- * VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.scenegraph.example;\r
-\r
-import javax.swing.RepaintManager;\r
-import javax.swing.UIManager;\r
-import javax.swing.UnsupportedLookAndFeelException;\r
-import javax.swing.UIManager.LookAndFeelInfo;\r
-\r
-import org.eclipse.swt.events.DisposeEvent;\r
-import org.eclipse.swt.events.DisposeListener;\r
-import org.eclipse.swt.widgets.Composite;\r
-import org.eclipse.ui.part.ViewPart;\r
-\r
-import org.simantics.scenegraph.g2d.nodes.TransformNode;\r
-import org.simantics.scenegraph.swing.SliderNode;\r
-\r
-public class G2DLocalView extends ViewPart {\r
- SGComponent c;\r
- \r
- protected boolean rotate = true;\r
- protected TransformNode transform = null;\r
- protected TransformNode transform2 = null;\r
- protected SliderNode sn1 = null;\r
- protected SliderNode sn2 = null;\r
- protected SampleThread t = new SampleThread() {\r
- public void repaint() {\r
- if(c != null) {\r
- RepaintManager rm = RepaintManager.currentManager(c.getCanvas());\r
- rm.markCompletelyDirty(c.getCanvas());\r
- }\r
- }\r
- };\r
-\r
- @Override\r
- public void createPartControl(Composite parent) {\r
- try {\r
- for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {\r
- if ("Nimbus".equals(info.getName())) {\r
- UIManager.setLookAndFeel(info.getClassName());\r
- break;\r
- }\r
- }\r
- } catch (UnsupportedLookAndFeelException e) {\r
- // handle exception\r
- } catch (ClassNotFoundException e) {\r
- // handle exception\r
- } catch (InstantiationException e) {\r
- // handle exception\r
- } catch (IllegalAccessException e) {\r
- // handle exception\r
- }\r
- \r
- c = new SGComponent(parent, 0);\r
- c.syncPopulate();\r
- \r
- c.addDisposeListener(new DisposeListener(){\r
- @Override\r
- public void widgetDisposed(DisposeEvent e) {\r
- t.stop();\r
- }});\r
- \r
- c.getCanvas().setSceneGraph(t.sg);\r
- \r
- c.initListeners();\r
-\r
- t.start();\r
- }\r
- \r
- @Override\r
- public void setFocus() {\r
- c.setFocus();\r
- }\r
- \r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management
+ * in Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
+package org.simantics.scenegraph.example;
+
+import javax.swing.RepaintManager;
+import javax.swing.UIManager;
+import javax.swing.UnsupportedLookAndFeelException;
+import javax.swing.UIManager.LookAndFeelInfo;
+
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.part.ViewPart;
+
+import org.simantics.scenegraph.g2d.nodes.TransformNode;
+import org.simantics.scenegraph.swing.SliderNode;
+
+public class G2DLocalView extends ViewPart {
+ SGComponent c;
+
+ protected boolean rotate = true;
+ protected TransformNode transform = null;
+ protected TransformNode transform2 = null;
+ protected SliderNode sn1 = null;
+ protected SliderNode sn2 = null;
+ protected SampleThread t = new SampleThread() {
+ public void repaint() {
+ if(c != null) {
+ RepaintManager rm = RepaintManager.currentManager(c.getCanvas());
+ rm.markCompletelyDirty(c.getCanvas());
+ }
+ }
+ };
+
+ @Override
+ public void createPartControl(Composite parent) {
+ try {
+ for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
+ if ("Nimbus".equals(info.getName())) {
+ UIManager.setLookAndFeel(info.getClassName());
+ break;
+ }
+ }
+ } catch (UnsupportedLookAndFeelException e) {
+ // handle exception
+ } catch (ClassNotFoundException e) {
+ // handle exception
+ } catch (InstantiationException e) {
+ // handle exception
+ } catch (IllegalAccessException e) {
+ // handle exception
+ }
+
+ c = new SGComponent(parent, 0);
+ c.syncPopulate();
+
+ c.addDisposeListener(new DisposeListener(){
+ @Override
+ public void widgetDisposed(DisposeEvent e) {
+ t.stop();
+ }});
+
+ c.getCanvas().setSceneGraph(t.sg);
+
+ c.initListeners();
+
+ t.start();
+ }
+
+ @Override
+ public void setFocus() {
+ c.setFocus();
+ }
+
+}