mycolour.java

来自「此程序可实现:在一个可视化界面中随机生成3种safe-colour(不显示白色)」· Java 代码 · 共 62 行

JAVA
62
字号
/**
 * An color class to indicating if a colour is white
 * and returning the hexadecimal value of a colour.
 * @author Ruixiao Wu
 * @version 1.0  02/06/2006
 */
import java.awt.Color;

public class MyColour extends Color {
	/**
	 * A class extends Color
	 * 
	 * @author Ruixiao Wu
	 * @version 1.0 02/06/2006
	 */
	private static final long serialVersionUID = 4502401381904651057L;

	public MyColour(int R, int G, int B) {
		super(R, G, B);
	}

	/**
	 * A method to check the color and ndicating if a colour is white.
	 * 
	 * @param R,G,B,checkcolor
	 */
	public static boolean checkColor(int R, int G, int B) {
		boolean checkcolor;
		if (R == 255 && G == 255 && B == 255)
			checkcolor = true;
		else
			checkcolor = false;
		return checkcolor;
	}

	/**
	 * A method to convert the green value to hexadecimal.
	 * 
	 * @param greenHex,integer
	 */
	public static String convertGreenTohex(Integer integer) {
		//if(integer!=0)
		String greenHex = Integer.toHexString(integer).toUpperCase();
		if (integer == 0)
			greenHex = "00";
		return greenHex;
	}

	/**
	 * A method to convert the blue value to hexadecimal.
	 * 
	 * @param blueHex,integer
	 */
	public static String convertBlueTohex(Integer integer) {
		String blueHex = Integer.toHexString(integer).toUpperCase();
		blueHex.toUpperCase();
		if (integer == 0)
			blueHex = "00";
		return blueHex;
	}// End method.
}// End MyColour class.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?