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:util.program.ProgramTextCreator.java

private static void startInfoSection(StringBuilder buffer, String section) {
    Color foreground = Color.black;//Settings.propProgramPanelForegroundColor.getColor();

    buffer.append("<tr><td valign=\"top\" style=\"color:#808080; font-size:");
    buffer.append(mBodyFontSize);//from   w ww. j a  va2s . c  o  m
    buffer.append("\"><b>");
    buffer.append(section);
    buffer.append("</b></td><td style=\"color:rgb(" + foreground.getRed() + "," + foreground.getGreen() + ","
            + foreground.getBlue() + "); font-size:");
    buffer.append(mBodyFontSize);
    buffer.append("\">");
}

From source file:net.sf.maltcms.chromaui.charts.GradientPaintScale.java

/**
 *
 * @param f/*  w  w  w.ja v a 2 s  .  c  o  m*/
 */
public void saveGradientPaintScale(File f) {
    try (BufferedWriter bw = new BufferedWriter(new FileWriter(f))) {
        double lowerBound = getLowerBound();
        double upperBound = getUpperBound();
        double incr = (upperBound - lowerBound) / 256.0d;
        double value = lowerBound;
        for (int i = 0; i < 256; i++) {
            Paint p = getPaint(value);
            if (p instanceof Color) {
                Color c = (Color) p;
                bw.write(c.getRed() + "\t" + c.getGreen() + "\t" + c.getBlue());
                bw.newLine();
            }
            lowerBound += incr;
        }
    } catch (IOException ex) {
        Exceptions.printStackTrace(ex);
    }
}

From source file:org.webcurator.ui.admin.controller.CreateFlagController.java

public String getComplementColour(String hexColour) throws JspException {

    String output = null;/*  www  .j  av  a  2 s .com*/
    Integer i = null;

    if (hexColour == null || hexColour.equals("")) {
        i = 0;
    } else {
        i = Integer.parseInt(hexColour, 16);
    }

    int red = (i >> 16);
    int green = (i >> 8) & 0xFF;
    int blue = i & 0xFF;

    float[] hsl;
    float alpha;

    Color rgb = new Color(red, green, blue);
    hsl = fromRGB(rgb);
    alpha = rgb.getAlpha() / 255.0f;

    float hue = (hsl[0] + 180.0f) % 360.0f;
    Color complement = toRGB(hue, hsl[1], hsl[2], 1.0f);

    output = rgb2hex(complement.getRed(), complement.getGreen(), complement.getBlue());

    return output;
}

From source file:org.polymap.core.data.image.WmsRenderProcessor.java

protected void getMap(GetMapRequest request, ProcessorContext context) throws Exception {
    int width = request.getWidth();
    int height = request.getHeight();
    BoundingBox bbox = request.getBoundingBox();
    log.debug("bbox=" + bbox + ", imageSize=" + width + "x" + height);

    Set<ILayer> layers = context.getLayers();
    IService service = context.getService();

    // skip if no layers are visible
    if (layers.isEmpty()) {
        log.debug("no layers.");
    }/*from   w w  w .j  a va  2 s .  co m*/

    WebMapServer wms = service.resolve(WebMapServer.class, null);
    org.geotools.data.wms.request.GetMapRequest getMap = wms.createGetMapRequest();

    getMap.setFormat(request.getFormat());
    getMap.setDimensions(width, height);
    getMap.setTransparent(true);
    Color color = request.getBgColor();
    if (color != null) {
        getMap.setBGColour(String.format("#%02X%02X%02X", color.getRed(), color.getGreen(), color.getBlue()));
    }
    //getMap.setBGColour( "0xFFFFFF" );

    //CRSEnvelope envelop = calculateRequestBBox( )
    // CRSEnvelope envelop = new CRSEnvelope( "EPSG:31468", 4621529.925,5657790.683333333,4623149.175,5659484.016666667 );
    BoundingBox requestBBox = bbox;
    getMap.setBBox(requestBBox.getMinX() + "," + requestBBox.getMinY() //$NON-NLS-1$
            + "," + requestBBox.getMaxX() //$NON-NLS-1$
            + "," + requestBBox.getMaxY()); //$NON-NLS-1$
    // FIXME hack for LRA to support EPSG3857, see GeoServerWms
    // check to see if backend wms supports 900913 or not
    String srs = request.getCRS();
    //String srs = request.getCRS().equals( "EPSG:900913" )
    //        ? "EPSG:3857" : request.getCRS(); 
    getMap.setSRS(srs);

    //getMap.setBBox(  );

    //request.setSRS( "EPSG:4326" );
    //request.setBBox( "-131.13151509433965,46.60532747661736,-117.61620566037737,56.34191403281659" );
    // Note: you can look at the layer metadata to determine a layer's bounding box for a SRS

    //        Map sortedLayersMap = MultiValueMap.decorate( new TreeMap() );
    //        for (Iterator it=visibleLayers.referencedLayers(); it.hasNext();) {
    //            Layer layer = (Layer)availableLayers.get( it.next() );
    //            Integer layerOrder = (Integer)layerOrderMap.get( layer.getName() );
    //            // reverse order; request.addLayer() works that way
    //            Integer key = Integer.valueOf( Integer.MAX_VALUE - layerOrder.intValue() );
    //            sortedLayersMap.put( key, layer );
    //        }
    for (ILayer layer : layers) {
        IGeoResource geores = layer.getGeoResource();
        Layer wmsLayer = geores.resolve(org.geotools.data.ows.Layer.class, null);
        getMap.addLayer(wmsLayer);
        log.debug("    request: layer: " + layer.getLabel());
    }
    log.debug("    WMS URL:" + getMap.getFinalURL());

    InputStream in = null;
    try {
        long start = System.currentTimeMillis();
        GetMapResponse wmsResponse = wms.issueRequest(getMap);
        log.debug("Got repsonse (" + (System.currentTimeMillis() - start) + "ms). providing data: "
                + wmsResponse.getContentType());

        in = wmsResponse.getInputStream();
        int count = 0;
        byte[] buf = new byte[8 * 1024];
        for (int c = in.read(buf); c != -1; c = in.read(buf)) {
            context.sendResponse(new EncodedImageResponse(buf, c));
            buf = new byte[8 * 2048];
            //log.debug( "    --->data sent: " + c );
            count += c;
        }
        if (count == 0) {
            throw new IOException("WMSResponse is empty.");
        }
        context.sendResponse(ProcessorResponse.EOP);
        log.debug("...all data send.");
    } finally {
        IOUtils.closeQuietly(in);
    }
}

