for (double y=centre.y-step.height; y<=centre.y+step.height; y+=step.height) {
Position point = new Position(x, y);
if (!isWithinLoop(point, loop, clockwise, centre)) continue;
areaCircled += step.area();
grid.add(point);
Box box = ketPanel.findDeepestBox(point);
if (box==null) continue;
Argument argument = box.getArgument();
if (argument==null) continue;
counter.increment(argument);
if ( ! boxMap.containsKey(argument) ) {
boxMap.put(argument, box);
}
for (Branch a : argument.getAncestors()) {
counter.increment(a);
}
}
}
// Remove all keys associated with null boxes.
for (Argument argument : counter.keyList()) {
if (boxMap.get(argument)==null) {
//- System.out.println("[remove " + argument + "]");
counter.remove(argument);
}
}
// Scale grids by the size of each box so larger boxes require
// more area of the loop to be selected.
double norm = 0.0;
for (Argument argument : counter.keySet()) { // (box, argument, count)
Box box = boxMap.get(argument);
if (box==null) continue;
double count = counter.get(argument);
double selectedBoxArea = count*step.area();
double fracCircled = selectedBoxArea/areaCircled;
double fracBox = selectedBoxArea/box.getArea();
double weight = fracCircled * fracBox * selectedBoxArea;
/*-
double boxFrac = selectedBoxArea / box.getArea(); // Frac area of box.
//? double weight = boxFrac * selectedArea;
double weight = boxFrac * selectedBoxArea;