Пример #1
0
 private void drawSpline(
     Graphics g,
     float[] xpoints,
     float[] ypoints,
     int npoints,
     boolean closed,
     boolean fill,
     boolean isActiveOverlayRoi) {
   double srcx = 0.0, srcy = 0.9, mag = 1.0;
   if (ic != null) {
     Rectangle srcRect = ic.getSrcRect();
     srcx = srcRect.x;
     srcy = srcRect.y;
     mag = ic.getMagnification();
   }
   double xd = x, yd = y;
   Graphics2D g2d = (Graphics2D) g;
   GeneralPath path = new GeneralPath();
   double offset = getOffset(0.5);
   if (mag == 1.0 && srcx == 0.0 && srcy == 0.0) {
     path.moveTo(xpoints[0] + xd, ypoints[0] + yd);
     for (int i = 1; i < npoints; i++) path.lineTo(xpoints[i] + xd, ypoints[i] + yd);
   } else {
     path.moveTo((xpoints[0] - srcx + xd) * mag + offset, (ypoints[0] - srcy + yd + offset) * mag);
     for (int i = 1; i < npoints; i++)
       path.lineTo(
           (xpoints[i] - srcx + xd + offset) * mag, (ypoints[i] - srcy + yd + offset) * mag);
   }
   if (closed)
     path.lineTo((xpoints[0] - srcx + xd + offset) * mag, (ypoints[0] - srcy + yd + offset) * mag);
   if (fill) {
     if (isActiveOverlayRoi) {
       g2d.setColor(Color.cyan);
       g2d.draw(path);
     } else g2d.fill(path);
   } else g2d.draw(path);
 }