{ addLoaderThread(controller,this); final List thumbnails = new ArrayList(); int count = 1; int total = refList.size();  PlateLayoutMethod lm = new PlateLayoutMethod(refInfo.getNumRows(), refInfo.getNumCols()); model.setLayoutMethod(lm);  CompletePlate plate = new CompletePlate(); for(Iterator iter = refPlateList.iterator(); iter.hasNext();) { ImagePlate ip = (ImagePlate)iter.next(); plate.put(ip.getWell(),new Integer(ip.getImage().getID())); }  boolean wellSized = false; for(int i=0;i<refInfo.getNumRows();i++) { for(int j=0;j<refInfo.getNumCols();j++) {  if(kill) { j=refInfo.getNumCols(); i=refInfo.getNumRows(); break; } String row = refInfo.getRowName(i); String col = refInfo.getColumnName(j); String well = row+col; List sampleList = (List)plate.get(well); if(sampleList.size() == 1) { Integer intVal = (Integer)sampleList.get(0); ImageSummary sum = (ImageSummary)imageMap.get(intVal); try { Pixels pix = sum.getDefaultPixels().getPixels(); Image image = ps.getThumbnail(pix); if(!wellSized) { lm.setWellWidth(image.getWidth(null)); lm.setWellHeight(image.getHeight(null)); wellSized = true; } ThumbnailDataModel tdm = new ThumbnailDataModel(sum); tdm.setValue(UIConstants.WELL_KEY_STRING,well); tdm.getAttributeMap().putAttribute(pix);  ImageAnnotation annotation = (ImageAnnotation)refAnnotations.get(new Integer(sum.getID()));  if(annotation != null) { tdm.getAttributeMap().putAttribute(annotation); } final Thumbnail t = new Thumbnail(image,tdm); lm.setIndex(t,i,j);  final int theCount = count; final int theTotal = total; Runnable addTask = new Runnable() { public void run()
            public void run()            {                addLoaderThread(controller,this);                final List thumbnails = new ArrayList();                int count = 1;                int total = refList.size();                                PlateLayoutMethod lm = new PlateLayoutMethod(refInfo.getNumRows(),                                                             refInfo.getNumCols());                model.setLayoutMethod(lm);                                CompletePlate plate = new CompletePlate();                for(Iterator iter = refPlateList.iterator(); iter.hasNext();)                {                    ImagePlate ip = (ImagePlate)iter.next();                    plate.put(ip.getWell(),new Integer(ip.getImage().getID()));                }                                boolean wellSized = false;                for(int i=0;i<refInfo.getNumRows();i++)                {                    for(int j=0;j<refInfo.getNumCols();j++)                    {                        // explicit break out                        if(kill)                        {                            j=refInfo.getNumCols();                            i=refInfo.getNumRows();                            break;                        }                        String row = refInfo.getRowName(i);                        String col = refInfo.getColumnName(j);                        String well = row+col;                        List sampleList = (List)plate.get(well);                        if(sampleList.size() == 1)                        {                            Integer intVal = (Integer)sampleList.get(0);                            ImageSummary sum = (ImageSummary)imageMap.get(intVal);                            try                            {                                Pixels pix = sum.getDefaultPixels().getPixels();                                Image image = ps.getThumbnail(pix);                                if(!wellSized)                                {                                    lm.setWellWidth(image.getWidth(null));                                    lm.setWellHeight(image.getHeight(null));                                    wellSized = true;                                }                                ThumbnailDataModel tdm = new ThumbnailDataModel(sum);                                tdm.setValue(UIConstants.WELL_KEY_STRING,well);                                tdm.getAttributeMap().putAttribute(pix);                                                                ImageAnnotation annotation =                                    (ImageAnnotation)refAnnotations.get(new Integer(sum.getID()));                                                                    if(annotation != null)                                {                                    tdm.getAttributeMap().putAttribute(annotation);                                }                                final Thumbnail t = new Thumbnail(image,tdm);                                lm.setIndex(t,i,j);                                                                final int theCount = count;                                final int theTotal = total;                                Runnable addTask = new Runnable()                                {                                    public void run()                                    {                                        thumbnails.add(t);                                        String message =                                            ProgressMessageFormatter.format("Loaded image %n of %t...",                                                                            theCount,theTotal);                                        status.processAdvanced(message);                                    }                                };                                SwingUtilities.invokeLater(addTask);                                count++;                            }                            catch(ImageServerException ise)                            {                                UserNotifier un = registry.getUserNotifier();                                un.notifyError("ImageServer Error",ise.getMessage(),ise);                                status.processFailed("Error loading images.");                                return;                            }                        }                        else                        {                            Image[] images = new Image[sampleList.size()];                            ThumbnailDataModel[] models =                                new ThumbnailDataModel[sampleList.size()];                            for(int k=0;k<sampleList.size();k++)                            {                                Integer intVal = (Integer)sampleList.get(k);                                ImageSummary sum = (ImageSummary)imageMap.get(intVal);                                try                                {                                    Pixels pix = sum.getDefaultPixels().getPixels();                                    Image image = ps.getThumbnail(pix);                                    ThumbnailDataModel tdm = new ThumbnailDataModel(sum);                                    tdm.setValue(UIConstants.WELL_KEY_STRING,well);                                    tdm.getAttributeMap().putAttribute(pix);                                    images[k] = image;                                    models[k] = tdm;                                    count++;                                }                                catch(ImageServerException ise)                                {                                    UserNotifier un = registry.getUserNotifier();                                    un.notifyError("ImageServer Error",ise.getMessage(),ise);                                    status.processFailed("Error loading images.");                                    return;                                }                            }                                                        final Thumbnail t = new Thumbnail(images,models);                            lm.setIndex(t,i,j);                            final int theCount = count;                            final int theTotal = total;                                                        Runnable addTask = new Runnable()                            {                                public void run()                                {                                    String message =                                        ProgressMessageFormatter.format("Loaded image %n of %t...",                                                                        theCount,theTotal);                                    status.processAdvanced(message);                                    thumbnails.add(t);                                }                            };                            SwingUtilities.invokeLater(addTask);                        }                    }                }                                if(!kill)                {                    Runnable finalTask = new Runnable()                    {                        public void run()                        {                            Thumbnail[] ts = new Thumbnail[thumbnails.size()];                            thumbnails.toArray(ts);                            model.addThumbnails(ts);                            status.processSucceeded("All images loaded.");                        }                    };                    SwingUtilities.invokeLater(finalTask);                    return;                }                else                {                    System.err.println("killed OK");                }                removeLoaderThread(controller,this);            }