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:task5.deneme.java

private void getRGBs() {
    for (int i = 0; i < img.getWidth(); i++) {
        for (int j = 0; j < img.getHeight(); j++) {
            Color c = new Color(img.getRGB(i, j));
            red.add(c.getRed());/*from w ww .j a  va 2 s .  co m*/
            green.add(c.getGreen());
            blue.add(c.getBlue());
        }
    }
}

From source file:dk.dma.msinm.web.wms.WmsProxyServlet.java

/**
 * Masks out white colour//from ww w.j ava2  s .  c om
 * @param image the image to mask out
 * @return the resulting image
 */
private BufferedImage transformWhiteToTransparent(BufferedImage image) {

    BufferedImage dest = image;
    if (image.getType() != BufferedImage.TYPE_INT_ARGB) {
        dest = new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_ARGB);
        Graphics2D g2 = dest.createGraphics();
        g2.drawImage(image, 0, 0, null);
        g2.dispose();

        image.flush();
    }

    // Mask out the white pixels
    final int width = image.getWidth();
    int[] imgData = new int[width];

    for (int y = 0; y < dest.getHeight(); y++) {
        // fetch a line of data from each image
        dest.getRGB(0, y, width, 1, imgData, 0, 1);
        // apply the mask
        for (int x = 0; x < width; x++) {
            for (Color col : MASKED_COLORS) {
                int colDist = Math.abs(col.getRed() - (imgData[x] >> 16 & 0x000000FF))
                        + Math.abs(col.getGreen() - (imgData[x] >> 8 & 0x000000FF))
                        + Math.abs(col.getBlue() - (imgData[x] & 0x000000FF));
                if (colDist <= COLOR_DIST) {
                    imgData[x] = 0x00FFFFFF & imgData[x];
                }
            }
        }
        // replace the data
        dest.setRGB(0, y, width, 1, imgData, 0, 1);
    }
    return dest;
}

From source file:org.jtrfp.trcl.SkySystem.java

/**
 * @return the suggestedFogColor//from  w ww  .j  a v  a  2 s  . c  om
 */
public Color getSuggestedFogColor() {
    if (suggestedFogColor == null) {
        if (!hasClouds()) {
            return Color.black;
        } else {
            Color l = getHorizonGradientBottom();
            Color r = cloudTexture.getAverageColor();
            return new Color((l.getRed() + r.getRed()) / 2, (l.getGreen() + r.getGreen()) / 2,
                    (l.getBlue() + r.getBlue()) / 2, (l.getAlpha() + r.getAlpha()) / 2);
        }
    } //end if(suggestedFogColor==null)
    return suggestedFogColor;
}

From source file:net.sf.mzmine.chartbasics.chartthemes.EStandardChartTheme.java

public void setNoBackground(boolean state) {
    Color c = ((Color) this.getPlotBackgroundPaint());
    Color cchart = ((Color) this.getChartBackgroundPaint());
    this.setPlotBackgroundPaint(new Color(c.getRed(), c.getGreen(), c.getBlue(), state ? 0 : 255));
    this.setChartBackgroundPaint(
            new Color(cchart.getRed(), cchart.getGreen(), cchart.getBlue(), state ? 0 : 255));
    this.setLegendBackgroundPaint(
            new Color(cchart.getRed(), cchart.getGreen(), cchart.getBlue(), state ? 0 : 255));
}

From source file:haven.Utils.java

public static Color contrast(Color col) {
    int max = Math.max(col.getRed(), Math.max(col.getGreen(), col.getBlue()));
    if (max > 128) {
        return (new Color(col.getRed() / 2, col.getGreen() / 2, col.getBlue() / 2, col.getAlpha()));
    } else if (max == 0) {
        return (Color.WHITE);
    } else {/*from  w  w w.  j  a  va  2s  . c om*/
        int f = 128 / max;
        return (new Color(col.getRed() * f, col.getGreen() * f, col.getBlue() * f, col.getAlpha()));
    }
}

From source file:be.ugent.maf.cellmissy.gui.view.renderer.jfreechart.CompassRenderer.java

@Override
public void drawSeries(Graphics2D g2, Rectangle2D dataArea, PlotRenderingInfo info, PolarPlot plot,
        XYDataset dataset, int seriesIndex) {

    // compute the right color for the paint
    int length = GuiUtils.getAvailableColors().length;
    Color color = GuiUtils.getAvailableColors()[index % length];
    // get all the data points
    int numPoints = dataset.getItemCount(seriesIndex);
    // set STroke and Paint of the graphics
    g2.setStroke(new BasicStroke(1.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND));
    g2.setPaint(new Color(color.getRed(), color.getGreen(), color.getBlue(), 175));

    // iterate through the points of the dataset
    for (int i = 0; i < numPoints; i++) {
        double theta = dataset.getXValue(seriesIndex, i); // the angle at the center         
        double radius = dataset.getYValue(seriesIndex, i); // the frequency

        Point p0 = plot.translateToJava2D(0, 0, plot.getAxis(), dataArea);
        Point p1 = plot.translateToJava2D(theta, radius, plot.getAxis(), dataArea);

        Line2D line = new Line2D.Double(p0, p1);
        g2.draw(line);//  w w w . java  2 s .c om
    }
}

From source file:com.controlj.addon.gwttree.server.OpaqueBarRenderer3D.java

private Color getTopLight(Color primary) {
    float hsbVals[] = new float[3];
    Color.RGBtoHSB(primary.getRed(), primary.getGreen(), primary.getBlue(), hsbVals);
    hsbVals[1] = 0.3f;//w ww .j a va2s .c  o m
    hsbVals[2] = 0.97f;
    return Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2]);
}

From source file:com.controlj.addon.gwttree.server.OpaqueBarRenderer3D.java

private Color getTopDark(Color primary) {
    float hsbVals[] = new float[3];
    Color.RGBtoHSB(primary.getRed(), primary.getGreen(), primary.getBlue(), hsbVals);
    hsbVals[1] = 0.9f;/*from w  w w  .j  av a  2  s.  c o  m*/
    hsbVals[2] = 0.6f;
    return Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2]);
}

From source file:com.controlj.addon.gwttree.server.OpaqueBarRenderer3D.java

private Color getFrontDark(Color primary) {
    float hsbVals[] = new float[3];
    Color.RGBtoHSB(primary.getRed(), primary.getGreen(), primary.getBlue(), hsbVals);
    hsbVals[1] = 1.0f;/*from  www. j a  v  a  2  s .c o  m*/
    hsbVals[2] = 0.5f;
    return Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2]);
}

From source file:com.controlj.addon.gwttree.server.OpaqueBarRenderer3D.java

private Color getSideLight(Color primary) {
    float hsbVals[] = new float[3];
    Color.RGBtoHSB(primary.getRed(), primary.getGreen(), primary.getBlue(), hsbVals);
    hsbVals[1] = .6f;/*from   w ww  .ja v  a 2  s.c  o  m*/
    hsbVals[2] = 0.6f;
    return Color.getHSBColor(hsbVals[0], hsbVals[1], hsbVals[2]);
}