{
super.paintComponent(graphics);
final int maxW = getWidth();
final int maxH = getHeight();
final SectorFactory sectorFactory = this.game.getSectorFactory();
final int uniWidth = sectorFactory.getMaxX() * 100 + 150;
final int uniHeight = sectorFactory.getMaxY() * 100 + 150;
final float scaleX = (float) maxW / uniWidth;
final float scaleY = (float) maxH / uniHeight;
final float uniAR = (float) uniWidth / uniHeight;
final float winAR = maxW / (float) maxH;
final int width, height;
if (uniAR > winAR)
{
width = maxW;
height = maxW * uniHeight / uniWidth;
this.scale = scaleX;
}
else
{
height = maxH;
width = maxH * uniWidth / uniHeight;
this.scale = scaleY;
}
if (width <= 0 || height <= 0) return;
if (this.buffer == null || this.buffer.getWidth() != width
|| this.buffer.getHeight() != height)
this.buffer = new BufferedImage(width, height,
BufferedImage.TYPE_INT_ARGB);
final Graphics2D g = this.buffer.createGraphics();
final SortedSet<Sector> sectors = sectorFactory.getSectors();
g.setColor(Color.BLACK);
g.fillRect(0, 0, width, height);
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);