Example usage for java.awt Color Color

List of usage examples for java.awt Color Color

Introduction

In this page you can find the example usage for java.awt Color Color.

Prototype

public Color(int rgb) 

Source Link

Document

Creates an opaque sRGB color with the specified combined RGB value consisting of the red component in bits 16-23, the green component in bits 8-15, and the blue component in bits 0-7.

Usage

From source file:HTMLColors.java

/** Used to initialize the map */
private static void addColor(String colorName, int colorRGB) {
    addColor(colorName, new Color(colorRGB));
}

From source file:cn.z.Ocr5.java

public static int getColorBright(int colorInt) {
    Color color = new Color(colorInt);
    return color.getRed() + color.getGreen() + color.getBlue();
}

From source file:Main.java

public void update() {
    this.setForeground(new Color(r.nextInt()));
}

From source file:cn.z.Ocr5.java

public static int isBlack(int colorInt, int blackThreshold) {
    final Color color = new Color(colorInt);
    if (color.getRed() + color.getGreen() + color.getBlue() <= blackThreshold) {
        return 1;
    }//from  ww w .j  a v  a 2  s .  co m
    return 0;
}

From source file:ColorUtils.java

public static Color getColor(String hexaString) {
    return new Color(Integer.parseInt(hexaString, 16));
}

From source file:baocaoxla.xuly_compare.java

public ChartPanel displayhistogram(BufferedImage image) {

    HistogramDataset dataset = new HistogramDataset();

    final int w = image.getWidth();
    final int h = image.getHeight();
    double[] r = new double[w * h];
    double[] g = new double[w * h];
    double[] b = new double[w * h];
    int dem = 0;// w  w w  . ja  va2  s . c o m
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            Color c = new Color(image.getRGB(j, i));
            r[dem] = c.getRed();
            g[dem] = c.getGreen();
            b[dem] = c.getBlue();
            dem++;
        }
    }
    //r = raster.getSamples(0, 0, w, h, 0, r);
    dataset.addSeries("Red", r, 256);
    //r = raster.getSamples(0, 0, w, h, 1, r);
    dataset.addSeries("Green", g, 256);
    // r = raster.getSamples(0, 0, w, h, 2, r);
    dataset.addSeries("Blue", b, 256);
    // chart
    JFreeChart chart = ChartFactory.createHistogram("Histogram", "Value", "Count", dataset,
            PlotOrientation.VERTICAL, true, true, false);
    ChartPanel panel = new ChartPanel(chart);
    return panel;

}

From source file:net.kornr.swit.site.ColorConverter.java

public Object convert(Class clzz, Object obj) {
    if (Color.class.equals(clzz) == false)
        throw new ConversionException("Not a color conversion!");

    if (Color.class.equals(obj.getClass()))
        return obj;

    String value = obj.toString();
    if (value.startsWith("#"))
        value = value.substring(1);//from   w  w w. j av  a 2 s . com

    Integer i = Integer.parseInt(value, 16);
    return new Color(i);
}

From source file:ml.hsv.java

public static hsv[][] img2RGB2HSV(String ip) throws IOException {
    BufferedImage image;//w  w  w . j a  v  a2 s .c o m
    int width, height;

    File input = new File(ip);
    image = ImageIO.read(input);
    width = image.getWidth();
    height = image.getHeight();

    hsv hsvImage[][] = new hsv[height][width];

    for (int i = 0; i < height; i++) {
        for (int j = 0; j < width; j++) {
            Color c = new Color(image.getRGB(j, i));
            hsvImage[i][j] = new hsv(c.getRed(), c.getGreen(), c.getBlue());
        }
    }

    HSV2File(hsvImage, width, height);

    return hsvImage;
}

From source file:cn.z.Ocr5.java

public static int isWhite(int colorInt, int whiteThreshold) {
    final Color color = new Color(colorInt);
    if (color.getRed() + color.getGreen() + color.getBlue() > whiteThreshold) {
        return 1;
    }/* w  w  w .  j  a  v  a 2 s .  c o m*/
    return 0;
}

From source file:ColorComponentScaler.java

/**
 * split the argb value into its color components, multiply each color
 * component by its corresponding scaler factor and pack the components back
 * into a single pixel/*from w w w .  ja va  2 s .  c om*/
 */
public int filterRGB(int x, int y, int argb) {
    color = new Color(argb);
    newBlue = multColor(color.getBlue(), blueMultiplier);
    newGreen = multColor(color.getGreen(), greenMultiplier);
    newRed = multColor(color.getRed(), redMultiplier);
    newColor = new Color(newRed, newGreen, newBlue);
    return (newColor.getRGB());
}