Specialized non-localized anchor [message #730496] |
Wed, 28 September 2011 10:21  |
Eclipse User |
|
|
|
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 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 10:26] by Moderator
|
|
|
Re: Specialized non-localized anchor [message #730829 is a reply to message #730496] |
Thu, 29 September 2011 05:18   |
Eclipse User |
|
|
|
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 #730878 is a reply to message #730860] |
Thu, 29 September 2011 08:40  |
Eclipse User |
|
|
|
Michael Wenz wrote on Thu, 29 September 2011 08:43The 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.
|
|
|
Powered by
FUDForum. Page generated in 0.08144 seconds