automated font manipulation and textbox placement

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

automated font manipulation and textbox placement

jvander
Hello,

I am looking for help to do the following in a plug-in

Specify the font size and deselect smoothing
Select text tool and specify the location and size of the text box

as a bonus it wold be nice to automatically pass a character string to the text box and apply, but I am okay with the user having to enter it and hit Ctrl-D.

I tried turning the macro recorder on and performing those actions, but the recorder did not register anything but selecting the text tool and gave me the command

IJ.setTool("text");

thanks,

Joe vanderGracht

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: automated font manipulation and textbox placement

Christine Labno-2
Hello Joe,

I was able to record this using ImageJ 1.49j on Windows 7 using the Blobs sample image, but had to go to completion of the procedure before getting any code.  It does run as a macro.  You should be able to use it as a starting point, swapping out commands to get exactly what you want.  

------begin----------------

text="charater string"  //sets up variable name to pass character string
setFont("SansSerif", 12, " antialiased");   //font, size and smoothing
setColor("black");
drawString(text, 20, 50);  //if no variable, text to be printed goes in "", x position, y position

----------end-------

Best,
Christine

--------------------------------------------
Christine Labno, Ph.D.
Asst. Technical Director
Light Microscopy Core
University of Chicago
Office of Shared Research Facilities
KCBD 1250 900 E. 57th St.
(773) 834-9040 (phone)

________________________________________
From: ImageJ Interest Group [[hidden email]] on behalf of Joe Vandergracht [[hidden email]]
Sent: Thursday, November 13, 2014 10:15 AM
To: [hidden email]
Subject: automated font manipulation and textbox placement

Hello,

I am looking for help to do the following in a plug-in

Specify the font size and deselect smoothing
Select text tool and specify the location and size of the text box

as a bonus it wold be nice to automatically pass a character string to the text box and apply, but I am okay with the user having to enter it and hit Ctrl-D.

I tried turning the macro recorder on and performing those actions, but the recorder did not register anything but selecting the text tool and gave me the command

IJ.setTool("text");

thanks,

Joe vanderGracht

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: automated font manipulation and textbox placement

jvander
In reply to this post by jvander
Christine Labno responded to my original query with the helpful information that she was able to record a macro that did what I need:

Specify the font size and deselect smoothing
Select text tool and specify the location and size of the text box

I was able to duplicate what she did.  I used the macro recorder and was able to create a macro to do this.  I may just go with this solution, but I am trying to do it in a plug-in rather than a macro.  When I tell the macro recorder that I am making a plug-in, the  recorder only generates commands to set the text tool.  It does not set the font or start the drawing box.

Does anyone know the appropriate plug-in commands?  

as a bonus it wold be nice to automatically pass a character string to the text box and apply.

thanks,

Joe vanderGracht

____________________

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html