CustomContext in negative coordinate space [message #1080077] |
Mon, 05 August 2013 08:42  |
Eclipse User |
|
|
|
Hey, I have a feature tied to a context menu entry for right clicking on the diagram that allows me to insert text at the location where the context menu was spawned. This seems to work fine in positive coordinate space, but if I activate this feature in negative coordinate space I still get positive coordinates. Is this a bug or am I missing something? I'm just taking the coordinates given to me by the CustomContext passed into the execute method of my AbstractFeature/ICustomFeature.
Also, in case it is important, I'm using Graphiti 0.9.0 also tried 0.9.2.
Thanks,
Craig
[Updated on: Mon, 05 August 2013 08:59] by Moderator
|
|
|
|
|
Re: CustomContext in negative coordinate space [message #1090087 is a reply to message #1080077] |
Mon, 19 August 2013 13:42  |
Eclipse User |
|
|
|
So I wasn't able to figure out what I could be doing wrong, but I definitely have negative coordinates that only seemed to be handled incorrectly when going through a custom feature triggered by a context menu event. This is what I had to do to the coordinates passed into the custom feature's execute method to make them "correct":
@Override
public void execute(final ICustomContext context)
{
final CreateContext cc = new CreateContext();
final FigureCanvas fc = (FigureCanvas) ((DiagramEditor) this.getDiagramEditor()).getGraphicalViewer().getControl();
final org.eclipse.draw2d.geometry.Point location = fc.getViewport().getViewLocation();
cc.setLocation(context.getX() + location.x, context.getY() + location.y);
cc.setTargetContainer(this.getDiagram());
final TextPattern tp = new TextPattern();
tp.setFeatureProvider(this.getFeatureProvider());
if(tp.canCreate(cc))
{
tp.create(cc);
}
}
|
|
|
Powered by
FUDForum. Page generated in 0.11091 seconds