Java Color Encode encode(Color color)

Here you can find the source of encode(Color color)

Description

encode

License

Open Source License

Declaration

public static String encode(Color color) 

Method Source Code

//package com.java2s;
import java.awt.Color;

public class Main {
    public static String encode(int number) {
        if ((number < 0) || (number > 255))
            throw new IllegalArgumentException("" + number);
        String hex = "0123456789ABCDEF";
        char c1 = hex.charAt(number / 16);
        char c2 = hex.charAt(number % 16);
        return c1 + "" + c2;
    }//from w  ww .j a  v  a2s.  co  m

    public static String encode(Color color) {
        return "#" + encode(color.getRed()) + encode(color.getGreen())
                + encode(color.getBlue());
    }
}

Related

  1. encode(Color c)
  2. encode(Color color)
  3. encode(Color color)
  4. encode(Color color)
  5. encode(java.awt.Color c)