Example usage for java.awt Color getBlue

List of usage examples for java.awt Color getBlue

Introduction

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

Prototype

public int getBlue() 

Source Link

Document

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

Usage

From source file:BlendCompositeDemo.java

/**
 * <p>Returns the HSL (Hue/Saturation/Luminance) equivalent of a given
 * RGB color. All three HSL components are between 0.0 and 1.0.</p>
 *
 * @param color the RGB color to convert
 * @return a new array of 3 floats corresponding to the HSL components
 *//*from   ww w  . java  2 s  .  c  o m*/
public static float[] RGBtoHSL(Color color) {
    return RGBtoHSL(color.getRed(), color.getGreen(), color.getBlue(), null);
}

From source file:BlendCompositeDemo.java

/**
 * <p>Returns the HSL (Hue/Saturation/Luminance) equivalent of a given
 * RGB color. All three HSL components are between 0.0 and 1.0.</p>
 *
 * @param color the RGB color to convert
 * @param hsl a pre-allocated array of floats; can be null
 * @return <code>hsl</code> if non-null, a new array of 3 floats otherwise
 * @throws IllegalArgumentException if <code>hsl</code> has a length lower
 *   than 3//from  w w  w  .  j  av  a 2s  .  co  m
 */
public static float[] RGBtoHSL(Color color, float[] hsl) {
    return RGBtoHSL(color.getRed(), color.getGreen(), color.getBlue(), hsl);
}

From source file:com.groupdocs.HomeController.java

public int getIntFromColor(Color color) {
    return getIntFromColor(color.getRed(), color.getGreen(), color.getBlue());
}

From source file:org.esa.s1tbx.ocean.worldwind.layers.Level2ProductLayer.java

public static AnalyticSurface.GridPointAttributes createColorGradientAttributes(final double value,
        double minValue, double maxValue, double minHue, double maxHue, boolean whiteZero) {
    final double hueFactor = WWMath.computeInterpolationFactor(value, minValue, maxValue);

    //double hue = WWMath.mixSmooth(hueFactor, minHue, maxHue);
    final double hue = WWMath.mix(hueFactor, minHue, maxHue);
    double sat = 1.0;
    if (whiteZero) {
        sat = Math.abs(WWMath.mixSmooth(hueFactor, -1, 1));
    }/*  w w  w.  j av a 2s.  c om*/
    final Color color = Color.getHSBColor((float) hue, (float) sat, 1f);
    final double opacity = WWMath.computeInterpolationFactor(value, minValue,
            minValue + (maxValue - minValue) * 0.1);
    final Color rgbaColor = new Color(color.getRed(), color.getGreen(), color.getBlue(), (int) (255 * opacity));

    return AnalyticSurface.createGridPointAttributes(value, rgbaColor);
}

From source file:gr.iti.mklab.reveal.forensics.util.Util.java

public static float[][][] getImageDifference(BufferedImage image1, BufferedImage image2) {
    Color tmpColor1, tmpColor2;
    int width = image1.getWidth();
    int height = image1.getHeight();
    float[][][] outputMap = new float[3][width][height];
    for (int ii = 0; ii < width; ii++) {
        for (int jj = 0; jj < height; jj++) {
            tmpColor1 = new Color(image1.getRGB(ii, jj));
            tmpColor2 = new Color(image2.getRGB(ii, jj));
            outputMap[0][ii][jj] = (float) (tmpColor1.getRed() - tmpColor2.getRed())
                    * (tmpColor1.getRed() - tmpColor2.getRed());
            outputMap[1][ii][jj] = (float) (tmpColor1.getGreen() - tmpColor2.getGreen())
                    * (tmpColor1.getGreen() - tmpColor2.getGreen());
            outputMap[2][ii][jj] = (float) (tmpColor1.getBlue() - tmpColor2.getBlue())
                    * (tmpColor1.getBlue() - tmpColor2.getBlue());
        }/*from   w w  w.j  a  v a  2 s  .c o m*/
    }
    return outputMap;
}

From source file:pack1.test.java

@WebMethod(operationName = "convert")
public String convert(@WebParam(name = "encodedImageStr") String encodedImageStr,
        @WebParam(name = "fileName") String fileName, @WebParam(name = "AOR") String AOR,
        @WebParam(name = "val") int value) {
    System.out.println("Value" + value);
    FileOutputStream imageOutFile = null;
    try {//from   w ww  .j a  va2  s .  co m
        Connection con, con1;
        Statement stmtnew = null;
        area = Double.parseDouble(AOR);
        //int val=Integer.parseInt(value);
        System.out.println("connecting");
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        System.out.println("connected");
        con = DriverManager.getConnection("jdbc:odbc:test");
        System.out.println(" driver loaded in connection.jsp");
        stmtnew = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
        // Decode String using Base64 Class
        byte[] imageByteArray = encodedImageStr.getBytes();
        // Write Image into File system - Make sure you update the path
        imageOutFile = new FileOutputStream(
                "C:/Users/Kushagr Jolly/Documents/NetBeansProjects/webservice/IASRI/cropped" + fileName);
        imageOutFile.write(imageByteArray);
        imageOutFile.close();
        System.out.println("Image Successfully Stored");
        FileInputStream leafPicPath = new FileInputStream(
                "C:/Users/Kushagr Jolly/Documents/NetBeansProjects/webservice/IASRI/cropped" + fileName);
        BufferedImage cat;
        int height, width;
        cat = ImageIO.read(leafPicPath);
        height = cat.getHeight();
        width = cat.getWidth();
        for (int w = 0; w < cat.getWidth(); w++) {

            for (int h = 0; h < cat.getHeight(); h++) {
                // BufferedImage.getRGB() saves the colour of the pixel as a single integer.
                // use Color(int) to grab the RGB values individually.

                Color color = new Color(cat.getRGB(w, h));

                // use the RGB values to get their average.

                int averageColor = ((color.getRed() + color.getGreen() + color.getBlue()) / 3);
                // create a new Color object using the average colour as the red, green and blue

                // colour values

                Color avg = new Color(averageColor, averageColor, averageColor);

                // set the pixel at that position to the new Color object using Color.getRGB().            

                cat.setRGB(w, h, avg.getRGB());

            }

        }
        String greyPicPath = "C:/Users/Kushagr Jolly/Documents/NetBeansProjects/webservice/IASRI/greyscale"
                + fileName;
        greyPicPath = greyPicPath.trim();
        File outputfile = new File(greyPicPath);
        ImageIO.write(cat, "jpg", outputfile);
        System.out.println("Image is successfully converted to grayscale");

        String binPicPath = "C:/Users/Kushagr Jolly/Documents/NetBeansProjects/webservice/IASRI/binary"
                + fileName;
        File f2 = new File(binPicPath);
        System.out.println("1");
        ImageProcessor ip;
        ImagePlus imp = new ImagePlus(greyPicPath);
        System.out.println("2");
        ip = imp.getProcessor();
        ip.invertLut();
        ip.autoThreshold();
        System.out.println("3");
        BufferedImage bf = ip.getBufferedImage();
        System.out.println("4");
        ImageIO.write(bf, "jpg", f2);
        System.out.println("Image is successfully converted to binary image");
        if (choice == 1) {
            String Inserted1 = "insert into test (PhyAOR) values ('" + area + "')";
            System.out.println("InsertedQuery" + Inserted1);
            stmtnew.executeUpdate(Inserted1);
            Statement stmt = con.createStatement();
            ResultSet rs = null;
            String ID = "select MAX(id) as id from test";
            System.out.println("Query" + ID);
            rs = stmt.executeQuery(ID);
            while (rs.next()) {
                id = rs.getInt("id");
            }
            String Inserted2 = "update test set fileName0=? where id=?";
            PreparedStatement ps = con.prepareStatement(Inserted2);
            ps.setString(1, fileName);
            ps.setDouble(2, id);
            int rt = ps.executeUpdate();
            choice++;
        }
        System.out.println(choice);
        if (value == 1) {

            int count = countblackpixel(binPicPath);
            calculatepixA(count, area);
            //returnVal=value+"/"+count+"/"+OnepixArea;

        } else if (value == 2) {

            int flag = countblackpixel(binPicPath);
            // calculatepixA(flag, area);
            leafarea0(flag, area);
            //returnVal=value+"/"+flag+"/"+OnepixArea+"/"+leafArea0;
            //System.out.println(returnVal);
        } else if (value == 3) {
            String Inserted3 = "update test set fileName180=? where id=?";
            PreparedStatement ps1 = con.prepareStatement(Inserted3);
            ps1.setString(1, fileName);
            ps1.setDouble(2, id);
            int rt = ps1.executeUpdate();
            int black = countblackpixel(binPicPath);
            leafarea180(area, black);
            finalarea();
            Statement stmt = con.createStatement();
            ResultSet rs = null;
            String finalans = "select PhyAOR,onePixA,leafarea0,leafarea180,finalleafarea from test where id="
                    + id + "";
            rs = stmt.executeQuery(finalans);
            while (rs.next()) {
                returnVal = rs.getString("PhyAOR") + "/" + rs.getString("onePixA") + "/"
                        + rs.getString("leafarea0") + "/" + rs.getString("leafarea180") + "/"
                        + rs.getString("finalleafarea");
            }
            //returnVal=value+"/"+black+"/"+OnepixArea+"/"+leafArea180+"/"+Leaf_Area;
        } else if (value == 4) {
            finalarea();

        }
        imageOutFile.close();
    } catch (Exception ex) {
        Logger.getLogger(test.class.getName()).log(Level.SEVERE, null, ex);
        System.out.println(ex);

    }
    return returnVal;

}

From source file:com.stitchgalaxy.domain.Product.java

/**
 * @param avgColor the avgColor to set/*from w ww.  ja v  a 2 s .  c om*/
 */
public void setAvgColor(Color avgColor) {
    this.setAvgColorRed((Integer) avgColor.getRed());
    this.setAvgColorGreen((Integer) avgColor.getGreen());
    this.setAvgColorBlue((Integer) avgColor.getBlue());
}

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

private void configureGradientAreaFill(Graphics2D g2, CategoryPlot plot, Paint itemPaint,
        PlotRenderingInfo info, GradientLineAreaFill gradientLineAreaFill) {
    double plotWidth = info.getPlotArea().getWidth();
    double plotHeight = info.getPlotArea().getHeight();
    Double mainColorTransparency = gradientLineAreaFill.getMaxValueTransparency();
    Double bgColorTransparency = gradientLineAreaFill.getMinValueTransparency();

    if (itemPaint instanceof Color) {
        Color itemColor = (Color) itemPaint;
        int red = itemColor.getRed();
        int green = itemColor.getGreen();
        int blue = itemColor.getBlue();
        int mainColorAlpha = (mainColorTransparency >= 0.0 && mainColorTransparency <= 1.0)
                ? Math.round(255 * mainColorTransparency.floatValue())
                : 150;/*from   w ww.  j ava 2s .com*/
        int bgColorAlpha = (bgColorTransparency >= 0.0 && bgColorTransparency <= 1.0)
                ? Math.round(255 * bgColorTransparency.floatValue())
                : 128;

        Color mainColor = new Color(red, green, blue, mainColorAlpha);
        Paint bgColor = getBackgroundPaint();
        if (bgColor == null) {
            bgColor = plot.getBackgroundPaint();
        }
        Color secondaryColor = getSecondaryColor(bgColorAlpha, bgColor);
        Paint areaPaint = getAreaFillPaint(plot, plotWidth, plotHeight, mainColor, secondaryColor);

        g2.setPaint(areaPaint);
    } else {
        g2.setPaint(itemPaint);
    }
}

From source file:gov.redhawk.statistics.ui.views.StatisticsView.java

/**
 * This is a callback that will allow us to create the viewer and initialize it.
 *///w  ww  .  j  a  v a 2s.  c  o m
@Override
public void createPartControl(Composite comp) {

    parent = comp;
    parent.setLayout(GridLayoutFactory.fillDefaults().margins(10, 10).numColumns(1).create());

    // Custom Action for the View's Menu
    CustomAction customAction = new CustomAction() {

        @Override
        public void run() {
            SettingsDialog dialog = new SettingsDialog(parent.getShell(), datalist.length, curIndex, numBars);
            dialog.create();
            if (dialog.open() == Window.OK) {
                numBars = dialog.getNumBars();
                curIndex = dialog.getSelectedIndex();
                refreshJob.schedule();
            }
        }
    };
    customAction.setText("Settings");
    getViewSite().getActionBars().getMenuManager().add(customAction);

    // creation of chart composite and selection of associated options
    Composite chartComposite = new Composite(parent, SWT.EMBEDDED);
    chartComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());

    chart = ChartFactory.createXYBarChart(null, null, false, null, dataSet, PlotOrientation.VERTICAL, false,
            true, false);

    org.eclipse.swt.graphics.Color backgroundColor = chartComposite.getBackground();
    chart.setBackgroundPaint(
            new Color(backgroundColor.getRed(), backgroundColor.getGreen(), backgroundColor.getBlue()));
    chart.getXYPlot().setBackgroundPaint(ChartColor.WHITE);

    Frame chartFrame = SWT_AWT.new_Frame(chartComposite);
    chartFrame.setBackground(
            new Color(backgroundColor.getRed(), backgroundColor.getGreen(), backgroundColor.getBlue()));
    chartFrame.setLayout(new GridLayout());

    ChartPanel jFreeChartPanel = new ChartPanel(chart);
    chartFrame.add(jFreeChartPanel);

    ClusteredXYBarRenderer renderer = new ClusteredXYBarRenderer();
    renderer.setBarPainter(new StandardXYBarPainter());
    renderer.setMargin(0.05);
    renderer.setShadowVisible(false);
    renderer.setBaseItemLabelsVisible(true);
    renderer.setBaseItemLabelGenerator(new XYItemLabelGenerator() {
        @Override
        public String generateLabel(XYDataset dataset, int series, int item) {
            return String.valueOf((int) (dataset.getYValue(series, item)));
        }
    });
    renderer.setBasePaint(new Color(139, 0, 0));
    renderer.setLegendItemLabelGenerator(new XYSeriesLabelGenerator() {

        @Override
        public String generateLabel(XYDataset ds, int i) {
            if (ds.getSeriesCount() == 2) {
                if (i == 0) {
                    return "Real";
                } else if (i == 1) {
                    return "Imaginary";
                } else {
                    return "Complex";
                }
            } else if (ds.getSeriesCount() > 1) {
                return "Dimension " + i;
            }

            return null;
        }
    });
    chart.getXYPlot().setRenderer(renderer);

    dataSet.addChangeListener(new DatasetChangeListener() {

        @Override
        public void datasetChanged(DatasetChangeEvent event) {
            chart.getPlot().datasetChanged(event);

        }
    });

    // creation of the statistics composite
    FormToolkit toolkit = new FormToolkit(parent.getDisplay());
    section = toolkit.createSection(parent, Section.DESCRIPTION | Section.NO_TITLE | Section.CLIENT_INDENT);
    section.setBackground(parent.getBackground());
    section.setDescription("");
    section.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); // layout within parent

    // Composite for storing the data
    Composite composite = toolkit.createComposite(section, SWT.WRAP);
    composite.setBackground(parent.getBackground());
    composite.setLayout(GridLayoutFactory.fillDefaults().margins(10, 10).numColumns(4).create());
    composite.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); // layout within parent
    toolkit.paintBordersFor(composite);
    section.setClient(composite);

    for (int j = 0; j < STAT_PROPS.length; j++) {
        Label label = new Label(composite, SWT.None);
        label.setText(STAT_PROPS[j] + ":");
        labels[j] = new Label(composite, SWT.None);
        labels[j].setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
    }

}

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

private Object colorToHTML(Color color) {
    return "#" + String.format("%02x%02x%02x", color.getRed(), color.getGreen(), color.getBlue());
}