Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Nested GA inside FixedPointAnchors?
Nested GA inside FixedPointAnchors? [message #715897] Mon, 15 August 2011 21:45 Go to next message
Hernan Gonzalez is currently offline Hernan GonzalezFriend
Messages: 181
Registered: October 2010
Location: Buenos Aires, Argentina
Senior Member
This is driving me nuts. I (thought) understood that all coordinates for a GA (Graphic Algorithm) are relative to its parent GA. But I can't understand how that applies to a FixedPointAnchor.

[url=http://imageshack.us/photo/my-images/856/graphiti.png/]image[/img]


The figure (grid size=10) corresponds to this hierarchy:

containerShape ----> invisibleRectangle (100x200)
  |    |              |
  |    |              |__ roundedRectangle1 (BLUE, 10px right/left margins)
  |    |                    |
  |    |                    |__ roundedRectangle2 (RED)
  |    |
  |   shape2 --->  roundedRectangle3 (GREEN)
  |                |
  |                |___ roundedRectangle4 ( ORANGE)
  |
 anchor  (FIXED POINT ANCHOR: at 0-100)
     |
     |___ roundedRectangle5 (LIGHT_GREEN)
               |
               |__ roundedRectangle6 (LIGHT_ORANGE)



The coordinates of the first 4 roundedRectangles works as expected.
With the FixedPointAnchor, they don't, specially the nested roundedRectangle6

First: I had found out that every Pictogram Element (PE) (at least a Shape)
must contain a GA: a Shape per se doesnt know about its size or position, it's
its GA who knows that. But , what about anchors?
It's reasonable that roundedRectangle5 has its coordinates relative to the anchor position ? Has a FixedPointAnchor an implicit GA inside? (it seems to have a position but not a size).

But I could buy that; what I dont get is the behaviour of the nested GA (roundedRectangle6). To make it work, I had to specify a position that is not relative to its parent GA (roundedRectangle5), but to some combination of its parent and the anchor position. See code below. Is this a bug?

    ContainerShape containerShape =  peCreateService.createContainerShape(targetDiagram, true);
    int width = 100; 
    int height = 200;
    int grid = 10;
    {
      Rectangle invisibleRectangle =  gaService.createInvisibleRectangle(containerShape);
      gaService.setLocationAndSize(invisibleRectangle,
          context.getX(),context.getY(),width,height);
      RoundedRectangle roundedRectangle = gaService.createRoundedRectangle(invisibleRectangle, 5, 5);
      roundedRectangle.setBackground(manageColor(IColorConstant.BLUE));
      gaService.setLocationAndSize(roundedRectangle, grid,0,width-grid*2,height);
      
      
      RoundedRectangle roundedRectangle2 = gaService.createRoundedRectangle(roundedRectangle, 5, 5);
      roundedRectangle2.setBackground(manageColor(IColorConstant.RED));
      gaService.setLocationAndSize(roundedRectangle2, 5,5,20,20);
    }
    
    {
      Shape shape2 = peCreateService.createShape(containerShape, true);
      
      RoundedRectangle roundedRectangle3 = gaService.createRoundedRectangle(shape2, 5, 5);
      roundedRectangle3.setBackground(manageColor(IColorConstant.GREEN));
      gaService.setLocationAndSize(roundedRectangle3, 5,30,70,40);
      
      RoundedRectangle roundedRectangle4 = gaService.createRoundedRectangle(roundedRectangle3, 5, 5);
      roundedRectangle4.setBackground(manageColor(IColorConstant.ORANGE));
      gaService.setLocationAndSize(roundedRectangle4, 10,10,20,20);
    }
    
    {
      FixPointAnchor anchor = peCreateService.createFixPointAnchor(containerShape);
      Point fixPoint = gaService.createPoint(0,100);
      anchor.setLocation(fixPoint);
      
      RoundedRectangle rrect5 = gaService.createRoundedRectangle(anchor, 5, 5);
      rrect5.setBackground(manageColor(IColorConstant.LIGHT_GREEN));
      gaService.setLocationAndSize(rrect5, 5,-10,70,40);
      
      RoundedRectangle rrect6 = gaService.createRoundedRectangle(rrect5, 5, 5);
      rrect6.setBackground(manageColor(IColorConstant.LIGHT_ORANGE));
      //gaService.setLocationAndSize(rrect6, 10,10,20,20); // THIS SHOULD WORK, IT DOESNT
      gaService.setLocationAndSize(rrect6, 10,-90,20,20);
    }






[Updated on: Mon, 15 August 2011 21:49]

Report message to a moderator

Re: Nested GA inside FixedPointAnchors? [message #716103 is a reply to message #715897] Tue, 16 August 2011 13:11 Go to previous messageGo to next message
Matthias Gorning is currently offline Matthias GorningFriend
Messages: 81
Registered: April 2010
Location: Germany
Member
Hi Hernan,
the FixPointAnchor doesn't have an implicit GA, but it has a position. The coordinates of the graphics algorithm (which is assigned to the FixPointAnchor), are relative to this anchor position.

I've tested your code. You are right, there is a bug in Graphiti if a FixPointAnchor has nested GA's.

Please open a bugzilla. You can simply reference this posting.

BR,
Matthias

Re: Nested GA inside FixedPointAnchors? [message #716122 is a reply to message #716103] Tue, 16 August 2011 13:46 Go to previous message
Hernan Gonzalez is currently offline Hernan GonzalezFriend
Messages: 181
Registered: October 2010
Location: Buenos Aires, Argentina
Senior Member
Matthias Gorning wrote on Tue, 16 August 2011 10:11

I've tested your code. You are right, there is a bug in Graphiti if a FixPointAnchor has nested GA's.

Please open a bugzilla. You can simply reference this posting.



Done: #354824. Thanks.

HernĂ¡n

[Updated on: Tue, 16 August 2011 13:46]

Report message to a moderator

Previous Topic:Diagram properties
Next Topic:Drag and Drop to SWT
Goto Forum:
  


Current Time: Wed Nov 26 07:02:34 GMT 2014

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

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