Java Code Examples for java.awt.Graphics.fillOval()

The following are Jave code examples for showing how to use fillOval() of the java.awt.Graphics class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: QN-ACTR-Release   File: DefaultIcons.java   View Source Code Vote up 8 votes
public static Image getStationIcon(String type, Rectangle bounds) {
	BufferedImage bi = new BufferedImage(bounds.width, bounds.height, BufferedImage.TYPE_4BYTE_ABGR);
	Graphics g = bi.getGraphics();
	int qLength = bounds.width * 3 / 5, height = bounds.height, width = bounds.width;
	for (int i = 0, monoChannel = 0; i < 5; i++, monoChannel = (int) ((1 - Math.exp(-i)) * 50)) {
		g.setColor(new Color(230 - monoChannel, 230 - monoChannel, 230 - monoChannel, 255));
		g.drawPolyline(new int[] { i, i, qLength - i }, new int[] { height - i, i, i }, 3);
		g.fillArc(width - height + i, i, height - 2 * i, height - 2 * i, 45, 180);
		g.setColor(new Color(130 + monoChannel, 130 + monoChannel, 130 + monoChannel, 255));
		g.drawPolyline(new int[] { i, qLength - i, qLength - i }, new int[] { height - i, height - i, i }, 3);
		g.fillArc(width - height + i, i, height - 2 * i, height - 2 * i, 225, 180);
	}
	g.fillRect(5, 5, qLength - 9, height - 9);
	g.fillOval(width - height + 5, 5, height - 10, height - 10);
	return bi;
}
 
Example 2
Project: sota-sxt   File: Face.java   View Source Code Vote up 8 votes
@Override
    public void paintComponent(Graphics g){
//        dibujar cara
        g.setColor(Color.YELLOW);
        g.fillOval(10,10,200,200);
        
//        dibujar ojos
        g.setColor(Color.BLACK);
        g.fillOval(55, 65, 30, 30);
        g.fillOval(135, 65, 30, 30);
        
//        dibujar boca
        g.fillOval(50, 110, 120, 60);
        
//        hace la sonrisa
        g.setColor(Color.YELLOW);
        g.fillRect(50,110, 120, 30);
        g.fillOval(50, 120, 120, 40);
        
    }
 
Example 3
Project: Logisim   File: Led.java   View Source Code Vote up 7 votes
@Override
public void paintInstance(InstancePainter painter) {
	InstanceDataSingleton data = (InstanceDataSingleton) painter.getData();
	Value val = data == null ? Value.FALSE : (Value) data.getValue();
	Bounds bds = painter.getBounds().expand(-1);

	Graphics g = painter.getGraphics();
	if (painter.getShowState()) {
		Color onColor = painter.getAttributeValue(Io.ATTR_ON_COLOR);
		Color offColor = painter.getAttributeValue(Io.ATTR_OFF_COLOR);
		Boolean activ = painter.getAttributeValue(Io.ATTR_ACTIVE);
		Object desired = activ.booleanValue() ? Value.TRUE : Value.FALSE;
		g.setColor(val == desired ? onColor : offColor);
		g.fillOval(bds.getX(), bds.getY(), bds.getWidth(), bds.getHeight());
	}
	g.setColor(Color.BLACK);
	GraphicsUtil.switchToWidth(g, 2);
	g.drawOval(bds.getX(), bds.getY(), bds.getWidth(), bds.getHeight());
	GraphicsUtil.switchToWidth(g, 1);
	painter.drawLabel();
	painter.drawPorts();
}
 
Example 4
Project: jmt   File: DefaultIconsToolkit.java   View Source Code Vote up 7 votes
@Override
public Image getStationIcon(String type, Rectangle bounds) {
	int qLength = 60, height = 40, width = 100;
	BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR);
	Graphics g = bi.getGraphics();
	for (int i = 0, monoChannel = 0; i < 10; i++, monoChannel = (int) ((1 - Math.exp(-i)) * 50)) {
		g.setColor(new Color(230 - monoChannel, 230 - monoChannel, 230 - monoChannel));
		g.drawPolyline(new int[] { i, i, qLength - i }, new int[] { height - i, i, i }, 3);
		g.fillArc(width - height + i, i, height - 2 * i, height - 2 * i, 45, 180);
		g.setColor(new Color(130 + monoChannel, 130 + monoChannel, 130 + monoChannel));
		g.drawPolyline(new int[] { i, qLength - i, qLength - i }, new int[] { height - i, height - i, i }, 3);
		g.fillArc(width - height + i, i, height - 2 * i, height - 2 * i, 225, 180);
	}
	g.fillRect(5, 5, qLength - 9, height - 9);
	g.fillOval(width - height + 5, 5, height - 10, height - 10);
	return bi.getScaledInstance(bounds.width, bounds.height, Image.SCALE_SMOOTH);
}
 
