当前位置: 首页>>代码示例>>Java>>正文


Java Graphics.fillPolygon方法代码示例

本文整理汇总了Java中java.awt.Graphics.fillPolygon方法的典型用法代码示例。如果您正苦于以下问题:Java Graphics.fillPolygon方法的具体用法?Java Graphics.fillPolygon怎么用?Java Graphics.fillPolygon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.Graphics的用法示例。


在下文中一共展示了Graphics.fillPolygon方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: paintIcon

import java.awt.Graphics; //导入方法依赖的package包/类
@Override
public void paintIcon(java.awt.Component c, Graphics g, int x, int y) {
	// draw tool icon
	Graphics gIcon = g.create();
	ComponentDrawContext context = new ComponentDrawContext(c, null, null, g, gIcon);
	comp.getFactory().paintIcon(context, x, y, comp.getAttributeSet());
	gIcon.dispose();

	if (triangleState != TRIANGLE_NONE) {
		int[] xp;
		int[] yp;
		if (triangleState == TRIANGLE_CLOSED) {
			xp = new int[] { x + 13, x + 13, x + 17 };
			yp = new int[] { y + 11, y + 19, y + 15 };
		} else {
			xp = new int[] { x + 11, x + 19, x + 15 };
			yp = new int[] { y + 13, y + 13, y + 17 };
		}
		g.setColor(Color.LIGHT_GRAY);
		g.fillPolygon(xp, yp, 3);
		g.setColor(Color.DARK_GRAY);
		g.drawPolygon(xp, yp, 3);
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:25,代码来源:ComponentIcon.java

示例2: rasterize

import java.awt.Graphics; //导入方法依赖的package包/类
/**
 * rasterize the mask clipped with the Rectangle scaled back to full size with an offset onto a BufferedImage
 */
public BufferedImage rasterize(Rectangle rect, int offsetX, int offsetY, double scalingFactor) {

	// create the buffered image of the size of the Rectangle
    BufferedImage image = new BufferedImage(rect.width, rect.height, BufferedImage.TYPE_BYTE_BINARY);
    GeometryFactory gf = new GeometryFactory();

    // define the clipping region in full scale
    Coordinate[] coords = new Coordinate[]{
        new Coordinate((int) (((double) rect.getMinX() / scalingFactor)), (int) (((double) rect.getMinY() / scalingFactor))),
        new Coordinate((int) (((double) rect.getMaxX() / scalingFactor)), (int) (((double) rect.getMinY() / scalingFactor))),
        new Coordinate((int) (((double) rect.getMaxX() / scalingFactor)), (int) (((double) rect.getMaxY() / scalingFactor))),
        new Coordinate((int) (((double) rect.getMinX() / scalingFactor)), (int) (((double) rect.getMaxY() / scalingFactor))),
        new Coordinate((int) (((double) rect.getMinX() / scalingFactor)), (int) (((double) rect.getMinY() / scalingFactor))),};

    Polygon geom = gf.createPolygon(gf.createLinearRing(coords));

    Graphics g2d = image.getGraphics();

    g2d.setColor(Color.white);
    for (Geometry p : maskGeometries) {
    	/*if(p instanceof MultiPolygon){
    		p=p.getBoundary();
    	}*/
        if (p.intersects(geom)) {
            int[] xPoints = new int[p.getNumPoints()];//build array for x coordinates
            int[] yPoints = new int[p.getNumPoints()];//build array for y coordinates
            int i = 0;
            for (Coordinate c : p.getCoordinates()) {
                xPoints[i] = (int) ((c.x + offsetX ) * scalingFactor);
                yPoints[i] = (int) ((c.y + offsetY ) * scalingFactor);
                i++;
            }
            g2d.fillPolygon(xPoints, yPoints, i);
        }
    }
    g2d.dispose();
    return image;

}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:43,代码来源:MaskGeometries.java

示例3: rasterize

import java.awt.Graphics; //导入方法依赖的package包/类
public BufferedImage rasterize(BufferedImage image, int offsetX, int offsetY, double scalingFactor) {
    Rectangle rect = image.getRaster().getBounds();
    GeometryFactory gf = new GeometryFactory();
    Coordinate[] coords = new Coordinate[]{
        new Coordinate((int) (((double) rect.getMinX() / scalingFactor) + offsetX), (int) (((double) rect.getMinY() / scalingFactor) + offsetY)),
        new Coordinate((int) (((double) rect.getMaxX() / scalingFactor) + offsetX), (int) (((double) rect.getMinY() / scalingFactor) + offsetY)),
        new Coordinate((int) (((double) rect.getMaxX() / scalingFactor) + offsetX), (int) (((double) rect.getMaxY() / scalingFactor) + offsetY)),
        new Coordinate((int) (((double) rect.getMinX() / scalingFactor) + offsetX), (int) (((double) rect.getMaxY() / scalingFactor) + offsetY)),
        new Coordinate((int) (((double) rect.getMinX() / scalingFactor) + offsetX), (int) (((double) rect.getMinY() / scalingFactor) + offsetY)),
    };
    Polygon geom = gf.createPolygon(gf.createLinearRing(coords), null);
    Graphics g2d = image.getGraphics();
    g2d.setColor(Color.WHITE);
    for (Geometry p : glayer.getGeometries()) {
        if (p.intersects(geom)) {
            int[] xPoints = new int[p.getNumPoints()];
            int[] yPoints = new int[p.getNumPoints()];
            int i = 0;
            for (Coordinate c : p.getCoordinates()) {
                xPoints[i] = (int) ((c.x - offsetX) * scalingFactor);
                yPoints[i++] = (int) ((c.y - offsetY) * scalingFactor);
            }
            g2d.fillPolygon(xPoints, yPoints, p.getNumPoints());
        }
    }
    g2d.dispose();
    return image;
}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:29,代码来源:InterpolatedVectorLayer.java

示例4: paintIcon

import java.awt.Graphics; //导入方法依赖的package包/类
public void paintIcon (java.awt.Component c, Graphics g, int x, int y) {

            g.setColor ( armed ?
                    UIManager.getColor ( "List.selectionForeground" ) : //NOI18N
                    UIManager.getColor ( "controlShadow" ) ); //NOI18N
/*            int[] xPoints = new int[] {x+getIconWidth()/2, x+getIconWidth(), x};
            int[] yPoints = new int[] {y, y+getIconHeight()-1, y+getIconHeight()-1};
 */
            int[] xPoints = new int[]{x, x + 8, x + 4};
            int[] yPoints = new int[]{y + 5, y + 5, y};

            g.fillPolygon ( xPoints, yPoints, 3 );
        }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:TapPanel.java

示例5: paintIcon

import java.awt.Graphics; //导入方法依赖的package包/类
public void paintIcon(Component c, Graphics g, int x, int y) {
  Dimension size = c.getSize();
  Graphics g2 = g.create(size.width / 2 - 5, size.height / 2 - 5, 10, 10);
  g2.setColor(Color.GRAY);
  g2.drawPolygon(xPoints, yPoints, 3);
  if (c.isEnabled()) {
    g2.setColor(Color.BLACK);
    g2.fillPolygon(xPoints, yPoints, 3);
  }
  g2.dispose();
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:12,代码来源:MenuScroller.java

示例6: paint

import java.awt.Graphics; //导入方法依赖的package包/类
@Override public void paint(Graphics graphics) {
	graphics.setColor(Color.BLACK);
	graphics.drawRect(10, 0, size.width-10, size.height);
	for(int input=0;input<inputs.length;input++) {
		Polygon polygon = new Polygon(POLYGONS_X[input], POLYGONS_Y[input], 7);
		polygon.translate(15, 4);
		if(inputs[input].isCharged()) {
			graphics.setColor(Color.RED);
			graphics.fillPolygon(polygon);
		}
		graphics.setColor(Color.BLACK);
		graphics.drawPolyline(polygon.xpoints, polygon.ypoints, polygon.npoints);
	}
	ContactUtilities.paintSolderingJoints(graphics, 10, 0, inputs);
}
 
开发者ID:kristian,项目名称:JDigitalSimulator,代码行数:16,代码来源:SevenSegmentDisplay.java

示例7: paintComponent

import java.awt.Graphics; //导入方法依赖的package包/类
@Override
public void paintComponent(Graphics g)
{
   super.paintComponent(g); 

   // draw polygon with Polygon object
   int[] xValues = {20, 40, 50, 30, 20, 15};
   int[] yValues = {50, 50, 60, 80, 80, 60};
   Polygon polygon1 = new Polygon(xValues, yValues, 6);
   g.drawPolygon(polygon1);

   // draw polylines with two arrays
   int[] xValues2 = {70, 90, 100, 80, 70, 65, 60};
   int[] yValues2 = {100, 100, 110, 110, 130, 110, 90};
   g.drawPolyline(xValues2, yValues2, 7);

   // fill polygon with two arrays
   int[] xValues3 = {120, 140, 150, 190};
   int[] yValues3 = {40, 70, 80, 60};
   g.fillPolygon(xValues3, yValues3, 4);

   // draw filled polygon with Polygon object
   Polygon polygon2 = new Polygon();
   polygon2.addPoint(165, 135);
   polygon2.addPoint(175, 150);
   polygon2.addPoint(270, 200);
   polygon2.addPoint(200, 220);
   polygon2.addPoint(130, 180);
   g.fillPolygon(polygon2);
}
 
开发者ID:cleitonferreira,项目名称:LivroJavaComoProgramar10Edicao,代码行数:31,代码来源:PolygonsJPanel.java

示例8: paintIcon

import java.awt.Graphics; //导入方法依赖的package包/类
@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
  Dimension size = c.getSize();
  Graphics g2 = g.create(size.width / 2 - 5, size.height / 2 - 5, 10, 10);
  g2.setColor(Color.GRAY);
  g2.drawPolygon(xPoints, yPoints, 3);
  if (c.isEnabled()) {
    g2.setColor(Color.BLACK);
    g2.fillPolygon(xPoints, yPoints, 3);
  }
  g2.dispose();
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:13,代码来源:MenuScroller.java

示例9: runTest

import java.awt.Graphics; //导入方法依赖的package包/类
public void runTest(Object ctx, int numReps) {
    RenderTests.Context rctx = (RenderTests.Context) ctx;
    int size = rctx.size;
    int x = rctx.initX;
    int y = rctx.initY;
    int hexaX[] = new int[6];
    int hexaY[] = new int[6];
    Graphics g = rctx.graphics;
    g.translate(rctx.orgX, rctx.orgY);
    Color rCArray[] = rctx.colorlist;
    int ci = rctx.colorindex;
    do {
        hexaX[0] = x;
        hexaX[1] = hexaX[5] = x+size/4;
        hexaX[2] = hexaX[4] = x+size-size/4;
        hexaX[3] = x+size;
        hexaY[1] = hexaY[2] = y;
        hexaY[0] = hexaY[3] = y+size/2;
        hexaY[4] = hexaY[5] = y+size;

        if (rCArray != null) {
            g.setColor(rCArray[ci++ & NUM_RANDOMCOLORMASK]);
        }
        g.fillPolygon(hexaX, hexaY, 6);
        if ((x -= 3) < 0) x += rctx.maxX;
        if ((y -= 1) < 0) y += rctx.maxY;
    } while (--numReps > 0);
    rctx.colorindex = ci;
    g.translate(-rctx.orgX, -rctx.orgY);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:31,代码来源:RenderTests.java

示例10: paintIcon

import java.awt.Graphics; //导入方法依赖的package包/类
public void paintIcon(Component c, Graphics g, int x, int y) {
    Polygon p = new Polygon();
    p.addPoint(x, y);
    p.addPoint(x+getIconWidth(), y+getIconHeight()/2);
    p.addPoint(x, y+getIconHeight());
    g.fillPolygon(p);

}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:9,代码来源:BasicIconFactory.java

示例11: drawCheckBezel

import java.awt.Graphics; //导入方法依赖的package包/类
public void drawCheckBezel(Graphics g, int x, int y, int csize,
                       boolean shade, boolean out, boolean check, boolean flat)
{


    Color oldColor = g.getColor();
    g.translate(x, y);


    //bottom
    if(!flat) {
        if (out) {
            g.setColor(control);
            g.fillRect(1,1,csize-2,csize-2);
            g.setColor(shadow);
        } else {
            g.setColor(lightShadow);
            g.fillRect(0,0,csize,csize);
            g.setColor(highlight);
        }

        g.drawLine(1,csize-1,csize-2,csize-1);
        if (shade) {
            g.drawLine(2,csize-2,csize-3,csize-2);
            g.drawLine(csize-2,2,csize-2 ,csize-1);
            if (out) {
                g.setColor(highlight);
            } else {
                g.setColor(shadow);
            }
            g.drawLine(1,2,1,csize-2);
            g.drawLine(1,1,csize-3,1);
            if (out) {
                g.setColor(shadow);
            } else {
                g.setColor(highlight);
            }
        }
        //right
        g.drawLine(csize-1,1,csize-1,csize-1);

        //left
        if (out) {
            g.setColor(highlight);
        } else {
            g.setColor(shadow);
        }
        g.drawLine(0,1,0,csize-1);

        //top
        g.drawLine(0,0,csize-1,0);
    }

    if (check) {
        // draw check
        g.setColor(foreground);
        int[] xa = {csize - 12, csize - 8, csize - 7, csize - 4,
                    csize - 2, csize - 2, csize - 8, csize - 10,
                    csize - 11};
        int[] ya = new int[]{6, 10, 10, 4, 2, 1, 7, 5, 5};
        g.fillPolygon(xa, ya, 9);
    }
    g.translate(-x, -y);
    g.setColor(oldColor);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:66,代码来源:MotifIconFactory.java

示例12: paint

import java.awt.Graphics; //导入方法依赖的package包/类
public void paint(Polygon shape, Graphics g, Color color, int side) {
    g.setColor(((side + 1) % 4 < 2) == (type == Value.INSET) ?
                        getShadowColor(color) : getLightColor(color));
    g.fillPolygon(shape);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:6,代码来源:CSSBorder.java

示例13: drawArea

import java.awt.Graphics; //导入方法依赖的package包/类
/**
* This function draw te area among the axis and the point of the convex hull
 * @param g The graphic object
 * @param allConvex The vector with the points of the convex hull
 * @param allDominants The vector with the dominant points
 * @param area The filter area
 * @param maskedoff The vector with the masked-off points
 */
public void drawArea(Graphics g, Vector<Point2D> allConvex, Vector<Point2D> allDominants, Color area, Color maskedoff) {
	//The first color in the maskedoff color beacause after will be draw
	//the non-maskedoff areas
	g.setColor(maskedoff);
	Polygon poly = new Polygon();

	DPoint p;
	p = (DPoint) allConvex.get(0);

	poly.addPoint((int) (p.getX() * scale) + tran_x, tran_y);

	//Add the point a the polygon for paint the convex area
	for (int i = 0; i < allConvex.size(); i++) {
		p = (DPoint) allConvex.get(i);
		poly.addPoint((int) (p.getX() * scale) + tran_x, tran_y - (int) (p.getY() * scale));
	}

	p = (DPoint) allConvex.get(allConvex.size() - 1);
	poly.addPoint(1 + tran_x, tran_y - (int) (p.getY() * scale));
	poly.addPoint(1 + tran_x, tran_y);
	g.fillPolygon(poly);
	g.setColor(Color.GRAY);
	g.drawPolygon(poly);

	//Draw the non-maskedoff area for each dominant point
	Polygon masked = new Polygon();
	g.setColor(area);

	int k = 0;
	for (k = 0; k < allDominants.size() - 1; k++) {
		p = (DPoint) allDominants.get(k);
		if (!p.intEquals((DPoint) allDominants.get(k + 1))) {
			masked = twoPointRectangle(1 + tran_x, tran_y, (int) (p.getX() * scale) + tran_x, tran_y - (int) (p.getY() * scale));
			g.fillPolygon(masked);
		}
	}
	//Last area is 1 point small
	p = (DPoint) allDominants.get(k);
	masked = twoPointRectangle(1 + tran_x, tran_y, (int) (p.getX() * scale) + tran_x, tran_y - (int) (p.getY() * scale) + 1);
	g.fillPolygon(masked);
}
 
开发者ID:HOMlab,项目名称:QN-ACTR-Release,代码行数:50,代码来源:PainterConvex2D.java

示例14: paint

import java.awt.Graphics; //导入方法依赖的package包/类
public void paint(Polygon shape, Graphics g, Color color, int side) {
    g.setColor(color);
    g.fillPolygon(shape);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:5,代码来源:CSSBorder.java

示例15: drawArrow

import java.awt.Graphics; //导入方法依赖的package包/类
private void drawArrow(Graphics g, int x, int y, int d) {
	int[] px = { x + d, x, x + d };
	int[] py = { y + d, y, y - d };
	g.fillPolygon(px, py, 3);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:6,代码来源:Shifter.java


注:本文中的java.awt.Graphics.fillPolygon方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。