From source file:com.fanniemae.ezpie.actions.HighlightScan.java

private boolean checkIfColorInRange(Color colorFound, Color toCompare, int range) {
    int red = colorFound.getRed() - toCompare.getRed();
    int green = colorFound.getGreen() - toCompare.getGreen();
    int blue = colorFound.getBlue() - toCompare.getBlue();
    if (Math.abs(red) < range && Math.abs(green) < range && Math.abs(blue) < range)
        return true;
    return false;
}

From source file:com.hygenics.imaging.ImageCleanup.java

public byte[] reaverage(double factor, byte[] ibytes) {
    // tone red coloring
    BufferedImage color = BufferImage(ibytes);

    if (color != null) {
        BufferedImage averaged = new BufferedImage(color.getWidth(), color.getHeight(),
                BufferedImage.TYPE_INT_RGB);

        for (int i = 0; i < color.getWidth(); i++) {
            for (int j = 0; j < color.getHeight(); j++) {
                Color c = new Color(color.getRGB(i, j));

                averaged.setRGB(i, j,//from w  w  w .j  av a2s.  com
                        new Color((int) Math.round(c.getRed() / factor), c.getGreen(), c.getBlue()).getRGB());
            }
        }

        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        // convert to jpeg for compression
        try {
            // use apache to read to a buffered image with certain metadata
            // and then convert to a jpg
            ImageIO.write(averaged, "jpg", bos);
            return ibytes = bos.toByteArray();

        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    return ibytes;

}

From source file:be.ugent.maf.cellmissy.gui.controller.analysis.singlecell.PlateHeatMapController.java

/**
 * Plot the z-scores: simple scatterplot
 *//*  ww w  . j ava2s .c o  m*/
private void plotZScores() {
    XYSeriesCollection xySeriesCollection = new XYSeriesCollection();
    Map<Well, Double> map = computeZScoresForMap();

    List<PlateCondition> plateConditionList = trackCoordinatesController.getPlateConditionList();

    for (int i = 0; i < plateConditionList.size(); i++) {
        // current condition
        PlateCondition condition = plateConditionList.get(i);
        XYSeries series = new XYSeries(i + "-" + condition);
        for (int j = 0; j < condition.getSingleCellAnalyzedWells().size(); j++) {
            // current well
            Well well = condition.getSingleCellAnalyzedWells().get(j);
            series.add(i + 1, map.get(well));
        }
        xySeriesCollection.addSeries(series);
    }

    JFreeChart jfreechart = ChartFactory.createScatterPlot("z*-score", "condition number", "z*-score",
            xySeriesCollection, PlotOrientation.VERTICAL, false, true, false);
    JFreeChartUtils.setupXYPlot(jfreechart.getXYPlot());
    jfreechart.getXYPlot().getDomainAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    // line for the median speed
    ValueMarker marker = new ValueMarker(0);
    marker.setPaint(Color.GRAY);
    Stroke dashedStroke = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f,
            new float[] { 1.0f, 3.0f }, 0.0f);
    marker.setStroke(dashedStroke);
    jfreechart.getXYPlot().addRangeMarker(marker);

    marker = new ValueMarker(3);
    marker.setPaint(Color.GRAY);
    marker.setStroke(dashedStroke);
    jfreechart.getXYPlot().addRangeMarker(marker);

    marker = new ValueMarker(-3);
    marker.setPaint(Color.GRAY);
    marker.setStroke(dashedStroke);
    jfreechart.getXYPlot().addRangeMarker(marker);

    XYItemRenderer renderer = jfreechart.getXYPlot().getRenderer();
    for (int i = 0; i < xySeriesCollection.getSeriesCount(); i++) {
        // plot lines according to conditions indexes
        int colorIndex = i % GuiUtils.getAvailableColors().length;
        Color color = GuiUtils.getAvailableColors()[colorIndex];
        color = new Color(color.getRed(), color.getGreen(), color.getBlue(), 127);
        renderer.setSeriesPaint(i, color);
        renderer.setSeriesShape(i, new Ellipse2D.Double(0, 0, 10, 10));
    }
    zScoreChartPanel.setChart(jfreechart);
}

From source file:haven.Utils.java

public static Color blendcol(Color x, Color y, double a) {
    int f1 = (int) (a * 255), f2 = 255 - f1;
    return (new Color(((x.getRed() * f2) + (y.getRed() * f1)) / 255,
            ((x.getGreen() * f2) + (y.getGreen() * f1)) / 255, ((x.getBlue() * f2) + (y.getBlue() * f1)) / 255,
            ((x.getAlpha() * f2) + (y.getAlpha() * f1)) / 255));
}

From source file:be.vds.jtbdive.client.view.core.dive.profile.DiveProfileChartPanelEditor.java

private Component createChartPanel() {
    depthSerie = new XYSeries("depth");
    XYSeriesCollection depthCollection = new XYSeriesCollection();
    depthCollection.addSeries(depthSerie);

    JFreeChart chart = ChartFactory.createXYLineChart("",
            I18nResourceManager.sharedInstance().getString("time"),
            I18nResourceManager.sharedInstance().getString("depth"), depthCollection, PlotOrientation.VERTICAL,
            true, true, false);//www.j a v  a  2s.  c om
    plot = chart.getXYPlot();
    Paint p = new GradientPaint(0f, 0f, UIAgent.getInstance().getColorWaterBottom(), 200f, 200f,
            UIAgent.getInstance().getColorWaterSurface(), false);
    plot.setBackgroundPaint(p);

    XYAreaRenderer renderer0 = new XYAreaRenderer();
    renderer0.setOutline(true);
    renderer0.setBaseOutlinePaint(UIAgent.getInstance().getColorProfileEdition());

    Color baseColor = UIAgent.getInstance().getColorBaseBackground();
    renderer0.setSeriesPaint(0, new Color(baseColor.getRed(), baseColor.getGreen(), baseColor.getBlue(), 50));
    plot.setRenderer(0, renderer0);

    dAxis = new NumberAxis();
    rAxis = new NumberAxis();
    // dAxis.setAutoRange(false);
    // rAxis.setAutoRange(false);
    // dAxis.setRange(0, maxTime);
    // rAxis.setRange(lowestDepth, 0);
    plot.setDomainAxis(dAxis);
    plot.setRangeAxis(rAxis);

    // plot.setRangeCrosshairLockedOnData(false);
    // plot.setDomainCrosshairLockedOnData(false);
    ((NumberAxis) plot.getDomainAxis()).setNumberFormatOverride(new MinutesNumberFormat());

    panel = new ChartPanel(chart);
    // panel.addChartMouseListener(new ChartMouseListener() {
    //
    // @Override
    // public void chartMouseMoved(ChartMouseEvent arg0) {
    // // TODO Auto-generated method stub
    //
    // }
    //
    // @Override
    // public void chartMouseClicked(ChartMouseEvent evt) {
    //
    // double x = plot.getDomainAxis().java2DToValue(
    // panel.translateScreenToJava2D(
    // evt.getTrigger().getPoint()).getX(),
    // panel.getChartRenderingInfo().getPlotInfo()
    // .getDataArea(), plot.getDomainAxisEdge());
    //
    // double y = plot.getRangeAxis().java2DToValue(
    // panel.translateScreenToJava2D(
    // evt.getTrigger().getPoint()).getY(),
    // panel.getChartRenderingInfo().getPlotInfo()
    // .getDataArea(), plot.getRangeAxisEdge());
    //
    // diveProfileEditor.addEntry(x, y, this);
    // }
    // });

    createDecoWarningCollection();
    createAscentTooFastCollection();
    createRemainBottomTimeCollection();
    createDecoEntriesCollection();

    return panel;
}

From source file:haven.Utils.java

public static Color blendcol(Color in, Color bl) {
    int f1 = bl.getAlpha();
    int f2 = 255 - bl.getAlpha();
    return (new Color(((in.getRed() * f2) + (bl.getRed() * f1)) / 255,
            ((in.getGreen() * f2) + (bl.getGreen() * f1)) / 255,
            ((in.getBlue() * f2) + (bl.getBlue() * f1)) / 255, in.getAlpha()));
}