Example usage for java.awt Color getBlue

List of usage examples for java.awt Color getBlue

Introduction

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

Prototype

public int getBlue() 

Source Link

Document

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

Usage

From source file:Utils.java

public static String getHTMLColorString(Color color) {
    String red = Integer.toHexString(color.getRed());
    String green = Integer.toHexString(color.getGreen());
    String blue = Integer.toHexString(color.getBlue());

    return "#" + (red.length() == 1 ? "0" + red : red) + (green.length() == 1 ? "0" + green : green)
            + (blue.length() == 1 ? "0" + blue : blue);
}

From source file:Main.java

/**
 * Creates a new <code>Color</code> that is a brighter version of this
 * <code>Color</code>. This method is the same implementation
 * java.awt.Color#brighter is usind except it has a configurable factor.
 * The java.awt.Color default facotr is 0.7
 * @return     a new <code>Color</code> object that is  
 *                 a brighter version of this <code>Color</code>.
 * @see        java.awt.Color#darker/*from   w  w  w .  j a  v a  2 s.c om*/
 */
public static Color brighterColor(Color color, double factor) {
    int r = color.getRed();
    int g = color.getGreen();
    int b = color.getBlue();

    /* From 2D group:
     * 1. black.brighter() should return grey
     * 2. applying brighter to blue will always return blue, brighter
     * 3. non pure color (non zero rgb) will eventually return white
     */
    int i = (int) (1.0 / (1.0 - factor));
    if (r == 0 && g == 0 && b == 0) {
        return new Color(i, i, i);
    }
    if (r > 0 && r < i)
        r = i;
    if (g > 0 && g < i)
        g = i;
    if (b > 0 && b < i)
        b = i;

    return new Color(Math.min((int) (r / factor), 255), Math.min((int) (g / factor), 255),
            Math.min((int) (b / factor), 255));
}

From source file:proteinHypernetworkVisualization.implementation.jung.visualization.DefaultGraphStyle.java

public static Color makeTransparent(Color c) {
    return new Color(c.getRed(), c.getGreen(), c.getBlue(), 150);
}

From source file:Main.java

/**
 * @param color//from  w  w  w.  jav  a 2 s  . co m
 * @param factor
 * @return a new color, darker than the one passed as argument by a percentage factor
 *
 * <br>author Cyril Gambis  - [Mar 17, 2005]
 */
public static Color darker(Color color, double factor) {
    return new Color(Math.max((int) (color.getRed() * factor), 0),
            Math.max((int) (color.getGreen() * factor), 0), Math.max((int) (color.getBlue() * factor), 0));
}

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:edu.ku.brc.ui.ColorWrapper.java

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

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

/**
 * Create a lighter color using a factor.
 *
 * @param color//from   ww w .ja v  a  2  s.  co  m
 * @param factor
 * @return lighter color
 */
public static Color lighter(final Color color, float factor) {
    return new Color(Math.max((int) (color.getRed() / factor), 0),
            Math.max((int) (color.getGreen() / factor), 0), Math.max((int) (color.getBlue() / factor), 0));
}

From source file:Main.java

/**
 * Create a darker color using a factor.
 *
 * @param color/*from  w  ww  .  java 2s .com*/
 * @param factor
 * @return darker color
 */
public static Color darker(final Color color, float factor) {
    return new Color(Math.max((int) (color.getRed() * factor), 0),
            Math.max((int) (color.getGreen() * factor), 0), Math.max((int) (color.getBlue() * factor), 0));
}

From source file:Main.java

/**
 * Creates a new <code>Color</code> that is a darker version of this
 * <code>Color</code>. This method is the same implementation
 * java.awt.Color#darker is usind except it has a configurable factor.
 * The java.awt.Color default facotr is 0.7
 * @return  a new <code>Color</code> object that is 
 *                    a darker version of this <code>Color</code>.
 * @see        java.awt.Color#brighter// w ww . ja v a  2  s.  c o  m
 */
public static Color darkerColor(Color color, double factor) {
    return new Color(Math.max((int) (color.getRed() * factor), 0),
            Math.max((int) (color.getGreen() * factor), 0), Math.max((int) (color.getBlue() * factor), 0));
}