for(Point each: points.keySet()) {
int x = toMapCoords(each.x);
int y = toMapCoords(each.y);
org.eclipse.swt.graphics.Point extent = new org.eclipse.swt.graphics.Point(x, y);
int fontsize = (points.get(each))/3;
labels.add(new Label(x-20, y-60, extent, fontsize, each.getDocument(), new Location(each, 0, x, y)));
}
labeling = new Labeling(labels);
MapInstance mapInstance = configuration.withSize(mapSize, new MapScheme<Double>() {
@Override
public Double forLocation(Point location) {
// TODO fill in size
return (double) points.get(location);
}
});
DEMAlgorithm algorithm = new DEMAlgorithm();
algorithm.setMap(mapInstance);
float[][] DEM = algorithm.call();
ShadeAlgorithm hsa = new ShadeAlgorithm();
hsa.setMap(mapInstance);
double[][] shading = hsa.call();
int mapSize = mapInstance.getWidth();
Device device = Display.getCurrent();
background = new Image(device, mapSize, mapSize);
GC gc = new GC(background);
String makeRed = "MapPerProject";
CodemapColors colors = new CodemapColors();
colors.setColor(makeRed, new MColor(255, 0, 0));
Iterable<Location> locations = mapInstance.locations();
ColorBrewer colorBrewer = new ColorBrewer();
for (Location location : locations) {
MColor color = colorBrewer.forPackage(location.getDocument());
colors.setColor(location.getDocument(), color);
}
Color black = new Color(gc.getDevice(), 0, 0, 0);
gc.setBackground(black);
gc.fillRectangle(gc.getClipping());
black.dispose();
Image image = new FastBackgroundRenderer(DEM, shading, mapInstance, colors, device).render();
gc.drawImage(image, 0, 0);
gc.setForeground(new Color(gc.getDevice(), 255, 0, 0));
for(int x = 0; x < mapInstance.width; x++) {
for (int y = 0; y < mapInstance.height; y++) {
Location kdTreeNearest = mapInstance.kdTreeNearest(x, y);
Location naiveNearest = mapInstance.naiveNearest(x, y);
if (naiveNearest.equals(kdTreeNearest)) continue;
gc.drawPoint(x, y);
// assertEquals(naiveNearest, kdTreeNearest);
}
}