Home » Modeling » Graphiti » ChopBoxAnchor vs. BoxRelativeAnchor
ChopBoxAnchor vs. BoxRelativeAnchor [message #909289] |
Thu, 06 September 2012 22:07 |
Hallvard Traetteberg Messages: 673 Registered: July 2009 Location: Trondheim, Norway |
Senior Member |
|
|
Hi,
I am working on an editor where I have connections from arrow-like shape
to another (from the tip of one to the base of the other). I use a
chopbox anchor for making the source and target easier to hit and a
boxrelative anchor for placing the end-points afterwards. I.e. the
boxrelative anchors are passed to the add service after the chopbox
anchors have been used/hit by the user.
However, when the new connection is rendered, the position of the
boxrelative anchor/ellipses ends up far outside the polygon to which it
is attached, so far that the connection isn't visible without a lot of
scrolling. If I instead use the chopbox anchor for positioning the
connection it works fine, but the line will of course not start and end
at the tip and base respectively.
Here's the relevant code I use for configuring the anchors.
IGaService gaService = Graphiti.getGaService();
int portSize = LayoutPortFeature.DEFAULT_PORT_SIZE;
Polygon polygon = gaService.createPlainPolygon(shape, new int[]{0, 0,
portSize, 0, portSize, portSize, 0, portSize});
polygon.setForeground(manageColor(LayoutPortFeature.PORT_FOREGROUND));
polygon.setLineWidth(1);
BoxRelativeAnchor boxAnchor =
peCreateService.createBoxRelativeAnchor(shape);
boxAnchor.setReferencedGraphicsAlgorithm(polygon);
Ellipse anchorEllipse = gaService.createEllipse(boxAnchor);
anchorEllipse.setForeground(manageColor(LayoutPortFeature.PORT_FOREGROUND));
anchorEllipse.setBackground(manageColor(LayoutPortFeature.PORT_BACKGROUND));
gaService.setLocationAndSize(anchorEllipse, -2, -2, 5, 5);
ChopboxAnchor chopBoxAnchor = peCreateService.createChopboxAnchor(shape);
chopBoxAnchor.setReferencedGraphicsAlgorithm(polygon);
Is this a known problem with boxrelativeanchor?
Best regards,
Hallvard Trætteberg
|
|
| |
Re: ChopBoxAnchor vs. BoxRelativeAnchor [message #909737 is a reply to message #909609] |
Fri, 07 September 2012 17:18 |
Hallvard Traetteberg Messages: 673 Registered: July 2009 Location: Trondheim, Norway |
Senior Member |
|
|
Michael,
The structure is simple, I have a Shape with a Polygon as its GA and the
BoxRelativeAnchor inside the Shape related to the Polyon with an Ellipse
inside. Here's the code for creating them:
Shape shape = peCreateService.createShape(parentShape, true);
Polygon polygon = gaService.createPlainPolygon(shape, new int[]{0, 0,
portSize, 0, portSize, portSize, 0, portSize});
BoxRelativeAnchor boxAnchor =
peCreateService.createBoxRelativeAnchor(shape);
boxAnchor.setReferencedGraphicsAlgorithm(polygon);
Ellipse anchorEllipse = gaService.createEllipse(boxAnchor);
gaService.setLocationAndSize(anchorEllipse, -2, -2, 5, 5);
> there are two things that come to my mind:
> - do you set relative width and height for the BoxRelativeAnchor? They
> define where the anchor is positioned (default would be 0).
Yes, but even though the default width=0, height=0 were used, the anchor
would be within the polygon.
> - Is the root shape (variable shape) active? In case not and shape is a
> direct child of the diagram it will use the coordinate system of the
> diagram to position the anchor; in combination with 0 as relative width
> and height this might result in the origin of the diagram.
But in any case, the Polygon and the BoxRelativeAnchor w/Ellipse should
be rendered together, now they're miles (in pixels) apart!
I've been trying to debug by setting breakpoints inside the
GFChopBoxAnchor that is used to render the BoxRelativeAnchor, but I
haven't been able to find out when the position values are getting so
wrong. Any hints of where to look?
Hallvard
|
|
|
Re: ChopBoxAnchor vs. BoxRelativeAnchor [message #909759 is a reply to message #909737] |
Fri, 07 September 2012 18:17 |
Hallvard Traetteberg Messages: 673 Registered: July 2009 Location: Trondheim, Norway |
Senior Member |
|
|
Michael,
I replaced the Polygon with a rectangle with the same location and size
(in fact with the same corners/edges so it looked exactly alike) and
then the anchor seemed to appear at the correct position. I then mixed
them so that the source anchor was on a rectangle and the target on a
polygon, and it was easy to see that the source anchor was correctly
location and the target anchor far off.
Any hints on where to set breakpoints to find out where the computation
is wrong?
BTW, I use Indigo but have updated to 0.9.0.
Hallvard
On 07.09.12 10.18, Hallvard Trætteberg wrote:
> Michael,
>
> The structure is simple, I have a Shape with a Polygon as its GA and the
> BoxRelativeAnchor inside the Shape related to the Polyon with an Ellipse
> inside. Here's the code for creating them:
>
> Shape shape = peCreateService.createShape(parentShape, true);
> Polygon polygon = gaService.createPlainPolygon(shape, new int[]{0, 0,
> portSize, 0, portSize, portSize, 0, portSize});
> BoxRelativeAnchor boxAnchor =
> peCreateService.createBoxRelativeAnchor(shape);
> boxAnchor.setReferencedGraphicsAlgorithm(polygon);
> Ellipse anchorEllipse = gaService.createEllipse(boxAnchor);
> gaService.setLocationAndSize(anchorEllipse, -2, -2, 5, 5);
> > there are two things that come to my mind:
>
>> - do you set relative width and height for the BoxRelativeAnchor? They
>> define where the anchor is positioned (default would be 0).
>
> Yes, but even though the default width=0, height=0 were used, the anchor
> would be within the polygon.
>
>> - Is the root shape (variable shape) active? In case not and shape is a
>> direct child of the diagram it will use the coordinate system of the
>> diagram to position the anchor; in combination with 0 as relative width
>> and height this might result in the origin of the diagram.
>
> But in any case, the Polygon and the BoxRelativeAnchor w/Ellipse should
> be rendered together, now they're miles (in pixels) apart!
>
> I've been trying to debug by setting breakpoints inside the
> GFChopBoxAnchor that is used to render the BoxRelativeAnchor, but I
> haven't been able to find out when the position values are getting so
> wrong. Any hints of where to look?
>
> Hallvard
|
|
| |
Goto Forum:
Current Time: Thu Mar 28 12:45:04 GMT 2024
Powered by FUDForum. Page generated in 0.01635 seconds
|