Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » CustomContext in negative coordinate space
CustomContext in negative coordinate space [message #1080077] Mon, 05 August 2013 12:42 Go to next message
Craig Petre is currently offline Craig PetreFriend
Messages: 32
Registered: April 2011
Member
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 12:59]

Report message to a moderator

Re: CustomContext in negative coordinate space [message #1080117 is a reply to message #1080077] Mon, 05 August 2013 13:36 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
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 13:59 Go to previous messageGo to next message
Craig Petre is currently offline Craig PetreFriend
Messages: 32
Registered: April 2011
Member
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 17:42 Go to previous message
Craig Petre is currently offline Craig PetreFriend
Messages: 32
Registered: April 2011
Member
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: Fri Apr 26 00:08:08 GMT 2024

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

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

Back to the top