Re: working with text extent

From: David Brown <dbrown_at_nyahnyahspammersnyahnyah>
Date: Tue, 16 Dec 2008 13:08:23 -0700

Hi Dave,

Like all viewable HLU objects, text objects are members of the View
class. This means that if you have the object id, you can get the
text extent by calling the 'getvalues' method as follows:

getvalues txid
     "vpWidthF" : w
     "vpHeightF" : h
end getvalues

Once you have these values you can adjust the size proportionally
simply by scaling them with a corresponding 'setvalues' call.
However, in order to preserve the justification and positioning of
the text you would probably be better off using your knowledge of the
width and height to proportionally scale the txFontHeightF. You might
want to read the description of the TextItem object at http://
www.ncl.ucar.edu/Document/HLUs/Classes/TextItem.shtml.

Unfortunately, however, it is not always easy to get the object id of
text objects if, for instance, they are titles or some other defined
annotation of a plot object.
In this case you may be able to use the NhlGetBB function to get the
bounding box of the plot object. From this you could indirectly infer
when a title has gone out of the boundary you want it to stay within
and take compensating action.

Hope this helps somewhat.
  -dave

On Dec 16, 2008, at 9:26 AM, David B. Reusch wrote:

> Hello,
>
> I am running into problems with title strings that are too long
> (they get truncated by the side margins on each end) and am seeking
> a way to dynamically adjust my textsize so that the resulting title
> will fit on the pagewidth. These titles are done in two different
> plot settings: associated with panel plots and as text I'm adding
> myself in NDC coordinates. I create lots of plots and the title
> text depends on the particular plot. I'm picturing iteratively
> adjusting the text height until my title text fits, or possibly
> just rescaling a text object to make it fit. Either way, I'm not
> at all clear how to proceed. For example, I wonder whether objects
> can be deleted after creation but before the draw is done? Not
> sure this would help but it seems like one possible approach
> (create, check size, delete if too big, try again...).
>
> I see txPosXF and txPosYF resources for position but nothing
> directly reflecting height/width of the text object.
>
> Hope this is clear and thanks in advance for any advice, etc.,
>
> Dave Reusch
>
> --
> 517 Deike Building
> Earth & Environmental Systems Institute
> Penn State University
> University Park, PA 16802
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Dec 16 2008 - 13:08:23 MST

This archive was generated by hypermail 2.2.0 : Sat Dec 20 2008 - 12:36:21 MST