List of usage examples for java.awt RenderingHints VALUE_ANTIALIAS_ON
Object VALUE_ANTIALIAS_ON
To view the source code for java.awt RenderingHints VALUE_ANTIALIAS_ON.
Click Source Link
From source file:Main.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); Shape ball = new Ellipse2D.Float(i++, i++, 5, 5); g2.setColor(Color.RED);/*from w w w . ja v a 2 s . com*/ g2.fill(ball); }
From source file:ImageDuplicity.java
private void createOffscreenImage() { Dimension d = getSize();//w w w. ja v a 2s. c om int width = d.width; int height = d.height; image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); try { String filename = "largeJava2sLogo.jpg"; InputStream in = getClass().getResourceAsStream(filename); JPEGImageDecoder decoder = JPEGCodec.createJPEGDecoder(in); BufferedImage image = decoder.decodeAsBufferedImage(); in.close(); g2.drawImage(image, 0, 0, width, height, null); } catch (Exception e) { System.out.print(e); } g2.setStroke(new BasicStroke(2)); Color[] colors = { Color.red, Color.blue, Color.green }; for (int i = -32; i < 40; i += 8) { g2.setPaint(colors[Math.abs(i) % 3]); g2.drawOval(i, i, width - i * 2, height - i * 2); } }
From source file:Main.java
@Override protected void paintIndeterminate(Graphics g, JComponent c) { Graphics2D g2d = (Graphics2D) g; g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); r = getBox(r);/*from w ww. j av a 2 s . c o m*/ g.setColor(progressBar.getForeground()); g.fillOval(r.x, r.y, r.width, r.height); }
From source file:BallRoom.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); Shape ball = new Ellipse2D.Float(i++, i++, 5, 5); g2.setColor(Color.RED);/*from w w w.j a va 2 s. co m*/ g2.fill(ball); }
From source file:DashedRectangleDemo2D.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setPaint(Color.gray);/*from w w w .j a va 2 s.c o m*/ int x = 5; int y = 7; g2.setStroke(dashed); g2.draw(new RoundRectangle2D.Double(x, y, 200, 200, 10, 10)); g2.drawString("RoundRectangle2D", x, 250); }
From source file:GuiUtil.java
public static final void setAntiAliasing(Graphics g, boolean yesno) { Object obj = yesno ? RenderingHints.VALUE_ANTIALIAS_ON : RenderingHints.VALUE_ANTIALIAS_OFF; ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, obj); }
From source file:dataminning2.Graphplot.java
protected void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); int w = getWidth(); int h = getHeight(); // Draw ordinate. g2.draw(new Line2D.Double(PAD, PAD, PAD, h - PAD)); // Draw abcissa. g2.draw(new Line2D.Double(PAD, h - PAD, w - PAD, h - PAD)); double xInc = (double) (w - 2 * PAD) / (data.length - 1); double scale = (double) (h - 2 * PAD) / 88; // Mark data points. g2.setPaint(Color.red);//www .j av a2 s .c om int length1 = 0; int length2 = data.length / 3; for (int i = 0; i < length2; i++) { double x = PAD + i * dataX[i]; double y = h - PAD - scale * dataY[i]; g2.fill(new Ellipse2D.Double(x - 2, y - 2, 4, 4)); } g2.setPaint(Color.BLUE); int lengthnew = length1 + length2; length2 = length2 + lengthnew; for (int i = lengthnew; i < length2; i++) { double x = PAD + i * dataX[i]; double y = h - PAD - scale * dataY[i]; g2.fill(new Ellipse2D.Double(x - 2, y - 2, 4, 4)); } g2.setPaint(Color.YELLOW); lengthnew = lengthnew + lengthnew; for (int i = length2; i < data.length; i++) { double x = PAD + i * dataX[i]; double y = h - PAD - scale * dataY[i]; g2.fill(new Ellipse2D.Double(x - 2, y - 2, 4, 4)); } }
From source file:dataminning2.DBScanGraphplot.java
protected void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); int w = getWidth(); int h = getHeight(); // Draw ordinate. g2.draw(new Line2D.Double(PAD, PAD, PAD, h - PAD)); // Draw abcissa. g2.draw(new Line2D.Double(PAD, h - PAD, w - PAD, h - PAD)); double xInc = (double) (w - 2 * PAD) / (data.length - 1); double scale = (double) (h - 2 * PAD) / 88; // Mark data points. g2.setPaint(Color.red);// w w w . j a va 2 s .c o m int length1 = 0; int length2 = data.length / 3; for (int i = 0; i < data.length; i++) { double x = PAD + i * dataX[i]; double y = h - PAD - scale * dataY[i]; g2.fill(new Ellipse2D.Double(x - 2, y - 2, 4, 4)); } }
From source file:Main.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); int cx = getSize().width / 2; int cy = getSize().height / 2; g2.translate(cx, cy);//from ww w . j a va 2 s .c o m g2.rotate(theta * Math.PI / 180); Shape oldClip = g2.getClip(); Shape e = new Ellipse2D.Float(-cx, -cy, cx * 2, cy * 2); g2.clip(e); Shape c = new Ellipse2D.Float(-cx, -cy, cx * 3 / 4, cy * 2); g2.setPaint(new GradientPaint(40, 40, Color.blue, 60, 50, Color.white, true)); g2.fill(c); g2.setPaint(Color.yellow); g2.fillOval(cx / 4, 0, cx, cy); g2.setClip(oldClip); g2.setFont(new Font("Times New Roman", Font.PLAIN, 64)); g2.setPaint(new GradientPaint(-cx, 0, Color.red, cx, 0, Color.black, false)); g2.drawString("Hello, 2D!", -cx * 3 / 4, cy / 4); AlphaComposite ac = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, (float) .75); g2.setComposite(ac); Shape r = new RoundRectangle2D.Float(0, -cy * 3 / 4, cx * 3 / 4, cy * 3 / 4, 20, 20); g2.setStroke(new BasicStroke(4)); g2.setPaint(Color.magenta); g2.fill(r); g2.setPaint(Color.green); g2.draw(r); g2.drawImage(image, -cx / 2, -cy / 2, this); }
From source file:Main.java
@Override protected void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D twoD = (Graphics2D) g; RenderingHints rh = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); rh.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); twoD.setRenderingHints(rh);//from w ww . ja va2 s . c o m twoD.setColor(Color.BLACK); twoD.drawString(raised, 5, 90); }