Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » GraphicsAlgorithm coordinates: relative to....?
GraphicsAlgorithm coordinates: relative to....? [message #873150] Thu, 17 May 2012 15:47 Go to next message
Hernan Gonzalez is currently offline Hernan Gonzalez
Messages: 181
Registered: October 2010
Location: Buenos Aires, Argentina
Senior Member
The GraphicAlgorithm's coordinates are relative to... what?

This is surely a very simple question but the docs are quite obscure (I've already filled a bug with respect to the docs).

Specifically: If, inside a parent ContainerShape I want to create the following

containerShape (active) -> Rectangle rect
  |
  |
  containerShape2 (inactive) -> Rectangle rect2
       |
       | shape3 (active) -> Rectangle rect3


ContainerShape containerShape2 = peCreateService.createContainerShape(containerShape, false);
Rectangle rect2 = gaService.createRectangle(containerShape2);
gaService.setLocationAndSize(rect2, 3, 31, 23, 48);
rect2.setBackground(manageColor(IColorConstant.BLUE));

Shape shape3 = peCreateService.createContainerShape(containerShape2, true);
Rectangle rect3 = gaService.createRectangle(shape3);
// rect3.setParentGraphicsAlgorithm(rect2); // SO!!!
gaService.setLocationAndSize(rect3, 1, 1, 20, 12);
rect3.setBackground(manageColor(IColorConstant.YELLOW));


it seems that the coordinates of rect3 are relative to rect2 if containerShape2 is active, but if if it's not, it's relative to rect (the grandparent shape). Is this correct, and expected behaviuor?
Further, if I uncomment the setParentGraphicsAlgorithm() line, I get a StackOverflowException (I guess this is a bug?)

[Updated on: Thu, 17 May 2012 15:48]

Report message to a moderator

Re: GraphicsAlgorithm coordinates: relative to....? [message #873215 is a reply to message #873150] Thu, 17 May 2012 18:03 Go to previous messageGo to next message
Hernan Gonzalez is currently offline Hernan Gonzalez
Messages: 181
Registered: October 2010
Location: Buenos Aires, Argentina
Senior Member
I answer my own question: The documentation about the behaviour of inactive/active flag from shapes happens to be, not in the Shape.isActive() javadocs, but in IPeCreateService (https://bugs.eclipse.org/bugs/show_bug.cgi?id=379825#c1 )

"an inactive [shape] does not provide[a coordinate system] but uses the coordinate
system of its next active parent for layouting its children."

Clear enough.

I'm reporting the issue about the SO when calling setParentGraphicsAlgorithm()
Re: GraphicsAlgorithm coordinates: relative to....? [message #873259 is a reply to message #873215] Thu, 17 May 2012 20:31 Go to previous messageGo to next message
Hernan Gonzalez is currently offline Hernan Gonzalez
Messages: 181
Registered: October 2010
Location: Buenos Aires, Argentina
Senior Member
Still some doubts remain.

- Does a ContainerShape, even if it's intended only to group Shapes, requires always a GA ? (it seems it does)
- Is the GA of a ContainerShape a parent (in Draw2D terms) of the GA of the children shapes?
Re: GraphicsAlgorithm coordinates: relative to....? [message #875122 is a reply to message #873259] Tue, 22 May 2012 07:29 Go to previous messageGo to next message
Michael Wenz is currently offline Michael Wenz
Messages: 1595
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Simple answer to both questions: yes

Michael

"Hernan Gonzalez" schrieb im Newsbeitrag
news:jp3n73$8ab$1@xxxxxxxxe.org...

Still some doubts remain.

- Does a ContainerShape, even if it's intended only to group Shapes,
requires always a GA ? (it seems it does)
- Is the GA of a ContainerShape a parent (in Draw2D terms) of the GA of the
children shapes?
Re: GraphicsAlgorithm coordinates: relative to....? [message #875970 is a reply to message #875122] Wed, 23 May 2012 16:33 Go to previous messageGo to next message
Hernan Gonzalez is currently offline Hernan Gonzalez
Messages: 181
Registered: October 2010
Location: Buenos Aires, Argentina
Senior Member
Hmmm are you sure about the second one?

If think that that's not true if the ContainerShape is inactive.

Example:

ContainerShape1  (active) ===> GA: rectangle1 400x400
  |
   -->  ContainerShape2  (inactive) ===> GA: rectangle2 200x200, pos: 100,100 
         |               (in the middle of rectangle1 )
         |
          ---> Shape3   (active) ===> GA: rectangle3 20x20, pos: 40,40


Is the position of Shape3 relative to the rectangle2 or rectangle1?
That's the point of my question. And the answer, unless I'm mistaken,
is that IF ContainerShape2 IS INACTIVE, it's relative to rectangle1
(hence, it's drawn outside rectangle2)

This would implies two things:
1 - the layout can change dramatically when toggling the active/inactive flag for a shape (which makes sense, but is not very intuitive - that's why I think the javadocs of setActive/getActive should make this clear)
2 - rectangle3 cannot be (in the Draw2D world) a children of rectangle2

Please correct me if I got something wrong.

Michael Wenz wrote on Tue, 22 May 2012 04:29
Simple answer to both questions: yes

Michael

"Hernan Gonzalez" schrieb im Newsbeitrag
news:jp3n73$8ab$1@xxxxxxxxe.org...

Still some doubts remain.

- Does a ContainerShape, even if it's intended only to group Shapes,
requires always a GA ? (it seems it does)
- Is the GA of a ContainerShape a parent (in Draw2D terms) of the GA of the
children shapes?
Re: GraphicsAlgorithm coordinates: relative to....? [message #876025 is a reply to message #875970] Wed, 23 May 2012 19:18 Go to previous messageGo to next message
Hernan Gonzalez is currently offline Hernan Gonzalez
Messages: 181
Registered: October 2010
Location: Buenos Aires, Argentina
Senior Member
BTW, if my answer to the second question is right, then I'm not sure why it's obligatory for a inactive shape to have a GA (first question).
Re: GraphicsAlgorithm coordinates: relative to....? [message #876332 is a reply to message #875970] Thu, 24 May 2012 11:47 Go to previous messageGo to next message
Michael Wenz is currently offline Michael Wenz
Messages: 1595
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Hm, good question - That goes right into the depths of the rendering
engine....

I simply tried it out and found the behavior rather strange. The inner shape
is drawn outside of the middle rectangle (which indicates a different Draw2D
hierarchy than what I originally wrote); besides it is active and resizable,
but redraw on such an action is missing.

The original intention of inactive shapes was to allow for a simple
structuring of shapes, it was not really meant to be used as parents of
active shapes. We should rethink what should happen here or if that should
be allowed at all. I opened Bugzilla
http://www.eclipse.org/forums/index.php/t/352589/ to track this.

Michael
Re: GraphicsAlgorithm coordinates: relative to....? [message #916680 is a reply to message #876332] Wed, 19 September 2012 10:02 Go to previous messageGo to next message
Jos Warmer is currently offline Jos Warmer
Messages: 108
Registered: October 2010
Senior Member
Michael, I cannot find the bugzilla under the link, just this forum.

Is this already fixed ? We would like to be able to make container shapes not selectable (thus setting them to not active), but still be able to see them and to use them as coordinate system for their children. That does feel like the intuitive way it should work.

Can you tell what the current status is?

Jos
Re: GraphicsAlgorithm coordinates: relative to....? [message #917699 is a reply to message #916680] Thu, 20 September 2012 10:42 Go to previous message
Michael Wenz is currently offline Michael Wenz
Messages: 1595
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Ups, seems I copied and pasted the wrong link, here's the right one:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=380526

Thanks,
Michael
Previous Topic:Adjusting CreateConnectionContext
Next Topic:Delayed coloring of shapes throws exception
Goto Forum:
  


Current Time: Mon Sep 22 00:17:45 GMT 2014

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

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