]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Moved some hover stuff to the common elements
authorlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Thu, 29 Jul 2010 13:43:57 +0000 (13:43 +0000)
committerlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Thu, 29 Jul 2010 13:43:57 +0000 (13:43 +0000)
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@16872 ac1ea38d-2e2b-0410-8846-a27921b304fc

12 files changed:
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/AuxiliaryFactory.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/CloudFactory.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/HoverHandler.java [deleted file]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/HoverTextElementNoBounds.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/HoverTextNode.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/InputFactory.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/ModuleFactory.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/StockFactory.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/SysdynElementFactory.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/SysdynElementHints.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/SysdynElementUtils.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/ValveFactory.java

index 8c35303834e2b1c2debc409ea8a88864af101933..5047328919e5d2d8d556cb03299d4a298680a10b 100644 (file)
@@ -19,6 +19,7 @@ import org.simantics.db.Resource;
 import org.simantics.g2d.element.ElementClass;\r
 import org.simantics.g2d.element.handler.impl.BoundsOutline;\r
 import org.simantics.g2d.element.handler.impl.DefaultTransform;\r
+import org.simantics.g2d.element.handler.impl.HoverImpl;\r
 import org.simantics.g2d.element.handler.impl.ObjectTerminal;\r
 import org.simantics.g2d.element.handler.impl.OutlinePick;\r
 import org.simantics.g2d.element.handler.impl.SimpleElementLayers;\r
@@ -53,7 +54,7 @@ public class AuxiliaryFactory extends SysdynElementFactory {
                 StaticSymbolImageInitializer.INSTANCE,\r
                 HoverTextElementHandler.INSTANCE,\r
                 BoundsOutline.INSTANCE,\r
-                HoverHandler.INSTANCE,\r
+                HoverImpl.INSTANCE,\r
                 new WholeElementTerminals(terminals)\r
         ).setId(AuxiliaryFactory.class.getSimpleName());\r
     }\r
index 034b02af24db667da85f2cade22982c33887b084..504b790d844efd8acb643810598c6af174e10097 100644 (file)
@@ -29,6 +29,7 @@ import org.simantics.g2d.element.handler.InternalSize;
 import org.simantics.g2d.element.handler.SceneGraph;\r
 import org.simantics.g2d.element.handler.impl.BoundsOutline;\r
 import org.simantics.g2d.element.handler.impl.DefaultTransform;\r
+import org.simantics.g2d.element.handler.impl.HoverImpl;\r
 import org.simantics.g2d.element.handler.impl.ObjectTerminal;\r
 import org.simantics.g2d.element.handler.impl.OutlinePick;\r
 import org.simantics.g2d.element.handler.impl.SimpleElementLayers;\r
@@ -92,7 +93,7 @@ public class CloudFactory extends SysdynElementFactory {
                 new StaticSymbolImpl(DEFAULT_IMAGE),\r
                 StaticSymbolImageInitializer.INSTANCE,\r
                 CloudSceneGraph.INSTANCE,\r
-                HoverHandler.INSTANCE,\r
+                HoverImpl.INSTANCE,\r
                 BoundsOutline.INSTANCE,\r
                 new WholeElementTerminals(terminals)\r
         ).setId(CloudFactory.class.getSimpleName());\r
