Пример #1
0
 void drawCrosses() {
   GeneralPath path = new GeneralPath();
   float arm = 5;
   for (int h = 0; h < linesV; h++) {
     for (int v = 0; v < linesH; v++) {
       float x = (float) (xstart + h * tileWidth);
       float y = (float) (ystart + v * tileHeight);
       path.moveTo(x - arm, y);
       path.lineTo(x + arm, y);
       path.moveTo(x, y - arm);
       path.lineTo(x, y + arm);
     }
   }
   showGrid(path);
 }
Пример #2
0
 void drawLines() {
   GeneralPath path = new GeneralPath();
   int width = imp.getWidth();
   int height = imp.getHeight();
   for (int i = 0; i < linesV; i++) {
     float xoff = (float) (xstart + i * tileWidth);
     path.moveTo(xoff, 0f);
     path.lineTo(xoff, height);
   }
   for (int i = 0; i < linesH; i++) {
     float yoff = (float) (ystart + i * tileHeight);
     path.moveTo(0f, yoff);
     path.lineTo(width, yoff);
   }
   showGrid(path);
 }
Пример #3
0
 void drawGridLines(int lines) {
   ImageCanvas ic = imp.getCanvas();
   if (ic == null) return;
   if (lines == 0) {
     ic.setDisplayList(null);
     return;
   }
   GeneralPath path = new GeneralPath();
   float width = imp.getWidth();
   float height = imp.getHeight();
   float xinc = width / lines;
   float yinc = height / lines;
   float xstart = xinc / 2f;
   float ystart = yinc / 2f;
   for (int i = 0; i < lines; i++) {
     path.moveTo(xstart + xinc * i, 0f);
     path.lineTo(xstart + xinc * i, height);
     path.moveTo(0f, ystart + yinc * i);
     path.lineTo(width, ystart + yinc * i);
   }
   ic.setDisplayList(path, null, null);
 }
Пример #4
0
 void drawPoints() {
   int one = 1;
   int two = 2;
   GeneralPath path = new GeneralPath();
   for (int h = 0; h < linesV; h++) {
     for (int v = 0; v < linesH; v++) {
       float x = (float) (xstart + h * tileWidth);
       float y = (float) (ystart + v * tileHeight);
       path.moveTo(x - two, y - one);
       path.lineTo(x - two, y + one);
       path.moveTo(x + two, y - one);
       path.lineTo(x + two, y + one);
       path.moveTo(x - one, y - two);
       path.lineTo(x + one, y - two);
       path.moveTo(x - one, y + two);
       path.lineTo(x + one, y + two);
     }
   }
   showGrid(path);
 }
Пример #5
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);
 }