参考网上文章,做了两种颜色选择器。
一种是固定颜色的选择器,这个很简单,只要画出来各种颜色区域,用户选择哪个,就选择了什么颜色。
另一种是万能颜色选择器,这个有一些算法的,所以就参考了网上的文章(由于原始出处不详,就不表示感谢了),又做了一些优化和修改。
目前的这个万能颜色选择器的功能已经足够了,也没什么可保密的,就放上来,给需要的人做个参考。喜欢就拿去好了。
/**
* Color chooser's type. One is defined color panel, another is universal color
* panel.
*
* @author http://blog.csdn.net/arui319
*
*/
public class ColorChooserType {
private int type = 0;
private static final int DEFINED_COLOR = 1;
private static final int UNIVERSAL_COLOR = 2;
public static final ColorChooserType DEFINED_COLOR_TYPE = new ColorChooserType(
DEFINED_COLOR);
public static final ColorChooserType UNIVERSAL_COLOR_TYPE = new ColorChooserType(
UNIVERSAL_COLOR);
private ColorChooserType(int type) {
this.type = type;
}
public int getType() {
return type;
}
@Override
public boolean equals(Object type) {
if (type instanceof ColorChooserType) {
if (this.getType() == ((ColorChooserType) type).getType()) {
return true;
}
}
return false;
}
@Override
public int hashCode() {
return this.getType();
}
}