summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/view/impl/ImageUtil.java
blob: 6af816e9659b359ad88eaf43f6335304fadc6d26 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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) {
		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);
	}
}