]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Removed the need for HoverImpl with TextElementNoBounds
authorlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Thu, 29 Jul 2010 14:02:35 +0000 (14:02 +0000)
committerlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Thu, 29 Jul 2010 14:02:35 +0000 (14:02 +0000)
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@16873 ac1ea38d-2e2b-0410-8846-a27921b304fc

org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/AuxiliaryFactory.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/HoverTextElementNoBounds.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/ValveFactory.java

index 5047328919e5d2d8d556cb03299d4a298680a10b..1620323ba5713b7b3c622f34bb0e290d278558d4 100644 (file)
@@ -19,7 +19,6 @@ 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
@@ -54,7 +53,7 @@ public class AuxiliaryFactory extends SysdynElementFactory {
                 StaticSymbolImageInitializer.INSTANCE,\r
                 HoverTextElementHandler.INSTANCE,\r
                 BoundsOutline.INSTANCE,\r
-                HoverImpl.INSTANCE,\r
+//                HoverImpl.INSTANCE,\r
                 new WholeElementTerminals(terminals)\r
         ).setId(AuxiliaryFactory.class.getSimpleName());\r
     }\r
index 35b93769bbea421030c2c2a6d54b981eaa2d26da..c12ae287025ed96f303cc9b772406acf3c258370 100644 (file)
@@ -45,6 +45,8 @@ public class HoverTextElementNoBounds extends TextElementNoBounds {
 \r
     public static final Key                SG_NODE          = new SceneGraphNodeKey(TextNode.class, "TEXT_SG_NODE");\r
 \r
+    private IHintListener hoverHintListener;\r
+    \r
     public HoverTextElementNoBounds() {\r
         super(0, 0, Alignment.LEADING, 0);\r
     }\r
@@ -120,10 +122,17 @@ public class HoverTextElementNoBounds extends TextElementNoBounds {
                 if(key == ElementHints.KEY_HOVER) {\r
                     IElement e = (IElement)sender;\r
                     TextNode name = (TextNode) e.getHint(SG_NODE);\r
-                    name.setHover(ElementUtils.isHovering(e));\r
+                    name.setHover((Boolean)e.getHint(ElementHints.KEY_HOVER));\r
                 }\r
             }\r
         };\r
         e.addHintListener(hoverHintListener);\r
     }\r
+    \r
+    @Override\r
+    public void cleanup(IElement e) {\r
+        if(hoverHintListener != null)\r
+            e.removeHintListener(hoverHintListener);\r
+        ElementUtils.removePossibleNode(e, SG_NODE);\r
+    }\r
 }
\ No newline at end of file
index 2b4cea2efb0ae1695ca0777427f7fbf821c5d631..dfc9cfef02054cba247a22708be82e585702ed9d 100644 (file)
@@ -145,6 +145,7 @@ public class InputFactory extends SysdynElementFactory {
         Font font = ElementUtils.getTextFont(e);\r
         font = font.deriveFont(font.getStyle() + Font.ITALIC);\r
         ElementUtils.setTextFont(e, font);\r
+        ElementUtils.setHover(e, false);\r
     }\r
 \r
 \r
index b36ad234bc4df68b87cf73d94db6266389b7cd5d..b73b3f15ce1e61c843bba113eea0d5c69313d286 100644 (file)
@@ -19,7 +19,6 @@ 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
@@ -52,7 +51,6 @@ public class ModuleFactory extends SysdynElementFactory {
                 StaticSymbolImageInitializer.INSTANCE,\r
                 new HoverTextElementHandler(0, 0, Alignment.LEADING, 0.2f),\r
                 BoundsOutline.INSTANCE,\r
-                HoverImpl.INSTANCE,\r
                 new WholeElementTerminals(terminals)\r
         ).setId(ModuleFactory.class.getSimpleName());\r
     }\r
index a4ed759d586e7b6513f5e6bc347d9b0e4b72f393..44476a87b8bb82604a9e14fbb306c1ab22947bb6 100644 (file)
@@ -19,7 +19,6 @@ 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
@@ -52,7 +51,6 @@ public class StockFactory extends SysdynElementFactory {
                 StaticSymbolImageInitializer.INSTANCE,\r
                 new HoverTextElementHandler(0, 0, Alignment.LEADING, 1f),\r
                 BoundsOutline.INSTANCE,\r
-                HoverImpl.INSTANCE,\r
                 new WholeElementTerminals(terminals)\r
         ).setId(StockFactory.class.getSimpleName());\r
     }\r
index 50352b4e7db0500cfd5cc6807382c9084eb578b0..989380f0178789c87aeb8286277c22bc93ef8a63 100644 (file)
@@ -35,6 +35,7 @@ import org.simantics.diagram.synchronization.graph.TransformSynchronizer;
 import org.simantics.g2d.canvas.ICanvasContext;\r
 import org.simantics.g2d.diagram.IDiagram;\r
 import org.simantics.g2d.element.ElementClass;\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.handler.impl.ObjectTerminal;\r
@@ -94,7 +95,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
-        ElementUtils.setHover(e, false);\r
+        e.setHint(ElementHints.KEY_HOVER, false);\r
     }\r
 \r
     @Override\r
index f6b8c28d9062d79f32b72b4f86503702212ca968..d231adbdadd28a2efcd2c0badec86466a628a2b7 100644 (file)
@@ -134,11 +134,9 @@ public class ValveFactory extends SysdynElementFactory {
                 @Override\r
                 public void hintChanged(IHintObservable sender, Key key, Object oldValue, Object newValue) {\r
                     IElement e = (IElement)sender;\r
-//                    TextNode name = (TextNode) e.getHint(SG_NODE);\r
                     HoverShapeNode shape = (HoverShapeNode) e.getHint(NODE);\r
                     boolean hover = ElementUtils.isHovering(e);\r
                     shape.setHover(hover);\r
-//                    name.setHover(hover);\r
                 }\r
             };\r
             e.addHintListener(hoverHintListener);\r