-/*******************************************************************************\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.tooltip;\r
-\r
-import java.awt.geom.Point2D;\r
-\r
-import org.simantics.g2d.canvas.impl.DependencyReflection.Dependency;\r
-import org.simantics.g2d.diagram.participant.pointertool.PointerInteractor;\r
-import org.simantics.g2d.diagram.participant.pointertool.TerminalUtil.TerminalInfo;\r
-import org.simantics.g2d.element.ElementHints;\r
-import org.simantics.g2d.element.handler.TerminalData;\r
-import org.simantics.scenegraph.g2d.events.EventHandlerReflection.EventHandler;\r
-import org.simantics.scenegraph.g2d.events.MouseEvent.MouseMovedEvent;\r
-import org.simantics.utils.datastructures.hints.IHintContext.Key;\r
-import org.simantics.utils.datastructures.hints.IHintContext.KeyOf;\r
-\r
-\r
-/**\r
- * TooltipParticipan that is able to show terminal tooltips\r
- * \r
- * Note: this participant does not co-operate with TooltipParticipant.\r
- * \r
- * \r
- * @author Marko Luukkainen <marko.luukkainen@vtt.fi>\r
- *\r
- */\r
-public class TerminalTooltipParticipant extends BaseTooltipParticipant {\r
-\r
- public static final Key KEY_TOOLTIP_TEXT = new KeyOf(String.class, "TERMINAL_TOOLTIP_TEXT");\r
-\r
- @Dependency PointerInteractor interactor;\r
-\r
- @EventHandler(priority = 0)\r
- public boolean handleMove(MouseMovedEvent me) {\r
- update(me.controlPosition);\r
- return false;\r
- }\r
-\r
- private void update(Point2D controlPos) {\r
- TerminalInfo info = interactor.pickTerminal(controlPos);\r
-\r
- if (info != null) {\r
- TerminalData data = info.e.getElementClass().getAtMostOneItemOfClass(TerminalData.class);\r
- if (data == null)\r
- return;\r
-\r
- String text = data.getHint(info.e, info.t, ElementHints.KEY_TEXT);\r
- // this is not a really good way to provide terminal name\r
- info.e.setHint(KEY_TOOLTIP_TEXT, text);\r
- showTooltipFor(info.e);\r
- } else\r
- hideTooltip();\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.tooltip;
+
+import java.awt.geom.Point2D;
+
+import org.simantics.g2d.canvas.impl.DependencyReflection.Dependency;
+import org.simantics.g2d.diagram.participant.pointertool.PointerInteractor;
+import org.simantics.g2d.diagram.participant.pointertool.TerminalUtil.TerminalInfo;
+import org.simantics.g2d.element.ElementHints;
+import org.simantics.g2d.element.handler.TerminalData;
+import org.simantics.scenegraph.g2d.events.EventHandlerReflection.EventHandler;
+import org.simantics.scenegraph.g2d.events.MouseEvent.MouseMovedEvent;
+import org.simantics.utils.datastructures.hints.IHintContext.Key;
+import org.simantics.utils.datastructures.hints.IHintContext.KeyOf;
+
+
+/**
+ * TooltipParticipan that is able to show terminal tooltips
+ *
+ * Note: this participant does not co-operate with TooltipParticipant.
+ *
+ *
+ * @author Marko Luukkainen <marko.luukkainen@vtt.fi>
+ *
+ */
+public class TerminalTooltipParticipant extends BaseTooltipParticipant {
+
+ public static final Key KEY_TOOLTIP_TEXT = new KeyOf(String.class, "TERMINAL_TOOLTIP_TEXT");
+
+ @Dependency PointerInteractor interactor;
+
+ @EventHandler(priority = 0)
+ public boolean handleMove(MouseMovedEvent me) {
+ update(me.controlPosition);
+ return false;
+ }
+
+ private void update(Point2D controlPos) {
+ TerminalInfo info = interactor.pickTerminal(controlPos);
+
+ if (info != null) {
+ TerminalData data = info.e.getElementClass().getAtMostOneItemOfClass(TerminalData.class);
+ if (data == null)
+ return;
+
+ String text = data.getHint(info.e, info.t, ElementHints.KEY_TEXT);
+ // this is not a really good way to provide terminal name
+ info.e.setHint(KEY_TOOLTIP_TEXT, text);
+ showTooltipFor(info.e);
+ } else
+ hideTooltip();
+ }
+
+}