void drawOutline(ImageProcessor ip, Roi roi, int count) {
   if (showChoice == OVERLAY_OUTLINES || showChoice == OVERLAY_MASKS) {
     if (overlay == null) {
       overlay = new Overlay();
       overlay.drawLabels(true);
       overlay.setLabelFont(new Font("SansSerif", Font.PLAIN, fontSize));
     }
     Roi roi2 = (Roi) roi.clone();
     roi2.setStrokeColor(Color.cyan);
     if (lineWidth != 1) roi2.setStrokeWidth(lineWidth);
     if (showChoice == OVERLAY_MASKS) roi2.setFillColor(Color.cyan);
     overlay.add(roi2);
   } else {
     Rectangle r = roi.getBounds();
     int nPoints = ((PolygonRoi) roi).getNCoordinates();
     int[] xp = ((PolygonRoi) roi).getXCoordinates();
     int[] yp = ((PolygonRoi) roi).getYCoordinates();
     int x = r.x, y = r.y;
     if (!inSituShow) ip.setValue(0.0);
     ip.moveTo(x + xp[0], y + yp[0]);
     for (int i = 1; i < nPoints; i++) ip.lineTo(x + xp[i], y + yp[i]);
     ip.lineTo(x + xp[0], y + yp[0]);
     if (showChoice != BARE_OUTLINES) {
       String s = ResultsTable.d2s(count, 0);
       ip.moveTo(r.x + r.width / 2 - ip.getStringWidth(s) / 2, r.y + r.height / 2 + fontSize / 2);
       if (!inSituShow) ip.setValue(1.0);
       ip.drawString(s);
     }
   }
 }
Beispiel #2
0
 public void drawPixels(ImageProcessor ip) {
   int saveWidth = ip.getLineWidth();
   if (getStrokeWidth() > 1f) ip.setLineWidth((int) Math.round(getStrokeWidth()));
   double offset = getOffset(0.5);
   if (xSpline != null) {
     ip.moveTo(
         x + (int) (Math.round(xSpline[0]) + offset), y + (int) Math.round(ySpline[0] + offset));
     for (int i = 1; i < splinePoints; i++)
       ip.lineTo(
           x + (int) (Math.round(xSpline[i]) + offset), y + (int) Math.round(ySpline[i] + offset));
     if (type == POLYGON || type == FREEROI || type == TRACED_ROI)
       ip.lineTo(
           x + (int) (Math.round(xSpline[0]) + offset), y + (int) Math.round(ySpline[0] + offset));
   } else if (xpf != null) {
     ip.moveTo(x + (int) (Math.round(xpf[0]) + offset), y + (int) Math.round(ypf[0] + offset));
     for (int i = 1; i < nPoints; i++)
       ip.lineTo(x + (int) (Math.round(xpf[i]) + offset), y + (int) Math.round(ypf[i] + offset));
     if (type == POLYGON || type == FREEROI || type == TRACED_ROI)
       ip.lineTo(x + (int) (Math.round(xpf[0]) + offset), y + (int) Math.round(ypf[0] + offset));
   } else {
     ip.moveTo(x + xp[0], y + yp[0]);
     for (int i = 1; i < nPoints; i++) ip.lineTo(x + xp[i], y + yp[i]);
     if (type == POLYGON || type == FREEROI || type == TRACED_ROI) ip.lineTo(x + xp[0], y + yp[0]);
   }
   ip.setLineWidth(saveWidth);
   updateFullWindow = true;
 }
  public void drawInto(ImageProcessor ip, int value, int linewidth, GeneralPath path) {
    ip.setValue(value);
    ip.setLineWidth(linewidth);
    PathIterator it = path.getPathIterator(null);
    float[] seg = new float[6];
    int px = 0, py = 0;
    while (!it.isDone()) {
      int l = it.currentSegment(seg);
      int x = Math.round(seg[0]);
      int y = Math.round(seg[1]);
      double d = Math.sqrt((px - x) * (px - x) + (py - y) * (py - y));

      if (l == PathIterator.SEG_MOVETO || d > 15) ip.moveTo(x, y);
      else ip.lineTo(x, y);
      px = x;
      py = y;
      it.next();
    }
  }