don't want the centering effect of TreeExample [message #205483] |
Mon, 19 December 2005 00:07  |
Eclipse User |
|
|
|
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 18:56  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.25042 seconds