Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » [Draw2d] BorderLayout.CENTER and spanning over available space
[Draw2d] BorderLayout.CENTER and spanning over available space [message #142806] Thu, 15 July 2004 13:48 Go to next message
Marion Schmid is currently offline Marion SchmidFriend
Messages: 35
Registered: July 2009
Member
Hello *,

I have problems with getting my BorderLayout-ed figure working as desired,
found the solution in CVS with the BorderLayout revision 1.7, but realized,
that this solution has been reverted/changed in later revisions (1.8/1.9)

http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.draw2d/ src/org/eclipse/draw2d/BorderLayout.java?cvsroot=Tools_Proje ct&only_with_tag=

To come to the problem:
I have 3 figures:

IFigure mainPane = new Figure();
IFigure labelPane= new Figure();
IFigure contentPane = new Figure();

with the layouts

mainPane.setLayoutManager(new BorderLayout());
labelPane.setLayoutManager(new ToolbarLayout());
contentPane.setLayoutManager(new ToolbarLayout());

The mainPane figure contains the labelPane and the contentPane figures.
The labelPane is at the top of the mainPane,
the contentPane shall span the rest of the available space of the mainPane
figure.

mainPane.add(labelPane, BorderLayout.TOP);
mainPane.add(contentPane, BorderLayout.CENTER);

somehow like this
(a)
_______________
|___labelPane____|
| |
| contentPane |
|______________|

With the version of the layout() method of BorderLayout in revision 1.7, the
contentPane is spanned over all available space in the parent figure
(mainPane).
With some old revision (my eclipse m9 installation) and the latest revisions
(1.8 and 1.9) the BorderLayout does not behave as I desire.

looks this way, means, contentPane is actually in the center and not spanned
over the whole available space.
(b)
_______________
|___labelPane____|
| |
|______________|
|___contentPane__|
| |
|______________|


So, my question: how can I specify the way, the contentPane figure is
displayed in its parent figure with the constraint BorderLayout.CENTER, so
that either the contentPane spans the whole available space of the parent
figure (mainpane) [ a) ] or does not span the available space (the
behaviour I have since revision 1.8 of BorderLayout) [ b) ]?

Or is CENTER the wrong constraint and I have to do some other additional
things to achieve result a) ?

Can anyone of you help me?

Thanks a lot in advance!

