package jrummikub.view.impl;

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;

import javax.swing.ImageIcon;

class ImageUtil {
	private ImageUtil() {
	}

	static ImageIcon createColorIcon(Color c, int size, int border) {
		BufferedImage image = new BufferedImage(size, size,
				BufferedImage.TYPE_INT_RGB);
		Graphics2D g = image.createGraphics();

		g.setColor(Color.BLACK);
		g.fillRect(0, 0, size, size);

		g.setColor(c);
		g.fillRect(border, border, size - 2 * border, size - 2 * border);

		return new ImageIcon(image);
	}

	static ImageIcon createPauseIcon(int size) {
		size = Math.max(size, 1);

		BufferedImage image = new BufferedImage(size, size,
				BufferedImage.TYPE_INT_ARGB);

		Graphics2D g = image.createGraphics();

		g.setColor(Color.BLACK);
		int barWidth = (int) (size * 0.425f);
		g.fillRect(0, 0, barWidth, size);
		g.fillRect(size - barWidth, 0, barWidth, size);

		return new ImageIcon(image);
	}
}
