Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemi Schnekenburger2016-12-06 10:48:54 +0000
committerRemi Schnekenburger2016-12-06 15:30:42 +0000
commit78fb0b33a3b85eceeeca1ecd44384d0c95c4c70f (patch)
tree775c73d0e433031308dac875db2c081e70de820b
parente28d6a4a344231c310b9a4f8acf1ba21a3d9f866 (diff)
downloadorg.eclipse.papyrus-78fb0b33a3b85eceeeca1ecd44384d0c95c4c70f.tar.gz
org.eclipse.papyrus-78fb0b33a3b85eceeeca1ecd44384d0c95c4c70f.tar.xz
org.eclipse.papyrus-78fb0b33a3b85eceeeca1ecd44384d0c95c4c70f.zip
Bug 508732: PortLocator may return a lot lot of warning
https://bugs.eclipse.org/bugs/show_bug.cgi?id=508732 - removing useless warning. Conflicts: plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/locator/PortPositionLocator.java Change-Id: I5894b14a4e5f5aa6b02b8b79d522641912db9e11 Signed-off-by: Remi Schnekenburger <remi.schnekenburger@cea.fr>
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/locator/PortPositionLocator.java56
1 files changed, 23 insertions, 33 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/locator/PortPositionLocator.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/locator/PortPositionLocator.java
index d468974fbe8..ef24e9ce14d 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/locator/PortPositionLocator.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/locator/PortPositionLocator.java
@@ -29,7 +29,6 @@ import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SVGNodePlateFigure;
import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SlidableRoundedRectangleAnchor;
import org.eclipse.papyrus.infra.gmfdiag.common.utils.FigureUtils;
import org.eclipse.papyrus.infra.gmfdiag.common.utils.PortPositionEnum;
-import org.eclipse.papyrus.uml.diagram.common.Activator;
/**
*
@@ -80,9 +79,9 @@ public class PortPositionLocator implements IBorderItemLocator {
* the parent figure
* @param preferredSide
* unused
- * @deprecated
+ * @deprecated use PortPositionLocator(final IFigure parentFigure)
*/
- @Deprecated // use PortPositionLocator(final IFigure parentFigure)
+ @Deprecated
public PortPositionLocator(final IFigure parentFigure, final int preferredSide) {
// The preferredSide parameter is not used, just kept here to ensure compatibility
// with GMF generated code.
@@ -122,8 +121,8 @@ public class PortPositionLocator implements IBorderItemLocator {
*/
public void setPosition(final PortPositionEnum position) {
this.position = position;
- }
-
+ }
+
/**
* get the parent figure
*
@@ -154,10 +153,8 @@ public class PortPositionLocator implements IBorderItemLocator {
*/
public Rectangle getConstraint() {
return constraint;
- }
-
+ }
-
/**
* {@inheritDoc}
*
@@ -178,10 +175,9 @@ public class PortPositionLocator implements IBorderItemLocator {
public Rectangle getPreferredLocation(final Rectangle proposedLocation) {
// If it's a SVGNodePlate get the anchor to get the position
if (parentFigure instanceof SVGNodePlateFigure &&
- ((SVGNodePlateFigure) parentFigure).getConnectionAnchor(NodeFigure.szAnchor) instanceof SlidableRoundedRectangleAnchor) {
- return getSVGPreferredLocation(proposedLocation,(SVGNodePlateFigure) parentFigure, (SlidableRoundedRectangleAnchor) ((SVGNodePlateFigure) parentFigure).getConnectionAnchor((NodeFigure.szAnchor)) );
- }
- else {
+ ((SVGNodePlateFigure) parentFigure).getConnectionAnchor(NodeFigure.szAnchor) instanceof SlidableRoundedRectangleAnchor) {
+ return getSVGPreferredLocation(proposedLocation, (SVGNodePlateFigure) parentFigure, (SlidableRoundedRectangleAnchor) ((SVGNodePlateFigure) parentFigure).getConnectionAnchor((NodeFigure.szAnchor)));
+ } else {
return getPreferedLocationOldWay(proposedLocation);
}
}
@@ -190,22 +186,23 @@ public class PortPositionLocator implements IBorderItemLocator {
/**
*
* Get the svg preferred position by letting the connection anchor calculate the position.
+ *
* @param proposedLocation
* @param svgNodePlateFigure
* @param slidableRoundedRectangleAnchor
* @return
*/
- private Rectangle getSVGPreferredLocation(final Rectangle proposedLocation,SVGNodePlateFigure svgNodePlateFigure,SlidableRoundedRectangleAnchor slidableRoundedRectangleAnchor) {
+ private Rectangle getSVGPreferredLocation(final Rectangle proposedLocation, SVGNodePlateFigure svgNodePlateFigure, SlidableRoundedRectangleAnchor slidableRoundedRectangleAnchor) {
Rectangle parentRec = getParentFigure().getBounds().getCopy();
// get the offset depending of the position of the port (inside, outside or onLine)
- Dimension proposedOffset = getPortOffset(proposedLocation.getSize());
+ Dimension proposedOffset = getPortOffset(proposedLocation.getSize());
Rectangle realLocation = new Rectangle(proposedLocation);
// Initialize port location with proposed location
// and resolve the bounds of it graphical parent
-
+
// Translate it to have the mouse at the center of the port
realLocation.translate(realLocation.width / 2, realLocation.height / 2);
-
+
// Translate location to absolute before calculating the location point (this is required, since getLocation
// from connectionAnchor work on absolute coordinates: see getPolygonPoints in GMF's BaseSlidableAnchor
// Use a precise rectangle to reduce precision loss during scaling
@@ -214,11 +211,11 @@ public class PortPositionLocator implements IBorderItemLocator {
// Set the offset
slidableRoundedRectangleAnchor.setOffset(proposedOffset);
-
+
// Yet, we get scaling issues, since the getLocation function only expects/returns a point and not the precise variant
Point location = new Point((int) Math.round(preciseLocation.preciseX()), (int) Math.round(preciseLocation.preciseY()));
Point locationForPort = slidableRoundedRectangleAnchor.getLocation(location);
-
+
// Reset the offset
slidableRoundedRectangleAnchor.setOffset(new Dimension());
@@ -233,19 +230,16 @@ public class PortPositionLocator implements IBorderItemLocator {
// despite of rounding above, it is possible that the conversion to absolute (and back) shifts the desired
// position by one pixel. Handle this specific case (in case of rectangles)
- if (realLocation.x == parentRec.x-1) {
+ if (realLocation.x == parentRec.x - 1) {
realLocation.x = parentRec.x;
- }
- else if (realLocation.y == parentRec.y-1) {
+ } else if (realLocation.y == parentRec.y - 1) {
realLocation.y = parentRec.y;
- }
- else if (realLocation.x == parentRec.x + parentRec.width - 1) {
+ } else if (realLocation.x == parentRec.x + parentRec.width - 1) {
realLocation.x = parentRec.x + parentRec.width;
- }
- else if (realLocation.y == parentRec.y + parentRec.height - 1) {
+ } else if (realLocation.y == parentRec.y + parentRec.height - 1) {
realLocation.y = parentRec.y + parentRec.height - 1;
}
-
+
// re-translate back from port center to top-left coordinates
realLocation.translate(-realLocation.width / 2, -realLocation.height / 2);
return realLocation;
@@ -366,7 +360,7 @@ public class PortPositionLocator implements IBorderItemLocator {
/**
- * Gets the current side of parent.
+ * Gets the current side of parent.
*
* @return the current side of parent
* @see org.eclipse.gmf.runtime.draw2d.ui.figures.IBorderItemLocator#getCurrentSideOfParent()
@@ -401,10 +395,6 @@ public class PortPositionLocator implements IBorderItemLocator {
Rectangle internalRectangle = basisRectangle.getShrinked(new Insets(skink_height, skink_width, skink_height, skink_width));
// let draw2D to compute position
int position = internalRectangle.getPosition(constraint.getTopLeft());
- // use to Debug
- if (PositionConstants.NONE == position){
- Activator.log.warn("Unknown current side( basisRectangle " +basisRectangle+" internalRectangle"+internalRectangle+ " constraint"+constraint+ " "+position+")"); //$NON-NLS-1$
- }
return position;
}
@@ -432,7 +422,7 @@ public class PortPositionLocator implements IBorderItemLocator {
// Refresh nodeShape bounds in case of resize
RoundedRectangleNodePlateFigure nodePlateFigure = FigureUtils.findChildFigureInstance(figure, RoundedRectangleNodePlateFigure.class);
- if (nodePlateFigure != null){
+ if (nodePlateFigure != null) {
if (figure instanceof RoundedRectangleNodePlateFigure) {
for (Object child : nodePlateFigure.getChildren()) {
if (child instanceof IFigure) {
@@ -441,7 +431,7 @@ public class PortPositionLocator implements IBorderItemLocator {
}
}
// to force the refresh, invalidate coordinates of the parent if refresh him + all children
- nodePlateFigure.invalidate();
+ nodePlateFigure.invalidate();
}
}
}

Back to the top