Home » Modeling » Graphiti » Specialized non-localized anchor
Specialized non-localized anchor [message #730496] |
Wed, 28 September 2011 14:21 |
Hernan Gonzalez 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 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 |
Michael Wenz 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.
|
|
| | | |
Goto Forum:
Current Time: Mon Sep 23 08:08:33 GMT 2024
Powered by FUDForum. Page generated in 5.19663 seconds
|