@@ -105,6 +106,8 @@ public class CloudFactory extends SysdynElementFactory {
         public static final CloudSceneGraph INSTANCE         = new CloudSceneGraph();\r
 \r
         private static final Key            NODE             = new SceneGraphNodeKey(ShapeNode.class, "VALVE_NODE");\r
+        \r
+        private IHintListener hoverHintListener;\r
 \r
         @Override\r
         public void init(IElement e, G2DParentNode parent) {\r
@@ -115,7 +118,7 @@ public class CloudFactory extends SysdynElementFactory {
             node.setColor(Color.BLACK);\r
             node.setShape(getCloudShape());\r
             \r
-            e.addHintListener(new IHintListener() {\r
+            hoverHintListener = new IHintListener() {\r
                 \r
                 @Override\r
                 public void hintRemoved(IHintObservable sender, Key key, Object oldValue) {\r
@@ -126,13 +129,15 @@ public class CloudFactory extends SysdynElementFactory {
                 public void hintChanged(IHintObservable sender, Key key, Object oldValue, Object newValue) {\r
                     IElement e = (IElement)sender;\r
                     HoverShapeNode shape = (HoverShapeNode) e.getHint(NODE);\r
-                    shape.setHover(SysdynElementUtils.isHovering(e));\r
+                    shape.setHover(ElementUtils.isHovering(e));\r
                 }\r
-            });\r
+            };\r
+            e.addHintListener(hoverHintListener);\r
         }\r
 \r
         @Override\r
         public void cleanup(IElement e) {\r
+            e.removeHintListener(hoverHintListener);\r
             ElementUtils.removePossibleNode(e, NODE);\r
         }\r
 \r
@@ -147,10 +152,10 @@ public class CloudFactory extends SysdynElementFactory {
         @Override\r
         public boolean handleMouseEvent(IElement e, ICanvasContext ctx, MouseEvent me) {\r
             if (me instanceof MouseEnterEvent) {\r
-                SysdynElementUtils.setHover(e, true);\r
+                ElementUtils.setHover(e, true);\r
                 return false;\r
             } else if (me instanceof MouseExitEvent) {\r
-                SysdynElementUtils.setHover(e, false);\r
+                ElementUtils.setHover(e, false);\r
                 return false;\r
             }\r
             return false;\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/HoverHandler.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/HoverHandler.java
deleted file mode 100644 (file)
index 8673fab..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-package org.simantics.sysdyn.ui.elements2;\r
-\r
-import org.simantics.g2d.element.IElement;\r
-import org.simantics.g2d.element.handler.ElementHandler;\r
-\r
-public class HoverHandler implements ElementHandler {\r
-    \r
-    private static final long serialVersionUID = -6392685799523448598L;\r
-    \r
-    public static final HoverHandler INSTANCE = new HoverHandler();\r
-    \r
-    public boolean isHovering(IElement e) {\r
-        return e.getHint(SysdynElementHints.KEY_HOVER);\r
-    }\r
-\r
-    \r
-    public void setHover(IElement e, boolean hover) {\r
-        e.setHint(SysdynElementHints.KEY_HOVER, hover);\r
-    }\r
-}\r
index f27813adb7c93655a50f61da63f8589b45ec4d70..35b93769bbea421030c2c2a6d54b981eaa2d26da 100644 (file)
@@ -13,29 +13,22 @@ package org.simantics.sysdyn.ui.elements2;
 \r
 import java.awt.Color;\r
 import java.awt.Font;\r
-import java.awt.geom.Point2D;\r
 \r
 import org.simantics.diagram.elements.ITextListener;\r
-import org.simantics.diagram.elements.TextEditActivation;\r
+import org.simantics.diagram.elements.TextElementNoBounds;\r
 import org.simantics.diagram.elements.TextNode;\r
-import org.simantics.g2d.canvas.ICanvasContext;\r
 import org.simantics.g2d.diagram.DiagramUtils;\r
 import org.simantics.g2d.diagram.IDiagram;\r
+import org.simantics.g2d.element.ElementHints;\r
 import org.simantics.g2d.element.ElementUtils;\r
 import org.simantics.g2d.element.IElement;\r
 import org.simantics.g2d.element.SceneGraphNodeKey;\r
-import org.simantics.g2d.element.handler.HandleMouseEvent;\r
-import org.simantics.g2d.element.handler.SceneGraph;\r
-import org.simantics.g2d.event.MouseEvent;\r
-import org.simantics.g2d.event.MouseEvent.MouseEnterEvent;\r
-import org.simantics.g2d.event.MouseEvent.MouseExitEvent;\r
-import org.simantics.g2d.participant.MouseUtil.MouseClickEvent;\r
 import org.simantics.g2d.utils.Alignment;\r
 import org.simantics.scenegraph.g2d.G2DParentNode;\r
 import org.simantics.utils.datastructures.Callback;\r
-import org.simantics.utils.datastructures.hints.IHintContext.Key;\r
 import org.simantics.utils.datastructures.hints.IHintListener;\r
 import org.simantics.utils.datastructures.hints.IHintObservable;\r
+import org.simantics.utils.datastructures.hints.IHintContext.Key;\r
 \r
 /**\r
  * ElementHandler for text elements\r
@@ -43,7 +36,7 @@ import org.simantics.utils.datastructures.hints.IHintObservable;
  * \r
  * @author Marko Luukkainen <marko.luukkainen@vtt.fi>\r
  */\r
-public class HoverTextElementNoBounds implements SceneGraph, HandleMouseEvent {\r
+public class HoverTextElementNoBounds extends TextElementNoBounds {\r
 \r
     private static final long serialVersionUID = -148784588840819612L;\r
 \r
@@ -52,38 +45,20 @@ public class HoverTextElementNoBounds implements SceneGraph, HandleMouseEvent {
 \r
     public static final Key                SG_NODE          = new SceneGraphNodeKey(TextNode.class, "TEXT_SG_NODE");\r
 \r
-    private final double originX;\r
-    private final double originY;\r
-    private final Alignment horizontalAlignment;\r
-    private final double borderWidth;\r
-    private final boolean editable;\r
-    private final double paddingX;\r
-    private final double paddingY;\r
-    private IHintListener hoverHintListener ;\r
-\r
     public HoverTextElementNoBounds() {\r
-        this(0, 0, Alignment.LEADING, 0);\r
+        super(0, 0, Alignment.LEADING, 0);\r
     }\r
 \r
     public HoverTextElementNoBounds(double originX, double originY, Alignment horizontalAlignment) {\r
-        this(originX, originY, horizontalAlignment, 0);\r
+        super(originX, originY, horizontalAlignment, 0);\r
     }\r
 \r
     public HoverTextElementNoBounds(double originX, double originY, Alignment horizontalAlignment, double borderWidth) {\r
-        this(originX, originY, horizontalAlignment, borderWidth, 2.0, 2.0, true);\r
+        super(originX, originY, horizontalAlignment, borderWidth);\r
     }\r
 \r
     public HoverTextElementNoBounds(double originX, double originY, Alignment horizontalAlignment, double borderWidth, double paddingX, double paddingY, boolean editable) {\r
-        if (horizontalAlignment == null)\r
-            throw new NullPointerException("null horizontal alignment");\r
-\r
-        this.originX = originX;\r
-        this.originY = originY;\r
-        this.horizontalAlignment = horizontalAlignment;\r
-        this.borderWidth = borderWidth;\r
-        this.editable = editable;\r
-        this.paddingX = paddingX;\r
-        this.paddingY = paddingY;\r
+        super(originX, originY, horizontalAlignment, borderWidth, paddingX, paddingY, editable);\r
     }\r
 \r
     @Override\r
@@ -130,10 +105,11 @@ public class HoverTextElementNoBounds implements SceneGraph, HandleMouseEvent {
         node.setBackgroundColor(fillColor);\r
         node.setBorderColor(borderColor);\r
         node.setHorizontalAlignment((byte) horizontalAlignment.ordinal());\r
-        node.setBorderWidth((float) borderWidth * 0.235);\r
-        node.setEditable(editable);\r
         node.setPadding(paddingX, paddingY);\r
-        hoverHintListener = new IHintListener() {\r
+        node.setBorderWidth((float) borderWidth);\r
+        node.setEditable(editable);\r
+        \r
+        this.hoverHintListener = new IHintListener() {\r
             @Override\r
             public void hintRemoved(IHintObservable sender, Key key, Object oldValue) {\r
 \r
@@ -141,99 +117,13 @@ public class HoverTextElementNoBounds implements SceneGraph, HandleMouseEvent {
 \r
             @Override\r
             public void hintChanged(IHintObservable sender, Key key, Object oldValue, Object newValue) {\r
-                if(key == SysdynElementHints.KEY_HOVER) {\r
+                if(key == ElementHints.KEY_HOVER) {\r
                     IElement e = (IElement)sender;\r
-                    HoverTextNode name = (HoverTextNode) e.getHint(SG_NODE);\r
-                    name.setHover(SysdynElementUtils.isHovering(e));\r
+                    TextNode name = (TextNode) e.getHint(SG_NODE);\r
+                    name.setHover(ElementUtils.isHovering(e));\r
                 }\r
             }\r
         };\r
-        \r
         e.addHintListener(hoverHintListener);\r
     }\r
-\r
-    @Override\r
-    public void cleanup(IElement e) {\r
-        ElementUtils.removePossibleNode(e, SG_NODE);\r
-        e.removeHintListener(hoverHintListener);\r
-    }\r
-\r
-    // FIXME: hazardous with TextElementHandler.INSTANCE\r
-    TextEditActivation editActivation = null;\r
-\r
-    @Override\r
-    public boolean handleMouseEvent(IElement e, ICanvasContext ctx, MouseEvent me) {\r
-        if (me instanceof MouseEnterEvent) {\r
-            SysdynElementUtils.setHover(e, true);\r
-        } else if (me instanceof MouseExitEvent) {\r
-            SysdynElementUtils.setHover(e, false);\r
-        } else if (me instanceof MouseClickEvent) {\r
-            MouseClickEvent mce = (MouseClickEvent)me;\r
-            if ((mce.button & MouseClickEvent.LEFT_BUTTON) > 0) {\r
-                TextNode node = (TextNode) e.getHint(SG_NODE);\r
-                if (node == null)\r
-                    return false;\r
-                if (node.isEditMode()) {\r
-                    Point2D p = new Point2D.Double();\r
-                    ElementUtils.controlToCanvasCoordinate(ctx, me.controlPosition, p);\r
-                    if (!ElementUtils.getElementBoundsOnDiagram(e).contains(p)) {\r
-                        endEdit(node);\r
-                    }\r
-                } else if (!node.isEditable()) {\r
-                    return false;\r
-                } else if (mce.clickCount > 1) {\r
-                    editActivation = new TextEditActivation(mce.mouseId, e, ctx);\r
-                    node.setEditMode(true);\r
-                    node.repaint();\r
-                }\r
-            }\r
-        }\r
-\r
-        return false;\r
-    }\r
-\r
-    private void endEdit(TextNode node) {\r
-        if (editActivation != null) {\r
-            editActivation.release();\r
-            editActivation = null;\r
-\r
-            node.setEditMode(false);\r
-            node.repaint();\r
-        }\r
-    }\r
-\r
-    @Override\r
-    public int hashCode() {\r
-        final int prime = 31;\r
-        int result = 1;\r
-        long temp;\r
-        temp = Double.doubleToLongBits(borderWidth);\r
-        result = prime * result + (int) (temp ^ (temp >>> 32));\r
-        result = prime * result + horizontalAlignment.hashCode();\r
-        temp = Double.doubleToLongBits(originX);\r
-        result = prime * result + (int) (temp ^ (temp >>> 32));\r
-        temp = Double.doubleToLongBits(originY);\r
-        result = prime * result + (int) (temp ^ (temp >>> 32));\r
-        return result;\r
-    }\r
-\r
-    @Override\r
-    public boolean equals(Object obj) {\r
-        if (this == obj)\r
-            return true;\r
-        if (obj == null)\r
-            return false;\r
-        if (getClass() != obj.getClass())\r
-            return false;\r
-        HoverTextElementNoBounds other = (HoverTextElementNoBounds) obj;\r
-        if (Double.doubleToLongBits(borderWidth) != Double.doubleToLongBits(other.borderWidth))\r
-            return false;\r
-        if (horizontalAlignment != other.horizontalAlignment)\r
-            return false;\r
-        if (Double.doubleToLongBits(originX) != Double.doubleToLongBits(other.originX))\r
-            return false;\r
-        if (Double.doubleToLongBits(originY) != Double.doubleToLongBits(other.originY))\r
-            return false;\r
-        return true;\r
-    }\r
 }
\ No newline at end of file
index b4fa4a617c9b5bc61cbb2c70b795001c2f4656e8..d6f1e37d026b4de0797e845a0781bf7e38958c6d 100644 (file)
@@ -13,13 +13,7 @@ import org.simantics.scenegraph.utils.NodeUtil;
 public class HoverTextNode extends TextNode {\r
 \r
     private static final long serialVersionUID = 3539499125943249895L;\r
-\r
-    transient public boolean hover = false;\r
-\r
-    public void setHover(boolean hover) {\r
-        this.hover = hover;\r
-        repaint();\r
-    }\r
+
 \r
     @Override\r
     public void render(Graphics2D g) {\r
index 366ab5b8dffc65a591e1a5c842799e41ac202897..2b4cea2efb0ae1695ca0777427f7fbf821c5d631 100644 (file)
@@ -24,6 +24,7 @@ import org.simantics.g2d.element.SceneGraphNodeKey;
 import org.simantics.g2d.element.handler.InternalSize;\r
 import org.simantics.g2d.element.handler.impl.BoundsOutline;\r
 import org.simantics.g2d.element.handler.impl.DefaultTransform;\r
+import org.simantics.g2d.element.handler.impl.HoverImpl;\r
 import org.simantics.g2d.element.handler.impl.ObjectTerminal;\r
 import org.simantics.g2d.element.handler.impl.OutlinePick;\r
 import org.simantics.g2d.element.handler.impl.SimpleElementLayers;\r
@@ -76,7 +77,7 @@ public class InputFactory extends SysdynElementFactory {
                 Input.INSTANCE,\r
                 new InputSceneGraph(0, 0, Alignment.LEADING),\r
                 BoundsOutline.INSTANCE,\r
-                HoverHandler.INSTANCE,\r
+                HoverImpl.INSTANCE,\r
                 new WholeElementTerminals(terminals)\r
         ).setId(InputFactory.class.getSimpleName());\r
     }\r
index c0d76dbb3dc2f0623d69edb87600cc040607309d..b36ad234bc4df68b87cf73d94db6266389b7cd5d 100644 (file)
@@ -19,6 +19,7 @@ import org.simantics.db.Resource;
 import org.simantics.g2d.element.ElementClass;\r
 import org.simantics.g2d.element.handler.impl.BoundsOutline;\r
 import org.simantics.g2d.element.handler.impl.DefaultTransform;\r
+import org.simantics.g2d.element.handler.impl.HoverImpl;\r
 import org.simantics.g2d.element.handler.impl.ObjectTerminal;\r
 import org.simantics.g2d.element.handler.impl.OutlinePick;\r
 import org.simantics.g2d.element.handler.impl.SimpleElementLayers;\r
@@ -49,9 +50,9 @@ public class ModuleFactory extends SysdynElementFactory {
                 new StaticObjectAdapter(elementType),\r
                 new StaticSymbolImpl(DEFAULT_IMAGE),\r
                 StaticSymbolImageInitializer.INSTANCE,\r
-                new HoverTextElementHandler(0, 0, Alignment.LEADING, 1f),\r
+                new HoverTextElementHandler(0, 0, Alignment.LEADING, 0.2f),\r
                 BoundsOutline.INSTANCE,\r
-                HoverHandler.INSTANCE,\r
+                HoverImpl.INSTANCE,\r
                 new WholeElementTerminals(terminals)\r
         ).setId(ModuleFactory.class.getSimpleName());\r
     }\r
index f94a2d8442458dbbc2ae93e551975da2ff354953..a4ed759d586e7b6513f5e6bc347d9b0e4b72f393 100644 (file)
@@ -19,6 +19,7 @@ import org.simantics.db.Resource;
 import org.simantics.g2d.element.ElementClass;\r
 import org.simantics.g2d.element.handler.impl.BoundsOutline;\r
 import org.simantics.g2d.element.handler.impl.DefaultTransform;\r
+import org.simantics.g2d.element.handler.impl.HoverImpl;\r
 import org.simantics.g2d.element.handler.impl.ObjectTerminal;\r
 import org.simantics.g2d.element.handler.impl.OutlinePick;\r
 import org.simantics.g2d.element.handler.impl.SimpleElementLayers;\r
@@ -49,9 +50,9 @@ public class StockFactory extends SysdynElementFactory {
                 new StaticObjectAdapter(elementType),\r
                 new StaticSymbolImpl(DEFAULT_IMAGE),\r
                 StaticSymbolImageInitializer.INSTANCE,\r
-                new HoverTextElementHandler(0, 0, Alignment.LEADING, 2f),\r
+                new HoverTextElementHandler(0, 0, Alignment.LEADING, 1f),\r
                 BoundsOutline.INSTANCE,\r
-                HoverHandler.INSTANCE,\r
+                HoverImpl.INSTANCE,\r
                 new WholeElementTerminals(terminals)\r
         ).setId(StockFactory.class.getSimpleName());\r
     }\r
index 9b739a505f824cc134bfe86e979a0722dd336389..50352b4e7db0500cfd5cc6807382c9084eb578b0 100644 (file)
@@ -94,7 +94,7 @@ public abstract class SysdynElementFactory extends SyncElementFactory {
         // This synchronizes only text and transformation (not font and color)\r
         e.setHint(SynchronizationHints.HINT_SYNCHRONIZER, SYNCHRONIZER);\r
         \r
-        SysdynElementUtils.setHover(e, false);\r
+        ElementUtils.setHover(e, false);\r
     }\r
 \r
     @Override\r
index 5c187767a91cc4d4ae01230fb08438c25f012a86..ef69bf4d41294b4a62735482de0328a9dcac065f 100644 (file)
@@ -7,5 +7,4 @@ public class SysdynElementHints {
 \r
     public static final Key KEY_INPUT_REFERENCE = new KeyOf(String.class, "INPUT_REFERENCE");\r
     \r
-    public static final Key KEY_HOVER = new KeyOf(Boolean.class, "HOVER");\r
 }\r
index a77038b3c9b2120edcfc053388a6dce132d4d535..dd82a3c974202d246df2a6233c63961039343928 100644 (file)
@@ -1,9 +1,8 @@
 package org.simantics.sysdyn.ui.elements2;\r
 \r
-import org.simantics.g2d.element.ElementUtils;\r
 import org.simantics.g2d.element.IElement;\r
 \r
-public class SysdynElementUtils extends ElementUtils {\r
+public class SysdynElementUtils {\r
 \r
     \r
     public static void setInputReference(IElement e, String inputReference)\r
@@ -18,15 +17,4 @@ public class SysdynElementUtils extends ElementUtils {
         return i.getInputReference(e);\r
     }\r
     \r
-    public static void setHover(IElement e, boolean hover)\r
-    {\r
-        HoverHandler hh = e.getElementClass().getSingleItem(HoverHandler.class);\r
-        hh.setHover(e, hover);\r
-    }\r
-\r
-    public static boolean isHovering(IElement e)\r
-    {\r
-        HoverHandler hh = e.getElementClass().getSingleItem(HoverHandler.class);\r
-        return hh.isHovering(e);\r
-    }    \r
 }\r
index 545dfc74be02e8d0c820c98fcc9d6fee015a3620..f6b8c28d9062d79f32b72b4f86503702212ca968 100644 (file)
@@ -26,6 +26,7 @@ import org.simantics.g2d.element.handler.HandleMouseEvent;
 import org.simantics.g2d.element.handler.InternalSize;\r
 import org.simantics.g2d.element.handler.impl.BoundsOutline;\r
 import org.simantics.g2d.element.handler.impl.DefaultTransform;\r
+import org.simantics.g2d.element.handler.impl.HoverImpl;\r
 import org.simantics.g2d.element.handler.impl.ObjectTerminal;\r
 import org.simantics.g2d.element.handler.impl.OutlinePick;\r
 import org.simantics.g2d.element.handler.impl.SimpleElementLayers;\r
@@ -70,7 +71,7 @@ public class ValveFactory extends SysdynElementFactory {
                 new StaticObjectAdapter(elementType),\r
                 new StaticSymbolImpl(VALVE_STATIC_IMAGE),\r
                 StaticSymbolImageInitializer.INSTANCE,\r
-                HoverHandler.INSTANCE,\r
+                HoverImpl.INSTANCE,\r
                 ValveSceneGraph.INSTANCE,\r
                 BoundsOutline.INSTANCE,\r
                 new WholeElementTerminals(terminals)\r
@@ -105,6 +106,8 @@ public class ValveFactory extends SysdynElementFactory {
         public static final ValveSceneGraph INSTANCE         = new ValveSceneGraph();\r
 \r
         private static final Key            NODE             = new SceneGraphNodeKey(ShapeNode.class, "VALVE_NODE");\r
+        \r
+        private IHintListener hoverHintListener;\r
 \r
         public ValveSceneGraph() {\r
             super(0, VALVE_SIZE + 3.0, Alignment.CENTER);\r
@@ -119,9 +122,9 @@ public class ValveFactory extends SysdynElementFactory {
             node.setScaleStroke(true);\r
             node.setColor(Color.BLACK);\r
             node.setShape(createShape(VALVE_SIZE, Boolean.TRUE.equals(e.getHint(KEY_ROTATED))));\r
-            node.setHover(SysdynElementUtils.isHovering(e));\r
+            node.setHover(ElementUtils.isHovering(e));\r
 \r
-            e.addHintListener(new IHintListener() {\r
+            hoverHintListener = new IHintListener() {\r
                 \r
                 @Override\r
                 public void hintRemoved(IHintObservable sender, Key key, Object oldValue) {\r
@@ -133,15 +136,17 @@ public class ValveFactory extends SysdynElementFactory {
                     IElement e = (IElement)sender;\r
 //                    TextNode name = (TextNode) e.getHint(SG_NODE);\r
                     HoverShapeNode shape = (HoverShapeNode) e.getHint(NODE);\r
-                    boolean hover = SysdynElementUtils.isHovering(e);\r
+                    boolean hover = ElementUtils.isHovering(e);\r
                     shape.setHover(hover);\r
 //                    name.setHover(hover);\r
                 }\r
-            });\r
+            };\r
+            e.addHintListener(hoverHintListener);\r
         }\r
 \r
         @Override\r
         public void cleanup(IElement e) {\r
+            e.removeHintListener(hoverHintListener);\r
             ElementUtils.removePossibleNode(e, NODE);\r
         }\r
 \r