Advertisement
ridjis

rg4

Mar 19th, 2015
466
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.27 KB | None | 0 0
  1. import java.awt.Graphics;
  2.  
  3. public class Arrow implements BasicPainter {
  4.  
  5.     @Override
  6.     public void paint(Graphics g, int x, int y, int width, int height, boolean fill) {
  7.         int[] xovi = {x, (x + width / 2), (x + width / 2), x + width, (x + width / 2), (x + width / 2), x};
  8.         int[] yoni = {y, y, (y - height / 4), (y + height / 4), (y + 3 * height / 4), (y + height / 2), (y + height / 2)};
  9.         if (fill)
  10.             g.fillPolygon(xovi,yoni,7);
  11.         else
  12.             g.drawPolygon(xovi,yoni,7);
  13.        
  14.     }
  15.  
  16. }
  17.  
  18. import java.awt.Graphics;
  19.  
  20. public class Circle implements BasicPainter {
  21.     @Override
  22.     public void paint(Graphics g, int x, int y, int width, int height, boolean fill) {
  23.         if (!fill)  
  24.             g.drawOval(x, y, width, height);
  25.         else
  26.             g.fillOval(x, y, width, height);
  27.     }
  28. }
  29.  
  30. import java.awt.Graphics;
  31.  
  32. public class Triangle implements BasicPainter {
  33.  
  34.     @Override
  35.     public void paint(Graphics g, int x, int y, int width, int height, boolean fill) {
  36.         if (!fill) {
  37.             g.drawLine(x, y, x + (width / 2), y + height);
  38.             g.drawLine(x + (width / 2), y + height, x - (width / 2), y + height);
  39.             g.drawLine(x - (width / 2), y + height, x, y);
  40.         } else {
  41.             int[] xovi = {x, x + (width / 2), x - (width / 2)};
  42.             int[] yoni = {y, y + height, y + height};
  43.             g.fillPolygon(xovi, yoni, 3);
  44.         }
  45.     }
  46.  
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement