public static void renderPolygon(Graphics2D graphics, Polygon poly, Color color) { graphics.setColor(color); final Stroke originalStroke = graphics.getStroke(); graphics.setStroke(new BasicStroke(2)); graphics.drawPolygon(poly); graphics.setColor(new Color(0, 0, 0, 50)); graphics.fillPolygon(poly); graphics.setStroke(originalStroke); }
if (i == selectedIndex) { g.setColor(colors.get(i)); g.fillPolygon(xPoints, yPoints, 3); g.fillRect(xPoints[1], yPoints[1] + 2, handleWidth + 1, 2); g.setColor(Color.black);
if (i == selectedIndex) { g.setColor(colors.get(i)); g.fillPolygon(xPoints, yPoints, 3); g.fillRect(xPoints[1], yPoints[1] + 2, handleWidth + 1, 2); g.setColor(Color.black);
if (i == selectedIndex) { g.setColor(colors.get(i)); g.fillPolygon(xPoints, yPoints, 3); g.fillRect(xPoints[1], yPoints[1] + 2, handleWidth + 1, 2); g.setColor(Color.black);
if (i == selectedIndex) { g.setColor(colors.get(i)); g.fillPolygon(xPoints, yPoints, 3); g.fillRect(xPoints[1], yPoints[1] + 2, handleWidth + 1, 2); g.setColor(Color.black);
protected void drawDot(Graphics2D g, int x, int y, int currentDotStyle) { switch (currentDotStyle) { case DOT_FULLCIRCLE: g.fillOval(x - dotSize / 2, y - dotSize / 2, dotSize, dotSize); break; case DOT_FULLSQUARE: g.fillRect(x - dotSize / 2, y - dotSize / 2, dotSize, dotSize); break; case DOT_FULLDIAMOND: g.fillPolygon(new int[] { x - dotSize / 2, x, x + dotSize / 2, x }, new int[] { y, y - dotSize / 2, y, y + dotSize / 2 }, 4); break; case DOT_EMPTYCIRCLE: g.drawOval(x - dotSize / 2, y - dotSize / 2, dotSize, dotSize); break; case DOT_EMPTYSQUARE: g.drawRect(x - dotSize / 2, y - dotSize / 2, dotSize, dotSize); break; case DOT_EMPTYDIAMOND: g.drawPolygon(new int[] { x - dotSize / 2, x, x + dotSize / 2, x }, new int[] { y, y - dotSize / 2, y, y + dotSize / 2 }, 4); break; default: break; } }
protected void drawDot(Graphics2D g, int x, int y, int currentDotStyle) { switch (currentDotStyle) { case DOT_FULLCIRCLE: g.fillOval(x - dotSize / 2, y - dotSize / 2, dotSize, dotSize); break; case DOT_FULLSQUARE: g.fillRect(x - dotSize / 2, y - dotSize / 2, dotSize, dotSize); break; case DOT_FULLDIAMOND: g.fillPolygon(new int[] { x - dotSize / 2, x, x + dotSize / 2, x }, new int[] { y, y - dotSize / 2, y, y + dotSize / 2 }, 4); break; case DOT_EMPTYCIRCLE: g.drawOval(x - dotSize / 2, y - dotSize / 2, dotSize, dotSize); break; case DOT_EMPTYSQUARE: g.drawRect(x - dotSize / 2, y - dotSize / 2, dotSize, dotSize); break; case DOT_EMPTYDIAMOND: g.drawPolygon(new int[] { x - dotSize / 2, x, x + dotSize / 2, x }, new int[] { y, y - dotSize / 2, y, y + dotSize / 2 }, 4); break; default: break; } }
public void fillPolygon( int[] polygon ) { switchForegroundBackgroundColors(); gc.fillPolygon( getSwingPolygon( polygon ) ); switchForegroundBackgroundColors(); }
public void fillPolygon( int[] polygon ) { switchForegroundBackgroundColors(); gc.fillPolygon( getSwingPolygon( polygon ) ); switchForegroundBackgroundColors(); }
@Signature public void polygon(Environment env, ForeachIterator array, DrawOptions options) { List<Integer> xPoints = new ArrayList<>(); List<Integer> yPoints = new ArrayList<>(); while (array.next()) { Memory value = array.getValue(); Integer x = null, y = null; ForeachIterator sub = value.getNewIterator(env); while (sub.next()) { if (x == null) { y = x = sub.getValue().toInteger(); } else { y = sub.getValue().toInteger(); } } if (x != null && y != null) { xPoints.add(x); yPoints.add(y); } } int[] xs = xPoints.stream().mapToInt(i -> i).toArray(); int[] ys = yPoints.stream().mapToInt(i -> i).toArray(); applyOptions(options); if (options.isOutline()) { gc.drawPolygon(xs, ys, Math.min(xs.length, ys.length)); } else { gc.fillPolygon(xs, ys, Math.min(xs.length, ys.length)); } }
/** * @see com.tagtraum.perf.gcviewer.view.ChartRenderer#paintComponent(java.awt.Graphics2D) */ public void paintComponent(Graphics2D g2d) { if ((!drawPolygon) && (!isDrawLine())) return; if (polygon == null) { // don't recompute polygon for each paint event polygon = computePolygon(getModelChart(), getModelChart().getModel()); } clippedPolygon = initClippedPolygon(polygon, g2d.getClip()); if (drawPolygon) { // don't antialias the polygon, if we are going to antialias the bounding lines Object oldAAHint = g2d.getRenderingHint(RenderingHints.KEY_ANTIALIASING); if (isDrawLine()) { g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } g2d.setPaint(createPaint(polygon)); g2d.fillPolygon(clippedPolygon); if (isDrawLine()) { g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, oldAAHint); } } if (isDrawLine()) { g2d.setPaint(getLinePaint()); g2d.drawPolyline(clippedPolygon.xpoints, clippedPolygon.ypoints, clippedPolygon.npoints-1); } }
graphics.fillPolygon(poly);
@Override public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints) { groupG2D.fillPolygon(xPoints, yPoints, nPoints); alphaG2D.fillPolygon(xPoints, yPoints, nPoints); }
public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints) { delegate.fillPolygon(xPoints, yPoints, nPoints); }
public void fillPolygon(Polygon p) { delegate.fillPolygon(p); }
void fillPolygon(int[] x, int[] y, Paint paint) { gd.setPaint(paint); gd.fillPolygon(x, y, x.length); }
@Override public void paint(Graphics2D g, double xOffset, double yOffset, int markerSize) { g.setStroke(stroke); double halfSize = (double) markerSize / 2; Polygon polygon = new Polygon(); for (int i = 1; i <= 4; i++) { polygon.addPoint( (int) ((xOffset) + (markerSize * 0.75) * Math.sin(i * 2 * Math.PI / 5)), (int) ((yOffset + (markerSize * 0.25)) + (markerSize * 0.75) * Math.cos(i * 2 * Math.PI / 5))); } g.fillPolygon(polygon); } }
void fillPolygon(double[] x, double[] yBottom, double[] yTop, Paint paint) { gd.setPaint(paint); PathIterator path = new PathIterator(yTop); for (int[] pos = path.getNextPath(); pos != null; pos = path.getNextPath()) { int start = pos[0], end = pos[1], n = end - start; int[] xDev = new int[n * 2], yDev = new int[n * 2]; for (int i = start; i < end; i++) { int ix1 = i - start, ix2 = n * 2 - 1 - i + start; xDev[ix1] = xDev[ix2] = (int) x[i]; yDev[ix1] = (int) yTop[i]; yDev[ix2] = (int) yBottom[i]; } gd.fillPolygon(xDev, yDev, xDev.length); gd.drawPolygon(xDev, yDev, xDev.length); } }
void fillPolygon(double[] x, double yBottom, double[] yTop, Paint paint) { gd.setPaint(paint); PathIterator path = new PathIterator(yTop); for (int[] pos = path.getNextPath(); pos != null; pos = path.getNextPath()) { int start = pos[0], end = pos[1], n = end - start; int[] xDev = new int[n + 2], yDev = new int[n + 2]; for (int i = start; i < end; i++) { xDev[i - start] = (int) x[i]; yDev[i - start] = (int) yTop[i]; } xDev[n] = xDev[n - 1]; xDev[n + 1] = xDev[0]; yDev[n] = yDev[n + 1] = (int) yBottom; gd.fillPolygon(xDev, yDev, xDev.length); gd.drawPolygon(xDev, yDev, xDev.length); } }
@Override public void drawSolidPolygon(Vec2[] vertices, int vertexCount, Color3f color) { Color f = cpool.getColor(color.x, color.y, color.z, .4f); Color s = cpool.getColor(color.x, color.y, color.z, 1f); Graphics2D g = getGraphics(); saveState(g); int[] xInts = xIntsPool.get(vertexCount); int[] yInts = yIntsPool.get(vertexCount); for (int i = 0; i < vertexCount; i++) { getWorldToScreenToOut(vertices[i], temp); xInts[i] = (int) temp.x; yInts[i] = (int) temp.y; } g.setStroke(stroke); g.setColor(f); g.fillPolygon(xInts, yInts, vertexCount); g.setColor(s); g.drawPolygon(xInts, yInts, vertexCount); restoreState(g); }