Example usage for java.awt Color getGreen

List of usage examples for java.awt Color getGreen

Introduction

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

Prototype

public int getGreen() 

Source Link

Document

Returns the green component in the range 0-255 in the default sRGB space.

Usage

From source file:edu.ku.brc.ui.ColorWrapper.java

/**
 * Helper to convert a Color into a string "r,g,b"
 * @param c the color/*from www. ja v a  2s.c o  m*/
 * @return the comma separated string
 */
public static String toString(Color c) {
    return c.getRed() + ", " + c.getGreen() + ", " + c.getBlue();
}

From source file:org.esa.beam.visat.toolviews.stat.MaskSelectionToolSupport.java

private static Color createAlphaColor(Color color, int alpha) {
    return new Color(color.getRed(), color.getGreen(), color.getBlue(), alpha);
}

From source file:Main.java

public static String getColorString(Color color) {
    StringBuffer buffer = new StringBuffer("#"); //$NON-NLS-1$
    appendComponent(buffer, color.getRed());
    appendComponent(buffer, color.getGreen());
    appendComponent(buffer, color.getBlue());
    return buffer.toString();
}

From source file:com.embedler.moon.jtxt2img.CoreHelper.java

public static String rgb2hex(Color color) {
    Validate.notNull(color, "Color must not be null");
    return String.format("#%02x%02x%02x", color.getRed(), color.getGreen(), color.getBlue());
}

From source file:Main.java

public static void addColorProperty(Document document, Element parent, String name, Color value) {
    addPropertyNode(document, parent, name).setAttribute(COLOR_ATTR,
            value.getRed() + "," + value.getGreen() + "," + value.getBlue());
}

From source file:ColorUtils.java

private static float[] toHSB(Color aColor) {
    return Color.RGBtoHSB(aColor.getRed(), aColor.getGreen(), aColor.getBlue(), null);
}

From source file:imageprocessingproject.ImageHistogram.java

private static int getGrayValue(int rgb) {
    Color c = new Color(rgb);
    return (c.getRed() + c.getGreen() + c.getBlue()) / 3;
}

From source file:HTML.java

/**
 * Utility method to format a color to HTML RGB color format (e.g. #FF0000 for Color.red).
 * @param color The color.//from   www.j a  va2 s. c  o  m
 * @return the HTML RGB color string.
 */
public static final String format(Color c) {
    String r = (c.getRed() < 16) ? "0" + Integer.toHexString(c.getRed()) : Integer.toHexString(c.getRed());
    String g = (c.getGreen() < 16) ? "0" + Integer.toHexString(c.getGreen())
            : Integer.toHexString(c.getGreen());
    String b = (c.getBlue() < 16) ? "0" + Integer.toHexString(c.getBlue()) : Integer.toHexString(c.getBlue());
    return "#" + r + g + b;
}

From source file:modelo.HTMLUtils.java

private static String colorToHex(Color color) {
    String hex = String.format("#%02x%02x%02x", color.getRed(), color.getGreen(), color.getBlue());
    return hex;//  www  . j  a  v a 2s  .  co  m
}

From source file:Main.java

/**
 * Adjusts a preset color to a roughness value.
 * @param orig The original color/*from   w  ww  .j av a 2 s .  c  om*/
 * @param a The roughness value.
 * @param maxmin The maximum and minimum differential.
 * @return A color that has been adjust to match the original and roughness.
 */
public static Color adjust(Color orig, double a, int maxmin) {
    if (a > 1)
        a = 1;
    if (a < 0)
        a = 0;

    int r = orig.getRed();
    int g = orig.getGreen();
    int b = orig.getBlue();

    r = (int) (r - (a * maxmin));
    g = (int) (g - (a * maxmin));
    b = (int) (b - (a * maxmin));

    r = colorSnap(r);
    g = colorSnap(g);
    b = colorSnap(b);
    return new Color(r, g, b, orig.getAlpha());
}