Hi Kenneth,
your code looks fine; I suspect that the problem is elsewhere.
I have created a JavaScript equivalent for your code; it works as expected:
imp = IJ.openImage("http://imagej.net/images/blobs.gif");
imp.show();
xPix=50.0;yPix=50.0;
r0 = 10.0;
r1 = 50.0;
overlay = new Overlay();
plusX = new Line(xPix + r0, yPix , xPix + r1, yPix );
minusX = new Line(xPix - r0, yPix , xPix - r1, yPix );
plusY = new Line(xPix , yPix + r0, xPix , yPix + r1);
minusY = new Line(xPix , yPix - r0, xPix , yPix - r1);
cursorStrokeWidth = 1;
plusX.setStrokeWidth(cursorStrokeWidth);
minusX.setStrokeWidth(cursorStrokeWidth);
plusY.setStrokeWidth(cursorStrokeWidth);
minusY.setStrokeWidth(cursorStrokeWidth);
cursorColor = Color.RED;
plusX.setStrokeColor(cursorColor);
minusX.setStrokeColor(cursorColor);
plusY.setStrokeColor(cursorColor);
minusY.setStrokeColor(cursorColor);
overlay.add(plusX);
overlay.add(minusX);
overlay.add(plusY);
overlay.add(minusY);
imp.setOverlay(overlay);
imp.updateAndDraw();
Michael
________________________________________________________________
On 06.11.24 02:10, Kenneth Sloan wrote:
I’m debugging a new Java plugin. It’s based on a much older plugin, which has
not changed in years). Both were working fine a week ago. Today, the new one
stopped displaying the Overlay. After struggling for awhile, I decided to
check the old one. It also fails.
Has ImageJ Overlay code changed recently?
[AHA - see below - image type and size appear to matter! Perhaps I have a
workaround - but I’d like to avoid that, if possible.]
I am running Sonoma 14.7 on my MacBook Pro laptop.
Here is the relevant code, from the old (unchanged in years) code. What am I
doing wrong, please?
Full plugin is available as AVL_Area_Fraction on the CreativeComputation ImageJ
Update Site.
The new plugin is available as Point_Counter on the same site (it doesn’t use
KeyPresses, which was my last problem, but may have other random bugs).
AVL_Area_Fraction works perfectly, except that Overlays are not shown.
AHA…one last thing. Overlays work (in the old plugin) with a smaller .bmp
image (384x496, RGB) as input. They fail with a much larger .tif image
(18936x5400, RGB).
Provisionally - it looks like my problem is with the SIZE of the image. Is
this known? Is there a workaround? If necessary, I could reduce the size of
the displayed image and keep the full image hidden (I need the full resolution
for other purposes).
I can do this - but it’s enough work that I’d like confirmation that this is a
known problem. If it’s an ImageJ bug, I’d rather see it fixed there. But, if
necessary...
// ipl, calibration, colors and stroke widths set globally
private int sampleAt(double x, double y)
throws InterruptedException
{
IJ.log("sampleAt("+x+", "+y+")");
double r0 = 10.0;
double r1 = 50.0;
overlay = new Overlay();
double xPix = calibration.getRawX(x);
double yPix = calibration.getRawY(y);
Roi plusX = new Line(xPix + r0, yPix , xPix + r1, yPix );
Roi minusX = new Line(xPix - r0, yPix , xPix - r1, yPix );
Roi plusY = new Line(xPix , yPix + r0, xPix , yPix + r1);
Roi minusY = new Line(xPix , yPix - r0, xPix , yPix - r1);
plusX.setStrokeWidth(cursorStrokeWidth);
plusX.setStrokeColor(cursorColor);
minusX.setStrokeWidth(cursorStrokeWidth);
minusX.setStrokeColor(cursorColor);
plusY.setStrokeWidth(cursorStrokeWidth);
plusY.setStrokeColor(cursorColor);
minusY.setStrokeWidth(cursorStrokeWidth);
minusY.setStrokeColor(cursorColor);
overlay.add(plusX);
overlay.add(minusX);
overlay.add(plusY);
overlay.add(minusY);
ipl.setOverlay(overlay);
ipl.updateAndDraw();
...
--
Kenneth Sloan
[email protected]
Vision is the art of seeing what is invisible to others.
--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html