package org.mote.wiimote.whiteboard.gui;

import java.awt.Color;
import java.awt.SystemColor;

import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JPanel;

import net.miginfocom.swing.MigLayout;

@SuppressWarnings("serial")
public class WiimoteIcon extends JPanel {

	public static final Color[] COLORS = { Color.white, Color.pink, Color.orange, Color.green };
	private JLabel idLabel;

	public WiimoteIcon(int id) {
		setBackground(COLORS[id - 1]);
		setBorder(BorderFactory.createLineBorder(Color.lightGray));
		setLayout(new MigLayout("insets 3, center"));
		for (int i = 1; i <= 4; i++) {
			JLabel l = new JLabel();
			l.setOpaque(true);
			l.setBackground(SystemColor.textInactiveText);
			add(l, "w 6!, h 6!");
			if (i == id) idLabel = l;
		}
	}
	
	public void displayConnected(boolean connected) {
		idLabel.setBackground(connected ? Color.blue : SystemColor.textInactiveText);
	}

}
