| [GEF] [Zest] problem with layouts to GEF and setLocation [message #245748] |
Fri, 10 October 2008 06:18  |
Eclipse User |
|
|
|
Hi I'm working on a plugin designed to apply layouts on gef diagrams and
i'm a gef newbie :(
I want to permit users to select a container and all elements inside
will be moved with zest layout information
first if this kind of plugin exists already please stop me now x/
second I success to get the edit part from the selection
for each node and connection I create an entities collection and a
relations collection and i apply the layout but the results are not very
pretty
my code is bellow if anybody can see maybe i did something wrong :/
my problem is when I apply the new locations on object my graph is
modified but when i select one element the others set location to their
previous location :/
before layout after layout I select X
----------- ----------- -----------
| | | | | |
|X | |X Y | |X |
| | | | | |
|Y | | | |Y |
----------- ----------- -----------
to modify my location i do :
part.getFigure().setLocation(new
Point((int)theNode.getX(),(int)theNode.getY()));
do you know what is my problem ? is it a edit policy problem :( ???
In my example i used topcased gef editor if it can helps
Thank you !
Collection<LayoutEntity> entities = new LinkedList<LayoutEntity>();
Collection<LayoutRelationship> relations = new
LinkedList<LayoutRelationship>();
AbstractGraphicalEditPart root = node ;
for (Object o : node.getChildren())
{
if (o instanceof AbstractGraphicalEditPart)
{
AbstractGraphicalEditPart n =
(AbstractGraphicalEditPart) o;
SimpleNode sn = getLayoutNode(entities, n);
sn.setLocation(n.getFigure().getBounds().x,
n.getFigure().getBounds().y);
for (Object e : n.getSourceConnections()){
if (e instanceof ConnectionEditPart)
{
ConnectionEditPart c = (ConnectionEditPart) e ;
SimpleNode source = getLayoutNode(entities,
c.getTarget());
SimpleRelationship r = new
SimpleRelationship(source,sn,false);
relations.add(r);
}
}
for (Object e : n.getTargetConnections()){
if (e instanceof ConnectionEditPart)
{
ConnectionEditPart c = (ConnectionEditPart) e ;
SimpleNode target = getLayoutNode(entities,
c.getSource());
SimpleRelationship r = new
SimpleRelationship(sn,target,false);
relations.add(r);
}
}
entities.add(sn);
}
}
try
{
// getAlgorithm takes a zest algo with environment preferences
getAlgorithm().addProgressListener(this);
getAlgorithm().applyLayout((LayoutEntity[])
entities.toArray(new LayoutEntity[0]),relations.toArray(new
LayoutRelationship[0]), root.getFigure().getBounds().x,
root.getFigure().getBounds().y, root.getFigure().getBounds().width,
root.getFigure().getBounds().height, true, false);
while (getAlgorithm().isRunning())
{
try
{
Thread.currentThread().sleep(10);
}
catch (InterruptedException e)
{
e.printStackTrace();
}
}
for (LayoutEntity l : entities)
{
try {
SimpleNode theNode = (SimpleNode) l ;
AbstractGraphicalEditPart part =
(AbstractGraphicalEditPart) theNode.getRealObject();
part.getFigure().setLocation(new
Point((int)theNode.getX(),(int)theNode.getY()));
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
catch (InvalidLayoutConfiguration e)
{
e.printStackTrace();
}
|
|
|
|
|
|
| transparent FigureCanvas [message #246052 is a reply to message #245777] |
Mon, 03 November 2008 09:32  |
Eclipse User |
|
|
|
Originally posted by: michael.jurke.justinmind.com
Hello,
I wanted to use the GEF framework to manipulate some underlaying grafics
and for this using a transparent FigureCanvas.
Well, it took me hours to change the API (only because everything to
change is private or package), creating a own MyFigureCanvas (because it
has the method checkStyles that does not permit SWT.TRANSPARENT),
MyScrollingGraphicalViewer etc. and finally it worked out perfectly.
I just wonder why there are so many restriction. Do I have to expect
platform depency issues o other problems?
From GEF's side, it is planned to offer an alternative canvas with
transparent feature?
Greetings,
M. Jurke
|
|
|
Powered by
FUDForum. Page generated in 0.05596 seconds