コード例 #1
0
 void updateImage(ImagePlus imp) {
   this.imp = imp;
   int width = imp.getWidth();
   int height = imp.getHeight();
   imageWidth = width;
   imageHeight = height;
   srcRect = new Rectangle(0, 0, imageWidth, imageHeight);
   setDrawingSize(imageWidth, (int) imageHeight);
   magnification = 1.0;
 }
コード例 #2
0
 protected void handleRoiMouseDown(MouseEvent e) {
   int sx = e.getX();
   int sy = e.getY();
   int ox = offScreenX(sx);
   int oy = offScreenY(sy);
   Roi roi = imp.getRoi();
   int handle = roi != null ? roi.isHandle(sx, sy) : -1;
   boolean multiPointMode =
       roi != null
           && (roi instanceof PointRoi)
           && handle == -1
           && Toolbar.getToolId() == Toolbar.POINT
           && Toolbar.getMultiPointMode();
   if (multiPointMode) {
     imp.setRoi(((PointRoi) roi).addPoint(ox, oy));
     return;
   }
   setRoiModState(e, roi, handle);
   if (roi != null) {
     if (handle >= 0) {
       roi.mouseDownInHandle(handle, sx, sy);
       return;
     }
     Rectangle r = roi.getBounds();
     int type = roi.getType();
     if (type == Roi.RECTANGLE
         && r.width == imp.getWidth()
         && r.height == imp.getHeight()
         && roi.getPasteMode() == Roi.NOT_PASTING
         && !(roi instanceof ImageRoi)) {
       imp.killRoi();
       return;
     }
     if (roi.contains(ox, oy)) {
       if (roi.modState == Roi.NO_MODS) roi.handleMouseDown(sx, sy);
       else {
         imp.killRoi();
         imp.createNewRoi(sx, sy);
       }
       return;
     }
     if ((type == Roi.POLYGON || type == Roi.POLYLINE || type == Roi.ANGLE)
         && roi.getState() == roi.CONSTRUCTING) return;
     int tool = Toolbar.getToolId();
     if ((tool == Toolbar.POLYGON || tool == Toolbar.POLYLINE || tool == Toolbar.ANGLE)
         && !(IJ.shiftKeyDown() || IJ.altKeyDown())) {
       imp.killRoi();
       return;
     }
   }
   imp.createNewRoi(sx, sy);
 }
コード例 #3
0
 public ImageCanvas(ImagePlus imp) {
   this.imp = imp;
   ij = IJ.getInstance();
   int width = imp.getWidth();
   int height = imp.getHeight();
   imageWidth = width;
   imageHeight = height;
   srcRect = new Rectangle(0, 0, imageWidth, imageHeight);
   setDrawingSize(imageWidth, (int) (imageHeight));
   magnification = 1.0;
   addMouseListener(this);
   addMouseMotionListener(this);
   addKeyListener(ij); // ImageJ handles keyboard shortcuts
   setFocusTraversalKeysEnabled(false);
 }