/* Copyright (C) 2007 Andre Seidelt, All Rights Reserved. This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /* * show info for a single cell. */ class CellInfo { // the selected cell private Cell mCell; // set cell to display, null for none public void setCurrent(Cell pCell) { mCell = pCell; } // paint the 'window' public void paint() { if(mCell != null) { // choose quadrant int baseX, baseY; if(mCell.mX > width/2) { baseX = 0; } else { baseX = width/2; } if(mCell.mY > height/2) { baseY = 0; } else { baseY = height/2; } // draw window int leftX = baseX + 10; int topY = baseY + 10; int rightX = baseX + width/2 - 10; int bottomY = baseY + height/2 - 10; stroke(220, 220, 255, ALPHA_VALUE); line(leftX, topY, mCell.mX, mCell.mY); // top left line(rightX, topY, mCell.mX, mCell.mY); // top right line(leftX, bottomY, mCell.mX, mCell.mY); // bottom left line(rightX, bottomY, mCell.mX, mCell.mY); // bottom right rectMode(CORNER); fill(0, 0, 55, ALPHA_VALUE); rect(leftX, topY, rightX-leftX, bottomY-topY); // add info stroke(40, 255, 55); fill(40, 255, 55); String txt = "Position : "+mCell.mX+" x "+mCell.mY+"\n"+ "Generation : "+mCell.mGeneration+"\n"+ "Parent : "+mCell.mParent+"\n"+ "Mutations : "+mCell.mGenome.mMutations+"\n"+ "Age : "+mCell.mAge+" / "+mCell.mMaxAge+" ("+mCell.mGenome.mAge.mValue+")\n"+ "Children : "+(mCell.mAge/mCell.mReproductionRate)+" / "+(mCell.mGenome.mAge.mValue/mCell.mReproductionRate)+" ("+(mCell.mAge/mCell.mGenome.mReproductionRate.mValue)+" / "+(mCell.mGenome.mAge.mValue/mCell.mGenome.mReproductionRate.mValue)+")\n"+ "Shape : "+mCell.getShape()+"\n"+ "Size : "+mCell.mGenome.mSize.mValue+"\n"+ "Line width : "+mCell.mGenome.mLineWidth.mValue+"\n"+ "Food demand : "+mCell.mFoodDemand+" ("+mCell.mGenome.mFoodDemand.mValue+")\n\n"+ "Genome : "+mCell.mGenome.toString()+"\n"+ "Parent : "+mCell.mParentGenome; printText(txt, leftX+10, topY+FONT_SIZE+12); } } }