--- /dev/null
+/*******************************************************************************\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.dnd;\r
+\r
+import java.awt.geom.Rectangle2D;\r
+\r
+import org.simantics.g2d.element.ElementClass;\r
+import org.simantics.g2d.element.handler.StaticSymbol;\r
+import org.simantics.g2d.image.Image;\r
+import org.simantics.scenegraph.g2d.G2DParentNode;\r
+import org.simantics.utils.datastructures.hints.HintContext;\r
+import org.simantics.utils.datastructures.hints.IHintContext;\r
+\r
+/**\r
+ * @author Tuukka Lehtonen\r
+ */\r
+public class ElementClassDragItem implements IDragItem {\r
+\r
+ private final ElementClass ec;\r
+ private final HintContext ctx = new HintContext();\r
+\r
+ public ElementClassDragItem(ElementClass ec) {\r
+ if (ec == null)\r
+ throw new NullPointerException("null element class");\r
+ this.ec = ec;\r
+ }\r
+\r
+ public ElementClass getElementClass() {\r
+ return ec;\r
+ }\r
+\r
+ @Override\r
+ public Rectangle2D getBounds() {\r
+ Image i = ec.getSingleItem(StaticSymbol.class).getImage();\r
+ return i.getBounds();\r
+ }\r
+\r
+ @Override\r
+ public void paint(G2DParentNode parent) {\r
+ Image i = ec.getSingleItem(StaticSymbol.class).getImage();\r
+ i.init(parent);\r
+ }\r
+\r
+ @Override\r
+ public IHintContext getHintContext() {\r
+ return ctx;\r
+ }\r
+\r
+}
\ No newline at end of file