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:baocaoxla.xuly_compare.java

public ChartPanel displayhistogram(BufferedImage image) {

    HistogramDataset dataset = new HistogramDataset();

    final int w = image.getWidth();
    final int h = image.getHeight();
    double[] r = new double[w * h];
    double[] g = new double[w * h];
    double[] b = new double[w * h];
    int dem = 0;/*from  ww  w .  j  a v a  2  s .com*/
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            Color c = new Color(image.getRGB(j, i));
            r[dem] = c.getRed();
            g[dem] = c.getGreen();
            b[dem] = c.getBlue();
            dem++;
        }
    }
    //r = raster.getSamples(0, 0, w, h, 0, r);
    dataset.addSeries("Red", r, 256);
    //r = raster.getSamples(0, 0, w, h, 1, r);
    dataset.addSeries("Green", g, 256);
    // r = raster.getSamples(0, 0, w, h, 2, r);
    dataset.addSeries("Blue", b, 256);
    // chart
    JFreeChart chart = ChartFactory.createHistogram("Histogram", "Value", "Count", dataset,
            PlotOrientation.VERTICAL, true, true, false);
    ChartPanel panel = new ChartPanel(chart);
    return panel;

}

From source file:org.geoserver.wms.wms_1_1_1.GetLegendGraphicTest.java

/**
 * Tests a dpi rescaled legend/*from   ww w .  ja  v  a 2  s  .c o  m*/
 */
@Test
public void testStatesLegendDpiRescaled() throws Exception {
    String base = "wms?service=WMS&version=1.1.1&request=GetLegendGraphic" + "&layer=sf:states&style=Population"
            + "&format=image/png&width=20&height=20&legend_options=dpi:180";
    BufferedImage image = getAsImage(base, "image/png");

    assertPixel(image, 20, 20, Color.RED);
    assertPixel(image, 20, 60, Color.GREEN);
    assertPixel(image, 20, 100, Color.BLUE);
    Color linePixel = getPixelColor(image, 20, 140);
    assertTrue(linePixel.getRed() < 10);
    assertTrue(linePixel.getGreen() < 10);
    assertTrue(linePixel.getBlue() < 10);
}

From source file:net.sf.mzmine.modules.peaklistmethods.dataanalysis.projectionplots.ProjectionPlotPanel.java

public ProjectionPlotPanel(ProjectionPlotWindow masterFrame, ProjectionPlotDataset dataset,
        ParameterSet parameters) {/*from   ww  w.j  av  a2  s.c om*/
    super(null);

    boolean createLegend = false;
    if ((dataset.getNumberOfGroups() > 1) && (dataset.getNumberOfGroups() < 20))
        createLegend = true;

    chart = ChartFactory.createXYAreaChart("", dataset.getXLabel(), dataset.getYLabel(), dataset,
            PlotOrientation.VERTICAL, createLegend, false, false);
    chart.setBackgroundPaint(Color.white);

    setChart(chart);

    // title

    TextTitle chartTitle = chart.getTitle();
    chartTitle.setMargin(5, 0, 0, 0);
    chartTitle.setFont(titleFont);
    chart.removeSubtitle(chartTitle);

    // disable maximum size (we don't want scaling)
    setMaximumDrawWidth(Integer.MAX_VALUE);
    setMaximumDrawHeight(Integer.MAX_VALUE);

    // set the plot properties
    plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));

    // set grid properties
    plot.setDomainGridlinePaint(gridColor);
    plot.setRangeGridlinePaint(gridColor);

    // set crosshair (selection) properties
    plot.setDomainCrosshairVisible(false);
    plot.setRangeCrosshairVisible(false);

    plot.setForegroundAlpha(dataPointAlpha);

    NumberFormat numberFormat = NumberFormat.getNumberInstance();

    // set the X axis (component 1) properties
    NumberAxis xAxis = (NumberAxis) plot.getDomainAxis();
    xAxis.setNumberFormatOverride(numberFormat);

    // set the Y axis (component 2) properties
    NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
    yAxis.setNumberFormatOverride(numberFormat);

    plot.setDataset(dataset);

    spotRenderer = new ProjectionPlotRenderer(plot, dataset);
    itemLabelGenerator = new ProjectionPlotItemLabelGenerator(parameters);
    spotRenderer.setBaseItemLabelGenerator(itemLabelGenerator);
    spotRenderer.setBaseItemLabelsVisible(true);
    spotRenderer.setBaseToolTipGenerator(new ProjectionPlotToolTipGenerator(parameters));
    plot.setRenderer(spotRenderer);

    // Setup legend
    if (createLegend) {
        LegendItemCollection legendItemsCollection = new LegendItemCollection();
        for (int groupNumber = 0; groupNumber < dataset.getNumberOfGroups(); groupNumber++) {
            Object paramValue = dataset.getGroupParameterValue(groupNumber);
            if (paramValue == null) {
                // No parameter value available: search for raw data files
                // within this group, and use their names as group's name
                String fileNames = new String();
                for (int itemNumber = 0; itemNumber < dataset.getItemCount(0); itemNumber++) {
                    String rawDataFile = dataset.getRawDataFile(itemNumber);
                    if (dataset.getGroupNumber(itemNumber) == groupNumber)
                        fileNames = fileNames.concat(rawDataFile);
                }
                if (fileNames.length() == 0)
                    fileNames = "Empty group";

                paramValue = fileNames;
            }
            Color nextColor = (Color) spotRenderer.getGroupPaint(groupNumber);
            Color groupColor = new Color(nextColor.getRed(), nextColor.getGreen(), nextColor.getBlue(),
                    (int) Math.round(255 * dataPointAlpha));
            legendItemsCollection.add(new LegendItem(paramValue.toString(), "-", null, null,
                    spotRenderer.getDataPointsShape(), groupColor));
        }
        plot.setFixedLegendItems(legendItemsCollection);
    }

}

