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


Java Graphics2D.drawOval方法代码示例

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


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

示例1: drawShadowPoint

import java.awt.Graphics2D; //导入方法依赖的package包/类
/**
 * It draw a temporary point when a point is moved in another place
 * @param g The graphic object
 * @param p The position of the point
 * @param c The color of the point
 * @param size The size of the point
 */
public void drawShadowPoint(Graphics2D g, Point p, Color c, int size) {
	g.setColor(c);

	int fontSize = 7 + pointSize;
	Font f = new Font("Arial", Font.PLAIN, fontSize);
	g.setFont(f);
	double x = Math.max((p.getX() - tran_x) / scale, 0);
	double y = Math.max((-p.getY() + tran_y) / scale, 0);
	double X = (x * scale) + tran_x;
	double Y = -((y * scale) - tran_y);

	g.drawString("(" + format2Dec.format(x) + ", " + format2Dec.format(y) + ")", (int) (X - (fontSize * 3)), (int) Y - 5 - pointSize);

	g.drawOval((int) X - (((size / 2))), (int) Y - (((size / 2))), size, size);

	g.setColor(Color.GRAY);
	Composite oldComp = g.getComposite();
	Composite alphaComp = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.3f);
	g.setComposite(alphaComp);
	g.fillOval((int) X - (((size / 2))), (int) Y - (((size / 2))), size, size);
	g.setComposite(oldComp);

}
 
开发者ID:max6cn,项目名称:jmt,代码行数:31,代码来源:PainterConvex2D.java

示例2: main

import java.awt.Graphics2D; //导入方法依赖的package包/类
public static void main(String[] args) throws InterruptedException {
	DrawFrame df = DrawFrame.create("example3", 800, 600);
	Graphics2D g = df.getGraphics2D();

	int n = 50;

	g.setFont(new Font("Dialog", Font.PLAIN, 16));
	g.drawString("Some Text", 10, 20);

	double incX = (double) df.getW() / n;
	double incY = (double) df.getH() / n;

	g.setStroke(new BasicStroke(1));
	g.setColor(Color.BLACK);
	g.drawOval(50, 50, 200, 100);

	for (int i = 1; i <= n; i++) {
		int x1 = (int) Math.round(i * incX);
		int y1 = 0;
		int x2 = (int) Math.round(incX * (n - i));
		int y2 = (int) Math.round(i * incY);
		g.drawLine(x1, y1, x2, y2);
	}

	df.refresh();
}
 
开发者ID:imagingbook,项目名称:JGraphix,代码行数:27,代码来源:JGraphix_Example_3.java

示例3: drawPoint

import java.awt.Graphics2D; //导入方法依赖的package包/类
/**
 * 随机画点
 *
 * @param image 图片
 */
private void drawPoint(BufferedImage image) {
    if (this.pointPower == -1) {
        return;
    }
    Random r = new Random();
    Graphics2D g2 = (Graphics2D) image.getGraphics();
    int max = this.w * this.h / this.pointPower;
    for (int i = 0; i < max; i++) {
        int x = r.nextInt(w);
        int y = r.nextInt(h);
        g2.setStroke(new BasicStroke(1.5F));
        g2.setColor(this.randomColor());
        g2.drawOval(x, y, 1, 1);
    }
    g2.dispose();
}
 
开发者ID:FlyingHe,项目名称:UtilsMaven,代码行数:22,代码来源:VerificationCodeImage.java

示例4: drawShadowPoint

import java.awt.Graphics2D; //导入方法依赖的package包/类
/**
 * It draw a temporary point when a point is moved in another place
 * @param g The graphic object
 * @param p The position of the point
 * @param c The color of the point
 * @param size The size of the point
 */
