Here you can find the source of toRgbText(int rgb)
Parameter | Description |
---|---|
rgb | the integer RGB value |
public static String toRgbText(int rgb)
//package com.java2s; /******************************************************************************* * Copyright (c) 2004 Actuate Corporation. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors:/* www.j av a 2s . c o m*/ * Actuate Corporation - initial API and implementation *******************************************************************************/ public class Main { /** * Convert an integer to an HTML RGB value. The result is of the form * #hhhhhh. The input rgb integer value will be clipped into the range 0 ~ * 0xFFFFFF * * @param rgb * the integer RGB value * @return the value as an HTML RGB string */ public static String toRgbText(int rgb) { // clip input value. if (rgb > 0xFFFFFF) rgb = 0xFFFFFF; if (rgb < 0) rgb = 0; String str = "000000" + Integer.toHexString(rgb); //$NON-NLS-1$ return "#" + str.substring(str.length() - 6); //$NON-NLS-1$ } }