Text annotation size and text placement control: help neededAll,
I need to place several text annotations on a plot.
They are one liners, but different length. So that's why I have to use Fixed Size(0) to adjust label length to match text.
But when I do that, it also adjusts the vertical size and puts the text way too high, which for some reason bothers me very much (plot on the left). If I set Fixed Size(1), then I can control size of the label directly and text placement looks OK (plot on the right), but I have text of different length, it's either label too long, or if text goes over the label size, it snaps to "Fixed Size(0)" behavior, looking very ugly.


Any idea how to adjust text positioning within label AND use Fixed Size(0)?
<< Vertical Alignment("bottom") doesn't work.
Here's the code:
Names Default To Here( 1 );
Open( "$SAMPLE_DATA/Big Class.jmp" );
biv = bivariate( y( :weight ), x( :height ) );
rbiv = biv << report;
taHeight = 20;
ta1 = rbiv << Add Text Annotation();
ta2 = rbiv << Add Text Annotation();
ta1 << Text( "We need to discuss this at the next meeting." );
ta1 << Text Box( {70, 80, 350, 80+taHeight} );
ta2 << Text( "We need to discuss this at the next " );
ta2 << Text Box( {70, 120, 350, 120+taHeight} );
{ta1, ta2} << Background Color( "Light Yellow" ) << Text Color( "red" )/*<<SET wrap=""></SET>
Automation and ScriptingRe: Text annotation size and text placement control: help neededNot sure if you can control that in text annotation unless you calculate the sizes of the textbox yourself.
Could you maybe utilize Graphic Script?
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
biv = dt << bivariate(y(:weight), x(:height));
rbiv = biv << report;
fb = rbiv[FrameBox(1)];
fb << Add Graphics Script(
Back Color("Light Yellow");
Text Color("Red");
Text(Erased, {50, 150}, "We need to discuss this at the next meeting.");
Text(Erased, {50, 135}, "We need to discuss this at the next");
);Re: Text annotation size and text placement control: help neededThe problem with Add Graphics Script is that the position of the text is specified in actual coordinates on the plot. In my case it can be any, starting 1e-07 to over 9000 
I might be interested in writing a function to calculate values for positions I want, but only if I can add border\frame around the text like in the first example. The graph might be quite busy, I need to visually separate this for fast reading and dispo-ing.
Re: Text annotation size and text placement control: help neededI got an idea.
What if I draw text annotations with Fixed Size(0) first, measure length, then change them to Fixed Size(1), and set the measured width and desired height manually?
The problem is, << Get Size() returns some bogus values:
Names Default To Here( 1 );
Open( "$SAMPLE_DATA/Big Class.jmp" );
biv = bivariate( y( :weight ), x( :height ) );
rbiv = biv << report;
taHeight = 40;
ta1 = rbiv << Add Text Annotation();
ta2 = rbiv << Add Text Annotation();
ta1 << Text( "We need to discuss this at the next meeting." );
ta1 << Text Box( {70, 80, 350, 80+taHeight} );
ta2 << Text( "We need to discuss this at the next " );
ta2 << Text Box( {70, 120, 350, 120+taHeight} );
{ta1, ta2} << Background Color( "Light Yellow" ) << Text Color( "red" )/*<<SET wrap=""></SET>
It produces:
//:*/
Show(ta1_x, ta2_x);
/*:
ta1_x = 328;
ta2_x = 328;
even though the labels are visibly of different length on the graph. Am I missing something?
Re: Text annotation size and text placement control: help neededTry using <
Re: Text annotation size and text placement control: help neededYou might be able to do the size check also with Text Box in new window
Names Default To Here( 1 );
Open( "$SAMPLE_DATA/Big Class.jmp" );
biv = bivariate( y( :weight ), x( :height ) );
rbiv = biv << report;
taHeight = 20;
ta1 = rbiv << Add Text Annotation();
ta2 = rbiv << Add Text Annotation();
nw = new window("", << Window View("Invisible"),
tb1 = Text Box("We need to discuss this at the next meeting."),
tb2 = Text Box("We need to discuss this at the next ")
);
w1 = tb1 << Get Size;
w2 = tb2 << Get Size;
nw << close window;
ta1 << Text( "We need to discuss this at the next meeting." );
ta1 << Text Box( {70, 80, w1[1]+20+70, 80+taHeight});
ta2 << Text( "We need to discuss this at the next " );
ta2 << Text Box( {70, 120, w2[1]+20+70, 120+taHeight});
{ta1, ta2} << Background Color( "Light Yellow" ) << Text Color( "red" )/*<<SET wrap=""></SET>Re: Text annotation size and text placement control: help neededThanks for the tip, yes, I can now get and set the sizes of the label.
The problem is that JSL doesn't line by line, instead, it kinda computes the final state for different properties separately... And then applies.
Like:
...
...
ta1<<FIXED size=""></FIXED>
So then the width remains the one that I initially set up:
ta1 << Text( "We need to discuss this at the next meeting." );
ta1 << Text Box( {70, 80, 350, 80+taHeight} );
ta2 << Text( "We need to discuss this at the next " );
ta2 << Text Box( {70, 120, 350, 120+taHeight} );
Adding Wait(0.5) helped to overcome that.
So the final script is:
Names Default To Here( 1 );
Open( "$SAMPLE_DATA/Big Class.jmp" );
biv = bivariate( y( :weight ), x( :height ) );
rbiv = biv << report;
taHeight = 40;
ta1 = rbiv << Add Text Annotation();
ta2 = rbiv << Add Text Annotation();
ta1 << Text( "We need to discuss this at the next meeting." );
ta1 << Text Box( {70, 80, 350, 80+taHeight} );
ta2 << Text( "We need to discuss this at the next " );
ta2 << Text Box( {70, 120, 350, 120+taHeight} );
{ta1, ta2} << Background Color( "Light Yellow" ) << Text Color( "red" )<<FIXED size=""></FIXED>
Re: Text annotation size and text placement control: help neededThis one works too. Subjectively even faster than my solution. Trying to measure it with the debugging tool.
Re: Text annotation size and text placement control: help neededSetting Wait(0) speeds things up - there is now actual wait, but screen is re-drawn.
Re: Text annotation size and text placement control: help neededNever mind, it works.
Before the loops:
taList = {};
Inside the loop:
Insert Into(taList, ta);
After the loops:
Wait(0);
taList << Fixed Size(1);
For Each({height, index}, taList << Get Height(),
taList[index] << Set Height(height*0.93)
);
Now the problem is that when implementing this in real scenario, when I have multiple plots with multiple Text Annotations - doing this trick with each annotation over two level loop is too slow.
I tried to create a list of text annotations:
taList={};
and then just inside the loops add the current ta to the list:
Insert Into(taList, ta);
At the end of the loops I have:
taList
/*:
{DisplayBox[gtext], DisplayBox[gtext],......}
But operations on this list or separate members do not work.
Any ideas? Mine are:
1. Try to use Context Box to separate variables between different ta's
2. Somehow pull those annotations from the report - but when I pull XML (<