From: lempinen Date: Thu, 29 Jul 2010 14:02:35 +0000 (+0000) Subject: Removed the need for HoverImpl with TextElementNoBounds X-Git-Tag: simantics-1.2.0~150 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=6809bebc850cc48e7cbfd8e6d366d32b345e2a57;p=simantics%2Fsysdyn.git Removed the need for HoverImpl with TextElementNoBounds git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@16873 ac1ea38d-2e2b-0410-8846-a27921b304fc --- diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/AuxiliaryFactory.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/AuxiliaryFactory.java index 50473289..1620323b 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/AuxiliaryFactory.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/AuxiliaryFactory.java @@ -19,7 +19,6 @@ import org.simantics.db.Resource; import org.simantics.g2d.element.ElementClass; import org.simantics.g2d.element.handler.impl.BoundsOutline; import org.simantics.g2d.element.handler.impl.DefaultTransform; -import org.simantics.g2d.element.handler.impl.HoverImpl; import org.simantics.g2d.element.handler.impl.ObjectTerminal; import org.simantics.g2d.element.handler.impl.OutlinePick; import org.simantics.g2d.element.handler.impl.SimpleElementLayers; @@ -54,7 +53,7 @@ public class AuxiliaryFactory extends SysdynElementFactory { StaticSymbolImageInitializer.INSTANCE, HoverTextElementHandler.INSTANCE, BoundsOutline.INSTANCE, - HoverImpl.INSTANCE, +// HoverImpl.INSTANCE, new WholeElementTerminals(terminals) ).setId(AuxiliaryFactory.class.getSimpleName()); } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/HoverTextElementNoBounds.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/HoverTextElementNoBounds.java index 35b93769..c12ae287 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/HoverTextElementNoBounds.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/HoverTextElementNoBounds.java @@ -45,6 +45,8 @@ public class HoverTextElementNoBounds extends TextElementNoBounds { public static final Key SG_NODE = new SceneGraphNodeKey(TextNode.class, "TEXT_SG_NODE"); + private IHintListener hoverHintListener; + public HoverTextElementNoBounds() { super(0, 0, Alignment.LEADING, 0); } @@ -120,10 +122,17 @@ public class HoverTextElementNoBounds extends TextElementNoBounds { if(key == ElementHints.KEY_HOVER) { IElement e = (IElement)sender; TextNode name = (TextNode) e.getHint(SG_NODE); - name.setHover(ElementUtils.isHovering(e)); + name.setHover((Boolean)e.getHint(ElementHints.KEY_HOVER)); } } }; e.addHintListener(hoverHintListener); } + + @Override + public void cleanup(IElement e) { + if(hoverHintListener != null) + e.removeHintListener(hoverHintListener); + ElementUtils.removePossibleNode(e, SG_NODE); + } } \ No newline at end of file diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/InputFactory.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/InputFactory.java index 2b4cea2e..dfc9cfef 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/InputFactory.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/InputFactory.java @@ -145,6 +145,7 @@ public class InputFactory extends SysdynElementFactory { Font font = ElementUtils.getTextFont(e); font = font.deriveFont(font.getStyle() + Font.ITALIC); ElementUtils.setTextFont(e, font); + ElementUtils.setHover(e, false); } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/ModuleFactory.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/ModuleFactory.java index b36ad234..b73b3f15 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/ModuleFactory.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/ModuleFactory.java @@ -19,7 +19,6 @@ import org.simantics.db.Resource; import org.simantics.g2d.element.ElementClass; import org.simantics.g2d.element.handler.impl.BoundsOutline; import org.simantics.g2d.element.handler.impl.DefaultTransform; -import org.simantics.g2d.element.handler.impl.HoverImpl; import org.simantics.g2d.element.handler.impl.ObjectTerminal; import org.simantics.g2d.element.handler.impl.OutlinePick; import org.simantics.g2d.element.handler.impl.SimpleElementLayers; @@ -52,7 +51,6 @@ public class ModuleFactory extends SysdynElementFactory { StaticSymbolImageInitializer.INSTANCE, new HoverTextElementHandler(0, 0, Alignment.LEADING, 0.2f), BoundsOutline.INSTANCE, - HoverImpl.INSTANCE, new WholeElementTerminals(terminals) ).setId(ModuleFactory.class.getSimpleName()); } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/StockFactory.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/StockFactory.java index a4ed759d..44476a87 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/StockFactory.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/StockFactory.java @@ -19,7 +19,6 @@ import org.simantics.db.Resource; import org.simantics.g2d.element.ElementClass; import org.simantics.g2d.element.handler.impl.BoundsOutline; import org.simantics.g2d.element.handler.impl.DefaultTransform; -import org.simantics.g2d.element.handler.impl.HoverImpl; import org.simantics.g2d.element.handler.impl.ObjectTerminal; import org.simantics.g2d.element.handler.impl.OutlinePick; import org.simantics.g2d.element.handler.impl.SimpleElementLayers; @@ -52,7 +51,6 @@ public class StockFactory extends SysdynElementFactory { StaticSymbolImageInitializer.INSTANCE, new HoverTextElementHandler(0, 0, Alignment.LEADING, 1f), BoundsOutline.INSTANCE, - HoverImpl.INSTANCE, new WholeElementTerminals(terminals) ).setId(StockFactory.class.getSimpleName()); } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/SysdynElementFactory.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/SysdynElementFactory.java index 50352b4e..989380f0 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/SysdynElementFactory.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/SysdynElementFactory.java @@ -35,6 +35,7 @@ import org.simantics.diagram.synchronization.graph.TransformSynchronizer; import org.simantics.g2d.canvas.ICanvasContext; import org.simantics.g2d.diagram.IDiagram; import org.simantics.g2d.element.ElementClass; +import org.simantics.g2d.element.ElementHints; import org.simantics.g2d.element.ElementUtils; import org.simantics.g2d.element.IElement; import org.simantics.g2d.element.handler.impl.ObjectTerminal; @@ -94,7 +95,7 @@ public abstract class SysdynElementFactory extends SyncElementFactory { // This synchronizes only text and transformation (not font and color) e.setHint(SynchronizationHints.HINT_SYNCHRONIZER, SYNCHRONIZER); - ElementUtils.setHover(e, false); + e.setHint(ElementHints.KEY_HOVER, false); } @Override diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/ValveFactory.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/ValveFactory.java index f6b8c28d..d231adbd 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/ValveFactory.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/ValveFactory.java @@ -134,11 +134,9 @@ public class ValveFactory extends SysdynElementFactory { @Override public void hintChanged(IHintObservable sender, Key key, Object oldValue, Object newValue) { IElement e = (IElement)sender; -// TextNode name = (TextNode) e.getHint(SG_NODE); HoverShapeNode shape = (HoverShapeNode) e.getHint(NODE); boolean hover = ElementUtils.isHovering(e); shape.setHover(hover); -// name.setHover(hover); } }; e.addHintListener(hoverHintListener);