public void drawShadowPoint(Graphics2D g, Point p, Color c, int size) {
	g.setColor(c);

	int fontSize = 7 + pointSize;
	Font f = new Font("Arial", Font.PLAIN, fontSize);
	g.setFont(f);
	double x = Math.max((p.getX() - tran_x) / scale, 0);
	double y = Math.max((-p.getY() + tran_y) / scale, 0);
	double X = (x * scale) + tran_x;
	double Y = -((y * scale) - tran_y);

	g.drawString("(" + format2Dec.format(x) + ", " + format2Dec.format(y) + ")", (int) (X - (fontSize * 3)), (int) Y - 5 - pointSize);

	g.drawOval((int) X - (((size / 2))), (int) Y - (((size / 2))), size, size);

	g.setColor(Color.gray);
	Composite oldComp = g.getComposite();
	Composite alphaComp = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.3f);
	g.setComposite(alphaComp);
	g.fillOval((int) X - (((size / 2))), (int) Y - (((size / 2))), size, size);
	g.setComposite(oldComp);

}
 
开发者ID:HOMlab,项目名称:QN-ACTR-Release,代码行数:31,代码来源:PainterConvex2D.java

示例5: paint

import java.awt.Graphics2D; //导入方法依赖的package包/类
@Override
public void paint(Graphics g) {
    final int r = 6;
    super.paint(g);

    // paint cross hairs to show center
    Graphics2D g2 = (Graphics2D) calibrationPanel.getGraphics();
    int w = calibrationPanel.getWidth(), h = calibrationPanel.getHeight();
    g2.setColor(Color.gray);
    g2.drawLine(w / 2, 0, w / 2, h);
    g2.drawLine(0, h / 2, w, h / 2);
    g2.setColor(Color.red) ;
    float x=w/2+w/2*currentPanTiltRad.x/controller.getTiltLimitRad();
    float y=h/2+h/2*(-currentPanTiltRad.y/controller.getTiltLimitRad());
    final int s=20;
    g2.drawOval((int)x-s/2, (int)y-s/2, s, s);

    trajectory.paint();
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:20,代码来源:LabyrinthTableTiltControllerGUI.java

示例6: createSystemTrayIconImage

import java.awt.Graphics2D; //导入方法依赖的package包/类
private Image createSystemTrayIconImage() {
    final BufferedImage trayImage = new BufferedImage(
            imageSize,
            imageSize,
            BufferedImage.TYPE_INT_ARGB);

    final Graphics2D imageGraphics = (Graphics2D) trayImage.getGraphics();

    imageGraphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
            RenderingHints.VALUE_ANTIALIAS_ON);

    imageGraphics.setColor(new Color(255, 255, 255, 0));
    imageGraphics.fillRect(0, 0, trayImage.getWidth(),
            trayImage.getHeight());

    imageGraphics.setColor(Color.green);

    int imageWidth = trayImage.getWidth() - 2 * imageInset;
    int imageHeight = trayImage.getHeight() - 2 * imageInset;

    imageGraphics.fillOval(imageInset, imageInset, imageWidth, imageHeight);
    imageGraphics.setColor(Color.darkGray);
    imageGraphics.drawOval(imageInset, imageInset, imageWidth, imageHeight);

    return trayImage;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:UpdatePopupMenu.java

示例7: onRender

import java.awt.Graphics2D; //导入方法依赖的package包/类
@Override
protected void onRender(Graphics2D g, Game game) {
	//Pointer outline////
	if(pointerOutlineStage > 0) {
		Stroke normalStroke = g.getStroke();
		g.setStroke(new BasicStroke(POINTER_SECONDARY_OUTLINE_WIDTH));
		
		
		int colorAlpha = (int) (255 * pointerOutlineStage);
		g.setColor(new Color(Pointer.POINTER_SECONDARY_COLOR.getRed(), Pointer.POINTER_SECONDARY_COLOR.getGreen(), Pointer.POINTER_SECONDARY_COLOR.getBlue(), colorAlpha));
		
		int outlineRadius = Player.SELECT_POINTER_SECONDARY_DISTANCE_LIMIT;
		g.drawOval((int) x - outlineRadius, (int) y - (height / 2) - outlineRadius, outlineRadius * 2, outlineRadius * 2);
		
		
		g.setStroke(normalStroke);
	}
}
 
开发者ID:ProjectK47,项目名称:Mafia,代码行数:19,代码来源:PlayerLocal.java

示例8: draw

import java.awt.Graphics2D; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void draw(Graphics g, RectBounds rect) {
    Graphics2D g2 = (Graphics2D) g;
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
            RenderingHints.VALUE_ANTIALIAS_ON);
    g2.setRenderingHint(RenderingHints.KEY_RENDERING,
            RenderingHints.VALUE_RENDER_QUALITY);
    g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
            RenderingHints.VALUE_INTERPOLATION_BICUBIC);
    g2.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING,
            RenderingHints.VALUE_COLOR_RENDER_QUALITY);
    g2.setColor(color);
    g2.drawOval(center.x - radius - rect.getMinX(), center.y - radius
            - rect.getMinY(), 2 * radius, 2 * radius);
}
 