Example 5
Project: Logisim   File: PolyTool.java   View Source Code Vote up 6 votes
@Override
public void draw(Canvas canvas, Graphics g) {
	if (active) {
		g.setColor(Color.GRAY);
		int size = locations.size();
		int[] xs = new int[size];
		int[] ys = new int[size];
		for (int i = 0; i < size; i++) {
			Location loc = locations.get(i);
			xs[i] = loc.getX();
			ys[i] = loc.getY();
		}
		g.drawPolyline(xs, ys, size);
		int lastX = xs[xs.length - 1];
		int lastY = ys[ys.length - 1];
		g.fillOval(lastX - 2, lastY - 2, 4, 4);
	}
}
 
Example 6
Project: Logisim   File: Joystick.java   View Source Code Vote up 6 votes
@Override
public void paint(InstancePainter painter) {
	State state = (State) painter.getData();
	if (state == null) {
		state = new State(0, 0);
		painter.setData(state);
	}
	Bounds bds = painter.getBounds();
	int x = bds.getX() + 30;
	int y = bds.getY() + 15;
	Graphics g = painter.getGraphics();
	g.setColor(Color.BLACK);
	g.fillOval(x - 19, y - 4, 8, 8);
	GraphicsUtil.switchToWidth(g, 3);
	int dx = state.xPos;
	int dy = state.yPos;
	int x0 = x - 15 + (dx > 5 ? 1 : dx < -5 ? -1 : 0);
	int y0 = y + (dy > 5 ? 1 : dy < 0 ? -1 : 0);
	int x1 = x - 15 + dx;
	int y1 = y + dy;
	g.drawLine(x0, y0, x1, y1);
	Color ballColor = painter.getAttributeValue(Io.ATTR_COLOR);
	Joystick.drawBall(g, x1, y1, ballColor, true);
}
 
Example 7
Project: Logisim   File: Keyboard.java   View Source Code Vote up 5 votes
private void drawDots(Graphics g, int x, int y, int width, int ascent) {
	int r = width / 10;
	if (r < 1)
		r = 1;
	int d = 2 * r;
	if (2 * r + 1 * d <= width)
		g.fillOval(x + r, y - d, d, d);
	if (3 * r + 2 * d <= width)
		g.fillOval(x + 2 * r + d, y - d, d, d);
	if (5 * r + 3 * d <= width)
		g.fillOval(x + 3 * r + 2 * d, y - d, d, d);
}
 
Example 8
Project: openjdk-jdk10   File: MenuItemIconTest.java   View Source Code Vote up 5 votes
protected static ImageIcon createIcon() {
    BufferedImage bi = new BufferedImage(IMAGE_WIDTH_AND_HEIGHT,
            IMAGE_WIDTH_AND_HEIGHT, BufferedImage.TYPE_INT_ARGB);
    Graphics g = bi.createGraphics();
    g.setColor(Color.RED);
    g.fillOval(0, 0, IMAGE_WIDTH_AND_HEIGHT, IMAGE_WIDTH_AND_HEIGHT);
    return new ImageIcon(bi);
}
 
Example 9
Project: Logisim   File: WiringTool.java   View Source Code Vote up 5 votes
@Override
public void draw(Canvas canvas, ComponentDrawContext context) {
	// draw wire's shadow after mouse move
	Graphics g = context.getGraphics();
	if (exists) {
		Location e0 = start;
		Location e1 = cur;
		Wire shortenBefore = willShorten(start, cur);
		if (shortenBefore != null) {
			Wire shorten = getShortenResult(shortenBefore, start, cur);
			if (shorten == null) {
				return;
			} else {
				e0 = shorten.getEnd0();
				e1 = shorten.getEnd1();
			}
		}
		int x0 = e0.getX();
		int y0 = e0.getY();
		int x1 = e1.getX();
		int y1 = e1.getY();

		g.setColor(Color.BLACK);
		GraphicsUtil.switchToWidth(g, 3);
		if (direction == HORIZONTAL) {
			if (x0 != x1)
				g.drawLine(x0, y0, x1, y0);
			if (y0 != y1)
				g.drawLine(x1, y0, x1, y1);
		} else if (direction == VERTICAL) {
			if (y0 != y1)
				g.drawLine(x0, y0, x0, y1);
			if (x0 != x1)
				g.drawLine(x0, y1, x1, y1);
		}
	} else if (AppPreferences.ADD_SHOW_GHOSTS.getBoolean() && inCanvas) {
		g.setColor(Color.GRAY);
		g.fillOval(cur.getX() - 2, cur.getY() - 2, 5, 5);
	}
}
 
