Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Can a figure be resized automatically ?
Can a figure be resized automatically ? [message #160677] Mon, 06 December 2004 20:22 Go to next message
Cyril Chéné is currently offline Cyril ChénéFriend
Messages: 19
Registered: July 2009
Location: France
Junior Member
Hello

I have a figure that contains other figures. I'd like the container to be
automatically resized when a child figure is added.

Can anyone help ? I'm using ToolbarLayout (I tried FlowLayout which gave
the same result...)


Thx

Cyril
Re: Can a figure be resized automatically ? [message #160691 is a reply to message #160677] Mon, 06 December 2004 22:27 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

This depends on the layout in which the container exists. The container's
parent must query the container's perferred size and give it that size.
what is the container's container's layout?
"Cyril Chene" <cchene@genigraph.fr> wrote in message
news:cp2f2e$14i$1@www.eclipse.org...
> Hello
>
> I have a figure that contains other figures. I'd like the container to be
> automatically resized when a child figure is added.
>
> Can anyone help ? I'm using ToolbarLayout (I tried FlowLayout which gave
> the same result...)
>
>
> Thx
>
> Cyril
>
Re: Can a figure be resized automatically ? [message #160727 is a reply to message #160691] Tue, 07 December 2004 08:20 Go to previous messageGo to next message
Cyril Chéné is currently offline Cyril ChénéFriend
Messages: 19
Registered: July 2009
Location: France
Junior Member
The "top-level" container is a freeformlayout subclass.

I guess I should look around the "getConstraint" method of that layout =

manager...

Thanks for your help
Cyril


Le Mon, 6 Dec 2004 17:27:13 -0500, Randy Hudson <none@us.ibm.com> a =E9c=
rit :

This depends on the layout in which the container exists. The container=
's
parent must query the container's perferred size and give it that size.
what is the container's container's layout?
"Cyril Chene" <cchene@genigraph.fr> wrote in message
news:cp2f2e$14i$1@www.eclipse.org...
> Hello
> I have a figure that contains other figures. I'd like the container t=
o =

> be
> automatically resized when a child figure is added.
> Can anyone help ? I'm using ToolbarLayout (I tried FlowLayout which g=
ave
> the same result...)
> Thx
> Cyril
> =
Re: Can a figure be resized automatically ? [message #161186 is a reply to message #160727] Fri, 10 December 2004 06:15 Go to previous message
Barry Lay is currently offline Barry LayFriend
Messages: 48
Registered: July 2009
Member
Cyril,

I have done this with a ToolbarLayout container. I have also tried it
with an XYLayout container but I am still working on some problems.

I created an extension to the Figure I was using (LabeledContainer in my
case) and overrode the getPreferredSize method. This gets called by the
parent container when a refresh occurs. You can query your child
Figures to get their preferred size and calculate the bounds you need
for the container. You need to include the insets your container Figure
uses in your size calculation.

Something like this:

public Dimension getPreferredSize( int wHint, int hHint ) {
// resize larger if necessary
Dimension pref = super.getPreferredSize( wHint, hHint );
int childrenHeight = getInsets().top + getInsets().bottom;
for( Iterator iter = getChildren().iterator(); iter.hasNext(); ) {
IFigure child = (IFigure) iter.next();
childrenHeight += child.getPreferredSize().height;
}
if( pref.height < childrenHeight )
pref.height = childrenHeight;
return pref;
}

This obviously only works with a vertically-oriented ToolbarLayout. For
an XY layout you need to track both dimensions. It also assumes that
the hints are irrelevant, which is likely if you are using ToolbarLayout.

Hope this provides a path to a solution...
Barry

Cyril Chene wrote:

>> Hello
>> I have a figure that contains other figures. I'd like the container
>> to be
>> automatically resized when a child figure is added.
>> Can anyone help ? I'm using ToolbarLayout (I tried FlowLayout which gave
>> the same result...)
>> Thx
>> Cyril
>>
Previous Topic:Line Figure with a small circle at both end
Next Topic:Problem with picture using plugin
Goto Forum:
  


Current Time: Sat Apr 27 00:47:22 GMT 2024

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

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

Back to the top