开发者ID:fgulan,项目名称:java-course,代码行数:19,代码来源:Circle.java

示例9: iscrtaj

import java.awt.Graphics2D; //导入方法依赖的package包/类
public void iscrtaj(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;

    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
            RenderingHints.VALUE_ANTIALIAS_ON);
    g2.setRenderingHint(RenderingHints.KEY_RENDERING,
            RenderingHints.VALUE_RENDER_QUALITY);
    g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
            RenderingHints.VALUE_INTERPOLATION_BICUBIC);
    g2.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING,
            RenderingHints.VALUE_COLOR_RENDER_QUALITY);
    if (bojaPozadine != null) {
        g2.setColor(bojaPozadine);
        g2.fillOval(centar.x - radius, centar.y - radius, radius * 2,
                radius * 2);
    }

    g2.setColor(bojaObruba);
    g2.drawOval(centar.x - radius, centar.y - radius, radius * 2,
            radius * 2);

}
 
开发者ID:fgulan,项目名称:java-course,代码行数:23,代码来源:Krug.java

示例10: paintComponent

import java.awt.Graphics2D; //导入方法依赖的package包/类
@Override
protected void paintComponent(Graphics g) {
    if (!isEnabled()) {
        return;
    }
    Graphics2D g2d = (Graphics2D) g.create();
    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2d.setColor(color);
    Point topLeft = getTopLeftCorner();
    g2d.fillOval(topLeft.x, topLeft.y, SIZE.width, SIZE.height);
    g2d.setColor(UIHelper.getColor("ConnectorPoint.border"));
    g2d.drawOval(topLeft.x, topLeft.y, SIZE.width, SIZE.height);
    g2d.dispose();
}
 
开发者ID:VISNode,项目名称:VISNode,代码行数:15,代码来源:JConnectorPoint.java

示例11: paintOffset

import java.awt.Graphics2D; //导入方法依赖的package包/类
public static void paintOffset(Graphics2D g2d, Point p) {

        g2d.setColor(Color.red);
        int r = 4, x = p.x, y = p.y, dz = 4;
        g2d.setStroke(STROKE_OFFSET);
        g2d.drawLine(x, y - (r + dz), x, y + (r + dz));// --
        g2d.drawLine(x - (r + dz), y, x + (r + dz), y);// |
        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                RenderingHints.VALUE_ANTIALIAS_ON);
        g2d.setStroke(STROKE_OFFSET);
        g2d.drawOval(x - r, y - r, 2 * r, 2 * r);
        g2d.dispose();

    }
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:15,代码来源:Canvas.java

示例12: createTrayIconImage

