-/*******************************************************************************\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.elementclass;\r
-\r
-import org.simantics.g2d.element.ElementClass.Single;\r
-import org.simantics.g2d.element.IElement;\r
-import org.simantics.g2d.element.handler.ElementHandler;\r
-\r
-/**\r
- * A tagging element handler for telling whether an element can be considered a\r
- * branch point of a connection.\r
- * \r
- * @author Tuukka Lehtonen\r
- */\r
-@Single\r
-public interface BranchPoint extends ElementHandler {\r
-\r
- /**\r
- * Pass-through direction preference for branch or specifically route\r
- * points.\r
- */\r
- public enum Direction {\r
- Any, Horizontal, Vertical;\r
-\r
- public static Direction toDirection(boolean horizontal, boolean vertical) {\r
- if (horizontal && vertical)\r
- throw new IllegalArgumentException("branch point cannot be both horizontal and vertical");\r
- if (horizontal)\r
- return Horizontal;\r
- if (vertical)\r
- return Vertical;\r
- return Any;\r
- }\r
-\r
- public Direction toggleDetermined() {\r
- switch (this) {\r
- case Horizontal: return Vertical;\r
- case Vertical: return Horizontal;\r
- }\r
- return Any;\r
- }\r
-\r
- public Direction cycleNext() {\r
- Direction[] dirs = values();\r
- int newOrdinal = ordinal() + 1;\r
- return dirs[newOrdinal >= dirs.length ? 0 : newOrdinal];\r
- }\r
-\r
- public Direction cyclePrevious() {\r
- Direction[] dirs = values();\r
- int newOrdinal = ordinal() - 1;\r
- return dirs[newOrdinal < 0 ? dirs.length - 1 : newOrdinal];\r
- }\r
- }\r
-\r
- /**\r
- * Get the direction preference assigned for the specified branch point\r
- * element.\r
- * \r
- * @param e the branch point element to get the direction preference from\r
- * @param defaultValue this is returned if the element has no assigned\r
- * direction\r
- * @return direction preference\r
- */\r
- Direction getDirectionPreference(IElement e, Direction defaultValue);\r
-\r
- /**\r
- * Set the direction preference assigned for the specified branch point\r
- * element.\r
- * \r
- * @param e the branch point element to get the direction preference from\r
- * @param value the new direction preference\r
- */\r
- void setDirectionPreference(IElement e, Direction value);\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.elementclass;
+
+import org.simantics.g2d.element.ElementClass.Single;
+import org.simantics.g2d.element.IElement;
+import org.simantics.g2d.element.handler.ElementHandler;
+
+/**
+ * A tagging element handler for telling whether an element can be considered a
+ * branch point of a connection.
+ *
+ * @author Tuukka Lehtonen
+ */
+@Single
+public interface BranchPoint extends ElementHandler {
+
+ /**
+ * Pass-through direction preference for branch or specifically route
+ * points.
+ */
+ public enum Direction {
+ Any, Horizontal, Vertical;
+
+ public static Direction toDirection(boolean horizontal, boolean vertical) {
+ if (horizontal && vertical)
+ throw new IllegalArgumentException("branch point cannot be both horizontal and vertical");
+ if (horizontal)
+ return Horizontal;
+ if (vertical)
+ return Vertical;
+ return Any;
+ }
+
+ public Direction toggleDetermined() {
+ switch (this) {
+ case Horizontal: return Vertical;
+ case Vertical: return Horizontal;
+ }
+ return Any;
+ }
+
+ public Direction cycleNext() {
+ Direction[] dirs = values();
+ int newOrdinal = ordinal() + 1;
+ return dirs[newOrdinal >= dirs.length ? 0 : newOrdinal];
+ }
+
+ public Direction cyclePrevious() {
+ Direction[] dirs = values();
+ int newOrdinal = ordinal() - 1;
+ return dirs[newOrdinal < 0 ? dirs.length - 1 : newOrdinal];
+ }
+ }
+
+ /**
+ * Get the direction preference assigned for the specified branch point
+ * element.
+ *
+ * @param e the branch point element to get the direction preference from
+ * @param defaultValue this is returned if the element has no assigned
+ * direction
+ * @return direction preference
+ */
+ Direction getDirectionPreference(IElement e, Direction defaultValue);
+
+ /**
+ * Set the direction preference assigned for the specified branch point
+ * element.
+ *
+ * @param e the branch point element to get the direction preference from
+ * @param value the new direction preference
+ */
+ void setDirectionPreference(IElement e, Direction value);
+
+}