Skip to main content



      Home
Home » Modeling » Graphiti » CustomContext in negative coordinate space
CustomContext in negative coordinate space [message #1080077] Mon, 05 August 2013 08:42 Go to next message
Eclipse UserFriend
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 #1080117 is a reply to message #1080077] Mon, 05 August 2013 09:36 Go to previous messageGo to next message
Eclipse UserFriend
Craig,

the most upper left shape defines the origin of the coordinate system, so
there are no negative coordinates. On moving a shape out of the left or the
top of the diagram the complete coordinates will be adapted.

Michael
Re: CustomContext in negative coordinate space [message #1080130 is a reply to message #1080117] Mon, 05 August 2013 09:59 Go to previous messageGo to next message
Eclipse UserFriend
Hi Michael, the reason I ask is because if I try to then insert the text at the location given to me by the CustomContext it goes down and right of where the context menu spawned. I also noticed that in the case where I'm adding a pattern to the diagram, that the AddContext passed to the add function of "AddFeatureForPattern" has negative coordinates if I insert a pattern in a "negative" coordinate space. Thanks for the feedback though, I will check out how I'm inserting the text.. maybe I'm doing something wrong there.

Thanks,
Craig
Re: CustomContext in negative coordinate space [message #1090087 is a reply to message #1080077] Mon, 19 August 2013 13:42 Go to previous message
Eclipse UserFriend
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);
		}
	}
Previous Topic:Display additional information only in Editor
Next Topic:DiagramEditor mouse over
Goto Forum:
  


Current Time: Sat Jul 05 09:53:18 EDT 2025

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

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

Back to the top