1 18 package org.apache.batik.svggen; 19 20 import java.awt.*; 21 import java.awt.geom.*; 22 23 31 public class BasicShapes2 implements Painter { 32 public void paint(Graphics2D g) { 33 g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, 34 RenderingHints.VALUE_ANTIALIAS_ON); 35 36 g.setPaint(Color.black); 37 38 g.drawString("Arc2D", 10, 20); 40 Arc2D arc = new Arc2D.Float(10, 30, 50, 40, 0, 270, Arc2D.PIE); 41 g.draw(arc); 42 43 g.translate(0, 90); 44 45 g.drawString("Ellipse", 10, 20); 47 Ellipse2D ellipse = new Ellipse2D.Double(10, 30, 100, 40); 48 g.draw(ellipse); 49 50 g.translate(150, -90); 51 52 g.drawString("GeneralPath, lineTo", 10, 20); 54 GeneralPath lineToPath = new GeneralPath(); 55 lineToPath.moveTo(10, 30); 56 lineToPath.lineTo(60, 30); 57 lineToPath.lineTo(60, 70); 58 lineToPath.lineTo(10, 30); 59 lineToPath.closePath(); 60 g.draw(lineToPath); 61 62 g.translate(0, 90); 63 64 g.drawString("GeneralPath, curveTo", 10, 20); 66 GeneralPath curveToPath = new GeneralPath(); 67 curveToPath.moveTo(10, 30); 68 curveToPath.curveTo(35, 10, 35, 50, 60, 30); 69 curveToPath.curveTo(80, 55, 40, 55, 60, 80); 70 curveToPath.curveTo(35, 60, 35, 100, 10, 80); 71 curveToPath.curveTo(-10, 55, 30, 55, 10, 30); 72 curveToPath.closePath(); 73 g.draw(curveToPath); 74 } 75 } 76 | Popular Tags |