Posted by
Stein Rørvik on
Sep 28, 2018; 7:50am
URL: http://imagej.273.s1.nabble.com/Overlay-drawString-has-wrong-vertical-position-with-Left-justification-tp5021257.html
When combining setJustification("Right") or ("Left") and Overlay.drawString(...
the vertical justification is too high when the horizontal justification is "Left".
They should have been the same. setJustification("Right") gives a correct result.
Try this macro:
--------
run("Close All");
xSize = 200;
ySize = 200;
newImage("Untitled", "8-bit black", xSize, ySize, 1);
setLocation(100, 100);
setFont("SanSerif", 12);
setLineWidth(1);
xPos = xSize/2;
yPos = ySize/2;
setColor("Red");
Overlay.drawLine(xPos, 0, xPos, ySize);
Overlay.drawLine(0, yPos, xSize, yPos);
Overlay.show;
setColor("Yellow");
setJustification("Left");
Overlay.drawString("Left adjusted", xPos, yPos);
setJustification("Right");
Overlay.drawString("Right adjusted", xPos, yPos);
Overlay.show;
run("Duplicate...", " ");
run("Set... ", "zoom=200");
setLocation(350, 100);
run("Duplicate...", " ");
run("Set... ", "zoom=400");
setLocation(800, 100);
//the Right aligned text is drawn correctly
//when zooming in, the Left adjusted text moves upwards relative to the previous position
//when zooming in, the Right adjusted text stays in the same position as the flattened version
--------
Also, sometimes run("Set... ", "zoom=400") does not display correctly, you must zoom back to 100% and rezoom to update the image.
I am using daily build ImageJ 1.52h with Java 1.6 on Windows 7/64-bit.
Stein
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html