Login  Register

need help, I'm frustrated

Posted by Hao Jiang-3 on Jul 15, 2008; 8:06pm
URL: http://imagej.273.s1.nabble.com/need-help-I-m-frustrated-tp3695559.html

Currently I'm working on v1.37u, to write/modify a plugin.
 
The idea is after open an image (customer file type, grayscale), need to
draw (or just display) some points on it. Additional, after user zoom
the image in, the size of those points won't be enlarged, so the user is
able to find the precise position of every point.
 
After referred to some plugin's code, and numerous tests, that's what I
got so far
 
class CustomerWindow extends ImageWindow{
 
Vector HDPoints;
List pointsList = new ArrayList();
 
// some other methods
 
void getPoints(){
//read file, get points and put into HDPoints
}
 
void drawPoints(){
    ImagePlus imp = WindowManager.getCurrentImage();
    ImageCanvas ic = imp.getCanvas();
    double m = ic.getmagnification();
    int w = new double((double)3/m).intValue();  //w changed when zoom
value changed, keep it relative the same
 
    pointsList.clear();
 
    for(int i=0; i<HDPoints.size(); i++){
        Object o = HDPoints.elementAt(i);
        int x = o.getx();
        int y = o.gety();
        String color = o.getColor();
 
        OvalRoi oval = new OvalRoi(x-w/2, y-w/2, w, w);
        oval.setColor(color);
        pointsList.add(oval);
        IJ.getImage().setRoi(oval);
    }
 
    for(Iterator it = pointsList.iterator(); it.hasNext();){
        ShapeRoi roi = new ShapeRoi((OvalRoi)it.next());
        IJ.getImage().setRoi(roi);
    }
}
 
If there is only one point, this works perfectly fine, I get everything
I wanted. However, if there are many points, then except that last one,
points showed up one by one on image, but disappeared in the end.
 
Please help me,
 
Thank you very much
 
Hao Jiang


*************************************************************************
PRIVILEGE AND CONFIDENTIALITY NOTICE:

The information in this email is intended for the named recipients only.
It may contain privileged and confidential information.  If you have
received this communication in error, any use, copying or dissemination
of its contents is strictly prohibited.  Please erase all copies of the
message along with any included attachments and notify Intermap
Technologies or the sender immediately by telephone at the number
indicated on this page.

*************************************************************************