Login  Register

Re: Text justification issue with Overlay.drawString

Posted by Bill Christens-Barry-2 on Jul 28, 2018; 12:39pm
URL: http://imagej.273.s1.nabble.com/Text-justification-issue-with-Overlay-drawString-tp5020947p5021008.html

Using ImageJ 1.52f8 on MacOS 10.12.6, I've added several lines to Stein's example code to show a different, perhaps related issue:

run("Boats (356K)");
TextStr = "This the first line of the text\nThis is line two";
xPos = getWidth/2;
yPos = round(getHeight/7);

setFont("SansSerif", 28, "antialiased");
setColor("red");
setJustification("right");
Overlay.drawString(TextStr, xPos, yPos*1);
//problem: text is not right justified as expected
Overlay.show;

//additional lines to illustrate a different issue
run("To ROI Manager");
run("Hide Overlay");
roiManager("Select", 0);
// problem: only first line of text is displayed in the image selection

Only the first line of the text that was drawn in the overlay appears in the selection now created in the image.

Bill Christens-Barry

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