]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.g2d/src/org/simantics/g2d/elementclass/PaintableSymbolHandler.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.g2d / src / org / simantics / g2d / elementclass / PaintableSymbolHandler.java
index 8340420c23896fe6c4162e7455b4c982487c8d1a..da052041aa70b34e2feeb305c77ce787cb78b83c 100644 (file)
@@ -1,89 +1,89 @@
-/*******************************************************************************\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.g2d.elementclass;\r
-\r
-import java.awt.Shape;\r
-import java.awt.geom.Rectangle2D;\r
-\r
-import org.simantics.g2d.diagram.handler.PickRequest.PickPolicy;\r
-import org.simantics.g2d.element.IElement;\r
-import org.simantics.g2d.element.handler.InternalSize;\r
-import org.simantics.g2d.element.handler.Pick;\r
-import org.simantics.g2d.element.handler.SceneGraph;\r
-import org.simantics.g2d.image.Image;\r
-import org.simantics.g2d.utils.GeometryUtils;\r
-import org.simantics.scenegraph.g2d.G2DParentNode;\r
-import org.simantics.utils.datastructures.cache.IProvider;\r
-import org.simantics.utils.datastructures.cache.StaticProvider;\r
-\r
-/**\r
- * Handles pick and painting of paintable symbols\r
- * \r
- * @author Toni Kalajainen\r
- */\r
-public class PaintableSymbolHandler implements SceneGraph, Pick, InternalSize {\r
-\r
-    private static final long serialVersionUID = 8612101011132309291L;\r
-\r
-    private final Rectangle2D rect;\r
-    private final Double ratio;\r
-    private final Image ps;\r
-\r
-    private final IProvider<Image> symbolProvider;\r
-\r
-    public PaintableSymbolHandler(Image symbol)\r
-    {\r
-        this.symbolProvider = StaticProvider.provide(symbol);\r
-        ps = symbolProvider.get();\r
-        rect = ps.getBounds();\r
-        ratio = rect.getWidth() / rect.getHeight();\r
-    }\r
-\r
-    public PaintableSymbolHandler(IProvider<Image> symbolProvider)\r
-    {\r
-        this.symbolProvider = symbolProvider;\r
-        ps = symbolProvider.get();\r
-        rect = ps.getBounds();\r
-        ratio = rect.getWidth() / rect.getHeight();\r
-    }\r
-\r
-\r
-    @Override\r
-    public void cleanup(IElement e) {\r
-    }\r
-\r
-    @Override\r
-    public void init(IElement e, G2DParentNode parent) {\r
-        System.out.println("PaintableSymbolHandler.paint()");\r
-//      Graphics2D g = elementGC.getGraphics2D();\r
-//      Image ps = ctx.getSingleItem(SymbolUtil.class).get(symbolProvider, g.getDeviceConfiguration());\r
-//      ps.paint(elementGC);\r
-    }\r
-\r
-    @Override\r
-    public boolean pickTest(IElement e, Shape s, PickPolicy policy) {\r
-        Shape outline = ps.getOutline();\r
-        if (policy == PickPolicy.PICK_CONTAINED_OBJECTS)\r
-            return GeometryUtils.contains(s, outline);\r
-        if (policy == PickPolicy.PICK_INTERSECTING_OBJECTS)\r
-            return GeometryUtils.intersects(s, outline);\r
-        throw new RuntimeException("Unimplemented");\r
-    }\r
-\r
-    @Override\r
-    public Rectangle2D getBounds(IElement e, Rectangle2D size) {\r
-        if (size==null) size = new Rectangle2D.Double();\r
-        size.setFrame(rect);\r
-        return size;\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.g2d.elementclass;
+
+import java.awt.Shape;
+import java.awt.geom.Rectangle2D;
+
+import org.simantics.g2d.diagram.handler.PickRequest.PickPolicy;
+import org.simantics.g2d.element.IElement;
+import org.simantics.g2d.element.handler.InternalSize;
+import org.simantics.g2d.element.handler.Pick;
+import org.simantics.g2d.element.handler.SceneGraph;
+import org.simantics.g2d.image.Image;
+import org.simantics.g2d.utils.GeometryUtils;
+import org.simantics.scenegraph.g2d.G2DParentNode;
+import org.simantics.utils.datastructures.cache.IProvider;
+import org.simantics.utils.datastructures.cache.StaticProvider;
+
+/**
+ * Handles pick and painting of paintable symbols
+ * 
+ * @author Toni Kalajainen
+ */
+public class PaintableSymbolHandler implements SceneGraph, Pick, InternalSize {
+
+    private static final long serialVersionUID = 8612101011132309291L;
+
+    private final Rectangle2D rect;
+    private final Double ratio;
+    private final Image ps;
+
+    private final IProvider<Image> symbolProvider;
+
+    public PaintableSymbolHandler(Image symbol)
+    {
+        this.symbolProvider = StaticProvider.provide(symbol);
+        ps = symbolProvider.get();
+        rect = ps.getBounds();
+        ratio = rect.getWidth() / rect.getHeight();
+    }
+
+    public PaintableSymbolHandler(IProvider<Image> symbolProvider)
+    {
+        this.symbolProvider = symbolProvider;
+        ps = symbolProvider.get();
+        rect = ps.getBounds();
+        ratio = rect.getWidth() / rect.getHeight();
+    }
+
+
+    @Override
+    public void cleanup(IElement e) {
+    }
+
+    @Override
+    public void init(IElement e, G2DParentNode parent) {
+        System.out.println("PaintableSymbolHandler.paint()");
+//      Graphics2D g = elementGC.getGraphics2D();
+//      Image ps = ctx.getSingleItem(SymbolUtil.class).get(symbolProvider, g.getDeviceConfiguration());
+//      ps.paint(elementGC);
+    }
+
+    @Override
+    public boolean pickTest(IElement e, Shape s, PickPolicy policy) {
+        Shape outline = ps.getOutline();
+        if (policy == PickPolicy.PICK_CONTAINED_OBJECTS)
+            return GeometryUtils.contains(s, outline);
+        if (policy == PickPolicy.PICK_INTERSECTING_OBJECTS)
+            return GeometryUtils.intersects(s, outline);
+        throw new RuntimeException("Unimplemented");
+    }
+
+    @Override
+    public Rectangle2D getBounds(IElement e, Rectangle2D size) {
+        if (size==null) size = new Rectangle2D.Double();
+        size.setFrame(rect);
+        return size;
+    }
+
+}