Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Navigating to figure (in scalable editors)
Navigating to figure (in scalable editors) [message #543530] Tue, 29 June 2010 17:09 Go to next message
Jakub Fibinger is currently offline Jakub FibingerFriend
Messages: 2
Registered: June 2010
Junior Member
Hi,

I've problem with scaling in editor.
The goal is to make navigating method in scalable editor class, that will put node in the center of viewport. I've implemented it like this:

@Override
public void navigateToElement(IElement element) {
	Point elementCoords = ((IVisualSchemaBasicNode)element).getLocation().getCopy();
	Dimension viewDimension = getEditorViewport().getClientArea().getSize().getCopy();
	elementCoords.translate(viewDimension.getNegated().getScaled(0.5));
	getEditorViewport().setViewLocation(elementCoords);
}


The problem is that it works well only in case that zoom is set to 100%. Otherwise the view is displaced.
The question is: how to add scaling logic to this code?

Please help me, or just tell me which GEF object should I consider (where should I look for a solution).

[Updated on: Tue, 29 June 2010 20:45]

Report message to a moderator

Re: Navigating to figure (in scalable editors) [message #543727 is a reply to message #543530] Wed, 30 June 2010 12:33 Go to previous message
Jakub Fibinger is currently offline Jakub FibingerFriend
Messages: 2
Registered: June 2010
Junior Member
Problem solved.

The key is method:

ScrollingGraphicalViewer#reveal(EditPart);

It is revealing if node isn't visible, but this code can be easily adapted for putting figure in a center of view.
Previous Topic:GEF Shapes example
Next Topic:No MouseEvents in SCALED_FEEDBACK_LAYER?
Goto Forum:
  


Current Time: Fri Apr 26 10:44:15 GMT 2024

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

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

Back to the top