Java Code Examples for java.awt.Graphics#drawOval()
The following examples show how to use
java.awt.Graphics#drawOval() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MyCursor.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
@Override public void paint(Graphics gr) { gr.setColor(Color.GREEN); ((Graphics2D)gr).setStroke(new BasicStroke(3)); gr.translate(width/2, height/2); int R = width/4; gr.drawOval(-R, -R, 2*R, 2*R); gr.drawLine(-R, R, R, -R); }
Example 2
Source File: MyCursor.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
@Override public void paint(Graphics gr) { gr.setColor(Color.GREEN); ((Graphics2D)gr).setStroke(new BasicStroke(3)); gr.translate(width/2, height/2); int R = width/4; gr.drawOval(-R, -R, 2*R, 2*R); gr.drawLine(-R, R, R, -R); }
Example 3
Source File: MyCursor.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Override public void paint(Graphics gr) { gr.setColor(Color.GREEN); ((Graphics2D)gr).setStroke(new BasicStroke(3)); gr.translate(width/2, height/2); int R = width/4; gr.drawOval(-R, -R, 2*R, 2*R); gr.drawLine(-R, R, R, -R); }
Example 4
Source File: RenderTests.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
public void runTest(Object ctx, int numReps) { RenderTests.Context rctx = (RenderTests.Context) ctx; int size = rctx.size - 1; int x = rctx.initX; int y = rctx.initY; Graphics g = rctx.graphics; g.translate(rctx.orgX, rctx.orgY); Color rCArray[] = rctx.colorlist; int ci = rctx.colorindex; if (rctx.animate) { do { if (rCArray != null) { g.setColor(rCArray[ci++ & NUM_RANDOMCOLORMASK]); } g.drawOval(x, y, size, size); if ((x -= 3) < 0) x += rctx.maxX; if ((y -= 1) < 0) y += rctx.maxY; } while (--numReps > 0); } else { do { if (rCArray != null) { g.setColor(rCArray[ci++ & NUM_RANDOMCOLORMASK]); } g.drawOval(x, y, size, size); } while (--numReps > 0); } rctx.colorindex = ci; g.translate(-rctx.orgX, -rctx.orgY); }
Example 5
Source File: Drawgates.java From Logisim with GNU General Public License v3.0 | 5 votes |
static void paintNot(Graphics g, int x, int y, int width, int height) { int[] xp = new int[4]; int[] yp = new int[4]; xp[0] = x - 4; yp[0] = y; xp[1] = x - width; yp[1] = y - height / 2; xp[2] = x - width; yp[2] = y + height / 2; xp[3] = x - 4; yp[3] = y; g.drawPolyline(xp, yp, 4); g.drawOval(x - 4, y - 2, 4, 4); }
Example 6
Source File: Led.java From Logisim with GNU General Public License v3.0 | 5 votes |
@Override public void paintGhost(InstancePainter painter) { Graphics g = painter.getGraphics(); Bounds bds = painter.getBounds(); GraphicsUtil.switchToWidth(g, 2); g.drawOval(bds.getX() + 1, bds.getY() + 1, bds.getWidth() - 2, bds.getHeight() - 2); }
Example 7
Source File: MyCursor.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
@Override public void paint(Graphics gr) { gr.setColor(Color.GREEN); ((Graphics2D)gr).setStroke(new BasicStroke(3)); gr.translate(width/2, height/2); int R = width/4; gr.drawOval(-R, -R, 2*R, 2*R); gr.drawLine(-R, R, R, -R); }
Example 8
Source File: MyCursor.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
@Override public void paint(Graphics gr) { gr.setColor(Color.GREEN); ((Graphics2D)gr).setStroke(new BasicStroke(3)); gr.translate(width/2, height/2); int R = width/4; gr.drawOval(-R, -R, 2*R, 2*R); gr.drawLine(-R, R, R, -R); }
Example 9
Source File: RenderTests.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public void runTest(Object ctx, int numReps) { RenderTests.Context rctx = (RenderTests.Context) ctx; int size = rctx.size - 1; int x = rctx.initX; int y = rctx.initY; Graphics g = rctx.graphics; g.translate(rctx.orgX, rctx.orgY); Color rCArray[] = rctx.colorlist; int ci = rctx.colorindex; if (rctx.animate) { do { if (rCArray != null) { g.setColor(rCArray[ci++ & NUM_RANDOMCOLORMASK]); } g.drawOval(x, y, size, size); if ((x -= 3) < 0) x += rctx.maxX; if ((y -= 1) < 0) y += rctx.maxY; } while (--numReps > 0); } else { do { if (rCArray != null) { g.setColor(rCArray[ci++ & NUM_RANDOMCOLORMASK]); } g.drawOval(x, y, size, size); } while (--numReps > 0); } rctx.colorindex = ci; g.translate(-rctx.orgX, -rctx.orgY); }
Example 10
Source File: RenderTests.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
public void runTest(Object ctx, int numReps) { RenderTests.Context rctx = (RenderTests.Context) ctx; int size = rctx.size - 1; int x = rctx.initX; int y = rctx.initY; Graphics g = rctx.graphics; g.translate(rctx.orgX, rctx.orgY); Color rCArray[] = rctx.colorlist; int ci = rctx.colorindex; if (rctx.animate) { do { if (rCArray != null) { g.setColor(rCArray[ci++ & NUM_RANDOMCOLORMASK]); } g.drawOval(x, y, size, size); if ((x -= 3) < 0) x += rctx.maxX; if ((y -= 1) < 0) y += rctx.maxY; } while (--numReps > 0); } else { do { if (rCArray != null) { g.setColor(rCArray[ci++ & NUM_RANDOMCOLORMASK]); } g.drawOval(x, y, size, size); } while (--numReps > 0); } rctx.colorindex = ci; g.translate(-rctx.orgX, -rctx.orgY); }
Example 11
Source File: RenderTests.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public void runTest(Object ctx, int numReps) { RenderTests.Context rctx = (RenderTests.Context) ctx; int size = rctx.size - 1; int x = rctx.initX; int y = rctx.initY; Graphics g = rctx.graphics; g.translate(rctx.orgX, rctx.orgY); Color rCArray[] = rctx.colorlist; int ci = rctx.colorindex; if (rctx.animate) { do { if (rCArray != null) { g.setColor(rCArray[ci++ & NUM_RANDOMCOLORMASK]); } g.drawOval(x, y, size, size); if ((x -= 3) < 0) x += rctx.maxX; if ((y -= 1) < 0) y += rctx.maxY; } while (--numReps > 0); } else { do { if (rCArray != null) { g.setColor(rCArray[ci++ & NUM_RANDOMCOLORMASK]); } g.drawOval(x, y, size, size); } while (--numReps > 0); } rctx.colorindex = ci; g.translate(-rctx.orgX, -rctx.orgY); }
Example 12
Source File: RenderTests.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
public void runTest(Object ctx, int numReps) { RenderTests.Context rctx = (RenderTests.Context) ctx; int size = rctx.size - 1; int x = rctx.initX; int y = rctx.initY; Graphics g = rctx.graphics; g.translate(rctx.orgX, rctx.orgY); Color rCArray[] = rctx.colorlist; int ci = rctx.colorindex; if (rctx.animate) { do { if (rCArray != null) { g.setColor(rCArray[ci++ & NUM_RANDOMCOLORMASK]); } g.drawOval(x, y, size, size); if ((x -= 3) < 0) x += rctx.maxX; if ((y -= 1) < 0) y += rctx.maxY; } while (--numReps > 0); } else { do { if (rCArray != null) { g.setColor(rCArray[ci++ & NUM_RANDOMCOLORMASK]); } g.drawOval(x, y, size, size); } while (--numReps > 0); } rctx.colorindex = ci; g.translate(-rctx.orgX, -rctx.orgY); }
Example 13
Source File: MyCursor.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
@Override public void paint(Graphics gr) { gr.setColor(Color.GREEN); ((Graphics2D)gr).setStroke(new BasicStroke(3)); gr.translate(width/2, height/2); int R = width/4; gr.drawOval(-R, -R, 2*R, 2*R); gr.drawLine(-R, R, R, -R); }
Example 14
Source File: Moire.java From ThinkJavaCode2 with MIT License | 5 votes |
public void paint(Graphics g) { int i = 90; while (i < getWidth()) { g.drawOval(0, 0, i, i); i = i + 3; } }
Example 15
Source File: AnalogClock.java From DroidUIBuilder with Apache License 2.0 | 5 votes |
public void paint(Graphics g) { // 绘制背景 super.paintBackground(g); Calendar c = Calendar.getInstance(); c.setTime(new Date()); int hrs = c.get(Calendar.HOUR); int min = c.get(Calendar.MINUTE); double hr_a = Math.toRadians(90 - (hrs + min / 60.0) * 30); double hr_m = Math.toRadians(90 - min * 6); if (face_scale == null) { g.setColor(Color.white); g.fillOval(getX(), getY(), getWidth(), getHeight()); g.setColor(Color.black); g.drawOval(getX(), getY(), getWidth(), getHeight()); drawAngleLine(g, hr_a, 0.25); drawAngleLine(g, hr_m, 0.45); } else { g.drawImage(face_scale, getX(), getY(), null); g.drawImage(minute_scale, getX() + getWidth() / 2 - offx, getY(),null); g.drawImage(hour_scale, getX() + getWidth() / 2 - offx, getY(),null); } }
Example 16
Source File: MyCursor.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
@Override public void paint(Graphics gr) { gr.setColor(Color.GREEN); ((Graphics2D)gr).setStroke(new BasicStroke(3)); gr.translate(width/2, height/2); int R = width/4; gr.drawOval(-R, -R, 2*R, 2*R); gr.drawLine(-R, R, R, -R); }
Example 17
Source File: MultiPointCanvas.java From algorithms-nutshell-2ed with MIT License | 5 votes |
/** Properly converts Cartesian coordinates in p into AWT. */ @Override public void drawElement(Graphics sc, IMultiPoint p) { double x = p.getCoordinate(1); // x double y = getHeight() - p.getCoordinate(2); // y sc.setColor(Color.white); sc.fillOval((int)x-4,(int)y-4,8,8); sc.setColor(Color.black); sc.drawOval((int)x-4,(int)y-4,8,8); }
Example 18
Source File: NormalPlaneCanvas.java From SNT with GNU General Public License v3.0 | 4 votes |
protected void drawOverlay(final Graphics g) { final int z = imp.getCurrentSlice() - 1; if (z != last_slice) { final Integer fittedIndex = indexToValidIndex.get(z); if (fittedIndex != null) { final int px = fittedPath.getXUnscaled(fittedIndex.intValue()); final int py = fittedPath.getYUnscaled(fittedIndex.intValue()); final int pz = fittedPath.getZUnscaled(fittedIndex.intValue()); tracerPlugin.setSlicesAllPanes(px, py, pz); tracerPlugin.setCrosshair(px, py, pz); last_slice = z; } } if (valid[z]) g.setColor(Color.RED); else g.setColor(Color.MAGENTA); SNT.log("radiuses[" + z + "] is: " + radiuses[z]); final int x_top_left = screenXD(centre_x_positions[z] - radiuses[z]); final int y_top_left = screenYD(centre_y_positions[z] - radiuses[z]); g.fillRect(screenXD(centre_x_positions[z]) - 2, screenYD(centre_y_positions[z]) - 2, 5, 5); final int diameter = screenXD(centre_x_positions[z] + radiuses[z]) - screenXD(centre_x_positions[z] - radiuses[z]); g.drawOval(x_top_left, y_top_left, diameter, diameter); final double proportion = scores[z] / maxScore; final int drawToX = (int) (proportion * (imp.getWidth() - 1)); if (valid[z]) g.setColor(Color.GREEN); else g.setColor(Color.RED); g.fillRect(screenX(0), screenY(0), screenX(drawToX) - screenX(0), screenY(2) - screenY(0)); final int modeOvalX = screenXD(imp.getWidth() / 2.0 - modeRadiuses[z]); final int modeOvalY = screenYD(imp.getHeight() / 2.0 - modeRadiuses[z]); final int modeOvalDiameter = screenXD(imp.getWidth() / 2.0 + modeRadiuses[z]) - modeOvalX; g.setColor(Color.YELLOW); g.drawOval(modeOvalX, modeOvalY, modeOvalDiameter, modeOvalDiameter); // Show the angle between this one and the other two // so we can see where the path is "pinched": g.setColor(Color.GREEN); final double h = (imp.getWidth() * 3) / 8.0; final double centreX = imp.getWidth() / 2.0; final double centreY = imp.getHeight() / 2.0; final double halfAngle = angles[z] / 2; final double rightX = centreX + h * Math.sin(halfAngle); final double rightY = centreY - h * Math.cos(halfAngle); final double leftX = centreX + h * Math.sin(-halfAngle); final double leftY = centreX - h * Math.cos(halfAngle); g.drawLine(screenXD(centreX), screenYD(centreY), screenXD(rightX), screenYD(rightY)); g.drawLine(screenXD(centreX), screenYD(centreY), screenXD(leftX), screenYD(leftY)); }
Example 19
Source File: AbstractPolarAxis.java From osp with GNU General Public License v3.0 | 4 votes |
/** * Draws the rings for the polar plot. * @param panel * @param g * * @return double the ring separation used */ public double drawRings(double rmax, DrawingPanel panel, Graphics g) { double dr = Math.max(this.dr, 1.0e-9); if(autospaceRings) { int exponent = (int) (Math.log(rmax)/LOG10); double decade = Math.pow(10, exponent-1); dr = decade; while(rmax/dr>5*MAJOR_TIC) { // increase dr if we have more than 25 rings dr *= 2; if((dr/decade>3.5)&&(dr/decade<4.5)) { dr = 5*decade; decade *= 10; } } } else { int nrings = (int) (rmax/dr); while(nrings>10*MAJOR_TIC) { dr *= 2; nrings = (int) (rmax/dr); } } int xcenter = panel.xToPix(0); int ycenter = panel.yToPix(0); int xrad = (int) (panel.getXPixPerUnit()*rmax); int yrad = (int) (panel.getYPixPerUnit()*rmax); if(interiorColor!=null) { g.setColor(interiorColor); g.fillOval(xcenter-xrad, ycenter-yrad, 2*xrad, 2*yrad); } int counter = 0; for(double r = 0; r<=rmax; r += dr) { g.setColor(gridcolor); xrad = panel.xToPix(r)-xcenter; yrad = ycenter-panel.yToPix(r); if(counter%MAJOR_TIC==0) { g.setColor(gridcolor.darker()); } g.drawOval(xcenter-xrad, ycenter-yrad, 2*xrad, 2*yrad); counter++; } return dr; }
Example 20
Source File: Ball.java From JavaExercises with GNU General Public License v2.0 | 4 votes |
void paint(Graphics g) { g.drawOval(x - radius, y - radius, radius * 2, radius * 2); g.drawLine(x + (int)getDX(radius - 4), y + (int)getDY(radius - 4), x + (int)getDX(radius + 4), y + (int)getDY(radius + 4)); }