public void paint(Graphics g) {
        double scale = Math.min(getWidth() / (maxX-minX), getHeight() / (maxY-minY));

        // draw nodes as circles
        ((Graphics2D)g).setComposite( AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f) );    
		for (Node node : nodeToPosition.keySet()) {
            float hue = nodeToCluster.get(node) / (float)(maxCluster+1);  
			g.setColor(Color.getHSBColor(hue, 1.0f, 1.0f));
			int positionX = (int)Math.round((nodeToPosition.get(node)[0] - minX) * scale);
			int positionY = (int)Math.round((nodeToPosition.get(node)[1] - minY) * scale);
			int diameter  = (int)Math.round(Math.sqrt(node.weight) * scale);
			g.fillOval(positionX-diameter/2, positionY-diameter/2, diameter, diameter);
		}

        final int FONT_SIZE = 10;
        g.setFont(g.getFont().deriveFont(FONT_SIZE));                  
        ((Graphics2D)g).setComposite( AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1.0f) );
        for (Node node : nodeToPosition.keySet()) {
            if (labelledNodes.contains(node)) continue;
            if (!node.name.equalsIgnoreCase(searchedName) && !labelsEnabled) continue;

            g.setColor(node.name.equalsIgnoreCase(searchedName) ? Color.RED : Color.BLACK);
            int positionX = (int)Math.round((nodeToPosition.get(node)[0] - minX) * scale);
            int positionY = (int)Math.round((nodeToPosition.get(node)[1] - minY) * scale);
			g.drawString(node.name, 
                Math.min(positionX, getWidth() - g.getFontMetrics().stringWidth(node.name)), 
                Math.max(positionY, FONT_SIZE));
        }

        if (!labelledNodes.isEmpty()) {
            Node firstNode = labelledNodes.iterator().next();
			int positionX = (int)Math.round((nodeToPosition.get(firstNode)[0] - minX) * scale);			
			int positionY = (int)Math.round((nodeToPosition.get(firstNode)[1] - minY) * scale);
            positionY = Math.max(positionY, FONT_SIZE);
            for (Node node : labelledNodes) {
                g.setColor(node.name.equalsIgnoreCase(searchedName) ? Color.RED : Color.BLACK);
                g.drawString(node.name, 
                    Math.min(positionX, getWidth() - g.getFontMetrics().stringWidth(node.name)), 
                    positionY);
                positionY += FONT_SIZE;
            }
		}
	}