class Place { int code; String name; float x; float y; int partial[]; int matchDepth; public Place(int code,String name,float x,float y) { this.code = code; this.name = name; this.x = x; this.y = y; partial = new int[6]; partial[5] = code; partial[4] = partial[5] / 10; partial[3] = partial[4] / 10; partial[2] = partial[3] / 10; partial[1] = partial[2] / 10; } void check() { matchDepth = 0; if (typedCount != 0) { for (int j = typedCount; j>0; --j) { if (typedPartials[j] == partial[j]) { matchDepth = j; break; } } } if (matchDepth == typedCount) { foundCount++; if (typedCount == 5) { chosen = this; } if (x < boundsX1) boundsX1 = x; if (y < boundsY1) boundsY1 = y; if (x > boundsX2) boundsX2 = x; if (y > boundsY2) boundsY2 = y; } } void draw() { float xx = TX(x); float yy = TY(y); if (xx < 0 || yy < 0 || xx >= width || yy >= height) return; if (zoomDepth.value < 2.8f || !zoomEnabled) { set(int(xx),int(yy),faders[matchDepth].value); } else //complicated dots { noStroke(); fill(faders[matchDepth].value); if (matchDepth == typedCount) { if (typedCount == 4) //show last digit { text(code % 10, xx,yy); } else { rect(xx,yy,zoomDepth.value,zoomDepth.value); } } else //unselected places { rect(xx,yy,zoomDepth.value - 1,zoomDepth.value - 1); } } } void drawChosen() { noStroke(); fill(highlightColor); int size = zoomEnabled ? 6 : 4; rect(TX(x),TY(y),size,size); float textX = TX(x); float textY = TY(y) - size - 4; if (textY < 20) { textY = TY(y) + 20; } if (textY > height - 5) { textY = TY(y) - 20; } String location = name + " " + nf(code, 5); if (zoomEnabled) { textAlign(CENTER); text(location, textX, textY); } else { float wide = textWidth(location); if (textX > width / 3) { textX -= wide + 8; } else { textX += 8; } textAlign(LEFT); fill(highlightColor); text(location, textX, textY); } } }