import java.awt.Graphics2D; //导入方法依赖的package包/类
private static Image createTrayIconImage() {
    /**
     * Create a small image of a red circle to use as the icon for the tray icon
     */
    int trayIconImageSize = 32;
    final BufferedImage trayImage = new BufferedImage(trayIconImageSize, trayIconImageSize, BufferedImage.TYPE_INT_ARGB);
    final Graphics2D trayImageGraphics = (Graphics2D) trayImage.getGraphics();

    trayImageGraphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    trayImageGraphics.setColor(new Color(255, 255, 255, 0));
    trayImageGraphics.fillRect(0, 0, trayImage.getWidth(), trayImage.getHeight());

    trayImageGraphics.setColor(Color.red);

    int trayIconImageInset = 4;
    trayImageGraphics.fillOval(trayIconImageInset,
            trayIconImageInset,
            trayImage.getWidth() - 2 * trayIconImageInset,
            trayImage.getHeight() - 2 * trayIconImageInset);

    trayImageGraphics.setColor(Color.darkGray);

    trayImageGraphics.drawOval(trayIconImageInset,
            trayIconImageInset,
            trayImage.getWidth() - 2 * trayIconImageInset,
            trayImage.getHeight() - 2 * trayIconImageInset);

    return trayImage;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:31,代码来源:PopupMenuLeakTest.java

示例13: paint

import java.awt.Graphics2D; //导入方法依赖的package包/类
public boolean paint(Graphics g) {
	if (isMovePresent()) {
		prepareDeltas();
	}
	
	boolean ret = !isMovePresent();
	
	Graphics2D g2 = (Graphics2D)g;
	try {
		if (TEAM_COLOR != null) {
			g2.setColor(TEAM_COLOR);
			g2.setStroke(new BasicStroke(3));
			g2.drawOval((x * MAGNIFICATIONX) + dx, (y * MAGNIFICATIONY) + dy, MAGNIFICATIONX, MAGNIFICATIONY);
		}
		g2.drawImage(ret ? getImageToDraw() : getFinalImageToDraw(), (x * MAGNIFICATIONX) + dx, (y * MAGNIFICATIONY) + dy, MAGNIFICATIONX, MAGNIFICATIONY, null);
	} catch (Exception e) {
	}
	if ((x * MAGNIFICATIONX) + dx == (moveX * MAGNIFICATIONX)) {
		dx = 0;
		x = moveX;
	}
	if ((y * MAGNIFICATIONY) + dy == (moveY * MAGNIFICATIONY)) {
		dy = 0;
		y = moveY;
	}
	if ((x * MAGNIFICATIONX) + dx == (moveX * MAGNIFICATIONX) && (y * MAGNIFICATIONY) + dy == (moveY * MAGNIFICATIONY)) {
		setLocation(moveX, moveY);
	}
	
	return ret;
}
 
开发者ID:gamefest2017,项目名称:ants,代码行数:32,代码来源:SimpleGUIComponent.java

示例14: makeOval

import java.awt.Graphics2D; //导入方法依赖的package包/类
private static void makeOval(Graphics2D graphics, ImageSize maxSize, Random rand) {
	switchColor(graphics, rand);
	
	int x = rand.nextInt(maxSize.getWidth());
	int y = rand.nextInt(maxSize.getHeight());
	int width = rand.nextInt(maxSize.getWidth() - x) + 1;
	int height = rand.nextInt(maxSize.getHeight() - y) + 1;

	if (rand.nextBoolean()) {
		graphics.fillOval(x, y, width, height);
	}

	graphics.drawOval(x, y, width, height);
}
 
开发者ID:DescartesResearch,项目名称:Pet-Supply-Store,代码行数:15,代码来源:ImageCreator.java

示例15: getRecordImage

import java.awt.Graphics2D; //导入方法依赖的package包/类
/**
* Creates an icon for symbolizing the recording of a {@code KeyStroke}.
* @return The {@code ImageIcon}.
*/
public static ImageIcon getRecordImage() {
    BufferedImage bi = new BufferedImage(9, 9, BufferedImage.TYPE_INT_ARGB);
    Graphics2D g = bi.createGraphics();
    g.setColor(Color.RED);
    g.fillOval(0, 0, 9, 9);
    g.setColor(Color.BLACK);
    g.drawOval(0, 0, 9, 9);
    g.dispose();
    return new ImageIcon(bi);
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:15,代码来源:FreeColActionUI.java


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