Example 10
Project: jmt   File: PainterConvex2D.java   View Source Code Vote up 5 votes
/**
 * It draws the points contained in a vector. The coordinates of the point must be insered 
 * in a Point2D object
 * @param g The graphic object
 * @param points The Vector who contains the points
 * @param c The color of the points
 */
public void drawPoint(Graphics g, Vector<Point2D> points, Color c, int size) {

	for (int j = 0; j < points.size(); j++) {
		Point2D p = points.get(j);
		g.setColor(c);
		g.fillOval((int) (p.getX() * scale) - ((size / 2)) + tran_x, tran_y - (int) (p.getY() * scale) - ((size / 2)), size, size);
	}
}
 
Example 11
Project: jmt   File: DefaultIconsToolkit.java   View Source Code Vote up 5 votes
@Override
public Image getJobIcon(Rectangle bounds) {
	int width = 100, height = 100;
	BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR);
	Graphics g = bi.getGraphics();
	g.setColor(new Color(0, 0, 0, 50));
	g.fillOval(0, 0, width, height);
	for (int i = 0, monoChannel = 0; i < 10; i++, monoChannel = (int) ((1 - Math.exp(-i * 0.5)) * 255)) {
		g.setColor(new Color(monoChannel, monoChannel, monoChannel, 255));
		int r = (int) Math.pow(i, 1.5), s = (int) (r * 2.9);
		g.fillOval(r, r, width - s, height - s);
	}
	return bi.getScaledInstance(bounds.width, bounds.height, Image.SCALE_SMOOTH);
}
 
Example 12
Project: QN-ACTR-Release   File: SampleQNAnimation.java   View Source Code Vote up 5 votes
private void createCPU(Graphics g) {
	cpuPhase = (cpuPhase - 6) % 360;
	int width = getBounds().width, height = getBounds().height, x = getBounds().x, y = getBounds().y, turn = colors.length;
	g.setColor(Color.WHITE);
	g.fillOval(width - height + x + 1, y + 1, height - 2, height - 2);
	for (int i = 0; i < turn; i++) {
		g.setColor(colors[i % colors.length]);
		g.fillArc(width - height + x, y, height, height, (int) cpuPhase + (i * 360) / turn, 360 / turn);
	}
}
 
Example 13
Project: hearthstone   File: Furtividade.java   View Source Code Vote up 5 votes
@Override
public void paintComponent(Graphics g) {
    g.setColor(new Color(0, 0, 0, 120));
    g.fillOval(16, 10, 105, 140);
    g.drawImage(Img.getCirculo(Images.CARD_NEVOA, 0, 0, 110, 145).getImage(),
            15, 7, null);
}
 
Example 14
Project: QN-ACTR-Release   File: SmallCDF.java   View Source Code Vote up 5 votes
@Override
	public void paintComponent(Graphics g) {
		double[] x = model.getListObservations();
		
		super.paintComponent(g);
		g.setColor(Color.WHITE);
		g.fillRect(0, 0, 202, 202);
		//Draw Border
		g.setColor(Color.BLACK);
		g.drawRect(0, 0, 202, 202);
		//Draw gray lines\
		Graphics2D g1 = (Graphics2D) g;
		g1.setColor(Color.LIGHT_GRAY);
		for (int i = 1; i < 9; i++) {
			g1.drawLine(1, 1 + (i * (202 / 9)), 201, 1 + (i * (202 / 9)));
			g1.drawLine(1 + (i * (202 / 9)), 1, 1 + (i * (202 / 9)), 202);
		}
		g1.setColor(Color.BLACK);
		for (int i = 1; i < 9; i++) {
			g1.drawLine(1, 1 + (i * (202 / 9)), 6, 1 + (i * (202 / 9)));
			g1.drawLine(1 + (i * (202 / 9)), 1, 1 + (i * (202 / 9)), 6);
			g1.drawLine(197, 1 + (i * (202 / 9)), 202, 1 + (i * (202 / 9)));
			g1.drawLine(1 + (i * (202 / 9)), 198, 1 + (i * (202 / 9)), 202);
		}
	
		//Draw graph
		//Draw reference line
		g.setColor(Color.BLUE);
		for (int i = 0; i < x.length; i++) {
			g.fillOval((int) Math.round((x[i] / x[x.length-1]) * 200),
					200 - (int) Math.round((i*(1d/x.length)) * 200), 5, 5);
		}
		
		//g.fillOval(200,1, 5, 5);

}
 
