Example usage for java.awt Color getGreen

List of usage examples for java.awt Color getGreen

Introduction

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

Prototype

public int getGreen() 

Source Link

Document

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

Usage

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  ww w . j a  va  2  s .  co m
        g2.setPaint(new Color(itemColor.getRed(), itemColor.getGreen(), itemColor.getBlue(), alpha));
    } else {
        g2.setPaint(itemPaint);
    }
}

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

public Renderer setSunColor(final Color color) {
    gpu.getTr().getThreadManager().submitToGL(new Callable<Void>() {
        @Override// w ww  .ja v  a 2 s. 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.Renderer.java

public Renderer setAmbientLight(final Color color) {
    gpu.getTr().getThreadManager().submitToGL(new Callable<Void>() {
        @Override/*from  w ww . jav a  2s. c  o  m*/
        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.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   w  w w .j a v a2 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());
}

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

/**
 * @param one// w w  w  .  j  av  a  2 s .c  o 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:haven.Utils.java

public static Color preblend(Color c1, Color c2) {
    double a1 = c1.getAlpha() / 255.0;
    double a2 = c2.getAlpha() / 255.0;
    /* I can't help but feel that this should be possible to
     * express in some simpler form, but I can't see how. */
    double ac = a1 + a2 - (a1 * a2);
    return (new Color((int) Math.round((((c2.getRed() * a2) - (c1.getRed() * a2)) / ac) + c1.getRed()),
            (int) Math.round((((c2.getGreen() * a2) - (c1.getGreen() * a2)) / ac) + c1.getGreen()),
            (int) Math.round((((c2.getBlue() * a2) - (c1.getBlue() * a2)) / ac) + c1.getBlue()),
            (int) Math.round(ac * 255)));
}

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;/*  w  w  w  .  j  ava 2  s .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.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   w  w w . j ava  2  s  . co  m*/
}

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) {/*from   w w  w. java 2 s . c o  m*/
        log.error("Difference in color comparision. Expected: {}, Real: {} (distance={})", expectedColor,
                realColor, distance);
    }

    return out;
}

From source file:statechum.analysis.learning.Visualiser.java

private static PluggableRenderer labelEdges(Graph graph, PluggableRenderer render,
        final LayoutOptions graphLayoutOptions) {
    final EdgeColour paintChooser = new EdgeColour(graph);
    EdgeStringer stringer = new EdgeStringer() {

        @SuppressWarnings("unchecked")
        @Override/*from  w ww . ja v  a 2 s .  c o m*/
        public String getLabel(ArchetypeEdge e) {
            String result = "";

            if (e.containsUserDatumKey(JUConstants.LABEL)) {
                StringBuffer text = new StringBuffer();
                text.append("<html>");
                boolean first = true;
                //final String blowupAttribute = Math.abs(graphLayoutOptions.scaleText - 1)<Configuration.fpAccuracy?" ":
                //   " style=\"font-size:"+Math.round(graphLayoutOptions.scaleText*100.)+"%\"";
                String color = "black";
                if (e.containsUserDatumKey(JUConstants.DIFF)) {
                    Color rgb = (Color) e.getUserDatum(JUConstants.DIFF);
                    color = "rgb(" + rgb.getRed() + "," + rgb.getGreen() + "," + rgb.getBlue() + ")";
                }
                for (Label lbl : abstractLabels((Set<Label>) e.getUserDatum(JUConstants.LABEL),
                        graphLayoutOptions.componentsToPick)) {
                    if (!first) {// choose separator
                        text.append("<br>");// default layout is vertical
                    } else
                        first = false;

                    if (!(lbl instanceof ErlangLabel)) {
                        text.append("<font color=" + color + ">");
                        text.append(lbl.toString());
                    } else {
                        ErlangLabel l = (ErlangLabel) lbl;
                        text.append("<font color=blue>");
                        text.append(l.callName);
                        text.append("</font>,&nbsp;");
                        text.append("<font color=" + color + ">");
                        text.append(l.input);
                        text.append("</font>");
                        if (l.expectedOutput != null) {
                            text.append(",&nbsp;<font color=black>");
                            text.append(l.expectedOutput);
                            text.append("</font>");
                        }
                    }
                }
                text.append("</html>");
                result = text.toString();
            }

            return result;
        }
    };
    render.setEdgeArrowFunction(
            new DirectionalEdgeArrowFunction((int) Math.round(10. * graphLayoutOptions.scaleLines),
                    (int) Math.round(5. * graphLayoutOptions.scaleLines), 4));
    render.setEdgeStringer(stringer);
    render.setEdgeStrokeFunction(new ConstantEdgeStrokeFunction((float) graphLayoutOptions.scaleLines));
    render.setEdgePaintFunction(new AbstractEdgePaintFunction() {

        @Override
        public Paint getDrawPaint(Edge e) {
            Color result = paintChooser.getPickedColour(e, graphLayoutOptions);
            return result != null ? result : Color.BLACK;
        }
    });
    return render;
}