Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » don't want the centering effect of TreeExample
don't want the centering effect of TreeExample [message #205483] Mon, 19 December 2005 05:07 Go to next message
Francis Upton IV is currently offline Francis Upton IVFriend
Messages: 472
Registered: July 2009
Location: Oakland, CA
Senior Member
Hi Randy (I'm hoping you will look at this, since you wrote this code),

I'm implementing a UML diagram using draw2d, and the TreeExample gives
me nearly everything I want. However, there is one behavior I would
like to change, but can't figure out how.

When you collapse a node, it re-centers the remaining nodes. I would
like the nodes to always be left justified, which works fine, except
that the entire tree is centered upon collapsing.

I have done a small change in the NormalLayout.layout() method:

if (!contents.isVisible() || contents.getChildren().isEmpty()) {
// nodeLocation.x += (branchBounds.width - nodeLocation.width)/2;
node.setBounds(transposer.t(nodeLocation));
contents.setBounds(
transposer.t(nodeLocation.getTranslated(0, rowHeight).setSize(0, 0)));
return;
}

Commenting out the adjustment of the nodeLocation.x, and this makes the
expand/collapse of the root work as desired. However, when I collapse
an inner node, the tree is centered.

I have checked that the problem is not the enclosing Composites/Canvas
because I put colored borders around those and they always fill the
entire window. I also tried to debug this by looking at setBounds on
the TreeRoot, but the bounds was not being reset, and yet it was moving.
This seems like it is some behavior withing the enclosing ViewPort.

Thanks in advance for any insight to help with this.

Francis


Re: don't want the centering effect of TreeExample [message #205606 is a reply to message #205483] Mon, 19 December 2005 23:56 Go to previous message
Francis Upton IV is currently offline Francis Upton IVFriend
Messages: 472
Registered: July 2009
Location: Oakland, CA
Senior Member
I figured it out. Further down in the same method, I commented out this
code and it worked:


// int adjust = branchBounds.width
// - Rectangle.SINGLETON.setBounds(contentsLocation)
// .union(nodeLocation).width;
// adjust /= 2;
// nodeLocation.x += adjust;
// contentsLocation.x += adjust;


Francis Upton wrote:
> Hi Randy (I'm hoping you will look at this, since you wrote this code),
>
> I'm implementing a UML diagram using draw2d, and the TreeExample gives
> me nearly everything I want. However, there is one behavior I would
> like to change, but can't figure out how.
>
> When you collapse a node, it re-centers the remaining nodes. I would
> like the nodes to always be left justified, which works fine, except
> that the entire tree is centered upon collapsing.
>
> I have done a small change in the NormalLayout.layout() method:
>
> if (!contents.isVisible() || contents.getChildren().isEmpty()) {
> // nodeLocation.x += (branchBounds.width - nodeLocation.width)/2;
> node.setBounds(transposer.t(nodeLocation));
> contents.setBounds(
> transposer.t(nodeLocation.getTranslated(0,
> rowHeight).setSize(0, 0)));
> return;
> }
>
> Commenting out the adjustment of the nodeLocation.x, and this makes the
> expand/collapse of the root work as desired. However, when I collapse
> an inner node, the tree is centered.
>
> I have checked that the problem is not the enclosing Composites/Canvas
> because I put colored borders around those and they always fill the
> entire window. I also tried to debug this by looking at setBounds on
> the TreeRoot, but the bounds was not being reset, and yet it was moving.
> This seems like it is some behavior withing the enclosing ViewPort.
>
> Thanks in advance for any insight to help with this.
>
> Francis


Previous Topic:Opening a dialog on connection or figure creation
Next Topic:Coordinate system for a layout manager
Goto Forum:
  


Current Time: Wed Apr 24 22:52:53 GMT 2024

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

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

Back to the top