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:joinery.impl.Display.java

private static void addTrend(final Chart chart, final Series series, final List<Object> xdata) {
    final SimpleRegression model = new SimpleRegression();
    final Iterator<? extends Number> y = series.getYData().iterator();
    for (int x = 0; y.hasNext(); x++) {
        model.addData(x, y.next().doubleValue());
    }//w  w  w  .  j  av  a2  s .  co  m
    final Color mc = series.getMarkerColor();
    final Color c = new Color(mc.getRed(), mc.getGreen(), mc.getBlue(), 0x60);
    final Series trend = chart.addSeries(series.getName() + " (trend)",
            Arrays.asList(xdata.get(0), xdata.get(xdata.size() - 1)),
            Arrays.asList(model.predict(0), model.predict(xdata.size() - 1)));
    trend.setLineColor(c);
    trend.setMarker(SeriesMarker.NONE);
}

From source file:uk.bl.wa.tika.parser.imagefeatures.FaceDetectionParser.java

private static Color maxBrightness(Color c) {
    float[] hsv = new float[3];
    Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), hsv);
    return new Color(Color.HSBtoRGB(hsv[0], hsv[1], 1.0f));
}

From source file:Gradient.java

/**
 * Creates an array of Color objects for use as a gradient, using a linear
 * interpolation between the two specified colors.
 * /*w w  w .j  a v  a2 s . c o m*/
 * @param one
 *            Color used for the bottom of the gradient
 * @param two
 *            Color used for the top of the gradient
 * @param numSteps
 *            The number of steps in the gradient. 250 is a good number.
 */
public static Color[] createGradient(final Color one, final Color two, final int numSteps) {
    int r1 = one.getRed();
    int g1 = one.getGreen();
    int b1 = one.getBlue();
    int a1 = one.getAlpha();

    int r2 = two.getRed();
    int g2 = two.getGreen();
    int b2 = two.getBlue();
    int a2 = two.getAlpha();

    int newR = 0;
    int newG = 0;
    int newB = 0;
    int newA = 0;

    Color[] gradient = new Color[numSteps];
    double iNorm;
    for (int i = 0; i < numSteps; i++) {
        iNorm = i / (double) numSteps; // a normalized [0:1] variable
        newR = (int) (r1 + iNorm * (r2 - r1));
        newG = (int) (g1 + iNorm * (g2 - g1));
        newB = (int) (b1 + iNorm * (b2 - b1));
        newA = (int) (a1 + iNorm * (a2 - a1));
        gradient[i] = new Color(newR, newG, newB, newA);
    }

    return gradient;
}

From source file:ml.hsv.java

public static void HSV2File(hsv hsvImage[][], int width, int height) throws IOException //store img output as hsv2file.png
{
    BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
    WritableRaster raster = image.getRaster();
    for (int i = 0; i < height; i++) {
        for (int j = 0; j < width; j++) {
            int RGB = Color.HSBtoRGB(hsvImage[i][j].h, hsvImage[i][j].s, hsvImage[i][j].v);
            Color c = new Color(RGB);
            int temp[] = { c.getRed(), c.getGreen(), c.getBlue() };
            raster.setPixel(j, i, temp);
        }//from  ww  w.  j av  a 2 s .  c  om
    }
    ImageIO.write(image, "PNG",
            new File("/home/shinchan/FinalProject/PaperImplementation/Eclipse/ML/output/hsv2file.png"));
}

From source file:Main.java

public static Color getGradientRgbColor(float ratio, Color minColor, Color maxColor) {
    if (ratio < 0)
        ratio = 0.0F;// www.j  a va  2  s  .c  o  m
    if (ratio > 1.0)
        ratio = 1.0F;
    int red = (int) (maxColor.getRed() * ratio + minColor.getRed() * (1.0 - ratio));
    int green = (int) (maxColor.getGreen() * ratio + minColor.getGreen() * (1 - ratio));
    int blue = (int) (maxColor.getBlue() * ratio + minColor.getBlue() * (1 - ratio));
    Color gradient = new Color(red, green, blue);
    return gradient;
}

From source file:ColorUtil.java

public static final Color add(Color c1, Color c2) {
    return c1 == null ? c2
            : c2 == null ? c1/*from   w w w.j  av a  2  s.c om*/
                    : new Color(Math.min(255, c1.getRed() + c2.getRed()),
                            Math.min(255, c1.getGreen() + c2.getGreen()),
                            Math.min(255, c1.getBlue() + c2.getBlue()), c1.getAlpha());
}

From source file:org.testeditor.dashboard.TableDurationTrend.java

/**
 * composes awt color from swt color RGB.
 * // ww w  . j a  v  a 2  s. c o m
 * @param color
 *            SWT
 * @return java.awt.Color
 */
public static java.awt.Color toAwtColor(org.eclipse.swt.graphics.Color color) {
    return new java.awt.Color(color.getRed(), color.getGreen(), color.getBlue());
}

From source file:Main.java

/**
 * Make a color scaled using a defined factor.
 *
 * @param color/*  ww w  .j  a v a  2  s .  c  o m*/
 *          the color to scale.
 * @param factor
 *          the factor to use.
 * @return the scaled color.
 */
public static Color getScaledColor(Color color, double factor) {
    if (color == null) {
        return null;
    }
    if (factor <= 1) {
        return new Color(Math.max((int) (color.getRed() * factor), 0),
                Math.max((int) (color.getGreen() * factor), 0), Math.max((int) (color.getBlue() * factor), 0),
                color.getAlpha());
    }
    int r = color.getRed();
    int g = color.getGreen();
    int b = color.getBlue();

    int i = (int) (1.0 / (factor - 1));
    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 / (2 - factor)), 255), Math.min((int) (g / (2 - factor)), 255),
            Math.min((int) (b / (2 - factor)), 255));

}

From source file:ColorUtilities.java

public static Color blend(Color c0, Color c1) {
    double totalAlpha = c0.getAlpha() + c1.getAlpha();
    double weight0 = c0.getAlpha() / totalAlpha;
    double weight1 = c1.getAlpha() / totalAlpha;

    double r = weight0 * c0.getRed() + weight1 * c1.getRed();
    double g = weight0 * c0.getGreen() + weight1 * c1.getGreen();
    double b = weight0 * c0.getBlue() + weight1 * c1.getBlue();
    double a = Math.max(c0.getAlpha(), c1.getAlpha());

    return new Color((int) r, (int) g, (int) b, (int) a);
}

From source file:com.igormaznitsa.jhexed.swing.editor.ui.Utils.java

public static int calculateBrightness(final Color color) {
    return (int) Math.sqrt(color.getRed() * color.getRed() * .241d + color.getGreen() * color.getGreen() * .691d
            + color.getBlue() * color.getBlue() * .068d);
}