don't want the centering effect of TreeExample [message #205483] |
Mon, 19 December 2005 05:07 |
Francis Upton IV 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
Platform UI Committer for Common Navigator
http://wiki.eclipse.org/index.php/Common_Navigator_Framework
http://help.eclipse.org/galileo/topic/org.eclipse.platform.d oc.isv/guide/cnf.htm
|
|
|
Re: don't want the centering effect of TreeExample [message #205606 is a reply to message #205483] |
Mon, 19 December 2005 23:56 |
Francis Upton IV 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
Platform UI Committer for Common Navigator
http://wiki.eclipse.org/index.php/Common_Navigator_Framework
http://help.eclipse.org/galileo/topic/org.eclipse.platform.d oc.isv/guide/cnf.htm
|
|
|
Powered by
FUDForum. Page generated in 0.02697 seconds