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


Java Graphics2D.fill方法代码示例

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


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

示例1: runTest

import java.awt.Graphics2D; //导入方法依赖的package包/类
public void runTest(Object ctx, int numReps) {
    FillEllipse2Ds.Context cctx = (FillEllipse2Ds.Context) ctx;
    int size = cctx.size;
    int x = cctx.initX;
    int y = cctx.initY;
    Ellipse2D ellipse = cctx.ellipse;
    Graphics2D g2d = (Graphics2D) cctx.graphics;
    g2d.translate(cctx.orgX, cctx.orgY);
    Color rCArray[] = cctx.colorlist;
    int ci = cctx.colorindex;
    do {
        if (rCArray != null) {
            g2d.setColor(rCArray[ci++ & NUM_RANDOMCOLORMASK]);
        }
        ellipse.setFrame(x, y, size, size);
        g2d.fill(ellipse);
        if ((x -= 3) < 0) x += cctx.maxX;
        if ((y -= 1) < 0) y += cctx.maxY;
    } while (--numReps > 0);
    cctx.colorindex = ci;
    g2d.translate(-cctx.orgX, -cctx.orgY);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:RenderTests.java

示例2: fillDomainGridBand

import java.awt.Graphics2D; //导入方法依赖的package包/类
/**
 * Fills a band between two values on the axis.  This can be used to color
 * bands between the grid lines.
 *
 * @param g2  the graphics device.
 * @param plot  the plot.
 * @param axis  the domain axis.
 * @param dataArea  the data area.
 * @param start  the start value.
 * @param end  the end value.
 */
public void fillDomainGridBand(Graphics2D g2,
                               XYPlot plot,
                               ValueAxis axis,
                               Rectangle2D dataArea,
                               double start, double end) {

    double x1 = axis.valueToJava2D(start, dataArea,
            plot.getDomainAxisEdge());
    double x2 = axis.valueToJava2D(end, dataArea,
            plot.getDomainAxisEdge());
    // TODO: need to change the next line to take account of plot
    //       orientation...
    Rectangle2D band = new Rectangle2D.Double(x1, dataArea.getMinY(),
            x2 - x1, dataArea.getMaxY() - dataArea.getMinY());
    Paint paint = plot.getDomainTickBandPaint();

    if (paint != null) {
        g2.setPaint(paint);
        g2.fill(band);
    }

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:34,代码来源:AbstractXYItemRenderer.java

示例3: drawStatus

import java.awt.Graphics2D; //导入方法依赖的package包/类
public void drawStatus(int status, double probability, Graphics2D g2d, Color sc, Color pc, Color borderC, boolean bold) {
	double x = 2.0 * (2.0 * STATUS_RAD + ELEMS_GAP) * status + START_GAP;
	double y = panelH / 2.0 - STATUS_RAD;
	double pie = probability * 360;
	Color ctmp = g2d.getColor();
	if (bold) {
		g2d.setStroke(strokeB);
	}
	statusE[status] = new Ellipse2D.Double(x, y, STATUS_RAD * 2.0, STATUS_RAD * 2.0);
	statusP[status] = new Arc2D.Double(x, y, STATUS_RAD * 2.0, STATUS_RAD * 2.0, 0.0, pie, Arc2D.PIE);
	g2d.setPaint(sc);
	g2d.fill(statusE[status]);
	g2d.setPaint(pc);
	g2d.fill(statusP[status]);
	g2d.setPaint(borderC);
	g2d.draw(statusE[status]);
	drawCenteredText(probabilityToString(probability, 3), Color.BLACK, x + STATUS_RAD, y - STATUS_RAD, g2d, false);
	drawCenteredText("" + status, borderC, x + STATUS_RAD, panelH / 2.0, g2d, false);
	g2d.setColor(ctmp);
	g2d.setStroke(stroke);
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:22,代码来源:StatiDrawer.java

示例4: drawLastStatus

import java.awt.Graphics2D; //导入方法依赖的package包/类
public void drawLastStatus(String jobStr, double probability, Graphics2D g2d, Color sc, Color pc) {
	double x = 2.0 * (2.0 * STATUS_RAD + ELEMS_GAP) * (queueLenght() - 1) + START_GAP;
	double y = panelH / 2.0 - STATUS_RAD;
	Color ctmp = g2d.getColor();
	lastStatusE = new Ellipse2D.Double(x, y, STATUS_RAD * 2.0, STATUS_RAD * 2.0);
	g2d.setPaint(sc);
	g2d.fill(lastStatusE);
	//if(queueMax != 0){
	double pie = probability * 360;
	lastStatusP = new Arc2D.Double(x, y, STATUS_RAD * 2.0, STATUS_RAD * 2.0, 0.0, pie, Arc2D.PIE);
	g2d.setPaint(pc);
	g2d.fill(lastStatusP);
	g2d.setPaint(Color.BLACK);
	drawCenteredText(probabilityToString(probability, 3), Color.BLACK, x + STATUS_RAD, y - STATUS_RAD, g2d, false);
	//drawCenteredText("" + queueMax, Color.BLACK, x + STATUS_RAD, panelH/2.0, g2d, false);
	drawCenteredText(jobStr, Color.BLACK, x + STATUS_RAD, panelH / 2.0, g2d, false);
	//}
	g2d.setPaint(Color.BLACK);
	g2d.draw(lastStatusE);
	g2d.setColor(ctmp);
}
 
开发者ID:HOMlab,项目名称:QN-ACTR-Release,代码行数:22,代码来源:StatiDrawer.java

示例5: draw

import java.awt.Graphics2D; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
public void draw(Graphics2D graphics, float x, float y) {

    // translating graphics to draw Shape !!!
    graphics.translate((int)x, (int)y);

    try {
        if (fStroke == STROKE) {
            // REMIND: set stroke to correct size
            graphics.draw(fShape);
        }
        else {
            graphics.fill(fShape);
        }
    }
    finally {
        graphics.translate(-(int)x, -(int)y);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:22,代码来源:ShapeGraphicAttribute.java

示例6: displayFogOfWar

import java.awt.Graphics2D; //导入方法依赖的package包/类
/**
 * Displays Fog of War of the tile onto the given Graphics2D object,
 * if necessary.
 *
 * @param g The {@code Graphics2D} object on which to draw
 *     the {@code Tile}.
 * @param tile The {@code Tile} to draw.
 */
void displayFogOfWar(Graphics2D g, Tile tile) {
    if (hasFogOfWar(tile)) {
        g.setColor(Color.BLACK);
        Composite oldComposite = g.getComposite();
        g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,
                                                  0.2f));
        g.fill(fog);
        g.setComposite(oldComposite);
    }
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:19,代码来源:TileViewer.java

示例7: draw

import java.awt.Graphics2D; //导入方法依赖的package包/类
/**
 * @see org.newdawn.slick.font.effects.Effect#draw(java.awt.image.BufferedImage, java.awt.Graphics2D, org.newdawn.slick.UnicodeFont, org.newdawn.slick.font.Glyph)
 */
public void draw(BufferedImage image, Graphics2D g, UnicodeFont unicodeFont, Glyph glyph) {
	int ascent = unicodeFont.getAscent();
	float height = (ascent) * scale;
	float top = -glyph.getYOffset() + unicodeFont.getDescent() + offset + ascent / 2 - height / 2;
	g.setPaint(new GradientPaint(0, top, topColor, 0, top + height, bottomColor, cyclic));
	g.fill(glyph.getShape());
}
 
开发者ID:j-dong,项目名称:trashjam2017,代码行数:11,代码来源:GradientEffect.java

示例8: runTest

import java.awt.Graphics2D; //导入方法依赖的package包/类
public void runTest(Object ctx, int numReps) {
    FillCubics.Context cctx = (FillCubics.Context) ctx;
    int size = cctx.size;
    // Note: 2x2 ends up hitting exactly 1 pixel...
    if (size < 2) size = 2;
    int x = cctx.initX;
    int y = cctx.initY;
    int cpoffset = (int) (size/relYmax/2);
    CubicCurve2D curve = cctx.curve;
    Graphics2D g2d = (Graphics2D) cctx.graphics;
    g2d.translate(cctx.orgX, cctx.orgY);
    Color rCArray[] = cctx.colorlist;
    int ci = cctx.colorindex;
    do {
        curve.setCurve(x, y+size/2.0,
                       x+size/2.0, y+size/2.0-cpoffset,
                       x+size/2.0, y+size/2.0+cpoffset,
                       x+size, y+size/2.0);

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

示例9: paintComponent

import java.awt.Graphics2D; //导入方法依赖的package包/类
@Override
protected void paintComponent(Graphics graphics) {
	super.paintComponent(graphics);
	double scaleX = (double) getWidth() / (double) processRenderer.getWidth();
	double scaleY = (double) getHeight() / (double) processRenderer.getHeight();
	scale = Math.min(scaleX, scaleY);
	double scaledW = processRenderer.getWidth() * scale;
	double scaledH = processRenderer.getHeight() * scale;

	Graphics2D g = (Graphics2D) graphics.create();
	g.translate((getWidth() - scaledW) / 2d, (getHeight() - scaledH) / 2d);
	g.scale(scale, scale);

	g.setRenderingHints(ProcessDrawer.LOW_QUALITY_HINTS);
	processRenderer.getOverviewPanelDrawer().draw(g, true);

	g.setStroke(new BasicStroke((int) (1d / scale)));

	Rectangle visibleRect = processRenderer.getVisibleRect();
	Rectangle drawRect = new Rectangle((int) visibleRect.getX(), (int) visibleRect.getY(),
			(int) visibleRect.getWidth() - 1, (int) visibleRect.getHeight() - 1);

	g.setColor(FILL_COLOR);
	g.fill(drawRect);

	g.setColor(DRAW_COLOR);
	g.draw(drawRect);

	g.dispose();
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:31,代码来源:OverviewPanel.java

示例10: paintTringle

import java.awt.Graphics2D; //导入方法依赖的package包/类
@Override
public void paintTringle(Graphics2D g) {
    if (paintTriangle >= 0) {
        // g.setClip(rect);
        g.fill(getTrianglePath(paintTriangle).createTransformedShape(
                AffineTransform.getScaleInstance(movingArea.zoom,
                        movingArea.zoom)));
        // g.setClip(null);
    }
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:11,代码来源:DFDSFunction.java

示例11: createCapitalLabel

import java.awt.Graphics2D; //导入方法依赖的package包/类
/**
 * Draws the pentagram indicating a native capital.
 *
 * @param extent The nominal height of the image.
 * @param padding Padding to add around the image.
 * @param backgroundColor The image background color.
 * @return A suitable {@code BufferedImage}.
 */
private static BufferedImage createCapitalLabel(int extent, int padding,
                                                Color backgroundColor) {
    // create path
    double deg2rad = Math.PI/180.0;
    double angle = -90.0 * deg2rad;
    double offset = extent * 0.5;
    double size1 = (extent - padding - padding) * 0.5;

    GeneralPath path = new GeneralPath();
    path.moveTo(Math.cos(angle) * size1 + offset, Math.sin(angle) * size1 + offset);
    for (int i = 0; i < 4; i++) {
        angle += 144 * deg2rad;
        path.lineTo(Math.cos(angle) * size1 + offset, Math.sin(angle) * size1 + offset);
    }
    path.closePath();

    // draw everything
    BufferedImage bi = new BufferedImage(extent, extent, BufferedImage.TYPE_INT_ARGB);
    Graphics2D g = bi.createGraphics();
    g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
    g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g.setColor(backgroundColor);
    g.fill(new RoundRectangle2D.Float(0, 0, extent, extent, padding, padding));
    g.setColor(Color.BLACK);
    g.setStroke(new BasicStroke(2.4f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
    g.draw(path);
    g.setColor(Color.WHITE);
    g.fill(path);
    g.dispose();
    return bi;
}
 
开发者ID:wintertime,项目名称:FreeCol,代码行数:40,代码来源:MapViewer.java

示例12: drawLegendBox

import java.awt.Graphics2D; //导入方法依赖的package包/类
/**
 * Draws the bounding box for the legend.
 * 
 * @param g2  the graphics device.
 * @param legendArea  the legend area.
 */
private void drawLegendBox(Graphics2D g2, RectangularShape legendArea) {
    // Draw the legend's bounding box
    g2.setPaint(this.backgroundPaint);
    g2.fill(legendArea);
    g2.setPaint(this.outlinePaint);
    g2.setStroke(this.outlineStroke);
    g2.draw(legendArea);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:15,代码来源:StandardLegend.java

示例13: paintSurveyColumn

import java.awt.Graphics2D; //导入方法依赖的package包/类
private void paintSurveyColumn(Graphics graphics, int column, float currentX, float columnDistance) {
	Graphics2D g = (Graphics2D) graphics.create();
	g.translate(currentX, 0);

	// draw weight rect
	if (dataTable.isSupportingColumnWeights()) {
		Color weightColor = getWeightColor(dataTable.getColumnWeight(column), this.maxWeight);
		Rectangle2D weightRect = new Rectangle2D.Double(0, MARGIN, columnDistance, this.dataTable.getNumberOfRows());
		g.setColor(weightColor);
		g.fill(weightRect);
	}

	if (this.dataTable.getNumberOfColumns() <= 10) {
		g.drawString(this.dataTable.getColumnName(column), 0, MARGIN - 3);
	}
	g.translate(0, MARGIN);

	g.setColor(GRID_COLOR);
	g.drawLine(0, 0, 0, this.dataTable.getNumberOfRows());

	g.translate(1, 0);
	columnDistance--;
	int counter = 0;
	Iterator<SurveyRow> s = dataRows.iterator();
	while (s.hasNext()) {
		SurveyRow row = s.next();
		double[] data = row.data;
		double length = norm(data, column) * columnDistance;
		double color = row.color;
		g.setColor(getColorProvider().getPointColor(color));
		g.drawLine(0, counter, (int) length, counter);
		counter++;
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:35,代码来源:SurveyPlotter.java

示例14: drawFill

import java.awt.Graphics2D; //导入方法依赖的package包/类
/**
 * Draws a colored background. Returns the area wich has been filled.
 */
private Rectangle2D drawFill(Graphics2D g2, Rectangle2D area) {
	Rectangle2D filledArea = (Rectangle2D) area.clone();
	filledArea = trimMargin(filledArea);
	filledArea = trimBorder(filledArea);
	area = trimPadding(area);
	g2.setPaint(this.fillPaint);
	g2.fill(filledArea);
	drawBorder(g2, filledArea);
	return filledArea;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:14,代码来源:ColoredBlockContainer.java

示例15: drawEQ

import java.awt.Graphics2D; //导入方法依赖的package包/类
private void drawEQ(Graphics2D g, GeneralPath shape) {
	g.setColor(Color.green);
	g.fill(shape);
	g.setColor( Color.blue );
	g.draw( shape );
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:7,代码来源:FocalMechanismSolutionDB.java


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