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:org.jfree.eastwood.ChartEngine.java

private static void applyColorsToPiePlot(PiePlot plot, Color[] colors) {
    if (colors.length == 1) {
        Color c = colors[0];
        colors = new Color[2];
        colors[0] = c;//from w  ww .  jav  a 2s .c  om
        colors[1] = new Color(255 - ((255 - c.getRed()) / 5), 255 - ((255 - c.getGreen()) / 5),
                255 - ((255 - c.getBlue()) / 5));
    }
    PieDataset dataset = plot.getDataset();
    int sectionCount = dataset.getItemCount();
    if (colors.length < sectionCount) { // we need to interpolate some
                                        // colors
        for (int i = 0; i < colors.length - 1; i++) {
            Color c1 = colors[i];
            Color c2 = colors[i + 1];
            int s1 = sectionIndexForColor(i, colors.length, sectionCount);
            int s2 = sectionIndexForColor(i + 1, colors.length, sectionCount);
            for (int s = s1; s <= s2; s++) {
                Color c = interpolatedColor(c1, c2, s - s1, s2 - s1);
                plot.setSectionPaint(dataset.getKey(s), c);
            }
        }
    } else {
        for (int i = 0; i < sectionCount; i++) {
            plot.setSectionPaint(dataset.getKey(i), colors[i]);
        }
    }
}

From source file:pl.edu.icm.visnow.lib.utils.ImageUtilities.java

public static void makeTransparent(BufferedImage img, Color trColor) {
    int w = img.getWidth();
    int h = img.getHeight();
    if (img.getType() != BufferedImage.TYPE_INT_ARGB) {
        return;//from   w w w.j ava2s  .c om
    }

    for (int x = 0; x < w; x++) {
        for (int y = 0; y < h; y++) {
            if (img.getRaster().getSample(x, y, 0) == trColor.getRed()
                    && img.getRaster().getSample(x, y, 1) == trColor.getGreen()
                    && img.getRaster().getSample(x, y, 2) == trColor.getBlue()) {
                img.getRaster().setSample(x, y, 3, 0);
            }
        }
    }
}

From source file:org.kurento.test.client.TestClient.java

public boolean compareColor(String videoTag, Color expectedColor) {
    @SuppressWarnings("unchecked")
    List<Long> realColor = (List<Long>) browserClient
            .executeScriptAndWaitOutput("return kurentoTest.colorInfo['" + videoTag + "'].currentColor;");

    long red = realColor.get(0);
    long green = realColor.get(1);
    long blue = realColor.get(2);

    double distance = Math.sqrt((red - expectedColor.getRed()) * (red - expectedColor.getRed())
            + (green - expectedColor.getGreen()) * (green - expectedColor.getGreen())
            + (blue - expectedColor.getBlue()) * (blue - expectedColor.getBlue()));

    boolean out = distance <= browserClient.getColorDistance();
    if (!out) {//w  w  w.  j av  a  2  s. co m
        log.error("Difference in color comparision. Expected: {}, Real: {} (distance={})", expectedColor,
                realColor, distance);
    }

    return out;
}

From source file:org.jtrfp.trcl.core.Renderer.java

public Renderer setSunColor(final Color color) {
    gpu.getTr().getThreadManager().submitToGL(new Callable<Void>() {
        @Override// w w  w . j a  v a 2s  .  co  m
        public Void call() throws Exception {
            factory.getDeferredProgram().use();
            factory.getDeferredProgram().getUniform("sunColor").set(color.getRed() / 128f,
                    color.getGreen() / 128f, color.getBlue() / 128f);
            gpu.defaultProgram();
            return null;
        }
    }).get();
    return this;
}

From source file:org.jtrfp.trcl.core.Texture.java

Texture(Color c, TR tr) {
    this(new PalettedVectorList(colorZeroRasterVL(), colorVL(c)), null,
            "SolidColor r=" + c.getRed() + " g=" + c.getGreen() + " b=" + c.getBlue(), tr, false);
}

From source file:org.jtrfp.trcl.core.Renderer.java

public Renderer setAmbientLight(final Color color) {
    gpu.getTr().getThreadManager().submitToGL(new Callable<Void>() {
        @Override// www  .j  a v a 2  s  . c om
        public Void call() throws Exception {
            factory.getDeferredProgram().use();
            factory.getDeferredProgram().getUniform("ambientLight").set(color.getRed() / 128f,
                    color.getGreen() / 128f, color.getBlue() / 128f);
            gpu.defaultProgram();
            return null;
        }
    }).get();
    return this;
}

From source file:org.openfaces.component.chart.impl.renderers.LineFillRenderer.java

private void configureSolidAreaFill(Graphics2D g2, Paint itemPaint, SolidLineAreaFill solidLineAreaFill) {
    final Double transparency = solidLineAreaFill.getTransparency();

    if (itemPaint instanceof Color && transparency >= 0.0 && transparency <= 1.0) {
        Color itemColor = (Color) itemPaint;
        int alpha = transparency >= 0.0 && transparency <= 1.0 ? Math.round(255 * transparency.floatValue())
                : 255;/*from  w ww. j av  a  2 s.c o m*/
        g2.setPaint(new Color(itemColor.getRed(), itemColor.getGreen(), itemColor.getBlue(), alpha));
    } else {
        g2.setPaint(itemPaint);
    }
}

From source file:org.griphyn.vdl.karajan.monitor.monitors.swing.GraphPanel.java

public void store(Preferences p) {
    p.putInt("enabledCount", enabled.size());
    for (int i = 0; i < enabled.size(); i++) {
        Preferences gp = p.node("series" + i);
        gp.put("key", enabled.get(i));
        Color color = (Color) chart.getPlot().getLegendItems().get(i).getLinePaint();
        gp.putInt("color.r", color.getRed());
        gp.putInt("color.g", color.getGreen());
        gp.putInt("color.b", color.getBlue());
    }/*from  ww w.ja va  2s .co m*/
}

From source file:net.sf.jclal.gui.view.components.chart.ExternalBasicChart.java

/**
 * @param one/*from  www .j  av a2 s  .co m*/
 * @param two
 * @param three
 * @return
 * <p>
 * return new color RBG
 */
private Color colorGenerator(Color one, Color two, Color three) {
    int red = (int) (one.getRed() + one.getBlue() + one.getGreen() / 3);
    int blue = (int) (two.getBlue() + two.getRed() + two.getGreen() / 3);
    int green = (int) (three.getGreen() + three.getRed() + three.getBlue() / 3);

    return new Color(red, blue, green);
}

From source file:org.apache.fop.afp.DataStream.java

/**
 * This method will create shading on the page using the specified
 * coordinates (the shading contrast is controlled via the red, green, blue
 * parameters, by converting this to grey scale).
 *
 * @param x//from   www  .  ja va  2  s . c  o  m
 *            the x coordinate of the shading
 * @param y
 *            the y coordinate of the shading
 * @param w
 *            the width of the shaded area
 * @param h
 *            the height of the shaded area
 * @param col
 *            the shading color
 */
public void createShading(int x, int y, int w, int h, Color col) {
    currentPageObject.createShading(x, y, w, h, col.getRed(), col.getGreen(), col.getBlue());
}