class Raster { //PROPERTIES Cell [][] arrayCells; //2D ARRAY mit Namen arrayCells int cellSize; // display size der Zellen int xPos; // Linke obere Ecke des Rasters int yPos; // Linke obere Ecke des Rasters // CONSTRUCTOR Raster( int xCount, int yCount, int mode ) { initCellArray(xCount, yCount, mode); } // METHODEN void initCellArray(int xCount, int yCount, int mode) //Intialisieren des Rasters { arrayCells = new Cell[xCount][yCount]; //2D Array mit grösse der Rasters for(int i=0; i= getXCount() || y >= getYCount() ) { Cell nirvanaCell = new Cell(); //falls die abgefragte Zelle ausserhalb liegt bekommt nirvanaCell.setMode(-1); //sie den Wert -1 return nirvanaCell; // rückgabe des Wertes } return arrayCells[x][y]; } int getXTopRight() //Abfragen x obere rechte Ecke des Rasters { int XTopRight = getRasterSizeX()+getPositionX() ; return XTopRight; } int getXCount() //Abfragen der Anzahl Felder in x-Richtung { int xCount = arrayCells.length ; return xCount; } int getYCount() //Abfragen der Anzahl Felder in y-Richtung { int yCount = arrayCells[0].length ; return yCount; } //SETTER void setCellMode(int xPos, int yPos, int mode) //setzten des Zellenmodus an Position x/y { if (xPos < 0 || yPos <0 || xPos >= getXCount() || yPos >= getYCount() ) { } else { arrayCells[xPos][yPos].setMode(mode); } } /////////////////////////////////////////////////////// //Grösse / Position in Abhängigkeit vom Applet void fitIntoRect(int w, int h) { if ( w / this.getXCount() < h /this.getYCount() ) { setWidth( w ); } else { setHeight( h ); } } void setWidth(int w) { this.cellSize = w / this.getXCount(); } void setHeight(int h) { this.cellSize = h / this.getYCount(); } void setPosition(int x, int y) { this.xPos = x; this.yPos = y; } int getPositionX() { return xPos; } int getPositionY() { return yPos; } void setCellSize(int size) { this.cellSize = size; } int getCellSize() { return this.cellSize; } int getRasterSizeX() { return getXCount()*this.cellSize ; } int getRasterSizeY() { return getYCount()*cellSize ; } /////////////////////////////////////////////////////// }