Advertisement
Guest User

Untitled

a guest
Apr 29th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. package drawer;
  2.  
  3. import command.*;
  4.  
  5. import java.util.*;
  6. import java.awt.*;
  7. import java.awt.event.*;
  8. import javax.swing.*;
  9.  
  10. public class DrawCanvas extends Canvas implements Drawable {
  11.  
  12. private Color color = Color.ORANGE;
  13.  
  14. private int radius = 20;
  15.  
  16. private MacroCommand history;
  17.  
  18. public DrawCanvas(int width, int height, MacroCommand history) {
  19. setSize(width, height);
  20. setBackground(Color.white);
  21. this.history = history;
  22. }
  23.  
  24. public void paint(Graphics g) {
  25. history.execute();
  26. }
  27.  
  28. public void draw(int x, int y) {
  29. Graphics g = getGraphics();
  30. g.setColor(color);
  31. g.fillOval(x - radius, y - radius, radius * 2, radius * 2);
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement