comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Calculate the size of text-output
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Calculate the size of text-output [message #89410] Fri, 10 October 2014 03:48 Go to next message
corinnefrey is currently offline  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 Go to previous message
chris_torrence@NOSPAM is currently offline  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
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Scaling cgColorbar to match data
Next Topic: IDL Programmer Wanted at Princeton University

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 09:08:29 PDT 2025

Total time taken to generate the page: 0.02824 seconds