Skip to main content



      Home
Home » Eclipse Projects » GEF » Resizing Figure
Resizing Figure [message #110593] Tue, 06 January 2004 09:37 Go to next message
Eclipse UserFriend
Originally posted by: david_danie.hotmail.com

Hi Friends,
My Figure contains one Label. The text of the label
should be editable. I like to resize my figure with respect to the text
of the Label. How can i do this?.

Regards,
David Danie.
Re: Resizing Figure [message #110628 is a reply to message #110593] Wed, 07 January 2004 02:55 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: brian.fernandes.codito.com

I think you can first make sure that the size of the label is such that it
accomodates the text in it.
Something like labelfigure.setSize(labelfigure.getTextBounds()); You can
place this in refreshVisuals so that whenever you have edited the text in
the label, you see that refreshVisuals is called (by a firePropertyChange
perhaps) and the labels size changes.

What figure are you using to contain the Label Figure and what Layout does
it have ?

Brian.
Re: Resizing Figure [message #110744 is a reply to message #110593] Wed, 07 January 2004 19:31 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

You have a figure which contains one label. I guess my first question would
be what does your figure do? Why not just use label?

If you do need to wrap one figure inside another, using draw2d's StackLayout
will allow the outer figure to return a correct preferred size based on its
insets and the inner figure's preferred size. Label already calculate its
preferred size correctly to accomodate the text and/or icon.

The final piece would be what is containing "My Figure"? If you put it
inside and XYLayout, and give it a width and height == "-1", it will be
auto-sized to its preferred size. (And stack layout will size the label
inside the wrapper figure).

Hope this helps

"David Danie" <david_danie@hotmail.com> wrote in message
news:bteh67$mkj$1@eclipse.org...
> Hi Friends,
> My Figure contains one Label. The text of the label
> should be editable. I like to resize my figure with respect to the text
> of the Label. How can i do this?.
>
> Regards,
> David Danie.
>
Re: Resizing Figure [message #110769 is a reply to message #110744] Wed, 07 January 2004 22:40 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: david_danie.hotmail.com

Randy Hudson wrote:
> You have a figure which contains one label. I guess my first question would
> be what does your figure do? Why not just use label?
>
> If you do need to wrap one figure inside another, using draw2d's StackLayout
> will allow the outer figure to return a correct preferred size based on its
> insets and the inner figure's preferred size. Label already calculate its
> preferred size correctly to accomodate the text and/or icon.
>
> The final piece would be what is containing "My Figure"? If you put it
> inside and XYLayout, and give it a width and height == "-1", it will be
> auto-sized to its preferred size. (And stack layout will size the label
> inside the wrapper figure).
>
> Hope this helps
>
> "David Danie" <david_danie@hotmail.com> wrote in message
> news:bteh67$mkj$1@eclipse.org...
>
>>Hi Friends,
>> My Figure contains one Label. The text of the label
>>should be editable. I like to resize my figure with respect to the text
>>of the Label. How can i do this?.
>>
>>Regards,
>>David Danie.
>>
>
>
>

Hi Randy,
My Figure have two compartments. the top level compartment
contains only one label. the other one contains multiple labels(i like
to add labels dynamically).

thanks
David Danie.
Re: Resizing Figure [message #110780 is a reply to message #110628] Wed, 07 January 2004 22:44 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: david_danie.hotmail.com

Brian Fernandes wrote:
> I think you can first make sure that the size of the label is such that it
> accomodates the text in it.
> Something like labelfigure.setSize(labelfigure.getTextBounds()); You can
> place this in refreshVisuals so that whenever you have edited the text in
> the label, you see that refreshVisuals is called (by a firePropertyChange
> perhaps) and the labels size changes.
>
> What figure are you using to contain the Label Figure and what Layout does
> it have ?
>
> Brian.
>
>

Hi Brain,
My Figure have two compartments. the top level compartment
contains only one label. the other one contains multiple labels(i like
to add labels dynamically). So i use ToolbarLayout.

thanks
David Danie.
Re: Resizing Figure [message #110792 is a reply to message #110769] Wed, 07 January 2004 23:32 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

This sounds like what is described in our article. Use a ToolbarLayout.

"David Danie" <david_danie@hotmail.com> wrote in message
news:btije6$acf$1@eclipse.org...
> Randy Hudson wrote:
> > You have a figure which contains one label. I guess my first question
would
> > be what does your figure do? Why not just use label?
> >
> > If you do need to wrap one figure inside another, using draw2d's
StackLayout
> > will allow the outer figure to return a correct preferred size based on
its
> > insets and the inner figure's preferred size. Label already calculate
its
> > preferred size correctly to accomodate the text and/or icon.
> >
> > The final piece would be what is containing "My Figure"? If you put it
> > inside and XYLayout, and give it a width and height == "-1", it will be
> > auto-sized to its preferred size. (And stack layout will size the label
> > inside the wrapper figure).
> >
> > Hope this helps
> >
> > "David Danie" <david_danie@hotmail.com> wrote in message
> > news:bteh67$mkj$1@eclipse.org...
> >
> >>Hi Friends,
> >> My Figure contains one Label. The text of the label
> >>should be editable. I like to resize my figure with respect to the text
> >>of the Label. How can i do this?.
> >>
> >>Regards,
> >>David Danie.
> >>
> >
> >
> >
>
> Hi Randy,
> My Figure have two compartments. the top level compartment
> contains only one label. the other one contains multiple labels(i like
> to add labels dynamically).
>
> thanks
> David Danie.
>
Re: Resizing Figure [message #110991 is a reply to message #110792] Fri, 09 January 2004 10:14 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: david_danie.hotmail.com

Randy Hudson wrote:
> This sounds like what is described in our article. Use a ToolbarLayout.
>
> "David Danie" <david_danie@hotmail.com> wrote in message
> news:btije6$acf$1@eclipse.org...
>
>>Randy Hudson wrote:
>>
>>>You have a figure which contains one label. I guess my first question
>
> would
>
>>>be what does your figure do? Why not just use label?
>>>
>>>If you do need to wrap one figure inside another, using draw2d's
>
> StackLayout
>
>>>will allow the outer figure to return a correct preferred size based on
>
> its
>
>>>insets and the inner figure's preferred size. Label already calculate
>
> its
>
>>>preferred size correctly to accomodate the text and/or icon.
>>>
>>>The final piece would be what is containing "My Figure"? If you put it
>>>inside and XYLayout, and give it a width and height == "-1", it will be
>>>auto-sized to its preferred size. (And stack layout will size the label
>>>inside the wrapper figure).
>>>
>>>Hope this helps
>>>
>>>"David Danie" <david_danie@hotmail.com> wrote in message
>>>news:bteh67$mkj$1@eclipse.org...
>>>
>>>
>>>>Hi Friends,
>>>> My Figure contains one Label. The text of the label
>>>>should be editable. I like to resize my figure with respect to the text
>>>>of the Label. How can i do this?.
>>>>
>>>>Regards,
>>>>David Danie.
>>>>
>>>
>>>
>>>
>>Hi Randy,
>> My Figure have two compartments. the top level compartment
>>contains only one label. the other one contains multiple labels(i like
>>to add labels dynamically).
>>
>>thanks
>>David Danie.
>>
>
>
>

Everything is working except the alignment. In my Figure i write this code,

{
XYLayout outerlayout = new XYLayout();
setLayoutManager(outerlayout);
Figure top = new Figure();
outerlayout.setConstraint(top, new Rectangle(5, 5, -1, -1));
ToolbarLayout layout = new ToolbarLayout();
layout.setMinorAlignment(ToolbarLayout.ALIGN_CENTER);
layout.setSpacing(20);
top.setLayoutManager(layout);
Label nameFigure = new Label();
nameFigure.setText("XYZ");
top.add(nameFigure);
add(top);
setOpaque(true);
}

The Label "XYZ" is always displayed in left corner. But i want to be
displayed in Center. What is wrong in my code.

thanks
David Danie.
Re: Resizing Figure [message #111004 is a reply to message #110991] Fri, 09 January 2004 12:49 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

I didn't try running your code. Sometimes it helps to put LineBorders on
things to see exactly where they are. If the label is wider than it needs
to be, you can have it center its text/icon using setLabelAlignment(int).

"David Danie" <david_danie@hotmail.com> wrote in message
news:btmge6$ojf$1@eclipse.org...
> Randy Hudson wrote:
> > This sounds like what is described in our article. Use a ToolbarLayout.
> >
> > "David Danie" <david_danie@hotmail.com> wrote in message
> > news:btije6$acf$1@eclipse.org...
> >
> >>Randy Hudson wrote:
> >>
> >>>You have a figure which contains one label. I guess my first question
> >
> > would
> >
> >>>be what does your figure do? Why not just use label?
> >>>
> >>>If you do need to wrap one figure inside another, using draw2d's
> >
> > StackLayout
> >
> >>>will allow the outer figure to return a correct preferred size based on
> >
> > its
> >
> >>>insets and the inner figure's preferred size. Label already calculate
> >
> > its
> >
> >>>preferred size correctly to accomodate the text and/or icon.
> >>>
> >>>The final piece would be what is containing "My Figure"? If you put it
> >>>inside and XYLayout, and give it a width and height == "-1", it will be
> >>>auto-sized to its preferred size. (And stack layout will size the label
> >>>inside the wrapper figure).
> >>>
> >>>Hope this helps
> >>>
> >>>"David Danie" <david_danie@hotmail.com> wrote in message
> >>>news:bteh67$mkj$1@eclipse.org...
> >>>
> >>>
> >>>>Hi Friends,
> >>>> My Figure contains one Label. The text of the label
> >>>>should be editable. I like to resize my figure with respect to the
text
> >>>>of the Label. How can i do this?.
> >>>>
> >>>>Regards,
> >>>>David Danie.
> >>>>
> >>>
> >>>
> >>>
> >>Hi Randy,
> >> My Figure have two compartments. the top level compartment
> >>contains only one label. the other one contains multiple labels(i like
> >>to add labels dynamically).
> >>
> >>thanks
> >>David Danie.
> >>
> >
> >
> >
>
> Everything is working except the alignment. In my Figure i write this
code,
>
> {
> XYLayout outerlayout = new XYLayout();
> setLayoutManager(outerlayout);
> Figure top = new Figure();
> outerlayout.setConstraint(top, new Rectangle(5, 5, -1, -1));
> ToolbarLayout layout = new ToolbarLayout();
> layout.setMinorAlignment(ToolbarLayout.ALIGN_CENTER);
> layout.setSpacing(20);
> top.setLayoutManager(layout);
> Label nameFigure = new Label();
> nameFigure.setText("XYZ");
> top.add(nameFigure);
> add(top);
> setOpaque(true);
> }
>
> The Label "XYZ" is always displayed in left corner. But i want to be
> displayed in Center. What is wrong in my code.
>
> thanks
> David Danie.
>
Re: Resizing Figure [message #111039 is a reply to message #111004] Sat, 10 January 2004 00:19 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: david_danie.hotmail.com

Randy Hudson wrote:
> I didn't try running your code. Sometimes it helps to put LineBorders on
> things to see exactly where they are. If the label is wider than it needs
> to be, you can have it center its text/icon using setLabelAlignment(int).
>
> "David Danie" <david_danie@hotmail.com> wrote in message
> news:btmge6$ojf$1@eclipse.org...
>
>>Randy Hudson wrote:
>>
>>>This sounds like what is described in our article. Use a ToolbarLayout.
>>>
>>>"David Danie" <david_danie@hotmail.com> wrote in message
>>>news:btije6$acf$1@eclipse.org...
>>>
>>>
>>>>Randy Hudson wrote:
>>>>
>>>>
>>>>>You have a figure which contains one label. I guess my first question
>>>
>>>would
>>>
>>>
>>>>>be what does your figure do? Why not just use label?
>>>>>
>>>>>If you do need to wrap one figure inside another, using draw2d's
>>>
>>>StackLayout
>>>
>>>
>>>>>will allow the outer figure to return a correct preferred size based on
>>>
>>>its
>>>
>>>
>>>>>insets and the inner figure's preferred size. Label already calculate
>>>
>>>its
>>>
>>>
>>>>>preferred size correctly to accomodate the text and/or icon.
>>>>>
>>>>>The final piece would be what is containing "My Figure"? If you put it
>>>>>inside and XYLayout, and give it a width and height == "-1", it will be
>>>>>auto-sized to its preferred size. (And stack layout will size the label
>>>>>inside the wrapper figure).
>>>>>
>>>>>Hope this helps
>>>>>
>>>>>"David Danie" <david_danie@hotmail.com> wrote in message
>>>>>news:bteh67$mkj$1@eclipse.org...
>>>>>
>>>>>
>>>>>
>>>>>>Hi Friends,
>>>>>> My Figure contains one Label. The text of the label
>>>>>>should be editable. I like to resize my figure with respect to the
>
> text
>
>>>>>>of the Label. How can i do this?.
>>>>>>
>>>>>>Regards,
>>>>>>David Danie.
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>Hi Randy,
>>>> My Figure have two compartments. the top level compartment
>>>>contains only one label. the other one contains multiple labels(i like
>>>>to add labels dynamically).
>>>>
>>>>thanks
>>>>David Danie.
>>>>
>>>
>>>
>>>
>>Everything is working except the alignment. In my Figure i write this
>
> code,
>
>>{
>>XYLayout outerlayout = new XYLayout();
>>setLayoutManager(outerlayout);
>>Figure top = new Figure();
>>outerlayout.setConstraint(top, new Rectangle(5, 5, -1, -1));
>>ToolbarLayout layout = new ToolbarLayout();
>>layout.setMinorAlignment(ToolbarLayout.ALIGN_CENTER);
>>layout.setSpacing(20);
>>top.setLayoutManager(layout);
>>Label nameFigure = new Label();
>>nameFigure.setText("XYZ");
>>top.add(nameFigure);
>>add(top);
>>setOpaque(true);
>>}
>>
>>The Label "XYZ" is always displayed in left corner. But i want to be
>>displayed in Center. What is wrong in my code.
>>
>>thanks
>>David Danie.
>>
>
>
>

I tried setLabelAlignment(int) method also. but i get the same result.


Thanks
David Danie.
Re: Resizing Figure [message #111293 is a reply to message #111039] Tue, 13 January 2004 17:29 Go to previous message
Eclipse UserFriend
> >>Everything is working except the alignment. In my Figure i write this
> >
> > code,
> >
> >>{
> >>XYLayout outerlayout = new XYLayout();
> >>setLayoutManager(outerlayout);
> >>Figure top = new Figure();
> >>outerlayout.setConstraint(top, new Rectangle(5, 5, -1, -1));
> >>ToolbarLayout layout = new ToolbarLayout();
> >>layout.setMinorAlignment(ToolbarLayout.ALIGN_CENTER);
> >>layout.setSpacing(20);
> >>top.setLayoutManager(layout);
> >>Label nameFigure = new Label();
> >>nameFigure.setText("XYZ");
> >>top.add(nameFigure);
> >>add(top);
> >>setOpaque(true);
> >>}
> >>
> >>The Label "XYZ" is always displayed in left corner. But i want to be
> >>displayed in Center. What is wrong in my code.
> >>
> >>thanks
> >>David Danie.
> >>
> >
> >
> >
>
> I tried setLabelAlignment(int) method also. but i get the same result.


I had this same problem a few days ago and resorted to using a StackLayout
within the containing figure, but that worked for me because I only had a
single label within the containing figure.

Sean.
Previous Topic:EclipseCon - Tutorials
Next Topic:drawPoint Doesn't Compile
Goto Forum:
  


Current Time: Tue Jul 22 15:30:29 EDT 2025

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

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

Back to the top