-/*******************************************************************************\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.element.handler.impl;\r
-\r
-import org.simantics.g2d.canvas.ICanvasContext;\r
-import org.simantics.g2d.element.IElement;\r
-import org.simantics.g2d.element.handler.Togglable;\r
-import org.simantics.scenegraph.g2d.events.MouseEvent;\r
-import org.simantics.utils.datastructures.hints.IHintContext.Key;\r
-import org.simantics.utils.datastructures.hints.IHintContext.KeyOf;\r
-\r
-\r
-/**\r
- * Base implementation for button handlers\r
- * \r
- * \r
- * @author Toni Kalajainen\r
- */\r
-public abstract class AbstractTogglable extends AbstractClickable implements Togglable {\r
-\r
- private static final long serialVersionUID = 8409636755289629134L;\r
- public static Key TOGGLE_KEY = new KeyOf(Boolean.class);\r
-\r
- public AbstractTogglable(Double strayDistance) {\r
- super(strayDistance);\r
- }\r
-\r
- public AbstractTogglable() {\r
- super();\r
- }\r
-\r
-\r
- @Override\r
- public boolean handleMouseEvent(IElement e, ICanvasContext ctx,\r
- MouseEvent me) {\r
-\r
- boolean b = super.handleMouseEvent(e, ctx, me);\r
- \r
- return b;\r
- }\r
-\r
- \r
- protected void onClicked(GrabInfo gi, ICanvasContext ctx) {\r
- IElement e = gi.e;\r
- Boolean b = e.getHint(TOGGLE_KEY);\r
- if (b == null)\r
- b = false;\r
- e.setHint(TOGGLE_KEY, !b);\r
- }\r
- \r
- @Override\r
- public boolean isChecked(IElement e) {\r
- Boolean b = e.getHint(TOGGLE_KEY);\r
- return (b == null ? false : b);\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.element.handler.impl;
+
+import org.simantics.g2d.canvas.ICanvasContext;
+import org.simantics.g2d.element.IElement;
+import org.simantics.g2d.element.handler.Togglable;
+import org.simantics.scenegraph.g2d.events.MouseEvent;
+import org.simantics.utils.datastructures.hints.IHintContext.Key;
+import org.simantics.utils.datastructures.hints.IHintContext.KeyOf;
+
+
+/**
+ * Base implementation for button handlers
+ *
+ *
+ * @author Toni Kalajainen
+ */
+public abstract class AbstractTogglable extends AbstractClickable implements Togglable {
+
+ private static final long serialVersionUID = 8409636755289629134L;
+ public static Key TOGGLE_KEY = new KeyOf(Boolean.class);
+
+ public AbstractTogglable(Double strayDistance) {
+ super(strayDistance);
+ }
+
+ public AbstractTogglable() {
+ super();
+ }
+
+
+ @Override
+ public boolean handleMouseEvent(IElement e, ICanvasContext ctx,
+ MouseEvent me) {
+
+ boolean b = super.handleMouseEvent(e, ctx, me);
+
+ return b;
+ }
+
+
+ protected void onClicked(GrabInfo gi, ICanvasContext ctx) {
+ IElement e = gi.e;
+ Boolean b = e.getHint(TOGGLE_KEY);
+ if (b == null)
+ b = false;
+ e.setHint(TOGGLE_KEY, !b);
+ }
+
+ @Override
+ public boolean isChecked(IElement e) {
+ Boolean b = e.getHint(TOGGLE_KEY);
+ return (b == null ? false : b);
+ }
+
+}