Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Zest Layout Algorithmn
Zest Layout Algorithmn [message #243719] Mon, 16 June 2008 15:12 Go to next message
kent gibson is currently offline kent gibsonFriend
Messages: 114
Registered: July 2009
Senior Member
I would either like to create a new Layout Algorithm or use one of the
preexisting ones in order to create the following behavior:

I have a row of nodes (they all have the same y coordinate). I want the
nodes to animate from the middle outwards alone the x (one half of the
nodes will go east and one half will go west).

Where would I start?

Thanks.
Re: Zest Layout Algorithmn [message #243741 is a reply to message #243719] Tue, 17 June 2008 04:47 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: irbull.cs.uvic.ca

This is a great question! Thanks for asking this and forcing me to
create a snippet to answer it.

There are two ways you can do this. You can either use the Draw2D
animation class. Simply call:

Animation.markBegin();
... Set your nodes where you want them
Animation.run(ANIMATION_TIME);

This will move the nodes and take ANIMATION_TIME to do so.

You can also create a custom layout algorithm. A custom layout
algorithm allows you to use progress monitors and it handles the
animation for you. The custom layout is pretty easy to write.

I have created two snippets.
[1] shows how you can use the animation class.
[2] shows how you can create a custom layout algorithm.


[1] http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.gef/tes t/org.eclipse.zest.tests/src/org/eclipse/zest/tests/swt/Anim ationSnippet.java?root=Tools_Project&view=co
[2] http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.gef/tes t/org.eclipse.zest.tests/src/org/eclipse/zest/tests/swt/Cust omLayout.java?root=Tools_Project&view=co

I have also put these on the snippet page [3] which is now linked to
from the main Zest page [4].

[3] http://www.eclipse.org/gef/zest/snippets.php
[4] http://www.eclipse.org/gef/zest/

kentusha wrote:
> I would either like to create a new Layout Algorithm or use one of the
> preexisting ones in order to create the following behavior:
>
> I have a row of nodes (they all have the same y coordinate). I want the
> nodes to animate from the middle outwards alone the x (one half of the
> nodes will go east and one half will go west).
>
> Where would I start?
>
> Thanks.
>
Re: Zest Layout Algorithmn [message #243761 is a reply to message #243741] Tue, 17 June 2008 07:12 Go to previous messageGo to next message
Zviki Cohen is currently offline Zviki CohenFriend
Messages: 25
Registered: July 2009
Junior Member
There's a problem with the "find the item under the mouse" snippet. It
will work, but not with scaled layouts. The coordinates need to be
translated. Moreover, why should I care about the figure? In most cases,
I need the node.

Let me suggest the followin method for the Graph class:

public GraphItem getItemAt(final int x, final int y) {
GraphItem result = null;
final Point point = new Point(x, y);
getRootLayer().translateToRelative(point);
final IFigure figureAtPoint = getFigureAt(point.x, point.y);
if (figureAtPoint != null) {
result = getGraphItem(figureAtPoint);
}
return result;
}
Re: Zest Layout Algorithmn [message #243775 is a reply to message #243761] Tue, 17 June 2008 14:44 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: irbull.cs.uvic.ca

Can you open a bug (bugs.eclipse.org) under tools/gef/zest with this
suggestion?

Thanks,
Ian

Zviki wrote:
> There's a problem with the "find the item under the mouse" snippet. It
> will work, but not with scaled layouts. The coordinates need to be
> translated. Moreover, why should I care about the figure? In most
> cases, I need the node.
>
> Let me suggest the followin method for the Graph class:
>
> public GraphItem getItemAt(final int x, final int y) {
> GraphItem result = null;
> final Point point = new Point(x, y);
> getRootLayer().translateToRelative(point);
> final IFigure figureAtPoint = getFigureAt(point.x, point.y);
> if (figureAtPoint != null) {
> result = getGraphItem(figureAtPoint);
> }
> return result;
> }
>
Re: Zest Layout Algorithmn [message #243781 is a reply to message #243775] Tue, 17 June 2008 15:19 Go to previous messageGo to next message
Zviki Cohen is currently offline Zviki CohenFriend
Messages: 25
Registered: July 2009
Junior Member
Bug 237479.

Cheers,
Zviki
Re: Zest Layout Algorithmn [message #243786 is a reply to message #243781] Tue, 17 June 2008 18:41 Go to previous message
kent gibson is currently offline kent gibsonFriend
Messages: 114
Registered: July 2009
Senior Member
thanks.
Previous Topic:[Zest] Basic questions
Next Topic:how to disable contextmenu?
Goto Forum:
  


Current Time: Thu Apr 25 22:44:44 GMT 2024

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

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

Back to the top