List of usage examples for java.awt Color getRed
public int getRed()
From source file:edu.ku.brc.ui.GradiantButton.java
/** * Generate the alpha version of this color * @param color the color in question// w w w . jav a2 s .c o m * @param alpha the alpha of the new color * @return Generate the alpha version of this color */ protected static Color alphaColor(Color color, int alpha) { return new Color(color.getRed(), color.getGreen(), color.getBlue(), alpha); }
From source file:com.gargoylesoftware.htmlunit.util.StringUtils.java
/** * Formats the specified color.// www. java 2s.c om * * @param aColor the color to format * @return the specified color, formatted */ public static String formatColor(final Color aColor) { return "rgb(" + aColor.getRed() + ", " + aColor.getGreen() + ", " + aColor.getBlue() + ")"; }
From source file:se.trixon.almond.GraphicsHelper.java
public static String colorToAABBGGRR(Color color, String... prefixSuffix) { String rr = StringUtils.leftPad(Integer.toHexString(color.getRed()), 2, "0"); String gg = StringUtils.leftPad(Integer.toHexString(color.getGreen()), 2, "0"); String bb = StringUtils.leftPad(Integer.toHexString(color.getBlue()), 2, "0"); String aa = StringUtils.leftPad(Integer.toHexString(color.getAlpha()), 2, "0"); StringBuilder builder = new StringBuilder(); if (prefixSuffix.length > 0) { builder.append(prefixSuffix[0]); }//from w w w . j ava2 s .c o m builder.append(aa).append(bb).append(gg).append(rr); if (prefixSuffix.length > 1) { builder.append(prefixSuffix[1]); } return builder.toString(); }
From source file:joinery.impl.Display.java
private static void addTrend(final Chart chart, final Series series, final List<Object> xdata) { final SimpleRegression model = new SimpleRegression(); final Iterator<? extends Number> y = series.getYData().iterator(); for (int x = 0; y.hasNext(); x++) { model.addData(x, y.next().doubleValue()); }//from www . j a v a2s . c om final Color mc = series.getMarkerColor(); final Color c = new Color(mc.getRed(), mc.getGreen(), mc.getBlue(), 0x60); final Series trend = chart.addSeries(series.getName() + " (trend)", Arrays.asList(xdata.get(0), xdata.get(xdata.size() - 1)), Arrays.asList(model.predict(0), model.predict(xdata.size() - 1))); trend.setLineColor(c); trend.setMarker(SeriesMarker.NONE); }
From source file:uk.bl.wa.tika.parser.imagefeatures.FaceDetectionParser.java
private static Color maxBrightness(Color c) { float[] hsv = new float[3]; Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), hsv); return new Color(Color.HSBtoRGB(hsv[0], hsv[1], 1.0f)); }
From source file:org.testeditor.dashboard.TableDurationTrend.java
/** * composes awt color from swt color RGB. * /*from w w w . j a va2 s . c om*/ * @param color * SWT * @return java.awt.Color */ public static java.awt.Color toAwtColor(org.eclipse.swt.graphics.Color color) { return new java.awt.Color(color.getRed(), color.getGreen(), color.getBlue()); }
From source file:de.bund.bfr.jung.JungUtils.java
private static Paint mixWith(Paint paint, Color mix) { if (paint instanceof Color) { Color c = (Color) paint; return new Color((c.getRed() + mix.getRed()) / 2, (c.getGreen() + mix.getGreen()) / 2, (c.getBlue() + mix.getBlue()) / 2, (c.getAlpha() + mix.getAlpha()) / 2); } else if (paint instanceof TexturePaint) { BufferedImage texture = ((TexturePaint) paint).getImage(); BufferedImage mixed = new BufferedImage(texture.getWidth(), texture.getHeight(), texture.getType()); for (int x = 0; x < texture.getWidth(); x++) { for (int y = 0; y < texture.getHeight(); y++) { mixed.setRGB(x, y, ((Color) mixWith(new Color(texture.getRGB(x, y)), mix)).getRGB()); }/* www . ja v a 2 s.c om*/ } return new TexturePaint(mixed, new Rectangle(mixed.getWidth(), mixed.getHeight())); } else { return paint; } }
From source file:com.sandbox.utils.HSLColor.java
/** * Convert a RGB Color to it corresponding HSL values. * * @param color the color to convert./*from w w w. j av a2 s .com*/ * @param dest the optional array to store the result in. * @return an array containing the 3 HSL values. */ public static float[] fromRGB(final Color color, float[] dest) { // Get RGB values in the range 0 - 1 final float r = color.getRed() / 255f; final float g = color.getGreen() / 255f; final float b = color.getBlue() / 255f; // Minimum and Maximum RGB values are used in the HSL calculations final float min = FastMath.min(r, FastMath.min(g, b)); final float max = FastMath.max(r, FastMath.max(g, b)); // Calculate the Hue float h = 0; if (max == min) h = 0; else if (max == r) h = ((g - b) / (max - min) / 6f + 1) % 1; else if (max == g) h = (b - r) / (max - min) / 6f + 1f / 3f; else if (max == b) h = (r - g) / (max - min) / 6f + 2f / 3f; // Calculate the Luminance final float l = (max + min) / 2; // Calculate the Saturation float s = 0; if (max == min) s = 0; else if (l <= .5f) s = (max - min) / (max + min); else s = (max - min) / (2 - max - min); if (dest == null) dest = new float[3]; dest[0] = h; dest[1] = s; dest[2] = l; return dest; }
From source file:ml.hsv.java
public static void HSV2File(hsv hsvImage[][], int width, int height) throws IOException //store img output as hsv2file.png { BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); WritableRaster raster = image.getRaster(); for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { int RGB = Color.HSBtoRGB(hsvImage[i][j].h, hsvImage[i][j].s, hsvImage[i][j].v); Color c = new Color(RGB); int temp[] = { c.getRed(), c.getGreen(), c.getBlue() }; raster.setPixel(j, i, temp); }//from w w w . jav a 2 s . c om } ImageIO.write(image, "PNG", new File("/home/shinchan/FinalProject/PaperImplementation/Eclipse/ML/output/hsv2file.png")); }
From source file:ImageProcessing.ImageProcessing.java
public static double[] extractRedColor(BufferedImage source) { //Extracts the Red value from the RGB value of the source pixels. int imageWidth = source.getWidth(); int imageHeight = source.getHeight(); double[] values = new double[imageWidth * imageHeight]; for (int i = 0; i < imageHeight; i++) { for (int j = 0; j < imageWidth; j++) { int rgbValue = source.getRGB(j, i); Color currentPixel = new Color(rgbValue, true); int value = currentPixel.getRed(); values[(i * imageWidth) + j] = value; }/* www. j a v a 2 s . c om*/ } return values; }