Advertisement
Guest User

Untitled

a guest
May 12th, 2014
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. package be.wout.draw.shapes;
  2.  
  3. import java.awt.Color;
  4. import java.awt.Graphics;
  5. import java.awt.image.BufferedImage;
  6.  
  7. import be.wout.staticThings.StaticVars;
  8.  
  9. public class Rectangle extends Shape
  10. {
  11.  
  12. public Rectangle(int x, int y, int x2, int y2, Color c)
  13. {
  14. super(x, y, x2, y2, c);
  15.  
  16. }
  17.  
  18. @Override
  19. public void render(Graphics g)
  20. {
  21.  
  22. g.setColor(getColor());
  23. int w = calcWidth();
  24. int h = calcHeight();
  25.  
  26. if (w <= 0 && h <= 0)
  27. {
  28. w = Math.abs(w);
  29. h = Math.abs(h);
  30. if (StaticVars.shapeFilled)
  31. {
  32. g.fillRect(getX2(), getY2(), w, h);
  33. }
  34. else
  35. {
  36. g.drawRect(getX2(), getY2(), w, h);
  37. }
  38.  
  39. }
  40. else if (w < 0 && h >= 0)
  41. {
  42. w = Math.abs(w);
  43. h = Math.abs(h);
  44.  
  45. if (StaticVars.shapeFilled)
  46. {
  47. g.fillRect(getX2(), getY(), w, h);
  48. }
  49. else
  50. {
  51. g.drawRect(getX2(), getY(), w, h);
  52. }
  53.  
  54. }
  55. else if (w >= 0 && h < 0)
  56. {
  57. w = Math.abs(w);
  58. h = Math.abs(h);
  59. if (StaticVars.shapeFilled)
  60. {
  61. g.fillRect(getX(), getY2(), w, h);
  62. }
  63. else
  64. {
  65. g.drawRect(getX(), getY2(), w, h);
  66. }
  67. }
  68. else
  69. {
  70. if (StaticVars.shapeFilled)
  71. {
  72. g.fillRect(getX(), getY(), w, h);
  73. }
  74. else
  75. {
  76. g.drawRect(getX(), getY(), w, h);
  77. }
  78. }
  79. }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement