Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » ChopBoxAnchor vs. BoxRelativeAnchor
ChopBoxAnchor vs. BoxRelativeAnchor [message #909289] Thu, 06 September 2012 22:07 Go to next message
Hallvard Traetteberg is currently offline Hallvard TraettebergFriend
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 #909609 is a reply to message #909289] Fri, 07 September 2012 12:10 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Hallvard,

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).
- 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.

Michael
Re: ChopBoxAnchor vs. BoxRelativeAnchor [message #909737 is a reply to message #909609] Fri, 07 September 2012 17:18 Go to previous messageGo to next message
Hallvard Traetteberg is currently offline Hallvard TraettebergFriend
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 Go to previous messageGo to next message
Hallvard Traetteberg is currently offline Hallvard TraettebergFriend
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
Re: ChopBoxAnchor vs. BoxRelativeAnchor [message #910671 is a reply to message #909759] Mon, 10 September 2012 07:37 Go to previous message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Hallvard,

hm, that appears to be a bug, would you please open a bugzilla to track
this?

Thanks,
Michael
Previous Topic:how to deal with EDataType
Next Topic:Adding function to the palette?
Goto Forum:
  


Current Time: Thu Mar 28 12:45:04 GMT 2024

Powered by FUDForum. Page generated in 0.01635 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top