}
scale.width = size.width;
scale.height = size.height;
Color white = ColorCache.getColor(display,255,255,255);
Color blue = ColorCache.getColor(display,66,87,104);
if (img != null && !img.isDisposed()) {
img.dispose();
}
img = new Image(display,size);
GC gc = new GC(img);
gc.setForeground(white);
gc.setBackground(white);
gc.fillRectangle(size);
if(SWT.getVersion() >= 3138 && antiAliasingAvailable) {
try {
//gc.setTextAntialias(SWT.ON);
//gc.setAntialias(SWT.ON);
} catch(Exception e) {
antiAliasingAvailable = false;
}
}
gc.setForeground(blue);
gc.setBackground(white);
DHTNetworkPosition _ownPosition = self.getNetworkPosition(DHTNetworkPosition.POSITION_TYPE_VIVALDI_V1);
if ( _ownPosition == null ){
return;
}
VivaldiPosition ownPosition = (VivaldiPosition)_ownPosition;
float ownErrorEstimate = ownPosition.getErrorEstimate();
HeightCoordinatesImpl ownCoords =
(HeightCoordinatesImpl) ownPosition.getCoordinates();
gc.drawText("Our error: " + ownErrorEstimate,10,10);
Color black = ColorCache.getColor(display, 0, 0, 0);
gc.setBackground(black); // Color of the squares
// Draw all known positions of other contacts
Iterator iter = contacts.iterator();
while(iter.hasNext()) {
DHTControlContact contact = (DHTControlContact) iter.next();
DHTNetworkPosition _position = contact.getTransportContact().getNetworkPosition(DHTNetworkPosition.POSITION_TYPE_VIVALDI_V1);
if ( _position == null ){
continue;
}
VivaldiPosition position = (VivaldiPosition)_position;
HeightCoordinatesImpl coord = (HeightCoordinatesImpl) position.getCoordinates();
if(coord.isValid()) {
draw(gc,coord.getX(),coord.getY(),coord.getH(),contact,(int)ownCoords.distance(coord),position.getErrorEstimate());
}
}
// Mark our own position
Color red = ColorCache.getColor(display, 255, 0, 0);
gc.setForeground(red);
drawSelf(gc, ownCoords.getX(), ownCoords.getY(),
ownCoords.getH(), ownErrorEstimate);