Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Zoom funtion in a View?(how do I add support for Zoom?)
icon5.gif  Zoom funtion in a View? [message #558462] Mon, 13 September 2010 07:10 Go to next message
Mikkel Jonassen is currently offline Mikkel Jonassen
Messages: 24
Registered: September 2010
Junior Member
Hello

I have been working a little with EMF and GMF.
I have followed this toturial:
http://wiki.eclipse.org/index.php/GMF_Tutorial

I have succesfully implemented the mindmap and can now add topics and subtopics in the diagram editor.

Then I created a View which shows the mindmap, but with pictures. Is there any way that i can make this View zoomable just like the diagram editor is as default?

I have been searching the net and found something about the classes:
ScalableFreeformRootEditPart and ScalableRootEditPart.
But I can't make it work.

Do any of you knows hav I can add support for zoom in my view?

Regards Mikkel
Re: Zoom funtion in a View? [message #558712 is a reply to message #558462] Tue, 14 September 2010 07:52 Go to previous messageGo to next message
Vijay Raj
Messages: 608
Registered: July 2009
Senior Member
((ScalableRootEditPart) getGraphicalViewer().getRootEditPart()).getZoomManager()

or

((ScalableFreeFormRootEditPart) getGraphicalViewer().getRootEditPart()).getZoomManager()

reuse org.eclipse.gef.ui.actions.ZoomInAction and org.eclipse.gef.ui.actions.ZoomOutAction

also org.eclipse.gef.ui.actions.ZoomComboContributionItem

hope this helps


---------------------
why, mr. Anderson, why, why do you persist?
Because I Choose To.
Regards,
Vijay
Re: Zoom funtion in a View? [message #558720 is a reply to message #558712] Tue, 14 September 2010 08:18 Go to previous messageGo to next message
Mikkel Jonassen is currently offline Mikkel Jonassen
Messages: 24
Registered: September 2010
Junior Member
Thanks for your time Smile

Where should I insert those lines?
I mean the problem is that it is not an editor part that I am working on adding this zoom.

I try to do it in a view part, but can't figure out how I make it work.

So I hope someone would be very kind and maybe post a little example in how to make a view with a zoom functionality.

Thanks in advantages Smile

Regards Mikkel

Re: Zoom funtion in a View? [message #558726 is a reply to message #558720] Tue, 14 September 2010 08:47 Go to previous messageGo to next message
Vijay Raj
Messages: 608
Registered: July 2009
Senior Member
In view you can have view actions,add them using viewactions extention point or IToolBarManager toolBarManager = getViewSite().getActionBars().getToolBarManager(); in createPartControl method...

add the specified actions and contribution items by providing them with zoommanager from your specific edit part...

for example in createPartControl you can call this method
/**
     * This method defines and adds all the actions required for UI functions required in the
     * Graphical Viewer, to the Menu Manager.
     */
    private final void appendActions()
    {
        IToolBarManager toolBarManager = getViewSite().getActionBars().getToolBarManager();

        IMenuManager menuManager = getViewSite().getActionBars().getMenuManager();

        List<IAction> toolBarLayoutActions = new ArrayList<IAction>();

        ZoomManager zoomManager = getZoomManager();
        if (zoomManager != null)
        {
            zoomManager.setZoomLevels(new double[] { .1, .3, .5, .7, 1.0, 1.5, 3, 6, 10, 15 });
            zoomInAction = new ZoomInAction(zoomManager);
            // Set ActionDefinitionId to null to disable GEF action id which is the Key binding
            zoomInAction.setActionDefinitionId(null);
            toolBarLayoutActions.add(zoomInAction);

            zoomOutAction = new ZoomOutAction(zoomManager);
            // Set ActionDefinitionId to null to disable GEF action id which is the Key binding
            zoomOutAction.setActionDefinitionId(null);
            toolBarLayoutActions.add(zoomOutAction);

            String[] zoomStrings = new String[] { ZoomManager.FIT_ALL, ZoomManager.FIT_HEIGHT,
                    ZoomManager.FIT_WIDTH };
            zoomComboContributionItem = new ZoomComboContributionItem(this,
                    zoomStrings);

            getViewSite().getActionBars().getToolBarManager().add(zoomComboContributionItem);
            ArrayList<String> contributions = new ArrayList<String>();
            contributions.add(ZoomManager.FIT_ALL);
            contributions.add(ZoomManager.FIT_HEIGHT);
            contributions.add(ZoomManager.FIT_WIDTH);
            zoomManager.setZoomLevelContributions(contributions);
        }    
}


---------------------
why, mr. Anderson, why, why do you persist?
Because I Choose To.
Regards,
Vijay

[Updated on: Tue, 14 September 2010 10:13]

Report message to a moderator

Re: Zoom funtion in a View? [message #558794 is a reply to message #558726] Tue, 14 September 2010 13:34 Go to previous messageGo to next message
Mikkel Jonassen is currently offline Mikkel Jonassen
Messages: 24
Registered: September 2010
Junior Member
Thanks alot Smile

I now see the zoom combobox next to the view tab exactly as it should, but when I choose another zoom level nothing happens.

The content inside the view just stay the same. :S

Do I somehow need to bind something more together?

Regards Mikkel
Re: Zoom funtion in a View? [message #558834 is a reply to message #558794] Tue, 14 September 2010 15:03 Go to previous messageGo to next message
Vijay Raj
Messages: 608
Registered: July 2009
Senior Member
show me your implementation of getZoomManager();

and also how are you drawing your diagrams using gefvieweer or plain draw2d???


---------------------
why, mr. Anderson, why, why do you persist?
Because I Choose To.
Regards,
Vijay
Re: Zoom funtion in a View? [message #558839 is a reply to message #558834] Tue, 14 September 2010 15:10 Go to previous messageGo to next message
Mikkel Jonassen is currently offline Mikkel Jonassen
Messages: 24
Registered: September 2010
Junior Member
Maybe it is because I draw my SWT components directly on the composite given as parameter in:

public void createPartControl(Composite comp)

Should I add these to a graphicalviewer somehow?.

And then create the ZoomManager with this graphicalviewer?
Re: Zoom funtion in a View? [message #558848 is a reply to message #558834] Tue, 14 September 2010 15:29 Go to previous messageGo to next message
Mikkel Jonassen is currently offline Mikkel Jonassen
Messages: 24
Registered: September 2010
Junior Member
Right now I'm using a composite with a background and then a simple SWT label above with some text.

My getZoomManager() looks like:

scalableFreeformRootEditPart.getZoomManager();

So I am using the default one I guess.

I use this since I couldn't use the example you provided. When I clicked on the view the zoombox faided out.


But do I need to add the composite where I draw my diagrams and SWT labels onto a graphical view or something? - in such case how?
Re: Zoom funtion in a View? [message #558851 is a reply to message #558839] Tue, 14 September 2010 15:33 Go to previous messageGo to next message
Vijay Raj
Messages: 608
Registered: July 2009
Senior Member
What do you mean by "Then I created a View which shows the mindmap, but with pictures"

can you show me a screen shot of your view...???


---------------------
why, mr. Anderson, why, why do you persist?
Because I Choose To.
Regards,
Vijay
Re: Zoom funtion in a View? [message #559114 is a reply to message #558851] Wed, 15 September 2010 16:23 Go to previous messageGo to next message
Mikkel Jonassen is currently offline Mikkel Jonassen
Messages: 24
Registered: September 2010
Junior Member
I don't know how to upload pictures on this site, but send me an email on:

mrfandusATSYMBOLgmail.com

Then I will gladly send you a screenshot together with my little code example.


What I mean with "pictures" is simply that I have an SWT.Image with a little bouble and underneth that I'am adding a little SWT Label with the text. All this is added to the composite in the createPartControl(Composite parent) method.

Is it because the zoom function doesn't work on SWT widgets? like buttons, image, labels etc.?

Regards Mikkel
Re: Zoom funtion in a View? [message #559134 is a reply to message #559114] Wed, 15 September 2010 17:26 Go to previous messageGo to next message
Vijay Raj
Messages: 608
Registered: July 2009
Senior Member
as i suspected your view does not have GEF or GMF components,
probably only swt components,so may be this will help...

still you can post u r image here by uploading it in u r picasa album(gmail account) and pasting the link here...


---------------------
why, mr. Anderson, why, why do you persist?
Because I Choose To.
Regards,
Vijay
Re: Zoom funtion in a View? [message #559145 is a reply to message #559134] Wed, 15 September 2010 18:44 Go to previous messageGo to next message
Mikkel Jonassen is currently offline Mikkel Jonassen
Messages: 24
Registered: September 2010
Junior Member
What you just showed me with the SWT image looks nice, but does this also work with SWT buttons.?

So all the contents will zoom?
Re: Zoom funtion in a View? [message #559153 is a reply to message #559145] Wed, 15 September 2010 19:21 Go to previous messageGo to next message
Vijay Raj
Messages: 608
Registered: July 2009
Senior Member
Thats only for SWT image no swt controls....

---------------------
why, mr. Anderson, why, why do you persist?
Because I Choose To.
Regards,
Vijay
Re: Zoom funtion in a View? [message #559158 is a reply to message #559153] Wed, 15 September 2010 19:32 Go to previous messageGo to next message
Mikkel Jonassen is currently offline Mikkel Jonassen
Messages: 24
Registered: September 2010
Junior Member
Ok.. thanks for your help Smile

Then I need to look at another solution.

Do you know where the action commands of the ZoomComboContributionItem is implemented?

Then I could maybe reuse the ZoomComboContributionItem and then just change the action methods to do what I want maybe resize alle the SWT components.


EDIT: I mean where is the method which is called when the zoomfactor is changed in the ZoomComboContributionItem at the toolbar. Then I could change this methods to do what I want.

[Updated on: Wed, 15 September 2010 19:43]

Report message to a moderator

Re: Zoom funtion in a View? [message #559164 is a reply to message #559158] Wed, 15 September 2010 19:53 Go to previous messageGo to next message
Vijay Raj
Messages: 608
Registered: July 2009
Senior Member
that will not help Mikkel...

first u send me the screen shot then may be we can see what can be done....


---------------------
why, mr. Anderson, why, why do you persist?
Because I Choose To.
Regards,
Vijay
Re: Zoom funtion in a View? [message #559727 is a reply to message #559164] Fri, 17 September 2010 17:27 Go to previous messageGo to next message
Mikkel Jonassen is currently offline Mikkel Jonassen
Messages: 24
Registered: September 2010
Junior Member
Hello vijay.

Sorry for the late answer I had to find a way to upload my work.

Now I have uploaded it here:
http://uploading.com/files/f6bf8766/zoom_view.zip/

The zip file contains a very simple version of the eclipse project and a screenshot of the view.

What I would like is a zoom functionality in the view, so that I can zoom in and out.

Thanks alot for your help.


EDIT: Maybe I should mention that you should only load the project and then select:
Window -> Show View -> Other -> Zoom View Test
You might know that already Smile

[Updated on: Fri, 17 September 2010 17:44]

Report message to a moderator

Re: Zoom funtion in a View? [message #559739 is a reply to message #559727] Fri, 17 September 2010 19:17 Go to previous message
Vijay Raj
Messages: 608
Registered: July 2009
Senior Member
Ya mikkel, i saw u r screen shot,
lets end this topic here n countinue on mail,
check u r mail..


---------------------
why, mr. Anderson, why, why do you persist?
Because I Choose To.
Regards,
Vijay
Previous Topic:Find Nodes in a Graph
Next Topic:[DND] TransferDropTargetListener should not be deprecated
Goto Forum:
  


Current Time: Fri Oct 24 16:09:46 GMT 2014

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

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