Home » Modeling » Graphiti » Connections between BoxRelativeAnchors with different GAs
Connections between BoxRelativeAnchors with different GAs [message #792960] |
Tue, 07 February 2012 15:58 |
Craig Petre Messages: 32 Registered: April 2011 |
Member |
|
|
Hey, I'm having some trouble making connections between BoxRelativeAnchors with different contained GraphicsAlgorithm. Here a screen shot of the issue I'm having:
The top connections are between 3 separate BoxRelativeAnchors. The left and right anchors contain a RoundedRectangle while the center anchor contains an Ellipse, they are setup like the following:
final ContainerShape portShape = PictogramsFactory.eINSTANCE.createContainerShape();
portShape.getProperties().addAll(new ArrayList<Property>(0));
portShape.setVisible(true);
portShape.setActive(true);
final Rectangle portRectangle = ga.createRectangle(portShape);
final BoxRelativeAnchor anchor = pe.createBoxRelativeAnchor(portShape);
anchor.setReferencedGraphicsAlgorithm(portRectangle);
anchor.setRelativeHeight(0);
anchor.setRelativeWidth(0);
final RoundedRectangle rect = ga.createRoundedRectangle(anchor, 5, 5);
The center anchor is created like this:
final ContainerShape rootShape = this.createContainerShape(targetDiagram, obj);
final Rectangle extRect = ga.createInvisibleRectangle(rootShape);
final int offsetFromCenter = (int) ((10 * 1.6) / 2);
extRect.setX(xloc - offsetFromCenter);
extRect.setY(yloc - offsetFromCenter);
final BoxRelativeAnchor anchor = pe.createBoxRelativeAnchor(rootShape);
anchor.setReferencedGraphicsAlgorithm(extRect);
anchor.setRelativeHeight(0);
anchor.setRelativeWidth(0);
final Ellipse dot = ga.createEllipse(anchor);
dot.setForeground(this.manageColor(255, 0, 0));
dot.setBackground(this.manageColor(0, 0, 255));
And as you can see, the end point of the connection to the middle anchor does not end up in the center. The only difference between the first three connections, where the end points are off center and the second set of three connections where they are on center, is I changed the middle anchor to contain a RoundedRectangle as in the case of the left and right anchors instead of an Ellipse.
//final Ellipse dot = ga.createEllipse(anchor);
final RoundedRectangle dot = ga.createRoundedRectangle(anchor, 5, 5);
dot.setForeground(this.manageColor(255, 0, 0));
dot.setBackground(this.manageColor(0, 0, 255));
I would expect the anchor to behave the same regardless of the contained shape, but maybe that assumption isn't valid, or maybe there is something wrong with my implementation?
Thanks,
Craig
-
Attachment: anchors.png
(Size: 1.47KB, Downloaded 564 times)
|
|
| |
Re: Connections between BoxRelativeAnchors with different GAs [message #794542 is a reply to message #794456] |
Thu, 09 February 2012 12:21 |
Craig Petre Messages: 32 Registered: April 2011 |
Member |
|
|
Hi Michael. The reason for the invisible rectangle around is that the "dot" can be moved by the user. So if they click on the dot, they can begin a connection and if they click around the edge of the dot they can move it.
The dot extends AbstractPattern and the size is set in the overridden "layout" function. Here are the contents of that function.
final IGaService ga = Graphiti.getGaService();
final Shape shape = (Shape) context.getPictogramElement();
// Layout the invisible rectangle
final int width = (int) (10 * 1.6);
ga.setSize(shape.getGraphicsAlgorithm(), width, width);
// Layout the anchor circle
final int offset = (width - 10) / 2;
ga.setLocationAndSize(shape.getAnchors().get(0).getGraphicsAlgorithm(), offset, offset, 10, 10);
return true;
I probably should have mentioned this before, but the two exterior connection points in the screen shot are part of a larger composite geometry (also extending AbstractPattern) whose sizing is also taken care of in the layout function. Here is a distilled version of the layout function which pertains only to the port sections of the pattern.
ga.setLocationAndSize(shape.getGraphicsAlgorithm(), 0, 21, 39, 19);
//Layout the anchor pad
ga.setLocationAndSize(shape.getAnchors().get(0).getGraphicsAlgorithm(), 29, 9, 10, 10);
The above is from a debug run of the layout of the port on the left side of the screen shot. There could be several ports on any given side and the "shape" referenced above actually looks something like ---[] with the anchor being the rectangle at the end.
Thanks for getting back to me, let me know if more information would be helpful,
Craig
|
|
|
Re: Connections between BoxRelativeAnchors with different GAs [message #868010 is a reply to message #792960] |
Tue, 01 May 2012 15:46 |
Craig Petre Messages: 32 Registered: April 2011 |
Member |
|
|
Sorry to bring this up again, but I believe I've been able to reproduce the issue I was seeing above (and still see) in the sketch tool. There are a couple things in the screen shots below that look a little weird. The first image at 0% zoom is a FreeFormConnection between two RoundedRectangles and another between a RoundedRectangle and Ellipse from the sketch palette. The connection between the RoundedRectangle and Ellipse seems to trail upwards from left to right instead of being perfectly horizontal as in the RoundedRectangle to RoundedRectangle case. In the second screen shot at 400% (same exact geometries/connections) you can see they end up looking about the same, though maybe this is just distortion from the zoom or something and not an actual improvement, it is hard to tell. The second thing I notice is that the connection is not centered on the grid, which is most obvious at the 400% zoom. I'm not sure what causes this, in some cases I am able to draw connections that do end up on grid, so the cases I'm illustrating here may be intermittent. The last small issue I see is that the right side of the connection always contains a space between the end of the connection and the start of the anchor. It doesn't seem to matter where you start or end the connection or between what anchor, the space is always there and always on the right side of the connection.
Any ideas? Or maybe I have enough information now where it may be helpful to file a bug report?
Thanks,
Craig
-
Attachment: no_zoom.png
(Size: 5.33KB, Downloaded 284 times) -
Attachment: 400_zoom.png
(Size: 26.21KB, Downloaded 325 times)
|
|
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
Goto Forum:
Current Time: Thu Sep 26 21:17:56 GMT 2024
Powered by FUDForum. Page generated in 0.24361 seconds
|