Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » laying out child figures in 2 columns
laying out child figures in 2 columns [message #199245] Fri, 14 October 2005 13:45 Go to next message
Eclipse UserFriend
Originally posted by: christian.sell.netcologne.de

Hello,

can somebody give me a hint how to lay out child figures in 2 columns,
such that the row contents are left-aligned in each columnn? Each row is
one edit part which has 2 text items. Example:
_________________________
|row1text row2text |
|moretexttext moretext |

thanks,
Christian
Re: laying out child figures in 2 columns [message #199269 is a reply to message #199245] Fri, 14 October 2005 14:07 Go to previous messageGo to next message
Felix L J Mayer is currently offline Felix L J MayerFriend
Messages: 202
Registered: July 2009
Senior Member
You need to write a LayoutManager for the parent figure.

"Christian Sell" <christian.sell@netcologne.de> wrote in message
news:diocps$98a$1@news.eclipse.org...
> Hello,
>
> can somebody give me a hint how to lay out child figures in 2 columns,
> such that the row contents are left-aligned in each columnn? Each row is
> one edit part which has 2 text items. Example:
> _________________________
> |row1text row2text |
> |moretexttext moretext |
>
> thanks,
> Christian
Re: laying out child figures in 2 columns [message #199326 is a reply to message #199269] Fri, 14 October 2005 14:39 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: christian.sell.netcologne.de

thanks, thats the answer I feared. My preference would have been "look
at example XYZ", or "see the code sample below". Should this turn out to
be a case of YCAGWYW (You Cant Always Get What You Want)?

christian

Felix L J Mayer wrote:
> You need to write a LayoutManager for the parent figure.
>
> "Christian Sell" <christian.sell@netcologne.de> wrote in message
> news:diocps$98a$1@news.eclipse.org...
>
>>Hello,
>>
>>can somebody give me a hint how to lay out child figures in 2 columns,
>>such that the row contents are left-aligned in each columnn? Each row is
>>one edit part which has 2 text items. Example:
>>_________________________
>>|row1text row2text |
>>|moretexttext moretext |
>>
>>thanks,
>>Christian
>
>
>
Re: laying out child figures in 2 columns [message #199402 is a reply to message #199326] Fri, 14 October 2005 15:47 Go to previous messageGo to next message
Felix L J Mayer is currently offline Felix L J MayerFriend
Messages: 202
Registered: July 2009
Senior Member
Okay, here is your example, I just removed some code that is specific to my
stacked layout to make it more readable.

public class StackedLayout extends AbstractLayout {

/**
* @see
org.eclipse.draw2d.AbstractLayout#calculatePreferredSize(org .eclipse.draw2d.IFigure,
int, int)
*/
protected Dimension calculatePreferredSize( IFigure container, int wHint,
int hHint ) {
Dimension preferred = new Dimension( 0, 0 );
if( container.isVisible() ) {
for( Iterator i = container.getChildren().iterator(); i.hasNext(); ) {
IFigure child = (IFigure) i.next();
Dimension current = child.getPreferredSize();
// compute preferred here
}//for
Insets insets = container.getInsets();
preferred.expand( insets.getWidth(), insets.getHeight() );
}//if
return preferred;
}//calculatePreferredSize()

/**
* @see
org.eclipse.draw2d.LayoutManager#getMinimumSize(org.eclipse. draw2d.IFigure,
int, int)
*/
public Dimension getMinimumSize( IFigure container, int wHint, int hHint )
{
// Compute the minimum size as the preferred size of the first
// Compartment, which should be the title of the classifier.
return ((IFigure) container.getChildren().get( 0 )).getPreferredSize();
}//getMinimumSize()

/**
* @see
org.eclipse.draw2d.AbstractLayout#layout(org.eclipse.draw2d. IFigure)
*/
public void layout( IFigure container ) {
Rectangle clientArea = container.getClientArea();
LOG.finest( "container=" + container + " clientArea=" + clientArea );
int maxHeight = clientArea.height;
Rectangle previous = new Rectangle( clientArea.x, clientArea.y,
clientArea.width, 0 );
for( Iterator i = container.getChildren().iterator(); i.hasNext(); ) {
IFigure child = (IFigure) i.next();
Rectangle bounds = // Whatever you need, previous probably helps
child.setBounds( bounds );
previous = bounds;
}//for
}//layout()

}

"Christian Sell" <christian.sell@netcologne.de> wrote in message
news:diofvo$e5e$1@news.eclipse.org...
> thanks, thats the answer I feared. My preference would have been "look at
> example XYZ", or "see the code sample below". Should this turn out to be a
> case of YCAGWYW (You Cant Always Get What You Want)?
>
> christian
>
> Felix L J Mayer wrote:
>> You need to write a LayoutManager for the parent figure.
>>
>> "Christian Sell" <christian.sell@netcologne.de> wrote in message
>> news:diocps$98a$1@news.eclipse.org...
>>
>>>Hello,
>>>
>>>can somebody give me a hint how to lay out child figures in 2 columns,
>>>such that the row contents are left-aligned in each columnn? Each row is
>>>one edit part which has 2 text items. Example:
>>>_________________________
>>>|row1text row2text |
>>>|moretexttext moretext |
>>>
>>>thanks,
>>>Christian
>>
>>
Re: laying out child figures in 2 columns [message #199425 is a reply to message #199402] Fri, 14 October 2005 16:38 Go to previous message
Eclipse UserFriend
Originally posted by: christian.sell.netcologne.de

thanks, I'll check this out.

chris

Felix L J Mayer wrote:
> Okay, here is your example, I just removed some code that is specific to my
> stacked layout to make it more readable.
>
> public class StackedLayout extends AbstractLayout {
>
> /**
> * @see
> org.eclipse.draw2d.AbstractLayout#calculatePreferredSize(org .eclipse.draw2d.IFigure,
> int, int)
> */
> protected Dimension calculatePreferredSize( IFigure container, int wHint,
> int hHint ) {
> Dimension preferred = new Dimension( 0, 0 );
> if( container.isVisible() ) {
> for( Iterator i = container.getChildren().iterator(); i.hasNext(); ) {
> IFigure child = (IFigure) i.next();
> Dimension current = child.getPreferredSize();
> // compute preferred here
> }//for
> Insets insets = container.getInsets();
> preferred.expand( insets.getWidth(), insets.getHeight() );
> }//if
> return preferred;
> }//calculatePreferredSize()
>
> /**
> * @see
> org.eclipse.draw2d.LayoutManager#getMinimumSize(org.eclipse. draw2d.IFigure,
> int, int)
> */
> public Dimension getMinimumSize( IFigure container, int wHint, int hHint )
> {
> // Compute the minimum size as the preferred size of the first
> // Compartment, which should be the title of the classifier.
> return ((IFigure) container.getChildren().get( 0 )).getPreferredSize();
> }//getMinimumSize()
>
> /**
> * @see
> org.eclipse.draw2d.AbstractLayout#layout(org.eclipse.draw2d. IFigure)
> */
> public void layout( IFigure container ) {
> Rectangle clientArea = container.getClientArea();
> LOG.finest( "container=" + container + " clientArea=" + clientArea );
> int maxHeight = clientArea.height;
> Rectangle previous = new Rectangle( clientArea.x, clientArea.y,
> clientArea.width, 0 );
> for( Iterator i = container.getChildren().iterator(); i.hasNext(); ) {
> IFigure child = (IFigure) i.next();
> Rectangle bounds = // Whatever you need, previous probably helps
> child.setBounds( bounds );
> previous = bounds;
> }//for
> }//layout()
>
> }
>
> "Christian Sell" <christian.sell@netcologne.de> wrote in message
> news:diofvo$e5e$1@news.eclipse.org...
>
>>thanks, thats the answer I feared. My preference would have been "look at
>>example XYZ", or "see the code sample below". Should this turn out to be a
>>case of YCAGWYW (You Cant Always Get What You Want)?
>>
>>christian
>>
>>Felix L J Mayer wrote:
>>
>>>You need to write a LayoutManager for the parent figure.
>>>
>>>"Christian Sell" <christian.sell@netcologne.de> wrote in message
>>>news:diocps$98a$1@news.eclipse.org...
>>>
>>>
>>>>Hello,
>>>>
>>>>can somebody give me a hint how to lay out child figures in 2 columns,
>>>>such that the row contents are left-aligned in each columnn? Each row is
>>>>one edit part which has 2 text items. Example:
>>>>_________________________
>>>>|row1text row2text |
>>>>|moretexttext moretext |
>>>>
>>>>thanks,
>>>>Christian
>>>
>>>
>
Previous Topic:Problem in opening a new file in the editor.
Next Topic:Display large text files using org.eclipse.draw2d.text
Goto Forum:
  


Current Time: Fri Apr 19 21:26:23 GMT 2024

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

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

Back to the top