Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/locators/BasePortChildLocator.java17
1 files changed, 13 insertions, 4 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/locators/BasePortChildLocator.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/locators/BasePortChildLocator.java
index c272bdd4369..4044ca25a3a 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/locators/BasePortChildLocator.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/locators/BasePortChildLocator.java
@@ -37,16 +37,16 @@ public abstract class BasePortChildLocator implements IBorderItemLocator {
int side = 0;
;
- if (yPortLocation == parent.y) {
+ if (nearByOne(yPortLocation, parent.y)) {
side = side | PositionConstants.NORTH;
}
- if (yPortLocation == parent.y + parent.height) {
+ if (nearByOne(yPortLocation, parent.y + parent.height)) {
side = side | PositionConstants.SOUTH;
}
- if (xPortLocation == parent.x) {
+ if (nearByOne(xPortLocation, parent.x)) {
side = side | PositionConstants.WEST;
}
- if (xPortLocation == parent.x + parent.width) {
+ if (nearByOne(xPortLocation, parent.x + parent.width)) {
side = side | PositionConstants.EAST;
}
@@ -54,6 +54,15 @@ public abstract class BasePortChildLocator implements IBorderItemLocator {
return side == 0 ? PositionConstants.SOUTH : side;
}
+ /**
+ * @param pos1 first number
+ * @param pos2 second number
+ * @return true, if absolute of the difference between two integers is smaller than one
+ */
+ private boolean nearByOne(int pos1, int pos2) {
+ return Math.abs(pos1-pos2) <= 1;
+ }
+
private Rectangle getParentBounds() {
IFigure parent = myPort.getParent();
while (false == parent instanceof SelectableBorderedNodeFigure && parent != null) {

Back to the top