|
|
Re: Dynamically set the length of a figure based on the text [message #223165 is a reply to message #223157] |
Thu, 21 September 2006 00:29 |
Eclipse User |
|
|
|
Originally posted by: none.unknown.com
Use FigureUtilties#getTextExtents().
"Barry Dresdner" <barry.dresdner@softwareagusa.com> wrote in message
news:ees8ed$eia$1@utils.eclipse.org...
> After researching this a bit further, it looks like I can probably use
> GC.textExtent as follows:
>
> Display display = Display.getCurrent();
> GC gc = new GC(display);
> Point pt = gc.textExtent(myText);
> this.setSize(new Dimension(pt));
>
> However I'm not sure about using Display.getCurrent() to instantiate GC.
> Can anyone tell me if this is correct? My main concern is that GC is
> computing the size based on the font used by GEF.
> Thanks - barry
>
>
> "Barry Dresdner" <barry.dresdner@softwareagusa.com> wrote in message
> news:ees5g8$t96$1@utils.eclipse.org...
>> I'd like to set the length of a figure based on the text it contains. I
>> don't always know what the text will be, nor do I know the Font name,
>> style or size. With AWT, I was able to use the FontMetrics class and
>> call the stringWidth method passing in the text. This would return an
>> integer value representing the width of the text in pixels. Is there
>> something similar I can use within the GEF framework? It is for a
>> compontent within a graph. Thanks in advance.
>>
>
>
|
|
|
|
Powered by
FUDForum. Page generated in 0.02836 seconds