本文整理了Java中java.awt.Graphics2D.fillPolygon()
方法的一些代码示例,展示了Graphics2D.fillPolygon()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Graphics2D.fillPolygon()
方法的具体详情如下:
包路径:java.awt.Graphics2D
类名称:Graphics2D
方法名:fillPolygon
暂无
代码示例来源:origin: runelite/runelite
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);
}
代码示例来源:origin: libgdx/libgdx
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);
代码示例来源:origin: libgdx/libgdx
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);
代码示例来源:origin: libgdx/libgdx
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);
代码示例来源:origin: libgdx/libgdx
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);
代码示例来源:origin: marytts/marytts
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;
}
}
代码示例来源:origin: marytts/marytts
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;
}
}
代码示例来源:origin: pentaho/pentaho-kettle
public void fillPolygon( int[] polygon ) {
switchForegroundBackgroundColors();
gc.fillPolygon( getSwingPolygon( polygon ) );
switchForegroundBackgroundColors();
}
代码示例来源:origin: pentaho/pentaho-kettle
public void fillPolygon( int[] polygon ) {
switchForegroundBackgroundColors();
gc.fillPolygon( getSwingPolygon( polygon ) );
switchForegroundBackgroundColors();
}
代码示例来源:origin: jphp-group/jphp
@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));
}
}
代码示例来源:origin: chewiebug/GCViewer
/**
* @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);
}
}
代码示例来源:origin: runelite/runelite
graphics.fillPolygon(poly);
代码示例来源:origin: apache/pdfbox
@Override
public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints)
{
groupG2D.fillPolygon(xPoints, yPoints, nPoints);
alphaG2D.fillPolygon(xPoints, yPoints, nPoints);
}
代码示例来源:origin: geotools/geotools
public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints) {
delegate.fillPolygon(xPoints, yPoints, nPoints);
}
代码示例来源:origin: geotools/geotools
public void fillPolygon(Polygon p) {
delegate.fillPolygon(p);
}
代码示例来源:origin: i2p/i2p.i2p
void fillPolygon(int[] x, int[] y, Paint paint) {
gd.setPaint(paint);
gd.fillPolygon(x, y, x.length);
}
代码示例来源:origin: knowm/XChart
@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);
}
}
代码示例来源:origin: i2p/i2p.i2p
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);
}
}
代码示例来源:origin: i2p/i2p.i2p
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);
}
}
代码示例来源:origin: jbox2d/jbox2d
@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);
}
内容来源于网络,如有侵权,请联系作者删除!