Guest User

Untitled

a guest
Oct 23rd, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.52 KB | None | 0 0
  1. /*
  2. * To change this template, choose Tools | Templates
  3. * and open the template in the editor.
  4. */
  5.  
  6. package cells;
  7. import java.awt.*;
  8. import java.awt.event.*;
  9. /**
  10. *
  11. * @author Tirmen
  12. */
  13. public class CellsPanel extends Panel{
  14. final static int freq=10;
  15. CellsGame cell;
  16.  
  17. public CellsPanel(){
  18. this.cell=new CellsGame(CellsApp.horsize,CellsApp.versize,CellsApp.first,CellsApp.second);
  19. }
  20. public int lilSqHei(){
  21. return this.getHeight()/((1+freq)*this.cell.height+1);
  22. }
  23. public int lilSqWid(){
  24. return this.getWidth()/((1+freq)*this.cell.width+1);
  25. }
  26. public void paint(Graphics g){
  27. super.paint(g);
  28. int height=this.getHeight();
  29. int width=this.getWidth();
  30. int sqheight=lilSqHei();
  31. int sqwidth=lilSqWid();
  32. g.setColor(Color.LIGHT_GRAY);
  33. g.fillRect(0, 0, width, height);
  34. g.setColor(Color.BLACK);
  35. for(int i=0;i<this.cell.height+1;i++)
  36. for(int j=0;j<this.cell.width+1;j++)
  37. g.fillRect(j*(1+freq)*sqwidth, i*(1+freq)*sqheight, sqwidth, sqheight);
  38. for(int i=0;i<this.cell.height;i++)
  39. for(int j=0;j<this.cell.width;j++){
  40. switch(this.cell.cellsColor[i][j]){
  41. case (1): g.setColor(this.cell.player[0]);break;
  42. case (2): g.setColor(this.cell.player[1]);break;
  43. default: g.setColor(Color.BLACK);
  44. }
  45. g.fillRect(j*(1+freq)*sqwidth+sqwidth, i*(1+freq)*sqheight+sqheight, freq*sqwidth, freq*sqheight);
  46. }
  47. for(int i=0;i<this.cell.height+1;i++)
  48. for(int j=0;j<this.cell.width;j++){
  49. switch(this.cell.horStaff[i][j]){
  50. case (1): g.setColor(this.cell.player[0]);break;
  51. case (2): g.setColor(this.cell.player[1]);break;
  52. default: g.setColor(Color.BLACK);
  53. }
  54. g.fillRect(j*(1+freq)*sqwidth+sqwidth, i*(1+freq)*sqheight, freq*sqwidth, sqheight);
  55. }
  56. for(int i=0;i<this.cell.height;i++)
  57. for(int j=0;j<this.cell.width+1;j++){
  58. switch(this.cell.verStaff[i][j]){
  59. case (1): g.setColor(this.cell.player[0]);break;
  60. case (2): g.setColor(this.cell.player[1]);break;
  61. default: g.setColor(Color.BLACK);
  62. }
  63. g.fillRect(j*(1+freq)*sqwidth, i*(1+freq)*sqheight+sqheight, sqwidth, freq*sqheight);
  64. }
  65. }
  66. }
Add Comment
Please, Sign In to add comment