U:\NetBeans\PokeBall\src\graphicslab04\GreatBall.java |
1 package graphicslab04; 2 3 import java.awt.Color; 4 import java.awt.Graphics; 5 import java.awt.Graphics2D; 6 import java.awt.geom.Arc2D; 7 import java.awt.geom.Area; 8 import java.awt.geom.Ellipse2D; 9 10 public class GreatBall extends PokeBall { 11 12 private static final Area wings = new Area(); 13 14 static { 15 wings.add(new Area(new Arc2D.Double(0, 0, 250, 250, 35, 20, Arc2D.PIE))); 16 wings.add(new Area(new Arc2D.Double(0, 0, 250, 250, 125, 20, Arc2D.PIE))); 17 wings.subtract(new Area(new Ellipse2D.Double(50, 50, 150, 150))); 18 wings.intersect(PokeBall.topHalf); 19 } 20 21 private final Area myTopHalf; 22 private final Area myWings; 23 24 public GreatBall(int xp, int yp) { 25 super(xp, yp); 26 myTopHalf = PokeBall.topHalf.createTransformedArea(shift); 27 myWings = wings.createTransformedArea(shift); 28 } 29 30 @Override 31 protected void drawTopHalf(Graphics g) { 32 g.setColor(new Color(0x7070ff)); 33 ((Graphics2D) g).fill(myTopHalf); 34 g.setColor(Color.red); 35 ((Graphics2D) g).fill(myWings); 36 } 37 } 38