X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.g2d%2Fsrc%2Forg%2Fsimantics%2Fg2d%2Felementclass%2FBranchPoint.java;h=ba95f31b7f1e3051809832090682b410fac5cec8;hb=56e6bade5f3a9cd2210184ffc13ffb29f007dccf;hp=62e0a3746462f51629cc20c7209ea4cbe38fe5ea;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.g2d/src/org/simantics/g2d/elementclass/BranchPoint.java b/bundles/org.simantics.g2d/src/org/simantics/g2d/elementclass/BranchPoint.java index 62e0a3746..ba95f31b7 100644 --- a/bundles/org.simantics.g2d/src/org/simantics/g2d/elementclass/BranchPoint.java +++ b/bundles/org.simantics.g2d/src/org/simantics/g2d/elementclass/BranchPoint.java @@ -1,85 +1,85 @@ -/******************************************************************************* - * 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); - -} +/******************************************************************************* + * 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); + +}