List of usage examples for java.awt Color getGreen
public int getGreen()
From source file:util.ui.UiUtilities.java
/** * Creates a Html EditorPane that holds a HTML-Help Text. * * Add a Listener if you want to have clickable Links * * @param html//from ww w . j av a 2 s . c o m * HTML-Text to display * @param listener * Link-Listener for this HelpText * @param background The color for the background. * @return EditorPane that holds a Help Text * @since 2.7.2 */ public static JEditorPane createHtmlHelpTextArea(String html, HyperlinkListener listener, Color background) { // Quick "hack". Remove HTML-Code and replace it with Code that includes the // correct Font if (html.indexOf("<html>") >= 0) { html = StringUtils.substringBetween(html, "<html>", "</html>"); } JLabel label = new JLabel(); Font font = label.getFont(); html = "<html><div style=\"color:" + UiUtilities.getHTMLColorCode(label.getForeground()) + ";font-family:" + font.getName() + "; font-size:" + font.getSize() + ";background-color:rgb(" + background.getRed() + "," + background.getGreen() + "," + background.getBlue() + ");\">" + html + "</div></html>"; final JEditorPane pane = new JEditorPane("text/html", html); pane.setBorder(BorderFactory.createEmptyBorder()); pane.setEditable(false); pane.setFont(font); pane.setOpaque(false); pane.setFocusable(false); if (listener != null) { pane.addHyperlinkListener(listener); } return pane; }
From source file:nz.ac.massey.cs.gql4jung.browser.resultviews.GraphBasedResultView.java
private Map<String, Color> createColorMap(MotifInstance instance) { if (instance == null) return new HashMap<String, Color>(0); Set<Vertex> vertices = instance.getVertices(); Set<String> packages = new HashSet<String>(vertices.size()); for (Vertex v : vertices) { packages.add(v.getNamespace());//from www .j a va 2s. c o m } int count = 0; Map<String, Color> pmap = new HashMap<String, Color>(packages.size()); float offset = 100 / packages.size(); offset = offset / 100; for (String p : packages) { Color hsb = Color.getHSBColor(count * offset, settings.getVertexSaturation(), settings.getVertexBrightness()); pmap.put(p, new Color(hsb.getRed(), hsb.getGreen(), hsb.getBlue(), settings.getVertexTransparency())); // transparency //pmap.put(p,hsb); count = count + 1; } return pmap; }
From source file:gr.iti.mklab.reveal.forensics.util.Util.java
public static float[][][] getResizedImageDifference(BufferedImage image1, BufferedImage image2, int newWidth, int newHeight) { // Calculate the subsampled difference between two buffered images float[][][] outputMap = new float[3][newWidth][newHeight]; float widthModifier = (float) image1.getWidth() / newWidth; float heightModifier = (float) image1.getHeight() / newHeight; Color tmpColor1, tmpColor2; for (int ii = 0; ii < newHeight; ii++) { for (int jj = 0; jj < newWidth; jj++) { try { tmpColor1 = new Color( image1.getRGB(Math.round(jj * widthModifier), Math.round(ii * heightModifier))); tmpColor2 = new Color( image2.getRGB(Math.round(jj * widthModifier), Math.round(ii * heightModifier))); outputMap[0][jj][ii] = (float) (tmpColor1.getRed() - tmpColor2.getRed()) * (tmpColor1.getRed() - tmpColor2.getRed()); outputMap[1][jj][ii] = (float) (tmpColor1.getGreen() - tmpColor2.getGreen()) * (tmpColor1.getGreen() - tmpColor2.getGreen()); outputMap[2][jj][ii] = (float) (tmpColor1.getBlue() - tmpColor2.getBlue()) * (tmpColor1.getBlue() - tmpColor2.getBlue()); } catch (Exception e) { System.out.println(newHeight + " " + newWidth + " " + image1.getHeight() + " " + image1.getWidth() + " " + ii + " " + jj + " " + Math.round(ii * heightModifier) + " " + Math.round(jj * widthModifier) + " " + heightModifier + " " + widthModifier); e.printStackTrace();/*from w w w .j a v a 2 s. c o m*/ return outputMap; } } } return outputMap; }
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 w w w . j ava 2 s . c o m*/ public static float[] RGBtoHSL(Color color) { return RGBtoHSL(color.getRed(), color.getGreen(), color.getBlue(), null); }
From source file:com.stitchgalaxy.domain.Product.java
/** * @param avgColor the avgColor to set/*from ww w . j a va 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: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 ww . jav a 2s . c o 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)); }/*from w w w . j a va 2s . co m*/ 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: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.jav a 2 s . c om 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: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 w w. j av a 2 s .c o 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; }