From source file:net.wastl.rdfdot.base.GraphvizSerializerBase.java

protected String graphvizColor(Color c) {
    return String.format("\"#%02x%02x%02x\"", c.getRed(), c.getGreen(), c.getBlue());
}

From source file:edu.ku.brc.ui.GradiantButton.java

/**
 * Sests the text Color/*  w  w  w . j ava2 s  . c o  m*/
 * @param textColor text color
 */
public void setTextColor(Color textColor) {
    this.textColor = textColor;
    textColorShadow = new Color(textColor.getRed(), textColor.getGreen(), textColor.getBlue(), 70);
}

From source file:net.sourceforge.processdash.ev.ui.chart.RangeXYItemRenderer.java

private Color transp(Color c, double alpha) {
    return new Color(c.getRed(), c.getGreen(), c.getBlue(), (int) (255 * alpha));
}

From source file:pdi.HistogramaRGB.java

public int[] pegaPixels(File file) {
    BufferedImage img = pegaImagem();
    int[] rgb = new int[w * h];

    for (int i = 0; i < w; i++)
        for (int j = 0; j < h; j++) {
            rgb[i * j] = img.getRGB(i, j);
        }//from  www  .  j  av a2  s.c o  m

    for (int i = 0; i < rgb.length; i++) {
        Color c = new Color(rgb[i]);
        System.out.println("Vermelho: " + c.getRed());
    }
    for (int i = 0; i < rgb.length; i++) {
        Color c = new Color(rgb[i]);
        System.out.println("Vermelho: " + c.getGreen());
    }
    for (int i = 0; i < rgb.length; i++) {
        Color c = new Color(rgb[i]);
        System.out.println("Vermelho: " + c.getBlue());
    }

    return rgb;
}

From source file:org.pentaho.ui.xul.swt.tags.SwtGrid.java

public void setBgcolor(String bgcolor) {
    this.bgcolor = bgcolor;
    Color c = Color.decode(bgcolor);
    grid.setBackground(/*from   w  w  w .  j a v  a  2 s .c  o  m*/
            new org.eclipse.swt.graphics.Color(grid.getDisplay(), c.getRed(), c.getGreen(), c.getBlue()));
    grid.setBackgroundMode(SWT.INHERIT_DEFAULT);
}

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

/**
 * Draws the gridlines for the plot's primary range axis, if they are
 * visible./*from   ww  w  . j  a v a2  s .  c o  m*/
 *
 * @param g2  the graphics device.
 * @param area  the data area.
 * @param ticks  the ticks.
 *
 * @see #drawDomainGridlines(Graphics2D, Rectangle2D, List)
 */
protected void drawRangeGridlines(Graphics2D g2, Rectangle2D area, List ticks) {

    // no renderer, no gridlines...
    if (getRenderer() == null) {
        return;
    }

    // draw the range grid lines, if any...
    if (isRangeGridlinesVisible() && this.yAxisStepSize > 0) {
        Stroke gridStroke = getRangeGridlineStroke();
        Paint gridPaint = getRangeGridlinePaint();
        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);
                }
                getRenderer().drawRangeLine(g2, this, getRangeAxis(), area, y, paint, gridStroke);
                y += this.yAxisStepSize;
            }
        }
    }
}

From source file:com.cedarsoft.serialization.serializers.jackson.ColorSerializer.java

@Override
public void serialize(@Nonnull JsonGenerator serializeTo, @Nonnull Color object, @Nonnull Version formatVersion)
        throws IOException, VersionException, JsonProcessingException {
    serializeTo.writeNumberField(PROPERTY_RED, object.getRed());
    serializeTo.writeNumberField(PROPERTY_GREEN, object.getGreen());
    serializeTo.writeNumberField(PROPERTY_BLUE, object.getBlue());
}