Dear all,
my idea is to move the mousecursor over an Imp, and the coordinates and the intensity are displayed on a defined static position on the imp as textroi. So the textroi is successfully displayed but I can't find a way to delete it and write the new text on the screen position. The new text is just added above the old text... Now my question: Like I want the screenlocation and the intensity displayed just for seconds, because the mouse don't stop moving, I want to update the textroi every 1000ms.. unfortunaltey it doesn't work or I don't see a possibility. Like a calibration bar is already added on the imp, another Overlay would erase the calibration bar. Here my code: ImageWindow win = imp.getWindow(); canvas =win.getCanvas(); images.addElement(id); canvas.addMouseListener(new MouseListener(){ public void mouseClicked(MouseEvent e) { int x = e.getX(); int y = e.getY(); ImageProcessor ip; ip = imp.getProcessor(); int i=imp.getCurrentSlice(); float inti = ip.getPixelValue(x, y); int offscreenX = canvas.offScreenX(x); int offscreenY = canvas.offScreenY(y); String string0="X: "; String string1=String.valueOf(offscreenX); String string1a="\nY: "; String string2=String.valueOf(offscreenY); String string2a="\nSUV: "; String string3=String.valueOf(inti); StringBuilder sb = new StringBuilder(); sb.append(string0); sb.append(string1); sb.append(string1a); sb.append(string2); sb.append(string2a); sb.append(string3); String stringf=sb.toString(); SegRegLexTex.overlaykoord(imp, i, stringf); imp.updateAndDraw(); public static void overlaykoord (ImagePlus imp, int aktuelleSlice, String string){ Font font = new Font("Arial", Font.PLAIN, 11); TextRoi tr = new TextRoi(50, 160, string, font); tr.setNonScalable(true); tr.setPosition(0, aktuelleSlice, 0); imp.getProcessor().setColor(Color.blue); imp.getCurrentSlice(); tr.drawPixels(imp.getProcessor()); //IJ.wait(100); //imp.updateAndDraw(); //tr.abortPaste(); //always nullpointerexception //imp.getProcessor().reset(); // deletes stack, ( stack only actual image) //tr.clear(ip); // deletes complete image in the stack , not only the roi Thanks for any advice or comment Marie -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |