Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/locators/InternalPortPositionLocator.java')
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/locators/InternalPortPositionLocator.java184
1 files changed, 92 insertions, 92 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/locators/InternalPortPositionLocator.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/locators/InternalPortPositionLocator.java
index bfb7d6be56a..aeb78ed8674 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/locators/InternalPortPositionLocator.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/locators/InternalPortPositionLocator.java
@@ -1,92 +1,92 @@
-/*****************************************************************************
- * Copyright (c) 2009-2011 CEA LIST.
- *
- *
- * 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:
- * Yann Tanguy (CEA LIST) yann.tanguy@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.composite.custom.locators;
-
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.papyrus.uml.diagram.common.locator.PortPositionLocator;
-
-
-public class InternalPortPositionLocator extends PortPositionLocator {
-
- /**
- * @since 3.0
- */
- public InternalPortPositionLocator(IFigure parentFigure) {
- super(parentFigure);
- }
-
- @Deprecated
- public InternalPortPositionLocator(IFigure parentFigure, int preferredSide) {
- super(parentFigure, preferredSide);
- }
-
-
- /**
- *
- * @param proposedLocation
- * the proposed location
- * @return a possible location on parent figure border
- */
- @Override
- public Rectangle getPreferredLocation(Rectangle proposedLocation) {
-
- // Initialize port location with proposed location
- // and resolve the bounds of it graphical parent
- Rectangle realLocation = new Rectangle(proposedLocation);
-
- Rectangle parentRec = getParentFigure().getBounds().getCopy();
-
- // Calculate Max position around the graphical parent (1/2 size or the port around
- // the graphical parent bounds.
- // this is an intra rectangle
- int xMin = parentRec.x;
- int xMax = parentRec.x - (2 * borderItemOffset) + parentRec.width;
- int yMin = parentRec.y;
- int yMax = parentRec.y - (2 * borderItemOffset) + parentRec.height;
-
- // Modify Port location if MAX X or Y are exceeded
- if (realLocation.x < xMin) {
- realLocation.x = xMin;
- }
-
- if (realLocation.x > xMax) {
- realLocation.x = xMax;
- }
-
- if (realLocation.y < yMin) {
- realLocation.y = yMin;
- }
-
- if (realLocation.y > yMax) {
- realLocation.y = yMax;
- }
-
- // Ensure the port is positioned on its parent borders and not in the middle.
- // Modify position if needed.
- if ((realLocation.y != yMin) && (realLocation.y != yMax)) {
- if ((realLocation.x != xMin) && (realLocation.x != xMax)) {
-
- if (realLocation.x <= (xMin + (parentRec.width / 2))) {
- realLocation.x = xMin;
- } else {
- realLocation.x = xMax;
- }
- }
- }
-
- // Return constrained location
- return realLocation;
- }
-}
+/*****************************************************************************
+ * Copyright (c) 2009-2011 CEA LIST.
+ *
+ *
+ * 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:
+ * Yann Tanguy (CEA LIST) yann.tanguy@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.diagram.composite.custom.locators;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.papyrus.uml.diagram.common.locator.PortPositionLocator;
+
+
+public class InternalPortPositionLocator extends PortPositionLocator {
+
+ /**
+ * @since 3.0
+ */
+ public InternalPortPositionLocator(IFigure parentFigure) {
+ super(parentFigure);
+ }
+
+ @Deprecated
+ public InternalPortPositionLocator(IFigure parentFigure, int preferredSide) {
+ super(parentFigure, preferredSide);
+ }
+
+
+ /**
+ *
+ * @param proposedLocation
+ * the proposed location
+ * @return a possible location on parent figure border
+ */
+ @Override
+ public Rectangle getPreferredLocation(Rectangle proposedLocation) {
+
+ // Initialize port location with proposed location
+ // and resolve the bounds of it graphical parent
+ Rectangle realLocation = new Rectangle(proposedLocation);
+
+ Rectangle parentRec = getParentFigure().getBounds().getCopy();
+
+ // Calculate Max position around the graphical parent (1/2 size or the port around
+ // the graphical parent bounds.
+ // this is an intra rectangle
+ int xMin = parentRec.x;
+ int xMax = parentRec.x - (2 * borderItemOffset) + parentRec.width;
+ int yMin = parentRec.y;
+ int yMax = parentRec.y - (2 * borderItemOffset) + parentRec.height;
+
+ // Modify Port location if MAX X or Y are exceeded
+ if (realLocation.x < xMin) {
+ realLocation.x = xMin;
+ }
+
+ if (realLocation.x > xMax) {
+ realLocation.x = xMax;
+ }
+
+ if (realLocation.y < yMin) {
+ realLocation.y = yMin;
+ }
+
+ if (realLocation.y > yMax) {
+ realLocation.y = yMax;
+ }
+
+ // Ensure the port is positioned on its parent borders and not in the middle.
+ // Modify position if needed.
+ if ((realLocation.y != yMin) && (realLocation.y != yMax)) {
+ if ((realLocation.x != xMin) && (realLocation.x != xMax)) {
+
+ if (realLocation.x <= (xMin + (parentRec.width / 2))) {
+ realLocation.x = xMin;
+ } else {
+ realLocation.x = xMax;
+ }
+ }
+ }
+
+ // Return constrained location
+ return realLocation;
+ }
+}

Back to the top