g2.setColor(Color.GRAY); for (Rectangle cell : cells) {
g2.draw(cell);
}
}
Font font = new Font("Arial", Font.PLAIN, 18);
g2.setFont(font);
g2.setColor(Color.RED);
g2.drawString("Round: " + simulationRoundCount , 8,20);
g2.dispose();
}
publicvoid update(Observable obs, Object arg) {
if(arg == null) return;
if(arg == "newRound")
{
simulationRoundCount++;
liveCells.clear();
List<Point> list = model.getLivingCells();
for (Point cord : list) {
addNewLiveCell(cord.x,cord.y);
}
}
repaint();
}
privatevoid addNewLiveCell(int x, int y)
{ int index = findIndexFromCoord(x,y);
if(index > 0)
liveCells.add(index);
}
privateint findIndexFromCoord(int x, int y)
{ if((x < sideSplit && x >= -sideSplit) && (y < sideSplit && y >= -sideSplit))
{
int index = zerozero + (-y * sideCount) +x;
if(0 <= index && index < cellCount) return index;
}
return -1;
}
privatevoid rebuildCells() {
cells.clear(); for (int row = 0; row < sideCount; row++) { for (int col = 0; col < sideCount; col++) {
Rectangle cell = new Rectangle(
xOffset + (col * cellWidth),
yOffset + (row * cellHeight),
cellWidth,
cellHeight);
cells.add(cell);
}
}
}
}
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.11Bemerkung:
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.