Calculate the size of text-output [message #89410] |
Fri, 10 October 2014 03:48  |
corinnefrey
Messages: 18 Registered: November 2006
|
Junior Member |
|
|
Hello,
I would like to know the size of a text-annotation in a plot:
eg.
w = window(dimensions=[200,200])
t = text(0,0,myannotation,font_name=myfont,font_size=15,/device)
How can I find out the pixel size of myannotation?
I need to know this for the scaling of another new window.
Thanks and best regards,
Corinne
|
|
|
Re: Calculate the size of text-output [message #89411 is a reply to message #89410] |
Fri, 10 October 2014 10:04  |
chris_torrence@NOSPAM
Messages: 528 Registered: March 2007
|
Senior Member |
|
|
On Friday, October 10, 2014 4:48:04 AM UTC-6, Corinne Frey wrote:
> Hello,
>
>
>
> I would like to know the size of a text-annotation in a plot:
>
>
>
> eg.
>
> w = window(dimensions=[200,200])
>
> t = text(0,0,myannotation,font_name=myfont,font_size=15,/device)
>
>
>
> How can I find out the pixel size of myannotation?
>
>
>
> I need to know this for the scaling of another new window.
>
>
>
> Thanks and best regards,
>
> Corinne
Hi Corinne,
You can use the undocumented "GetTextDimensions" method. For example:
IDL> p = plot(/test)
IDL> t = text(0, 1, 'Hello', /DATA, CLIP=0) ; ion the data layer
IDL> print, t.GetTextDimensions()
14.931223 0.072726995 0.00000000
IDL> t1 = text(0,0, 'Annotation') ; in the annotation layer
IDL> print, t1.GetTextDimensions()
0.30468721 0.054687291 0.00000000
For text in the "data" layer, the units will be in "data" units. For text in the "annotation" layer, the units will be normalized 0-1. You can use the ConvertCoord() method to convert between different coordinates.
Cheers,
Chris
ExelisVIS
|
|
|