Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Specialized non-localized anchor
Specialized non-localized anchor [message #730496] Wed, 28 September 2011 14:21 Go to next message
Hernan Gonzalez is currently offline Hernan GonzalezFriend
Messages: 188
Registered: October 2010
Location: Buenos Aires, Argentina
Senior Member
Suppose my diagram has a special thin horizontal rectangle fixed on top ("tob bar"), filling all the diagram's width (actually, the "diagram width" is a fuzzy concept today, but that's another discussion). I wish to draw connections from the top bar to "normal" shapes, so that the connection line is vertical, and keeps so if I move the shape.

One could think this either as an special anchor (with a non-localized coordinate) or as several anchors that are dynamically created/moved/removed as one manipulates a connection.

This can be done with GEF, but with Graphiti this seems currently impossible. The anchors types are fixed and, even if I try to extend the pictogram model, the graphical behaviour of an anchor is implemented in the Graphiti internals, it does not seem to be extensible in any way.

As I needed this, I did a simple but very ugly hack, using a AnchorFixed and adding the line

   // hack: if the rectangle is very wide, use the reference x coordinate
    if(r.width > 300) centerX = reference.x; 


at the end of ChopboxAnchorFixed.getLocation() internal method. Horrible, I know Embarrassed but it works for me.
I wonder if someone can think of an alternative.
Or if the general issue of how is the internal Graphiti code (the abstraction layer over GEF/Draw2D) tied rigidly to the current pictogram hierachy merits some consideration.
We know that sometimes we need to extend/depend on Graphiti internal code (when we extend the Editor, for example), which is undesirable... but this is worse, because I must modify the internal code.



[Updated on: Wed, 28 September 2011 14:26]

Report message to a moderator

Re: Specialized non-localized anchor [message #730829 is a reply to message #730496] Thu, 29 September 2011 09:18 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Another approach would be to modify the move feature of your "normal shapes"
so that it adjusts the location of the anchor in the top bar. Would that
work for you?

Michael


"Hernan" schrieb im Newsbeitrag news:j5v9qu$bmh$1@news.eclipse.org...

Suppose my diagram has a special thin horizontal rectangle fixed on top
("tob bar"), filling all the diagram's width (actually, the "diagram width"
is a fuzzy concept today, but that's another discussion). I wish to draw
connections from the top bar to "normal" shapes, so that the connection line
is vertical, and keeps so if I move the shape.

One could think this as an special anchor (with a non-localized coordinate)
or as anchors that are dynamically created/moved/removed as one manipulates
a connection.

This can be done with GEF, but with Graphiti this seems currently
impossible. The anchors types are fixed and, even if I try to extend the
pictogram model, the graphical behaviour of an anchor is implemented in the
Graphiti internals, it does not seem to be extensible in any way.

As I needed this, I did a simple but very ugly hack, using a AnchorFixed and
adding the line

// hack: if the rectangle is very wide, use the reference x coordinate
if(r.width > 300) centerX = reference.x;

at the end of ChopboxAnchorFixed.getLocation() internal method. Depressing,
I know :blush: but it works for me.
I wonder if someone can think of an alternative.
Or if the general issue of how is the internal Graphiti code (the
abstraction layer over GEF/Draw2D) tied rigidly to the current pictogram
hierachy merits some consideration.
Re: Specialized non-localized anchor [message #730851 is a reply to message #730829] Thu, 29 September 2011 11:01 Go to previous messageGo to next message
Hernan Gonzalez is currently offline Hernan GonzalezFriend
Messages: 188
Registered: October 2010
Location: Buenos Aires, Argentina
Senior Member
Michael Wenz wrote on Thu, 29 September 2011 06:18
Another approach would be to modify the move feature of your "normal shapes"
so that it adjusts the location of the anchor in the top bar. Would that
work for you?



But, apart from the move scenario, this does not solve the problem of how to create the vertical connection.
Re: Specialized non-localized anchor [message #730860 is a reply to message #730851] Thu, 29 September 2011 11:43 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
The location of the top anchor could be defined in the create feature for
the lower shape or in the create connection feature.

Michael


"Hernan" schrieb im Newsbeitrag news:j61ig7$k5a$1@news.eclipse.org...

Michael Wenz wrote on Thu, 29 September 2011 06:18
> Another approach would be to modify the move feature of your "normal
> shapes" so that it adjusts the location of the anchor in the top bar.
> Would that work for you?


But, apart from the move scenario, this does not solve the problem of how to
create the vertical connection.
Re: Specialized non-localized anchor [message #730878 is a reply to message #730860] Thu, 29 September 2011 12:40 Go to previous message
Hernan Gonzalez is currently offline Hernan GonzalezFriend
Messages: 188
Registered: October 2010
Location: Buenos Aires, Argentina
Senior Member
Michael Wenz wrote on Thu, 29 September 2011 08:43
The location of the top anchor could be defined in the create feature for the lower shape


You mean that, each time I create (move) a normal shape, I create (move) an anchor in the top bar ? That's an interesting idea, I'll lok into it.


Quote:

or in the create connection feature.


but to start drawing the connection I must already have an anchor in the top bar... Perhaps I could have a single anchor in the middle of the top bar to start drawing the connection, and when I really create it I create on the fly a new anchor? That's another interesting idea, though it would be a little less user friendly.

Thanks.
Previous Topic:Connections and Bendpoints within Containershapes?
Next Topic:How to disable the remove?
Goto Forum:
  


Current Time: Wed Apr 24 14:19:45 GMT 2024

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

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

Back to the top