Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » setMinimumSize() does nothing
setMinimumSize() does nothing [message #200929] Fri, 28 October 2005 10:40 Go to next message
Michael Pradel is currently offline Michael PradelFriend
Messages: 26
Registered: July 2009
Junior Member
Hi,

I'm trying to create a figure with a minimum size:

Figure f = new Figure();
f.setMinimumSize(new Dimension(50,50));
f.setBorder(new LineBorder());
f.setLayoutManager(new FlowLayout());

All I get as result is a little black point, so I assume that the figure
has not (50,50), but (0,0) as size.

What is missing here? Thanks for any ideas!
Re: setMinimumSize() does nothing [message #200944 is a reply to message #200929] Fri, 28 October 2005 12:27 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Lamont_Gilbert.rigidsoftware.com

Michael Pradel wrote:
> Hi,
>
> I'm trying to create a figure with a minimum size:
>
> Figure f = new Figure();
> f.setMinimumSize(new Dimension(50,50));
> f.setBorder(new LineBorder());
> f.setLayoutManager(new FlowLayout());
>
> All I get as result is a little black point, so I assume that the figure
> has not (50,50), but (0,0) as size.
>
> What is missing here? Thanks for any ideas!

I believe minimum and maximum are preferences ysed by layout managers.
They dont actually restrict direct sizing. If you want to restrict size
do it in the edit policy or edit part.


CL
Re: setMinimumSize() does nothing [message #201123 is a reply to message #200929] Sat, 29 October 2005 10:43 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mvsteenbergen.eljakim.scratch-this.nl

Your figure's final size is determined by its parent figure's layout
manager; not the figure's own layout manager. Make sure that the parent
figure actually has a layout manager and that it uses the figure's
minimum size to computer the final size.

Regards,

Martijn.

Michael Pradel wrote:
> Hi,
>
> I'm trying to create a figure with a minimum size:
>
> Figure f = new Figure();
> f.setMinimumSize(new Dimension(50,50));
> f.setBorder(new LineBorder());
> f.setLayoutManager(new FlowLayout());
>
> All I get as result is a little black point, so I assume that the figure
> has not (50,50), but (0,0) as size.
>
> What is missing here? Thanks for any ideas!
Re: setMinimumSize() does nothing [message #201127 is a reply to message #201123] Sat, 29 October 2005 11:26 Go to previous messageGo to next message
Michael Pradel is currently offline Michael PradelFriend
Messages: 26
Registered: July 2009
Junior Member
Thanks for the hint.

> Your figure's final size is determined by its parent figure's layout
> manager; not the figure's own layout manager. Make sure that the parent
> figure actually has a layout manager and that it uses the figure's
> minimum size to computer the final size.

Setting to layout manager of the parent figure to ToolbarLayout should
not compress the inner figure smaller than their minimum size.
However, the following snippet shows me a black line at the top of the
figure instead of a rectangle:

Figure contents = new Figure();
contents.setLayoutManager(new ToolbarLayout());
Figure f = new Figure();
f.setMinimumSize(new Dimension(50,50));
f.setBorder(new LineBorder());
f.setLayoutManager(new FlowLayout());
contents.add(f);

Any ideas why? Thanks.
Re: setMinimumSize() does nothing [message #201577 is a reply to message #201127] Wed, 02 November 2005 00:20 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.unknown.com

Your figure should be returning a preferred size that is at least as big as
the minimum size. ToolbarLayout only respects the minimum size in the minor
dimension. Some other layouts might completely ignore the minimum size.
It's better to use the preferred size to size your figures. In your case,
the flow layout is determining what the preferred size of f will be. Since
f has no children, just a border, it returns a preferred size of (2,2). If
you add a few figures to f (and set their sizes to some random size), you'll
see that f grows accordingly. If you want f to have a minimum size even
when it's empty, override FlowLayout's calculatePreferredSize() and union
super.calculatePreferredSize() with figure.getMinimumSize().

"Michael Pradel" <michael@binaervarianz.de> wrote in message
news:djvm8t$mt5$1@news.eclipse.org...
> Thanks for the hint.
>
> > Your figure's final size is determined by its parent figure's layout
> > manager; not the figure's own layout manager. Make sure that the parent
> > figure actually has a layout manager and that it uses the figure's
> > minimum size to computer the final size.
>
> Setting to layout manager of the parent figure to ToolbarLayout should
> not compress the inner figure smaller than their minimum size.
> However, the following snippet shows me a black line at the top of the
> figure instead of a rectangle:
>
> Figure contents = new Figure();
> contents.setLayoutManager(new ToolbarLayout());
> Figure f = new Figure();
> f.setMinimumSize(new Dimension(50,50));
> f.setBorder(new LineBorder());
> f.setLayoutManager(new FlowLayout());
> contents.add(f);
>
> Any ideas why? Thanks.
Re: setMinimumSize() does nothing [message #202001 is a reply to message #201577] Sat, 05 November 2005 11:38 Go to previous message
Michael Pradel is currently offline Michael PradelFriend
Messages: 26
Registered: July 2009
Junior Member
> If you want f to have a minimum size even
> when it's empty, override FlowLayout's calculatePreferredSize() and union
> super.calculatePreferredSize() with figure.getMinimumSize().

Thank you! I could make it work like this.

Michael
Previous Topic:Editors Deletions Selections and NullPointerException
Next Topic:Connections start one pixel away from node
Goto Forum:
  


Current Time: Fri Apr 26 09:12:39 GMT 2024

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

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

Back to the top