@Test public void testFill() { Brush b = new Fill(FOREGROUND); b.draw(ELLIPSE, g2, new Rectangle(0,0,WIDTH,HEIGHT)); for (int x = 0; x < WIDTH; x++) { for (int y = 0; y < HEIGHT; y++) { int dx = (WIDTH/2) - x; int dy = (HEIGHT/2) - y; double d = Math.sqrt(dx*dx + dy*dy); if (d < 149.0) AssertJUnit.assertEquals(image.getRGB(x, y), FOREGROUND.getRGB()); if (d > 151.0) AssertJUnit.assertEquals(image.getRGB(x, y), BACKGROUND.getRGB()); } } }
public void draw (Shape s, Graphics g, Rectangle bounds) { if (g instanceof Graphics2D) { Graphics2D g2 = (Graphics2D) g; AffineTransform transform = new AffineTransform(); Rectangle originalBounds = s.getBounds(); transform.translate(bounds.x, bounds.y); transform.scale((double)bounds.width / (double) originalBounds.width, (double)bounds.height / (double) originalBounds.height); transform.translate(-originalBounds.x, -originalBounds.y); drawTransformed(transform.createTransformedShape(s), g2); } }
Brush { public void draw (Shape s, Graphics g, Rectangle bounds) { if (g instanceof Graphics2D) { Graphics2D g2 = (Graphics2D) g; AffineTransform transform = new AffineTransform(); Rectangle originalBounds = s.getBounds(); transform.translate(bounds.x, bounds.y); transform.scale((double)bounds.width / (double) originalBounds.width, (double)bounds.height / (double) originalBounds.height); transform.translate(-originalBounds.x, -originalBounds.y); drawTransformed(transform.createTransformedShape(s), g2); } } }
Brush { public void draw (Shape s, Graphics g, Rectangle bounds) { if (g instanceof Graphics2D) { Graphics2D g2 = (Graphics2D) g; AffineTransform transform = new AffineTransform(); Rectangle originalBounds = s.getBounds(); transform.translate(bounds.x, bounds.y); transform.scale((double)bounds.width / (double) originalBounds.width, (double)bounds.height / (double) originalBounds.height); transform.translate(-originalBounds.x, -originalBounds.y); drawTransformed(transform.createTransformedShape(s), g2); } }  }
Brush { public void draw (Shape s, Graphics g, Rectangle bounds) { if (g instanceof Graphics2D) { Graphics2D g2 = (Graphics2D) g; AffineTransform transform = new AffineTransform(); Rectangle originalBounds = s.getBounds(); transform.translate(bounds.x, bounds.y); transform.scale((double)bounds.width / (double) originalBounds.width, (double)bounds.height / (double) originalBounds.height); transform.translate(-originalBounds.x, -originalBounds.y); drawTransformed(transform.createTransformedShape(s), g2); } }  void draw(Shape s, Graphics g, Rectangle bounds); }
Brush { public void draw (Shape s, Graphics g, Rectangle bounds) { if (g instanceof Graphics2D) { Graphics2D g2 = (Graphics2D) g; AffineTransform transform = new AffineTransform(); Rectangle originalBounds = s.getBounds(); transform.translate(bounds.x, bounds.y); transform.scale((double)bounds.width / (double) originalBounds.width, (double)bounds.height / (double) originalBounds.height); transform.translate(-originalBounds.x, -originalBounds.y); drawTransformed(transform.createTransformedShape(s), g2); } }  void draw(Shape s, Graphics g, Rectangle bounds);  }