001   /**
002    * In previous examples, we saw some jagged edges due to aliasing.
003    * Example05 illustrates how to use rendering hints to request
004    * an anti-aliased render from Graphics2D.
005    **/
006   public void paint(Graphics g) {
007     Graphics2D g2d = (Graphics2D) g;
008
009     //This time, we want to use anti-aliasing if possible
010     //to avoid the jagged edges that were so prominent in
011     //our last example.  With ask the Java 2D rendering
012     //engine (Graphics2D) to do this using a "rendering hint".
013     g2d.setRenderingHints(Graphics2D.ANTIALIASING,
014        Graphics2D.ANTIALIAS_ON);
015
016     //We reuse our GeneralPath filled shape.  We translate
017     //and rotate this shape as we did before.
018     GeneralPath path = new GeneralPath(GeneralPath.EVEN_ODD);
019     path.moveTo(0.0f,0.0f);
020     path.lineTo(0.0f,125.0f);
021     path.quadTo(100.0f,100.0f,225.0f,125.0f);
022     path.curveTo(260.0f,100.0f,130.0f,50.0f,225.0f,0.0f);
023     path.closePath();
024
025     AffineTransform at = new AffineTransform();
026     at.setToRotation(-Math.PI/8.0);
027     g2d.transform(at);
028     at.setToTranslation(0.0f,150.0f);
029     g2d.transform(at);
030
031     g2d.setColor(Color.green);
032     g2d.fill(path);
033
034     Font exFont = new Font("TimesRoman",Font.PLAIN,40);
035     g2d.setFont(exFont);
036     g2d.setColor(Color.black);
037     g2d.drawString("JavaWorld",0.0f,0.0f);
038   }

