/** Adds an ROI to this Overlay using the specified name. */ public void add(Roi roi, String name) { roi.setName(name); add(roi); }
/** Adds an ROI to this Overlay using the specified name. */ public void add(Roi roi, String name) { roi.setName(name); add(roi); }
public void rename(int index, String newName) { if (index<0 || index>=getCount()) throw new IllegalArgumentException("Index out of range: "+index); Roi roi = (Roi)rois.get(index); roi.setName(newName); listModel.setElementAt(newName, index); }
public void rename(int index, String newName) { if (index<0 || index>=getCount()) throw new IllegalArgumentException("Index out of range: "+index); Roi roi = (Roi)rois.get(index); roi.setName(newName); listModel.setElementAt(newName, index); }
/** Copy the attributes (outline color, fill color, outline width) of 'roi2' to the this selection. */ public void copyAttributes(Roi roi2) { this. strokeColor = roi2. strokeColor; this.fillColor = roi2.fillColor; this.setStrokeWidth(roi2.getStrokeWidth()); this.setName(roi2.getName()); }
/** Copy the attributes (outline color, fill color, outline width) of 'roi2' to the this selection. */ public void copyAttributes(Roi roi2) { this. strokeColor = roi2. strokeColor; this.fillColor = roi2.fillColor; this.setStrokeWidth(roi2.getStrokeWidth()); this.setName(roi2.getName()); }
/** Adds the specified ROI to the list. The third argument ('n') will * be used to form the first part of the ROI label if it is zero or greater. * @param imp the image associated with the ROI, or null * @param roi the Roi to be added * @param n if zero or greater, will be used to form the first part of the label */ public void add(ImagePlus imp, Roi roi, int n) { if (IJ.debugMode && n<3 && roi!=null) IJ.log("RoiManager.add: "+n+" "+roi.getName()); if (roi==null) return; String label = roi.getName(); String label2 = label; if (label==null) label = getLabel(imp, roi, n); else { if (n>=0) label = n+"-"+label; } if (label==null) return; listModel.addElement(label); if (label2!=null) roi.setName(label2); else roi.setName(label); rois.add((Roi)roi.clone()); }
void setSelectionName() { Roi roi = getImage().getRoi(); if (roi==null) interp.error("No selection"); else roi.setName(getStringArg()); }
void setSelectionName() { Roi roi = getImage().getRoi(); if (roi==null) interp.error("No selection"); else roi.setName(getStringArg()); }
private void assignPropertiesToRoi(final Roi roi, final Overlay overlay) { roi.setName(overlay.getName()); roi.setStrokeWidth((float) overlay.getLineWidth()); roi.setStrokeColor(AWTColors.getColor(overlay.getLineColor())); final Color fillColor = AWTColors.getColor(overlay.getFillColor()); final Color colorWithAlpha = new Color(fillColor.getRed(), fillColor.getGreen(), fillColor.getBlue(), overlay.getAlpha()); roi.setFillColor(colorWithAlpha); }
public void saveRoi(ImagePlus imp) throws IOException{ Roi roi = imp.getRoi(); if (roi==null) throw new IllegalArgumentException("ROI required"); String name = roi.getName(); if (name==null) name = imp.getTitle(); SaveDialog sd = new SaveDialog("Save Selection...", name, ".roi"); name = sd.getFileName(); if (name == null) return; String dir = sd.getDirectory(); RoiEncoder re = new RoiEncoder(dir+name); re.write(roi); if (name.endsWith(".roi")) name = name.substring(0, name.length()-4); roi.setName(name); }
public void saveRoi(ImagePlus imp) throws IOException{ Roi roi = imp.getRoi(); if (roi==null) throw new IllegalArgumentException("ROI required"); String name = roi.getName(); if (name==null) name = imp.getTitle(); SaveDialog sd = new SaveDialog("Save Selection...", name, ".roi"); name = sd.getFileName(); if (name == null) return; String dir = sd.getDirectory(); RoiEncoder re = new RoiEncoder(dir+name); re.write(roi); if (name.endsWith(".roi")) name = name.substring(0, name.length()-4); roi.setName(name); }
boolean rename(String name2) { int index = list.getSelectedIndex(); if (index<0) return error("Exactly one item in the list must be selected."); String name = (String)listModel.getElementAt(index); if (name2==null) name2 = promptForName(name); if (name2==null) return false; if (name2.equals(name)) return false; Roi roi = (Roi)rois.get(index); roi.setName(name2); int position = getSliceNumber(name2); if (position>0 && !roi.hasHyperStackPosition()) roi.setPosition(position); rois.set(index, roi); listModel.setElementAt(name2, index); list.setSelectedIndex(index); if (Prefs.useNamesAsLabels && labelsCheckbox.getState()) { ImagePlus imp = WindowManager.getCurrentImage(); if (imp!=null) imp.draw(); } if (record()) Recorder.record("roiManager", "Rename", name2); return true; }
public void keyPressed(KeyEvent e) { boolean thisPanel = e.getSource() instanceof PixelInspector; if (thisPanel && e.getKeyCode()==KeyEvent.VK_C) { copyToClipboard(); return; } if (e.getKeyCode()==KeyEvent.VK_UP && y0 > 0) { y0--; update(FULL_UPDATE); } else if (e.getKeyCode()==KeyEvent.VK_DOWN && y0<imp.getHeight()-1) { y0++; update(FULL_UPDATE); } else if (e.getKeyCode()==KeyEvent.VK_LEFT && x0>0) { x0--; update(FULL_UPDATE); } else if (e.getKeyCode()==KeyEvent.VK_RIGHT && x0<imp.getWidth()-1) { x0++; update(FULL_UPDATE); } else if (e.getSource() instanceof Button) ij.keyPressed(e); //forward other keys from the panel to ImageJ Overlay overlay = imp.getOverlay(); if (overlay==null) return; int index = getIndex(overlay, TITLE); if (index>=0) { overlay.remove(index); Roi roi = new Roi(x0-radius, y0-radius, radius*2+1, radius*2+1); roi.setName(TITLE); roi.setStrokeColor(Color.red); overlay.add(roi); imp.setOverlay(overlay); } }
public boolean showImageDialog(String name) { ImageRoi iRoi = (ImageRoi)roi; boolean zeroTransparent = iRoi.getZeroTransparent(); GenericDialog gd = new GenericDialog("Image ROI Properties"); gd.addStringField("Name:", name, 15); gd.addNumericField("Opacity (0-100%):", iRoi.getOpacity()*100.0, 0); gd.addCheckbox("Transparent background", zeroTransparent); if (addToOverlay) gd.addCheckbox("New Overlay", false); gd.showDialog(); if (gd.wasCanceled()) return false; name = gd.getNextString(); roi.setName(name.length()>0?name:null); double opacity = gd.getNextNumber()/100.0; iRoi.setOpacity(opacity); boolean zeroTransparent2 = gd.getNextBoolean(); if (zeroTransparent!=zeroTransparent2) iRoi.setZeroTransparent(zeroTransparent2); boolean newOverlay = addToOverlay?gd.getNextBoolean():false; if (newOverlay) roi.setName("new-overlay"); return true; }
public boolean showImageDialog(String name) { ImageRoi iRoi = (ImageRoi)roi; boolean zeroTransparent = iRoi.getZeroTransparent(); GenericDialog gd = new GenericDialog("Image ROI Properties"); gd.addStringField("Name:", name, 15); gd.addNumericField("Opacity (0-100%):", iRoi.getOpacity()*100.0, 0); gd.addCheckbox("Transparent background", zeroTransparent); if (addToOverlay) gd.addCheckbox("New Overlay", false); gd.showDialog(); if (gd.wasCanceled()) return false; name = gd.getNextString(); roi.setName(name.length()>0?name:null); double opacity = gd.getNextNumber()/100.0; iRoi.setOpacity(opacity); boolean zeroTransparent2 = gd.getNextBoolean(); if (zeroTransparent!=zeroTransparent2) iRoi.setZeroTransparent(zeroTransparent2); boolean newOverlay = addToOverlay?gd.getNextBoolean():false; if (newOverlay) roi.setName("new-overlay"); return true; }
private void showToolSize(int deltaWidth, ImagePlus imp) { if (deltaWidth !=0) { width = oldWidth + deltaWidth; if (width<1) width=1; Roi circle = new OvalRoi(xStart-width/2, yStart-width/2, width, width); circle.setName(CIRCLE_NAME); circle.setStrokeColor(Color.red); overlay = imp.getOverlay(); if (overlay==null) overlay = new Overlay(); else if (overlay.size()>0 && CIRCLE_NAME.equals(overlay.get(overlay.size()-1).getName())) overlay.remove(overlay.size()-1); overlay.add(circle); imp.setOverlay(overlay); } IJ.showStatus((isPencil?"Pencil":"Brush")+" width: "+ width); }
private void showToolSize(int deltaWidth, ImagePlus imp) { if (deltaWidth !=0) { width = oldWidth + deltaWidth; if (width<1) width=1; Roi circle = new OvalRoi(xStart-width/2, yStart-width/2, width, width); circle.setName(CIRCLE_NAME); circle.setStrokeColor(Color.red); overlay = imp.getOverlay(); if (overlay==null) overlay = new Overlay(); else if (overlay.size()>0 && CIRCLE_NAME.equals(overlay.get(overlay.size()-1).getName())) overlay.remove(overlay.size()-1); overlay.add(circle); imp.setOverlay(overlay); } IJ.showStatus((isPencil?"Pencil":"Brush")+" width: "+ width); }
private void clearOverlay(int first, int last, int rows) { ImagePlus imp = WindowManager.getCurrentImage(); if (imp==null) return; Overlay overlay = imp.getOverlay(); if (overlay==null) return; if (overlay.size()!=rows) return; String name1 = overlay.get(0).getName(); String name2 = overlay.get(overlay.size()-1).getName(); if (!"1".equals(name1) || !(""+rows).equals(name2)) return; int count = last-first+1; if (overlay.size()==count) { if (count==1 || IJ.showMessageWithCancel("ImageJ", "Delete the "+overlay.size()+" element overlay? ")) imp.setOverlay(null); return; } for (int i=0; i<count; i++) overlay.remove(first); for (int i=first; i<overlay.size(); i++) overlay.get(i).setName(""+(i+1)); imp.draw(); }
private void addRoiToOverlay() { Roi roi = imp.getRoi(); if (roi==null) return; roi = (Roi)roi.clone(); if (imp.getStackSize()>1) { if (imp.isHyperStack()||imp.isComposite()) roi.setPosition(0, imp.getSlice(), imp.getFrame()); else roi.setPosition(imp.getCurrentSlice()); } if (roi.getName()==null) roi.setName(""+rt.size()); //roi.setName(IJ.getString("Label:", "m"+rt.size())); roi.setIgnoreClipRect(true); Overlay overlay = imp.getOverlay(); if (overlay==null) overlay = new Overlay(); if (drawLabels) overlay.drawLabels(true); if (!overlay.getDrawNames()) overlay.drawNames(true); overlay.setLabelColor(Color.white); overlay.drawBackgrounds(true); overlay.add(roi); imp.setOverlay(overlay); if (roi.getType()==Roi.COMPOSITE && Toolbar.getToolId()==Toolbar.OVAL && Toolbar.getBrushSize()>0) imp.deleteRoi(); // delete ROIs created with the selection brush tool }