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:com.rapidminer.gui.new_plotter.engine.jfreechart.renderer.FormattedXYDifferenceRenderer.java

@Override
public Paint getNegativePaint() {
    StaticDebug.debug("getNegativePaint(): " + trueSeriesIdx);
    Color color = getFormatDelegate().getSeriesColor(trueSeriesIdx);
    if (color != null) {
        return (new Color(255 - color.getRed(), 255 - color.getGreen(), 255 - color.getBlue(),
                color.getAlpha() / 2));//w  w  w . j a v  a 2s. c  om
    } else {
        return super.getNegativePaint();
    }
}

From source file:com.anrisoftware.prefdialog.miscswing.lists.RubberBandingList.java

private Color createSelectionColor() {
    Color c = getSelectionBackground();
    int r = c.getRed(), g = c.getGreen(), b = c.getBlue();
    return r > g ? r > b ? new Color(r, 0, 0) : new Color(0, 0, b)
            : g > b ? new Color(0, g, 0) : new Color(0, 0, b);
}

From source file:com.mebigfatguy.polycasso.JavaSaver.java

private String getColorData(PolygonData[] data) {
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);

    String comma = "";
    for (PolygonData pd : data) {

        pw.println(comma);//from  w  w w  .  java  2 s . com
        pw.print(TABS);
        pw.print("{");

        Color color = pd.getColor();
        pw.print(color.getRed());
        pw.print(",");
        pw.print(color.getGreen());
        pw.print(",");
        pw.print(color.getBlue());
        pw.print("}");
        comma = ",";
    }

    pw.flush();
    return sw.toString();
}

From source file:util.ui.PictureAreaIcon.java

private boolean colorsInEqualRange(final Color c1, final Color c2) {
    return Math.abs(c1.getRed() - c2.getRed()) <= MAX_COLOR_DIFF
            && Math.abs(c1.getBlue() - c2.getBlue()) <= MAX_COLOR_DIFF
            && Math.abs(c1.getGreen() - c2.getGreen()) <= MAX_COLOR_DIFF;
}

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

public boolean areStarsVisible() {
    Color c = getHorizonGradientTop();
    return c.getRed() + c.getGreen() + c.getBlue() < 25 || !hasClouds();
}

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

/**
 * Masks out white colour//from  w w  w  .j  ava2s  .  c  o m
 * @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:edu.gmu.cs.sim.util.media.chart.SeriesAttributes.java

/** Given an opaque color and a desired opacity (from 0.0 to 1.0), returns a new color of the same tint but with
 the given opacity. *///from w  ww .  j a  v  a  2  s  . co m
public Color reviseColor(Color c, double opacity) {
    return new Color(c.getRed(), c.getGreen(), c.getBlue(), (int) (opacity * 255));
}

From source file:org.springframework.boot.ImageBanner.java

private int getLuminance(Color color, boolean inverse) {
    double luminance = 0.0;
    luminance += getLuminance(color.getRed(), inverse, RGB_WEIGHT[0]);
    luminance += getLuminance(color.getGreen(), inverse, RGB_WEIGHT[1]);
    luminance += getLuminance(color.getBlue(), inverse, RGB_WEIGHT[2]);
    return (int) Math.ceil((luminance / 0xFF) * 100);
}

From source file:org.jfree.eastwood.GCategoryPlot.java

/**
 * Draws the gridlines for the plot.//from  ww w  . j  a v  a2s .c om
 *
 * @param g2  the graphics device.
 * @param dataArea  the area inside the axes.
 * @param ticks  the ticks.
 *
 * @see #drawDomainGridlines(Graphics2D, Rectangle2D)
 */
protected void drawRangeGridlines(Graphics2D g2, Rectangle2D dataArea, List ticks) {
    // draw the range grid lines, if any...
    if (isRangeGridlinesVisible()) {
        Stroke gridStroke = getRangeGridlineStroke();
        Paint gridPaint = getRangeGridlinePaint();
        if ((gridStroke != null) && (gridPaint != null)) {
            ValueAxis axis = getRangeAxis();
            if (axis != null) {
                double lower = axis.getRange().getLowerBound();
                double upper = axis.getRange().getUpperBound();
                double y = lower;
                while (y <= upper) {
                    Paint paint = gridPaint;
                    if ((y == lower || y == upper) && gridPaint instanceof Color) {
                        Color c = (Color) gridPaint;
                        paint = new Color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha() / 3);
                    }
                    try {
                        setRangeGridlinePaint(paint);
                        getRenderer().drawRangeGridline(g2, this, getRangeAxis(), dataArea, y);
                    } finally {
                        setRangeGridlinePaint(gridPaint);
                    }
                    y += this.yAxisStepSize;
                }
            }
        }
    }
}

From source file:util.program.ProgramTextCreator.java

private static String addSearchLink(String topic, String displayText) {
    Color foreground = Color.black;//Settings.propProgramPanelForegroundColor.getColor();

    String style = " style=\"color:rgb(" + foreground.getRed() + "," + foreground.getGreen() + ","
            + foreground.getBlue() + "); border-bottom: 1px dashed;\"";
    StringBuilder buffer = new StringBuilder(32);
    buffer.append("<a href=\"");
    buffer.append(TVBROWSER_URL_PROTOCOL);
    buffer.append(StringUtils.remove(StringUtils.remove(topic, '"'), '\''));

    buffer.append("\" ");
    buffer.append(style);/* w  ww.  j  a  va2s.c  o  m*/
    buffer.append('>');
    buffer.append(displayText);
    buffer.append("</a>");
    return buffer.toString();
}