Guest User

Untitled

a guest
Dec 13th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. public abstract class Shapes {
  2. protected int xs1,ys1,xs2,ys2;
  3. public Paint style;
  4. protected int ColorIndex;
  5. protected Paint.Style PaintStyle;
  6. Shapes(){
  7. style = new Paint();
  8. setPaintStyle(Paint.Style.FILL);
  9. style.setStrokeWidth(12);
  10. setColorIndex(Color.BLACK);
  11. style.setAntiAlias(true);
  12. }
  13. // Shapes(int color,Paint.Style pstyle){
  14. // setColorIndex(color);
  15. // setPaintStyle(pstyle);
  16. //style.setColor(Color.CYAN);
  17. // }
  18. public final void Set(int x1,int y1,int x2,int y2)
  19. {
  20. xs1 = x1;
  21. ys1 = y1;
  22. xs2 = x2;
  23. ys2 = y2;
  24. }
  25. public void setColorIndex(int index){
  26. this.ColorIndex = index;
  27. }
  28. public int getColorIndex(){
  29. return ColorIndex;
  30. }
  31. public void setPaintStyle(Paint.Style pstyle){
  32. this.PaintStyle= pstyle;
  33. }
  34. public Paint.Style getPaintStyle(){
  35. return PaintStyle;
  36. }
  37. public void Show(Canvas canvas){
  38.  
  39. }
  40. }
  41.  
  42. public class RectShape extends Shapes{
  43. // public RectShape(){
  44. // super();
  45. // }
  46. public RectShape(int color,Paint.Style pstyle){
  47. //super(color,pstyle);
  48. super();
  49. setColorIndex(color);
  50. setPaintStyle(pstyle);
  51. //style.setColor(Color.CYAN);
  52. }
  53.  
  54. @Override
  55. public void Show(Canvas canvas){
  56. if(xs2>xs1 && ys2>ys1)
  57. canvas.drawRect(xs1,ys1,xs2,ys2, style);
  58. else if(xs2<xs1 && ys2>ys1)
  59. canvas.drawRect(xs2,ys1,xs1,ys2, style);
  60. else if(xs2>xs1 && ys2<ys1)
  61. canvas.drawRect(xs1,ys2,xs2,ys1, style);
  62. else
  63. canvas.drawRect(xs2,ys2,xs1,ys1, style);
  64. }
  65. }
Add Comment
Please, Sign In to add comment