Example 15
Project: openjdk-jdk10   File: MultiResolutionRenderingHintsTest.java   View Source Code Vote up 5 votes
private static BufferedImage createRVImage(int size, Color color) {
    BufferedImage image = new BufferedImage(size, size, BufferedImage.TYPE_INT_RGB);
    Graphics g = image.createGraphics();
    g.setColor(Color.BLACK);
    g.fillRect(0, 0, size, size);
    g.setColor(color);
    g.fillOval(0, 0, size, size);
    g.dispose();
    return image;
}
 
Example 16
Project: VASSAL-src   File: GridEditor.java   View Source Code Vote up 5 votes
protected void highlight(Graphics g, Point p) {
  final int r1 = 3;
  final int r2 = 10;

  if (p != null) {
    g.setColor(Color.red);
    g.fillOval(p.x-r1/2, p.y-r1/2, r1, r1);
    g.drawOval(p.x-r2/2, p.y-r2/2, r2, r2);
  }
}
 
Example 17
Project: Logisim   File: Pin.java   View Source Code Vote up 4 votes
private void paintIconBase(InstancePainter painter, BitWidth w) {
	PinAttributes attrs = (PinAttributes) painter.getAttributeSet();
	Direction dir = attrs.facing;
	boolean output = attrs.isOutput();
	boolean iconprinted = false;
	Graphics g = painter.getGraphics();
	g.setFont(ICON_WIDTH_FONT);
	if (output) {
		if (w.equals(BitWidth.ONE) && ICON_OUT != null) {
			Icons.paintRotated(g, 2, 2, dir, ICON_OUT, painter.getDestination());
			iconprinted = true;
		} else if (ICON_OUT_MULTI != null) {
			Icons.paintRotated(g, 2, 2, dir, ICON_OUT_MULTI, painter.getDestination());
			iconprinted = true;
		}
	} else {
		if (w.equals(BitWidth.ONE) && ICON_IN != null) {
			Icons.paintRotated(g, 2, 2, dir, ICON_IN, painter.getDestination());
			iconprinted = true;
		} else if (ICON_IN_MULTI != null) {
			Icons.paintRotated(g, 2, 2, dir, ICON_IN_MULTI, painter.getDestination());
			iconprinted = true;
		}
	}
	if (!iconprinted) {
		int pinx = 16;
		int piny = 9;
		if (dir == Direction.EAST) { // keep defaults
		} else if (dir == Direction.WEST) {
			pinx = 4;
		} else if (dir == Direction.NORTH) {
			pinx = 9;
			piny = 4;
		} else if (dir == Direction.SOUTH) {
			pinx = 9;
			piny = 16;
		}
		g.setColor(w.equals(BitWidth.ONE) ? Value.TRUE.getColor() : Color.WHITE);
		if (output) {
			g.fillOval(4, 4, 13, 13);
		} else {
			g.fillRect(4, 4, 13, 13);
		}
		g.fillOval(pinx, piny, 3, 3);

		g.setColor(Color.black);
		if (output) {
			g.drawOval(4, 4, 13, 13);
		} else {
			g.drawRect(4, 4, 13, 13);
		}
	}
	if (w.equals(BitWidth.ONE))
		g.setColor(Color.WHITE);
	else
		g.setColor(Color.BLACK);
	GraphicsUtil.drawCenteredText(g, "" + w.getWidth(), 10, 9);
}
 
