g.setColor(Color.WHITE);
g.fillRect(0, 0, size.width, size.height);
for(int cx=0; cx<_region.getWidth(); ++cx) {
for(int cy=0; cy<_region.getHeight(); ++cy) {
Column col = _region.getColumn(cx, cy);
Point circle = getColumnPos(col);
int gray = 255 - Math.round(col.getOverlapPercentage()*255.0f);
if(gray<255)
gray = gray;
g.setColor(new Color(gray,gray,gray));
g.fillOval(circle.x-rad, circle.y-rad, diam, diam);
boolean wasDrawn = false;
if(col.isActive()) {
wasDrawn = true;
g.setColor(Color.BLUE);
}
else
g.setColor(new Color(192,192,192));
g.drawOval(circle.x-rad, circle.y-rad, diam, diam);
//Now draw individual column cells inside the column's circle
int radCell = rad2sqrt+1;
int rad2C = rad2-1;
if(_region.getCellsPerCol()==1) {
radCell = rad-(rad/3);
rad2C = 0;
}
Point[] clocs = new Point[] {
new Point(circle.x-rad2C, circle.y-rad2C),
new Point(circle.x+rad2C, circle.y-rad2C),
new Point(circle.x-rad2C, circle.y+rad2C),
new Point(circle.x+rad2C, circle.y+rad2C)
};
for(int i=0; i<col.numCells(); ++i)
wasDrawn |= drawCell(g, clocs[i], radCell, col.getCell(i));
//Draw small black circle to indicate input bit origin locations
if(_showInput && _data!=null && _data[col.ix()][col.iy()]==1) {
wasDrawn = true;
int r = Math.max(2, rad/6);
g.setColor(new Color(128,0,128));
g.fillOval(circle.x-r, circle.y-r, r*2, r*2);
g.setColor(Color.BLACK);