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);
}
}
// gc.setForeground(new Color(gc.getDevice(), 123, 0, 0));
// ImageData id = image.getImageData();
// for(int x = 0; x < id.width; x++) {
// for (int y = 0; y < id.height; y++) {
// Location nn = mapInstance.nearestNeighbor(x, y);
// if (! nn.getDocument().equals(makeRed)) continue;
// gc.drawPoint(x, y);
// }
// }
gc.dispose();
// Location mpp = getLocation(mapInstance, "MapPerProject");
// Location dda = getLocation(mapInstance, "ColorDropDownAction");
// System.out.println("Distance to MapPerProject: " + Math.sqrt(Math.pow(575 - mpp.px, 2) + Math.pow(500 - mpp.py, 2)));
// System.out.println("Distance to ColorDropDownAction: " + Math.sqrt(Math.pow(575 - dda.px, 2) + Math.pow(500 - dda.py, 2)));