Example 18
Project: Logisim   File: PainterDin.java   View Source Code Vote up 4 votes
private static void paint(InstancePainter painter, int width, int height, boolean drawBubble, int dinType) {
	Graphics g = painter.getGraphics();
	int xMid = -width;
	int y0 = -height / 2;
	if (drawBubble) {
		width -= 8;
	}
	int diam = Math.min(height, 2 * width);
	if (dinType == AND) {
		; // nothing to do
	} else if (dinType == OR) {
		paintOrLines(painter, width, height, drawBubble);
	} else if (dinType == XOR || dinType == XNOR) {
		int elen = Math.min(diam / 2 - 10, 20);
		int ex0 = xMid + (diam / 2 - elen) / 2;
		int ex1 = ex0 + elen;
		g.drawLine(ex0, -5, ex1, -5);
		g.drawLine(ex0, 0, ex1, 0);
		g.drawLine(ex0, 5, ex1, 5);
		if (dinType == XOR) {
			int exMid = ex0 + elen / 2;
			g.drawLine(exMid, -8, exMid, 8);
		}
	} else {
		throw new IllegalArgumentException("unrecognized shape");
	}

	GraphicsUtil.switchToWidth(g, 2);
	int x0 = xMid - diam / 2;
	Color oldColor = g.getColor();
	if (painter.getShowState()) {
		Value val = painter.getPort(0);
		g.setColor(val.getColor());
	}
	g.drawLine(x0 + diam, 0, 0, 0);
	g.setColor(oldColor);
	if (height <= diam) {
		g.drawArc(x0, y0, diam, diam, -90, 180);
	} else {
		int x1 = x0 + diam;
		int yy0 = -(height - diam) / 2;
		int yy1 = (height - diam) / 2;
		g.drawArc(x0, y0, diam, diam, 0, 90);
		g.drawLine(x1, yy0, x1, yy1);
		g.drawArc(x0, y0 + height - diam, diam, diam, -90, 90);
	}
	g.drawLine(xMid, y0, xMid, y0 + height);
	if (drawBubble) {
		g.fillOval(x0 + diam - 4, -4, 8, 8);
		xMid += 4;
	}
}
 
Example 19
Project: QN-ACTR-Release   File: SmallPDF.java   View Source Code Vote up 4 votes
@Override
	public void paintComponent(Graphics g) {
		double[] x = model.getListObservations();
		double[] freq_y = new double[Math.round(x.length/10)];
		
		super.paintComponent(g);
		g.setColor(Color.WHITE);
		g.fillRect(0, 0, 202, 202);
		//Draw Border
		g.setColor(Color.BLACK);
		g.drawRect(0, 0, 202, 202);
		//Draw gray lines\
		Graphics2D g1 = (Graphics2D) g;
		g1.setColor(Color.LIGHT_GRAY);
		for (int i = 1; i < 9; i++) {
			g1.drawLine(1, 1 + (i * (202 / 9)), 201, 1 + (i * (202 / 9)));
			g1.drawLine(1 + (i * (202 / 9)), 1, 1 + (i * (202 / 9)), 202);
		}
		g1.setColor(Color.BLACK);
		for (int i = 1; i < 9; i++) {
			g1.drawLine(1, 1 + (i * (202 / 9)), 6, 1 + (i * (202 / 9)));
			g1.drawLine(1 + (i * (202 / 9)), 1, 1 + (i * (202 / 9)), 6);
			g1.drawLine(197, 1 + (i * (202 / 9)), 202, 1 + (i * (202 / 9)));
			g1.drawLine(1 + (i * (202 / 9)), 198, 1 + (i * (202 / 9)), 202);
		}
		
		//build the count of frequencies
		int j=0;
		double bucket_dim = x[x.length-1] / Math.round(x.length/10);
		for(int i=0;i<freq_y.length;i++) {
			
			while((x[j] < (i+1)*bucket_dim) && (x[j] >= i*bucket_dim)) {
				freq_y[i]++;
				j++;
			}
			
			if(i<(freq_y.length-1))
				freq_y[i] /= x.length;
			
			//System.out.println("Bucket from "+ i*bucket_dim + " to " + (i+1)*bucket_dim + " Percentage: " + freq_y[i]);
		}
		freq_y[freq_y.length-1]++;
		freq_y[freq_y.length-1] /= x.length;
		//******************************
	
		//Draw graph
		//Draw reference line
		g.setColor(Color.BLUE);
		for (int i = 0; i < freq_y.length; i++) {
			//System.out.println("x: " + Math.round((((i+1)*bucket_dim + i*bucket_dim)/2)/x[x.length-1] * 200) + " y: " + (int) Math.round(freq_y[i] * 200));
			g.fillOval((int) Math.round(((((i+1)*bucket_dim + i*bucket_dim)/2)/x[x.length-1])* 200),
					200 - (int) Math.round(freq_y[i] * 200), 5, 5);
		}

}
 
Example 20
Project: The-Kraken-Pathfinding   File: NavmeshNode.java   View Source Code Vote up 4 votes
@Override
public void print(Graphics g, GraphicPanel f)
{
	int rayon = 15;
	g.fillOval(f.XtoWindow(position.getX()) - f.distanceXtoWindow(rayon) / 2, f.YtoWindow(position.getY()) - f.distanceYtoWindow(rayon) / 2, f.distanceXtoWindow((int) (rayon)), f.distanceYtoWindow((int) (rayon)));
}