.. marion
Re: [Draw2d] BorderLayout.CENTER and spanning over available space [message #142934 is a reply to message #142806] Fri, 16 July 2004 05:02 Go to previous messageGo to next message
Pratik Shah is currently offline Pratik ShahFriend
Messages: 1077
Registered: July 2009
Senior Member
I am not sure why that functionality was changed. Randy probably knows why.

Here's a workaround you can try: have your contentPane's toolbarlayout
return the height that it needs to take up. Something like this:

contentPane.setToolbarLayout(new ToolbarLayout() {
protected Dimension calculatePreferredSize(IFigure container, int wHint,
int hHint) {
Dimension size = super.calculatePreferredSize(container, wHint,
hHint);
if (size.height < hHint) {
size.height = hHint;
}
return size;
}
});

"Marion Schmid" <marion.schmid@sap.com> wrote in message
news:cd61sf$7jg$1@eclipse.org...
> Hello *,
>
> I have problems with getting my BorderLayout-ed figure working as desired,
> found the solution in CVS with the BorderLayout revision 1.7, but
realized,
> that this solution has been reverted/changed in later revisions (1.8/1.9)
>
>
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.draw2d/ src/org/eclipse/draw2d/BorderLayout.java?cvsroot=Tools_Proje ct&only_with_tag=
>
> To come to the problem:
> I have 3 figures:
>
> IFigure mainPane = new Figure();
> IFigure labelPane= new Figure();
> IFigure contentPane = new Figure();
>
> with the layouts
>
> mainPane.setLayoutManager(new BorderLayout());
> labelPane.setLayoutManager(new ToolbarLayout());
> contentPane.setLayoutManager(new ToolbarLayout());
>
> The mainPane figure contains the labelPane and the contentPane figures.
> The labelPane is at the top of the mainPane,
> the contentPane shall span the rest of the available space of the mainPane
> figure.
>
> mainPane.add(labelPane, BorderLayout.TOP);
> mainPane.add(contentPane, BorderLayout.CENTER);
>
> somehow like this
> (a)
> _______________
> |___labelPane____|
> | |
> | contentPane |
> |______________|
>
> With the version of the layout() method of BorderLayout in revision 1.7,
the
> contentPane is spanned over all available space in the parent figure
> (mainPane).
> With some old revision (my eclipse m9 installation) and the latest
revisions
> (1.8 and 1.9) the BorderLayout does not behave as I desire.
>
> looks this way, means, contentPane is actually in the center and not
spanned
> over the whole available space.
> (b)
> _______________
> |___labelPane____|
> | |
> |______________|
> |___contentPane__|
> | |
> |______________|
>
>
> So, my question: how can I specify the way, the contentPane figure is
> displayed in its parent figure with the constraint BorderLayout.CENTER, so
> that either the contentPane spans the whole available space of the parent
> figure (mainpane) [ a) ] or does not span the available space (the
> behaviour I have since revision 1.8 of BorderLayout) [ b) ]?
>
> Or is CENTER the wrong constraint and I have to do some other additional
> things to achieve result a) ?
>
> Can anyone of you help me?
>
> Thanks a lot in advance!
>
> . marion
>
>
Re: [Draw2d] BorderLayout.CENTER and spanning over available space [message #142974 is a reply to message #142934] Fri, 16 July 2004 09:38 Go to previous messageGo to next message
Marion Schmid is currently offline Marion SchmidFriend
Messages: 35
Registered: July 2009
Member
Hello Pratik!
Thanks a lot for your immediate response and the workaround!

I extended ToolbarLayout and overrode calculatePreferredSize as you
suggested and
for the contentPane it works.

Unfortunately, with a scrollpane, that wraps the contentPane with the newly
dimensioned ToolbarLayout of the contentPane, this workaround does not work,
while with this special version of BorderLayout I did not have any problems
with the scrollpane.

So maybe Randy will comment this post some time, as I really wonder why in
version 1.8 the BorderLayout's functionality has been changed.

I would suggest to have some kind of additional way to specify in
BorderLayout, whether with CENTER orientation
the figure shall be spanned or not within the container figure.
I could imagine sth. like a FILL constant, so that the users can specify,
"how centered" they want the figure to be.

Best regards,

Marion

---
FYI - the scrollpane code is that way
-----------------------------------------------------------
if(hasScrollpane) {
ScrollPane scrollpane = createScrollpane(contentPane);
mainPane.add(scrollpane, BorderLayout.CENTER, -1);
} else {
mainPane.add(contentPane, BorderLayout.CENTER,-1);
}

public ScrollPane createScrollpane(IFigure contentsPane) {
ScrollPane scrollpane = new ScrollPane();
scrollpane.setBorder(new MarginBorder(4));
scrollpane.setContents(contentsPane);
return scrollpane;
}
------------------------------------------------------------ ---------

"Pratik Shah" <ppshah@us.ibm.com> wrote in message
news:cd7ne2$rar$1@eclipse.org...
> I am not sure why that functionality was changed. Randy probably knows
why.
>
> Here's a workaround you can try: have your contentPane's toolbarlayout
> return the height that it needs to take up. Something like this:
>
> contentPane.setToolbarLayout(new ToolbarLayout() {
> protected Dimension calculatePreferredSize(IFigure container, int
wHint,
> int hHint) {
> Dimension size = super.calculatePreferredSize(container, wHint,
> hHint);
> if (size.height < hHint) {
> size.height = hHint;
> }
> return size;
> }
> });
>
> "Marion Schmid" <marion.schmid@sap.com> wrote in message
> news:cd61sf$7jg$1@eclipse.org...
> > Hello *,
> >
> > I have problems with getting my BorderLayout-ed figure working as
desired,
> > found the solution in CVS with the BorderLayout revision 1.7, but
> realized,
> > that this solution has been reverted/changed in later revisions
(1.8/1.9)
> >
> >
>
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.draw2d/ src/org/eclipse/draw2d/BorderLayout.java?cvsroot=Tools_Proje ct&only_with_tag=
> >
> > To come to the problem:
> > I have 3 figures:
> >
> > IFigure mainPane = new Figure();
> > IFigure labelPane= new Figure();
> > IFigure contentPane = new Figure();
> >
> > with the layouts
> >
> > mainPane.setLayoutManager(new BorderLayout());
> > labelPane.setLayoutManager(new ToolbarLayout());
> > contentPane.setLayoutManager(new ToolbarLayout());
> >
> > The mainPane figure contains the labelPane and the contentPane figures.
> > The labelPane is at the top of the mainPane,
> > the contentPane shall span the rest of the available space of the
mainPane
> > figure.
> >
> > mainPane.add(labelPane, BorderLayout.TOP);
> > mainPane.add(contentPane, BorderLayout.CENTER);
> >
> > somehow like this
> > (a)
> > _______________
> > |___labelPane____|
> > | |
> > | contentPane |
> > |______________|
> >
> > With the version of the layout() method of BorderLayout in revision 1.7,
> the
> > contentPane is spanned over all available space in the parent figure
> > (mainPane).
> > With some old revision (my eclipse m9 installation) and the latest
> revisions
> > (1.8 and 1.9) the BorderLayout does not behave as I desire.
> >
> > looks this way, means, contentPane is actually in the center and not
> spanned
> > over the whole available space.
> > (b)
> > _______________
> > |___labelPane____|
> > | |
> > |______________|
> > |___contentPane__|
> > | |
> > |______________|
> >
> >
> > So, my question: how can I specify the way, the contentPane figure is
> > displayed in its parent figure with the constraint BorderLayout.CENTER,
so
> > that either the contentPane spans the whole available space of the
parent
> > figure (mainpane) [ a) ] or does not span the available space (the
> > behaviour I have since revision 1.8 of BorderLayout) [ b) ]?
> >
> > Or is CENTER the wrong constraint and I have to do some other additional
> > things to achieve result a) ?
> >
> > Can anyone of you help me?
> >
> > Thanks a lot in advance!
> >
> > . marion
> >
> >
>
>
Re: [Draw2d] BorderLayout.CENTER and spanning over available space [message #143013 is a reply to message #142974] Fri, 16 July 2004 16:36 Go to previous messageGo to next message
Pratik Shah is currently offline Pratik ShahFriend
Messages: 1077
Registered: July 2009
Senior Member
> Unfortunately, with a scrollpane, that wraps the contentPane with the
newly
> dimensioned ToolbarLayout of the contentPane, this workaround does not
work,
> while with this special version of BorderLayout I did not have any
problems
> with the scrollpane.

That's because the ScrollPane throws away the height hint and passes -1 to
its child (meaning that it can be as tall as it wants). The workaround that
I provided should be applied to the immediate figure in the CENTER. So, if
your content figure is in a scrollpane, you should remove the workaround
from ToolbarLayout and apply it to ScrollPaneLayout instead.

"Marion Schmid" <marion.schmid@sap.com> wrote in message
news:cd87l9$luo$1@eclipse.org...
> Hello Pratik!
> Thanks a lot for your immediate response and the workaround!
>
> I extended ToolbarLayout and overrode calculatePreferredSize as you
> suggested and
> for the contentPane it works.
>
> Unfortunately, with a scrollpane, that wraps the contentPane with the
newly
> dimensioned ToolbarLayout of the contentPane, this workaround does not
work,
> while with this special version of BorderLayout I did not have any
problems
> with the scrollpane.
>
> So maybe Randy will comment this post some time, as I really wonder why in
> version 1.8 the BorderLayout's functionality has been changed.
>
> I would suggest to have some kind of additional way to specify in
> BorderLayout, whether with CENTER orientation
> the figure shall be spanned or not within the container figure.
> I could imagine sth. like a FILL constant, so that the users can specify,
> "how centered" they want the figure to be.
>
> Best regards,
>
> Marion
>
> ---
> FYI - the scrollpane code is that way
> -----------------------------------------------------------
> if(hasScrollpane) {
> ScrollPane scrollpane = createScrollpane(contentPane);
> mainPane.add(scrollpane, BorderLayout.CENTER, -1);
> } else {
> mainPane.add(contentPane, BorderLayout.CENTER,-1);
> }
>
> public ScrollPane createScrollpane(IFigure contentsPane) {
> ScrollPane scrollpane = new ScrollPane();
> scrollpane.setBorder(new MarginBorder(4));
> scrollpane.setContents(contentsPane);
> return scrollpane;
> }
> ------------------------------------------------------------ ---------
>
> "Pratik Shah" <ppshah@us.ibm.com> wrote in message
> news:cd7ne2$rar$1@eclipse.org...
> > I am not sure why that functionality was changed. Randy probably knows
> why.
> >
> > Here's a workaround you can try: have your contentPane's toolbarlayout
> > return the height that it needs to take up. Something like this:
> >
> > contentPane.setToolbarLayout(new ToolbarLayout() {
> > protected Dimension calculatePreferredSize(IFigure container, int
> wHint,
> > int hHint) {
> > Dimension size = super.calculatePreferredSize(container, wHint,
> > hHint);
> > if (size.height < hHint) {
> > size.height = hHint;
> > }
> > return size;
> > }
> > });
> >
> > "Marion Schmid" <marion.schmid@sap.com> wrote in message
> > news:cd61sf$7jg$1@eclipse.org...
> > > Hello *,
> > >
> > > I have problems with getting my BorderLayout-ed figure working as
> desired,
> > > found the solution in CVS with the BorderLayout revision 1.7, but
> > realized,
> > > that this solution has been reverted/changed in later revisions
> (1.8/1.9)
> > >
> > >
> >
>
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.draw2d/ src/org/eclipse/draw2d/BorderLayout.java?cvsroot=Tools_Proje ct&only_with_tag=
> > >
> > > To come to the problem:
> > > I have 3 figures:
> > >
> > > IFigure mainPane = new Figure();
> > > IFigure labelPane= new Figure();
> > > IFigure contentPane = new Figure();
> > >
> > > with the layouts
> > >
> > > mainPane.setLayoutManager(new BorderLayout());
> > > labelPane.setLayoutManager(new ToolbarLayout());
> > > contentPane.setLayoutManager(new ToolbarLayout());
> > >
> > > The mainPane figure contains the labelPane and the contentPane
figures.
> > > The labelPane is at the top of the mainPane,
> > > the contentPane shall span the rest of the available space of the
> mainPane
> > > figure.
> > >
> > > mainPane.add(labelPane, BorderLayout.TOP);
> > > mainPane.add(contentPane, BorderLayout.CENTER);
> > >
> > > somehow like this
> > > (a)
> > > _______________
> > > |___labelPane____|
> > > | |
> > > | contentPane |
> > > |______________|
> > >
> > > With the version of the layout() method of BorderLayout in revision
1.7,
> > the
> > > contentPane is spanned over all available space in the parent figure
> > > (mainPane).
> > > With some old revision (my eclipse m9 installation) and the latest
> > revisions
> > > (1.8 and 1.9) the BorderLayout does not behave as I desire.
> > >
> > > looks this way, means, contentPane is actually in the center and not
> > spanned
> > > over the whole available space.
> > > (b)
> > > _______________
> > > |___labelPane____|
> > > | |
> > > |______________|
> > > |___contentPane__|
> > > | |
> > > |______________|
> > >
> > >
> > > So, my question: how can I specify the way, the contentPane figure is
> > > displayed in its parent figure with the constraint
BorderLayout.CENTER,
> so
> > > that either the contentPane spans the whole available space of the
> parent
> > > figure (mainpane) [ a) ] or does not span the available space (the
> > > behaviour I have since revision 1.8 of BorderLayout) [ b) ]?
> > >
> > > Or is CENTER the wrong constraint and I have to do some other
additional
> > > things to achieve result a) ?
> > >
> > > Can anyone of you help me?
> > >
> > > Thanks a lot in advance!
> > >
> > > . marion
> > >
> > >
> >
> >
>
>
Re: [Draw2d] BorderLayout.CENTER and spanning over available space [message #143402 is a reply to message #142974] Mon, 19 July 2004 18:24 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

This is a bug introduced by fixing other problems with this layout.

Isn't there a positive height hint being passed in during layout()? The
center figure could just return that its preferred size is that amount. So
in other words, prefSize.height = Math.max(hHint, prefsize.height);

"Marion Schmid" <marion.schmid@sap.com> wrote in message
news:cd87l9$luo$1@eclipse.org...
> Hello Pratik!
> Thanks a lot for your immediate response and the workaround!
>
> I extended ToolbarLayout and overrode calculatePreferredSize as you
> suggested and
> for the contentPane it works.
>
> Unfortunately, with a scrollpane, that wraps the contentPane with the
newly
> dimensioned ToolbarLayout of the contentPane, this workaround does not
work,
> while with this special version of BorderLayout I did not have any
problems
> with the scrollpane.
>
> So maybe Randy will comment this post some time, as I really wonder why in
> version 1.8 the BorderLayout's functionality has been changed.
>
> I would suggest to have some kind of additional way to specify in
> BorderLayout, whether with CENTER orientation
> the figure shall be spanned or not within the container figure.
> I could imagine sth. like a FILL constant, so that the users can specify,
> "how centered" they want the figure to be.
>
> Best regards,
>
> Marion
>
> ---
> FYI - the scrollpane code is that way
> -----------------------------------------------------------
> if(hasScrollpane) {
> ScrollPane scrollpane = createScrollpane(contentPane);
> mainPane.add(scrollpane, BorderLayout.CENTER, -1);
> } else {
> mainPane.add(contentPane, BorderLayout.CENTER,-1);
> }
>
> public ScrollPane createScrollpane(IFigure contentsPane) {
> ScrollPane scrollpane = new ScrollPane();
> scrollpane.setBorder(new MarginBorder(4));
> scrollpane.setContents(contentsPane);
> return scrollpane;
> }
> ------------------------------------------------------------ ---------
>
> "Pratik Shah" <ppshah@us.ibm.com> wrote in message
> news:cd7ne2$rar$1@eclipse.org...
> > I am not sure why that functionality was changed. Randy probably knows
> why.
> >
> > Here's a workaround you can try: have your contentPane's toolbarlayout
> > return the height that it needs to take up. Something like this:
> >
> > contentPane.setToolbarLayout(new ToolbarLayout() {
> > protected Dimension calculatePreferredSize(IFigure container, int
> wHint,
> > int hHint) {
> > Dimension size = super.calculatePreferredSize(container, wHint,
> > hHint);
> > if (size.height < hHint) {
> > size.height = hHint;
> > }
> > return size;
> > }
> > });
> >
> > "Marion Schmid" <marion.schmid@sap.com> wrote in message
> > news:cd61sf$7jg$1@eclipse.org...
> > > Hello *,
> > >
> > > I have problems with getting my BorderLayout-ed figure working as
> desired,
> > > found the solution in CVS with the BorderLayout revision 1.7, but
> > realized,
> > > that this solution has been reverted/changed in later revisions
> (1.8/1.9)
> > >
> > >
> >
>
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.draw2d/ src/org/eclipse/draw2d/BorderLayout.java?cvsroot=Tools_Proje ct&only_with_tag=
> > >
> > > To come to the problem:
> > > I have 3 figures:
> > >
> > > IFigure mainPane = new Figure();
> > > IFigure labelPane= new Figure();
> > > IFigure contentPane = new Figure();
> > >
> > > with the layouts
> > >
> > > mainPane.setLayoutManager(new BorderLayout());
> > > labelPane.setLayoutManager(new ToolbarLayout());
> > > contentPane.setLayoutManager(new ToolbarLayout());
> > >
> > > The mainPane figure contains the labelPane and the contentPane
figures.
> > > The labelPane is at the top of the mainPane,
> > > the contentPane shall span the rest of the available space of the
> mainPane
> > > figure.
> > >
> > > mainPane.add(labelPane, BorderLayout.TOP);
> > > mainPane.add(contentPane, BorderLayout.CENTER);
> > >
> > > somehow like this
> > > (a)
> > > _______________
> > > |___labelPane____|
> > > | |
> > > | contentPane |
> > > |______________|
> > >
> > > With the version of the layout() method of BorderLayout in revision
1.7,
> > the
> > > contentPane is spanned over all available space in the parent figure
> > > (mainPane).
> > > With some old revision (my eclipse m9 installation) and the latest
> > revisions
> > > (1.8 and 1.9) the BorderLayout does not behave as I desire.
> > >
> > > looks this way, means, contentPane is actually in the center and not
> > spanned
> > > over the whole available space.
> > > (b)
> > > _______________
> > > |___labelPane____|
> > > | |
> > > |______________|
> > > |___contentPane__|
> > > | |
> > > |______________|
> > >
> > >
> > > So, my question: how can I specify the way, the contentPane figure is
> > > displayed in its parent figure with the constraint
BorderLayout.CENTER,
> so
> > > that either the contentPane spans the whole available space of the
> parent
> > > figure (mainpane) [ a) ] or does not span the available space (the
> > > behaviour I have since revision 1.8 of BorderLayout) [ b) ]?
> > >
> > > Or is CENTER the wrong constraint and I have to do some other
additional
> > > things to achieve result a) ?
> > >
> > > Can anyone of you help me?
> > >
> > > Thanks a lot in advance!
> > >
> > > . marion
> > >
> > >
> >
> >
>
>
Re: [Draw2d] BorderLayout.CENTER and spanning over available space [message #143911 is a reply to message #143402] Thu, 22 July 2004 12:40 Go to previous messageGo to next message
Marion Schmid is currently offline Marion SchmidFriend
Messages: 35
Registered: July 2009
Member
Hello Randy,

if I understood you correctly, with a modified BorderLayout Version 1.9, my
specific problem could be solved the way you recommended:

// original 1.9 Version of BorderLayout#layout() - center-part:

if (center != null && center.isVisible()) {
childSize = center.getPreferredSize(
Math.max(0, area.width),
Math.max(0, area.height));
if (childSize.height < area.height) {
area.y += (area.height - childSize.height) / 2;
area.height = childSize.height;
}
center.setBounds(area);
}
--------------------------

// modified version of BorderLayout#layout() - center-part:
childSize = new Dimension();
childSize.width = center.getPreferredSize(Math.max(0, area.width),
Math.max(0, area.height)).width;
childSize.height = area.height;
center.setBounds(area);

---------------
So far, my problem is solved. But another point is - what if developers want
the BorderLayout.CENTER really be in CENTER and not spanned over the whole
available space? I'm quite satisfied if the center figure is spanned, as I
think in AWT it's the same, but who decides this, whether the spanning in
center is hard-coded or can be adjusted by a flag (to FILL or not to FILL) ?

Best regards and thanks a lot for your help!
marion


"Randy Hudson" <none@us.ibm.com> wrote in message
news:cdh3i1$qdm$1@eclipse.org...
> This is a bug introduced by fixing other problems with this layout.
>
> Isn't there a positive height hint being passed in during layout()? The
> center figure could just return that its preferred size is that amount.
So
> in other words, prefSize.height = Math.max(hHint, prefsize.height);
>
> "Marion Schmid" <marion.schmid@sap.com> wrote in message
> news:cd87l9$luo$1@eclipse.org...
> > Hello Pratik!
> > Thanks a lot for your immediate response and the workaround!
> >
> > I extended ToolbarLayout and overrode calculatePreferredSize as you
> > suggested and
> > for the contentPane it works.
> >
> > Unfortunately, with a scrollpane, that wraps the contentPane with the
> newly
> > dimensioned ToolbarLayout of the contentPane, this workaround does not
> work,
> > while with this special version of BorderLayout I did not have any
> problems
> > with the scrollpane.
> >
> > So maybe Randy will comment this post some time, as I really wonder why
in
> > version 1.8 the BorderLayout's functionality has been changed.
> >
> > I would suggest to have some kind of additional way to specify in
> > BorderLayout, whether with CENTER orientation
> > the figure shall be spanned or not within the container figure.
> > I could imagine sth. like a FILL constant, so that the users can
specify,
> > "how centered" they want the figure to be.
> >
> > Best regards,
> >
> > Marion
> >
> > ---
> > FYI - the scrollpane code is that way
> > -----------------------------------------------------------
> > if(hasScrollpane) {
> > ScrollPane scrollpane = createScrollpane(contentPane);
> > mainPane.add(scrollpane, BorderLayout.CENTER, -1);
> > } else {
> > mainPane.add(contentPane, BorderLayout.CENTER,-1);
> > }
> >
> > public ScrollPane createScrollpane(IFigure contentsPane) {
> > ScrollPane scrollpane = new ScrollPane();
> > scrollpane.setBorder(new MarginBorder(4));
> > scrollpane.setContents(contentsPane);
> > return scrollpane;
> > }
> > ------------------------------------------------------------ ---------
> >
> > "Pratik Shah" <ppshah@us.ibm.com> wrote in message
> > news:cd7ne2$rar$1@eclipse.org...
> > > I am not sure why that functionality was changed. Randy probably
knows
> > why.
> > >
> > > Here's a workaround you can try: have your contentPane's toolbarlayout
> > > return the height that it needs to take up. Something like this:
> > >
> > > contentPane.setToolbarLayout(new ToolbarLayout() {
> > > protected Dimension calculatePreferredSize(IFigure container, int
> > wHint,
> > > int hHint) {
> > > Dimension size = super.calculatePreferredSize(container,
wHint,
> > > hHint);
> > > if (size.height < hHint) {
> > > size.height = hHint;
> > > }
> > > return size;
> > > }
> > > });
> > >
> > > "Marion Schmid" <marion.schmid@sap.com> wrote in message
> > > news:cd61sf$7jg$1@eclipse.org...
> > > > Hello *,
> > > >
> > > > I have problems with getting my BorderLayout-ed figure working as
> > desired,
> > > > found the solution in CVS with the BorderLayout revision 1.7, but
> > > realized,
> > > > that this solution has been reverted/changed in later revisions
> > (1.8/1.9)
> > > >
> > > >
> > >
> >
>
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.draw2d/ src/org/eclipse/draw2d/BorderLayout.java?cvsroot=Tools_Proje ct&only_with_tag=
> > > >
> > > > To come to the problem:
> > > > I have 3 figures:
> > > >
> > > > IFigure mainPane = new Figure();
> > > > IFigure labelPane= new Figure();
> > > > IFigure contentPane = new Figure();
> > > >
> > > > with the layouts
> > > >
> > > > mainPane.setLayoutManager(new BorderLayout());
> > > > labelPane.setLayoutManager(new ToolbarLayout());
> > > > contentPane.setLayoutManager(new ToolbarLayout());
> > > >
> > > > The mainPane figure contains the labelPane and the contentPane
> figures.
> > > > The labelPane is at the top of the mainPane,
> > > > the contentPane shall span the rest of the available space of the
> > mainPane
> > > > figure.
> > > >
> > > > mainPane.add(labelPane, BorderLayout.TOP);
> > > > mainPane.add(contentPane, BorderLayout.CENTER);
> > > >
> > > > somehow like this
> > > > (a)
> > > > _______________
> > > > |___labelPane____|
> > > > | |
> > > > | contentPane |
> > > > |______________|
> > > >
> > > > With the version of the layout() method of BorderLayout in revision
> 1.7,
> > > the
> > > > contentPane is spanned over all available space in the parent figure
> > > > (mainPane).
> > > > With some old revision (my eclipse m9 installation) and the latest
> > > revisions
> > > > (1.8 and 1.9) the BorderLayout does not behave as I desire.
> > > >
> > > > looks this way, means, contentPane is actually in the center and not
> > > spanned
> > > > over the whole available space.
> > > > (b)
> > > > _______________
> > > > |___labelPane____|
> > > > | |
> > > > |______________|
> > > > |___contentPane__|
> > > > | |
> > > > |______________|
> > > >
> > > >
> > > > So, my question: how can I specify the way, the contentPane figure
is
> > > > displayed in its parent figure with the constraint
> BorderLayout.CENTER,
> > so
> > > > that either the contentPane spans the whole available space of the
> > parent
> > > > figure (mainpane) [ a) ] or does not span the available space (the
> > > > behaviour I have since revision 1.8 of BorderLayout) [ b) ]?
> > > >
> > > > Or is CENTER the wrong constraint and I have to do some other
> additional
> > > > things to achieve result a) ?
> > > >
> > > > Can anyone of you help me?
> > > >
> > > > Thanks a lot in advance!
> > > >
> > > > . marion
> > > >
> > > >
> > >
> > >
> >
> >
>
>
Re: [Draw2d] BorderLayout.CENTER and spanning over available space [message #221281 is a reply to message #143402] Fri, 11 August 2006 11:35 Go to previous message
Nhu Le is currently offline Nhu LeFriend
Messages: 47
Registered: July 2009
Member
Has this bug been fixed or is it correct behaviour this way? I am still
having exactly the same problem and the same work around still works
well for me.

Thanks for the update.
Nhu Le

Randy Hudson wrote:
> This is a bug introduced by fixing other problems with this layout.
>
> Isn't there a positive height hint being passed in during layout()? The
> center figure could just return that its preferred size is that amount. So
> in other words, prefSize.height = Math.max(hHint, prefsize.height);
>
> "Marion Schmid" <marion.schmid@sap.com> wrote in message
> news:cd87l9$luo$1@eclipse.org...
>> Hello Pratik!
>> Thanks a lot for your immediate response and the workaround!
>>
>> I extended ToolbarLayout and overrode calculatePreferredSize as you
>> suggested and
>> for the contentPane it works.
>>
>> Unfortunately, with a scrollpane, that wraps the contentPane with the
> newly
>> dimensioned ToolbarLayout of the contentPane, this workaround does not
> work,
>> while with this special version of BorderLayout I did not have any
> problems
>> with the scrollpane.
>>
>> So maybe Randy will comment this post some time, as I really wonder why in
>> version 1.8 the BorderLayout's functionality has been changed.
>>
>> I would suggest to have some kind of additional way to specify in
>> BorderLayout, whether with CENTER orientation
>> the figure shall be spanned or not within the container figure.
>> I could imagine sth. like a FILL constant, so that the users can specify,
>> "how centered" they want the figure to be.
>>
>> Best regards,
>>
>> Marion
>>
>> ---
>> FYI - the scrollpane code is that way
>> -----------------------------------------------------------
>> if(hasScrollpane) {
>> ScrollPane scrollpane = createScrollpane(contentPane);
>> mainPane.add(scrollpane, BorderLayout.CENTER, -1);
>> } else {
>> mainPane.add(contentPane, BorderLayout.CENTER,-1);
>> }
>>
>> public ScrollPane createScrollpane(IFigure contentsPane) {
>> ScrollPane scrollpane = new ScrollPane();
>> scrollpane.setBorder(new MarginBorder(4));
>> scrollpane.setContents(contentsPane);
>> return scrollpane;
>> }
>> ------------------------------------------------------------ ---------
>>
>> "Pratik Shah" <ppshah@us.ibm.com> wrote in message
>> news:cd7ne2$rar$1@eclipse.org...
>>> I am not sure why that functionality was changed. Randy probably knows
>> why.
>>> Here's a workaround you can try: have your contentPane's toolbarlayout
>>> return the height that it needs to take up. Something like this:
>>>
>>> contentPane.setToolbarLayout(new ToolbarLayout() {
>>> protected Dimension calculatePreferredSize(IFigure container, int
>> wHint,
>>> int hHint) {
>>> Dimension size = super.calculatePreferredSize(container, wHint,
>>> hHint);
>>> if (size.height < hHint) {
>>> size.height = hHint;
>>> }
>>> return size;
>>> }
>>> });
>>>
>>> "Marion Schmid" <marion.schmid@sap.com> wrote in message
>>> news:cd61sf$7jg$1@eclipse.org...
>>>> Hello *,
>>>>
>>>> I have problems with getting my BorderLayout-ed figure working as
>> desired,
>>>> found the solution in CVS with the BorderLayout revision 1.7, but
>>> realized,
>>>> that this solution has been reverted/changed in later revisions
>> (1.8/1.9)
>>>>
> http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.draw2d/ src/org/eclipse/draw2d/BorderLayout.java?cvsroot=Tools_Proje ct&only_with_tag=
>>>> To come to the problem:
>>>> I have 3 figures:
>>>>
>>>> IFigure mainPane = new Figure();
>>>> IFigure labelPane= new Figure();
>>>> IFigure contentPane = new Figure();
>>>>
>>>> with the layouts
>>>>
>>>> mainPane.setLayoutManager(new BorderLayout());
>>>> labelPane.setLayoutManager(new ToolbarLayout());
>>>> contentPane.setLayoutManager(new ToolbarLayout());
>>>>
>>>> The mainPane figure contains the labelPane and the contentPane
> figures.
>>>> The labelPane is at the top of the mainPane,
>>>> the contentPane shall span the rest of the available space of the
>> mainPane
>>>> figure.
>>>>
>>>> mainPane.add(labelPane, BorderLayout.TOP);
>>>> mainPane.add(contentPane, BorderLayout.CENTER);
>>>>
>>>> somehow like this
>>>> (a)
>>>> _______________
>>>> |___labelPane____|
>>>> | |
>>>> | contentPane |
>>>> |______________|
>>>>
>>>> With the version of the layout() method of BorderLayout in revision
> 1.7,
>>> the
>>>> contentPane is spanned over all available space in the parent figure
>>>> (mainPane).
>>>> With some old revision (my eclipse m9 installation) and the latest
>>> revisions
>>>> (1.8 and 1.9) the BorderLayout does not behave as I desire.
>>>>
>>>> looks this way, means, contentPane is actually in the center and not
>>> spanned
>>>> over the whole available space.
>>>> (b)
>>>> _______________
>>>> |___labelPane____|
>>>> | |
>>>> |______________|
>>>> |___contentPane__|
>>>> | |
>>>> |______________|
>>>>
>>>>
>>>> So, my question: how can I specify the way, the contentPane figure is
>>>> displayed in its parent figure with the constraint
> BorderLayout.CENTER,
>> so
>>>> that either the contentPane spans the whole available space of the
>> parent
>>>> figure (mainpane) [ a) ] or does not span the available space (the
>>>> behaviour I have since revision 1.8 of BorderLayout) [ b) ]?
>>>>
>>>> Or is CENTER the wrong constraint and I have to do some other
> additional
>>>> things to achieve result a) ?
>>>>
>>>> Can anyone of you help me?
>>>>
>>>> Thanks a lot in advance!
>>>>
>>>> . marion
>>>>
>>>>
>>>
>>
>
>
Previous Topic:ScrollPane is not scrolling!
Next Topic:Figures and EditParts
Goto Forum:
  


Current Time: Thu Mar 28 18:32:00 GMT 2024

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

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

Back to the top