List of usage examples for java.awt RenderingHints KEY_ANTIALIASING
Key KEY_ANTIALIASING
To view the source code for java.awt RenderingHints KEY_ANTIALIASING.
Click Source Link
From source file:Main.java
/** * Used after useAntiAliasing/* w ww . j a v a2 s .co m*/ * @param oldAA the value returned from useAntiAliasing */ public static void restoreAntiAliasing(Graphics2D g, Object oldAA) { g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, oldAA); }
From source file:Main.java
public static void draw(BufferedImage imageBG, BufferedImage imageFG) { Ellipse2D.Double ellipse1 = new Ellipse2D.Double(20, 20, 30, 30); Ellipse2D.Double ellipse2 = new Ellipse2D.Double(25, 25, 30, 30); Area circle = new Area(ellipse1); circle.subtract(new Area(ellipse2)); Graphics2D g = imageBG.createGraphics(); g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_ENABLE); g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON); g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); g.setClip(circle);//from w ww .java 2 s . com g.drawImage(imageFG, 0, 0, null); g.setClip(null); Stroke s = new BasicStroke(2); g.setStroke(s); g.setColor(Color.BLACK); g.draw(circle); g.dispose(); JLabel l = new JLabel(new ImageIcon(imageBG)); JOptionPane.showMessageDialog(null, l); }
From source file:Main.java
public static Graphics2D addAntiAliasing(Graphics g) { Graphics2D g2d = (Graphics2D) g; g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); return g2d;/*w ww. j a va 2s. c o m*/ }
From source file:Main.java
/** * Tell the G to use anti aliased drawing and text * @return old AA/* w ww. j av a 2 s . c o m*/ */ public static Object useAntiAliasing(Graphics2D g) { Object oldAA = g.getRenderingHint(RenderingHints.KEY_ANTIALIASING); g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); return oldAA; }
From source file:Main.java
public static void drawRoundBorder(Graphics g, Color c, int x, int y, int w, int h, int r) { Graphics2D g2D = (Graphics2D) g; Object savedRederingHint = g2D.getRenderingHint(RenderingHints.KEY_ANTIALIASING); g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2D.setColor(c);//from w w w.jav a 2 s . c o m g2D.drawRoundRect(x, y, w - 1, h - 1, r, r); g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, savedRederingHint); }
From source file:Main.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); Font font = new Font("Serif", Font.PLAIN, 96); g2.setFont(font);//from w w w. j a v a 2 s.c o m g2.drawString("java2s.com", 40, 120); }
From source file:DrawSimpleText.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); Font font = new Font("Serif", Font.PLAIN, 96); g2.setFont(font);//w w w. ja va 2s . c om g2.drawString("Java Source and Support", 40, 120); }
From source file:Main.java
private static BufferedImage renderRotatedObject(Object src, double angle, int width, int height, double tx, double ty) { BufferedImage dest = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); Graphics2D g2d = (Graphics2D) dest.getGraphics(); g2d.setColor(Color.black);/*from w w w . j ava 2 s .co m*/ g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); AffineTransform at = AffineTransform.getRotateInstance(angle); at.translate(tx, ty); g2d.setTransform(at); if (src instanceof TextLayout) { TextLayout tl = (TextLayout) src; tl.draw(g2d, 0, tl.getAscent()); } else if (src instanceof Image) { g2d.drawImage((Image) src, 0, 0, null); } g2d.dispose(); return dest; }
From source file:TextLayoutOne.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); String s = "Java Source and Support."; Font font = new Font("Serif", Font.PLAIN, 32); TextLayout textLayout = new TextLayout(s, font, g2.getFontRenderContext()); textLayout.draw(g2, 40, 80);//ww w . j a va 2 s . c o m }
From source file:Main.java
public void paint(Graphics g) { Graphics2D g2d = (Graphics2D) g; g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); AttributedString as1 = new AttributedString("1234567890"); as1.addAttribute(TextAttribute.STRIKETHROUGH, TextAttribute.STRIKETHROUGH_ON, 2, 8); g2d.drawString(as1.getIterator(), 15, 60); }