Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package cells;
- import java.awt.*;
- import java.awt.event.*;
- /**
- *
- * @author Tirmen
- */
- public class CellsPanel extends Panel{
- final static int freq=10;
- CellsGame cell;
- public CellsPanel(){
- this.cell=new CellsGame(CellsApp.horsize,CellsApp.versize,CellsApp.first,CellsApp.second);
- }
- public int lilSqHei(){
- return this.getHeight()/((1+freq)*this.cell.height+1);
- }
- public int lilSqWid(){
- return this.getWidth()/((1+freq)*this.cell.width+1);
- }
- public void paint(Graphics g){
- super.paint(g);
- int height=this.getHeight();
- int width=this.getWidth();
- int sqheight=lilSqHei();
- int sqwidth=lilSqWid();
- g.setColor(Color.LIGHT_GRAY);
- g.fillRect(0, 0, width, height);
- g.setColor(Color.BLACK);
- for(int i=0;i<this.cell.height+1;i++)
- for(int j=0;j<this.cell.width+1;j++)
- g.fillRect(j*(1+freq)*sqwidth, i*(1+freq)*sqheight, sqwidth, sqheight);
- for(int i=0;i<this.cell.height;i++)
- for(int j=0;j<this.cell.width;j++){
- switch(this.cell.cellsColor[i][j]){
- case (1): g.setColor(this.cell.player[0]);break;
- case (2): g.setColor(this.cell.player[1]);break;
- default: g.setColor(Color.BLACK);
- }
- g.fillRect(j*(1+freq)*sqwidth+sqwidth, i*(1+freq)*sqheight+sqheight, freq*sqwidth, freq*sqheight);
- }
- for(int i=0;i<this.cell.height+1;i++)
- for(int j=0;j<this.cell.width;j++){
- switch(this.cell.horStaff[i][j]){
- case (1): g.setColor(this.cell.player[0]);break;
- case (2): g.setColor(this.cell.player[1]);break;
- default: g.setColor(Color.BLACK);
- }
- g.fillRect(j*(1+freq)*sqwidth+sqwidth, i*(1+freq)*sqheight, freq*sqwidth, sqheight);
- }
- for(int i=0;i<this.cell.height;i++)
- for(int j=0;j<this.cell.width+1;j++){
- switch(this.cell.verStaff[i][j]){
- case (1): g.setColor(this.cell.player[0]);break;
- case (2): g.setColor(this.cell.player[1]);break;
- default: g.setColor(Color.BLACK);
- }
- g.fillRect(j*(1+freq)*sqwidth, i*(1+freq)*sqheight+sqheight, sqwidth, freq*sqheight);
- }
- }
- }
Add Comment
Please, Sign In to add comment