/*
 * 作成日: 2005/11/27
 */
package asandatabasebrowser.model;

import java.awt.Color;
import java.awt.Font;
import java.util.ArrayList;

import javax.swing.JLabel;


/**
 * ある特定のカラムを強調表示するための設定.
 * 例えば、UPDATE_DATEとかDEL_FLAGなど、プロジェクト固有の共通のカラムに対して
 * 色分けを行います。
 * @author Asan
 */
public class Highlight {
	String name;
	Color textColor;
	Color backColor;
	int fontStyle;
	ArrayList columnNameList;
	
	Highlight(String name, Color textColor, Color backColor, int fontStyle, ArrayList columnNameList) {
		this.name = name;
		this.textColor = textColor;
		this.backColor = backColor;
		this.fontStyle = fontStyle;
		this.columnNameList = columnNameList;
	}
	public boolean setHighlight(String name, JLabel label) {
		for (int i=0; i<columnNameList.size(); i++) {
			String pattern = (String) columnNameList.get(i);
			if (name.matches(pattern)) {
				label.setForeground(textColor);
				label.setBackground(backColor);
				Font font = label.getFont();
				font = new Font(font.getName(), fontStyle, font.getSize());
				label.setFont(font);
				return true;
			}
		}
		return false;
	}


	public String toString() {
		String result = "Highlight={name="+name + " textColor="
			+ textColor + " backColor=" + backColor + " fontStyle=" + fontStyle;
		result += " columnNameList=[";
		for (int i=0; i<columnNameList.size(); i++) {
			if (i!=0) result += ",";
			result += columnNameList.get(i);
		}
		return result + "]";
	}
}
