Example usage for java.awt Color getRed

List of usage examples for java.awt Color getRed

Introduction

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

Prototype

public int getRed() 

Source Link

Document

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

Usage

From source file:net.sourceforge.atunes.kernel.modules.state.ColorBean.java

/**
 * Creates new color bean//from w w  w  .j ava 2  s. c o  m
 * 
 * @param c
 */
public ColorBean(final Color c) {
    this.red = c.getRed();
    this.green = c.getGreen();
    this.blue = c.getBlue();
    this.alpha = c.getAlpha();
}

From source file:ToggleButton.java

public void actionPerformed(ActionEvent e) {
    Color color = display.getBackground();
    int red = color.getRed();
    int green = color.getGreen();
    int blue = color.getBlue();

    if (e.getActionCommand() == "red") {
        if (red == 0) {
            red = 255;//from   w w w.  jav  a  2 s .  c  o m
        } else {
            red = 0;
        }
    }

    if (e.getActionCommand() == "green") {
        if (green == 0) {
            green = 255;
        } else {
            green = 0;
        }
    }

    if (e.getActionCommand() == "blue") {
        if (blue == 0) {
            blue = 255;
        } else {
            blue = 0;
        }
    }

    Color setCol = new Color(red, green, blue);
    display.setBackground(setCol);
}

From source file:org.lnicholls.galleon.util.Tools.java

public static Color darken(Color color) {
    return new Color((int) (color.getRed() * 0.59), (int) (color.getGreen() * 0.59),
            (int) (color.getBlue() * 0.59));
}

From source file:com.galenframework.rainbow4j.colorscheme.SimpleColorClassifier.java

public SimpleColorClassifier(String name, Color color) {
    this.name = name;
    this.red = color.getRed();
    this.blue = color.getBlue();
    this.green = color.getGreen();
}

From source file:gr.iti.mklab.reveal.forensics.util.Util.java

public static int[][][] getRGBArray(BufferedImage imageIn) {
    // possible 10-fold speed increase in:
    // http://stackoverflow.com/questions/6524196/java-get-pixel-array-from-image
    // (but ensure all major bases are covered)
    int ImW = imageIn.getWidth();
    int ImH = imageIn.getHeight();
    Color tmpColor;
    int[][][] rgbValues = new int[3][ImW][ImH];

    for (int ii = 0; ii < ImW; ii++) {
        for (int jj = 0; jj < ImH; jj++) {
            tmpColor = new Color(imageIn.getRGB(ii, jj));
            rgbValues[0][ii][jj] = tmpColor.getRed();
            rgbValues[1][ii][jj] = tmpColor.getGreen();
            rgbValues[2][ii][jj] = tmpColor.getBlue();
        }/* w w  w .j a  v a2 s.  c o  m*/
    }
    return rgbValues;
}

From source file:lu.lippmann.cdb.graph.GraphUtil.java

/**
 * return if background of a node is dark or not
 * /*from w  ww  .  j a v a2s. co  m*/
 * @param v
 * @return
 */
public static boolean isDarkNode(final CNode v) {
    final Color c = v.getColor();
    return ((c.getBlue() + c.getGreen() + c.getRed()) / 3 < 128);
}

From source file:net.sf.mzmine.modules.peaklistmethods.dataanalysis.projectionplots.ProjectionPlotRenderer.java

private boolean isAvoidColor(Color color) {
    for (Color c : avoidColors) {
        if ((color.getRed() >= c.getRed()) && (color.getGreen() >= c.getGreen())
                && (color.getBlue() >= c.getBlue()))
            return true;
    }/*from   www. j a  v  a  2 s.co m*/

    return false;
}

From source file:dr.PlotRenderer.java

private boolean isAvoidColor(Color color) {
    for (Color c : avoidColors) {
        if ((color.getRed() >= c.getRed()) && (color.getGreen() >= c.getGreen())
                && (color.getBlue() >= c.getBlue())) {
            return true;
        }/*from  w w  w.j  av  a2 s  .co  m*/
    }

    return false;
}

From source file:ColorPicker3.java

protected int toGray(Color c) {
    int r = c.getRed();
    int g = c.getGreen();
    int b = c.getBlue();
    // Grab the luminance the same way GIMP does...
    return (int) Math.round(0.3 * r + 0.59 * g + 0.11 * b);
}

From source file:org.tros.utils.converters.ColorConverter.java

/**
 * Convert.//  w w  w .  j  a  v a  2  s.co  m
 *
 * @param <T>
 * @param type
 * @param value
 * @return
 */
@Override
@SuppressWarnings("unchecked")
public <T> T convert(Class<T> type, Object value) {
    if (type == String.class) {
        if (value.getClass() == Color.class) {
            Color c = (Color) value;
            return (T) String.format("#%02x%02x%02x", c.getRed(), c.getGreen(), c.getBlue());
        } else {
            return (T) value;
        }
    } else {
        try {
            return (T) Color.class.getField(value.toString()).get(null);
        } catch (NoSuchFieldException ex) {
        } catch (SecurityException | IllegalArgumentException | IllegalAccessException ex) {
        }
        return (T) Color.decode(value.toString());
    }
}