/** Overrides <code>Graphics.drawPolygon</code>. */ public void drawPolygon(int xPoints[], int yPoints[], int nPoints) { DebugGraphicsInfo info = info(); if (debugLog()) { info() .log( toShortString() + " Drawing polygon: " + " nPoints: " + nPoints + " X's: " + xPoints + " Y's: " + yPoints); } if (isDrawingBuffer()) { if (debugBuffered()) { Graphics debugGraphics = debugGraphics(); debugGraphics.drawPolygon(xPoints, yPoints, nPoints); debugGraphics.dispose(); } } else if (debugFlash()) { Color oldColor = getColor(); int i, count = (info.flashCount * 2) - 1; for (i = 0; i < count; i++) { graphics.setColor((i % 2) == 0 ? info.flashColor : oldColor); graphics.drawPolygon(xPoints, yPoints, nPoints); Toolkit.getDefaultToolkit().sync(); sleep(info.flashTime); } graphics.setColor(oldColor); } graphics.drawPolygon(xPoints, yPoints, nPoints); }
public void paint(Graphics g) { // do normal painting first super.paint(g); // draw polys ListIterator<Polygon> II = poly_draw.listIterator(0); ListIterator<Color> CC = poly_draw_color.listIterator(0); while (II.hasNext()) { Polygon P = II.next(); Color C = CC.next(); g.setColor(C); g.drawPolygon(P); } // fill polys II = poly_fill.listIterator(0); CC = poly_fill_color.listIterator(0); while (II.hasNext()) { Polygon P = II.next(); Color C = CC.next(); g.setColor(C); g.fillPolygon(P); } }
public void draw(Graphics g) { updatePolygon(); Color color = strokeColor != null ? strokeColor : ROIColor; boolean hasHandles = xSpline != null || type == POLYGON || type == POLYLINE || type == ANGLE; boolean isActiveOverlayRoi = !overlay && isActiveOverlayRoi(); if (isActiveOverlayRoi && !hasHandles) { if (color == Color.cyan) color = Color.magenta; else color = Color.cyan; } boolean fill = false; mag = getMagnification(); if (fillColor != null && !isLine() && state != CONSTRUCTING) { color = fillColor; fill = true; } g.setColor(color); Graphics2D g2d = (Graphics2D) g; if (stroke != null && !isActiveOverlayRoi) g2d.setStroke(getScaledStroke()); if (xSpline != null) { if (type == POLYLINE || type == FREELINE) { drawSpline(g, xSpline, ySpline, splinePoints, false, fill, isActiveOverlayRoi); if (wideLine && !overlay) { g2d.setStroke(onePixelWide); g.setColor(getColor()); drawSpline(g, xSpline, ySpline, splinePoints, false, fill, isActiveOverlayRoi); } } else drawSpline(g, xSpline, ySpline, splinePoints, true, fill, isActiveOverlayRoi); } else { if (type == POLYLINE || type == FREELINE || type == ANGLE || state == CONSTRUCTING) { g.drawPolyline(xp2, yp2, nPoints); if (wideLine && !overlay) { g2d.setStroke(onePixelWide); g.setColor(getColor()); g.drawPolyline(xp2, yp2, nPoints); } } else { if (fill) { if (isActiveOverlayRoi) { g.setColor(Color.cyan); g.drawPolygon(xp2, yp2, nPoints); } else g.fillPolygon(xp2, yp2, nPoints); } else g.drawPolygon(xp2, yp2, nPoints); } if (state == CONSTRUCTING && type != FREEROI && type != FREELINE) drawStartBox(g); } if (hasHandles && state != CONSTRUCTING && clipboard == null && !overlay) { int size2 = HANDLE_SIZE / 2; if (activeHandle > 0) drawHandle(g, xp2[activeHandle - 1] - size2, yp2[activeHandle - 1] - size2); if (activeHandle < nPoints - 1) drawHandle(g, xp2[activeHandle + 1] - size2, yp2[activeHandle + 1] - size2); handleColor = strokeColor != null ? strokeColor : ROIColor; drawHandle(g, xp2[0] - size2, yp2[0] - size2); handleColor = Color.white; for (int i = 1; i < nPoints; i++) drawHandle(g, xp2[i] - size2, yp2[i] - size2); } drawPreviousRoi(g); if (!(state == MOVING_HANDLE || state == CONSTRUCTING || state == NORMAL)) showStatus(); if (updateFullWindow) { updateFullWindow = false; imp.draw(); } }