Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Problem with DelegatingLayout
Problem with DelegatingLayout [message #155627] Tue, 26 October 2004 12:21 Go to next message
Dhiraj  is currently offline Dhiraj Friend
Messages: 18
Registered: July 2009
Junior Member
Hi,
I am using DelegatingLayout but am facing problems with it. I suspect
the code in the method calculatePreferredSize().
<code>
protected Dimension calculatePreferredSize(IFigure parent, int wHint,
int hHint) {
List children = parent.getChildren();
Dimension d = new Dimension();
for (int i = 0; i < children.size(); i++) {
IFigure child = (IFigure)children.get(i);
d.union(child.getPreferredSize());
}
return d;
}
</code>
Here the preferred size of the container is being calculated as the union
of the preferred sizes of the children...which doesn't correspond to the
actual size that would be occupied by the child figures.
It should rather compute the Union of the bounds of the child figures ?

Can someone clarify on this?
Re: Problem with DelegatingLayout [message #155697 is a reply to message #155627] Tue, 26 October 2004 15:09 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

I don't even know why that layout implements preferred size calculation.
You would have to layout in order to know the required size. Your figure
could override getPreferredSize() and just call validate() on itself, and
then union the children bounds.

"Dhiraj" <dhiraj@gmail.com> wrote in message
news:cllffs$lea$1@eclipse.org...
> Hi,
> I am using DelegatingLayout but am facing problems with it. I suspect
> the code in the method calculatePreferredSize().
> <code>
> protected Dimension calculatePreferredSize(IFigure parent, int wHint,
> int hHint) {
> List children = parent.getChildren();
> Dimension d = new Dimension();
> for (int i = 0; i < children.size(); i++) {
> IFigure child = (IFigure)children.get(i);
> d.union(child.getPreferredSize());
> }
> return d;
> }
> </code>
> Here the preferred size of the container is being calculated as the union
> of the preferred sizes of the children...which doesn't correspond to the
> actual size that would be occupied by the child figures.
> It should rather compute the Union of the bounds of the child figures ?
>
> Can someone clarify on this?
>
>
Re: Problem with DelegatingLayout [message #155971 is a reply to message #155697] Thu, 28 October 2004 05:32 Go to previous message
Dhiraj  is currently offline Dhiraj Friend
Messages: 18
Registered: July 2009
Junior Member
Thanks Randy. my problem is solved.

Randy Hudson wrote:

> I don't even know why that layout implements preferred size calculation.
> You would have to layout in order to know the required size. Your figure
> could override getPreferredSize() and just call validate() on itself, and
> then union the children bounds.

> "Dhiraj" <dhiraj@gmail.com> wrote in message
> news:cllffs$lea$1@eclipse.org...
> > Hi,
> > I am using DelegatingLayout but am facing problems with it. I suspect
> > the code in the method calculatePreferredSize().
> > <code>
> > protected Dimension calculatePreferredSize(IFigure parent, int wHint,
> > int hHint) {
> > List children = parent.getChildren();
> > Dimension d = new Dimension();
> > for (int i = 0; i < children.size(); i++) {
> > IFigure child = (IFigure)children.get(i);
> > d.union(child.getPreferredSize());
> > }
> > return d;
> > }
> > </code>
> > Here the preferred size of the container is being calculated as the union
> > of the preferred sizes of the children...which doesn't correspond to the
> > actual size that would be occupied by the child figures.
> > It should rather compute the Union of the bounds of the child figures ?
> >
> > Can someone clarify on this?
> >
> >
Previous Topic:Popup menu problem
Next Topic:Palette Questions
Goto Forum:
  


Current Time: Fri Jan 24 03:22:01 GMT 2025

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

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

Back to the top