List of usage examples for java.awt Color getBlue
public int getBlue()
From source file:ColorUtil.java
public static final Color mult(Color c, double amount) { return c == null ? null : new Color(Math.min(255, (int) (c.getRed() * amount)), Math.min(255, (int) (c.getGreen() * amount)), Math.min(255, (int) (c.getBlue() * amount)), c.getAlpha());/* w w w .j a va 2 s.com*/ }
From source file:ColorUtil.java
/** * Return the hex name of a specified color. * /*w w w . j a v a2 s . c o m*/ * @param color Color to get hex name of. * @return Hex name of color: "rrggbb". */ public static String getHexName(Color color) { int r = color.getRed(); int g = color.getGreen(); int b = color.getBlue(); String rHex = Integer.toString(r, 16); String gHex = Integer.toString(g, 16); String bHex = Integer.toString(b, 16); return (rHex.length() == 2 ? "" + rHex : "0" + rHex) + (gHex.length() == 2 ? "" + gHex : "0" + gHex) + (bHex.length() == 2 ? "" + bHex : "0" + bHex); }
From source file:org.esa.s2tbx.dataio.s2.l1b.L1bSceneDescription.java
private static Color addAlpha(Color color, int alpha) { return new Color(color.getRed(), color.getGreen(), color.getBlue(), alpha); }
From source file:ch.fork.AdHocRailway.ui.utils.ImageTools.java
public static Image TransformColorToTransparency(BufferedImage image, Color c1, Color c2) { // Primitive test, just an example final int r1 = c1.getRed(); final int g1 = c1.getGreen(); final int b1 = c1.getBlue(); final int r2 = c2.getRed(); final int g2 = c2.getGreen(); final int b2 = c2.getBlue(); ImageFilter filter = new RGBImageFilter() { public final int filterRGB(int x, int y, int rgb) { int r = (rgb & 0xFF0000) >> 16; int g = (rgb & 0xFF00) >> 8; int b = rgb & 0xFF; if (r >= r1 && r <= r2 && g >= g1 && g <= g2 && b >= b1 && b <= b2) { // Set fully transparent but keep color return rgb & 0xFFFFFF; }/* w w w . j ava 2s.c o m*/ return rgb; } }; ImageProducer ip = new FilteredImageSource(image.getSource(), filter); return Toolkit.getDefaultToolkit().createImage(ip); }
From source file:edu.ku.brc.ui.GradiantButton.java
/** * Generate the alpha version of this color * @param color the color in question/*from w ww . j a va 2s . 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:ColorUtil.java
/** * Check if a color is more dark than light. Useful if an entity of * this color is to be labeled: Use white label on a "dark" color and * black label on a "light" color./* ww w .j ava 2s . c o m*/ * * @param color Color to check. * @return True if this is a "dark" color, false otherwise. */ public static boolean isDark(Color color) { float r = color.getRed() / 255.0f; float g = color.getGreen() / 255.0f; float b = color.getBlue() / 255.0f; return isDark(r, g, b); }
From source file:ImageProcessing.ImageProcessing.java
public static double[] extractBlueColor(BufferedImage source) { //Extracts the Blue 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.getBlue(); values[(i * imageWidth) + j] = value; }/*from w w w . ja va2 s . c om*/ } return values; }
From source file:HTML.java
/** * Utility method to format a color to HTML RGB color format (e.g. #FF0000 for Color.red). * @param color The color./*from ww w . ja v a 2 s. c o m*/ * @return the HTML RGB color string. */ public static final String format(Color c) { String r = (c.getRed() < 16) ? "0" + Integer.toHexString(c.getRed()) : Integer.toHexString(c.getRed()); String g = (c.getGreen() < 16) ? "0" + Integer.toHexString(c.getGreen()) : Integer.toHexString(c.getGreen()); String b = (c.getBlue() < 16) ? "0" + Integer.toHexString(c.getBlue()) : Integer.toHexString(c.getBlue()); return "#" + r + g + b; }
From source file:Main.java
public static byte matchColor(Color c) { int i = 0;/*from www. j av a 2 s . c o m*/ int combinatronix = 100000; for (int z = 0; z < csamples.length; z++) { Color grab = csamples[z]; int calc = Math.abs(c.getRed() - grab.getRed()) + Math.abs(c.getGreen() - grab.getGreen()) + Math.abs(c.getBlue() - grab.getBlue()); if (calc < combinatronix) { combinatronix = calc; i = z; } } return (byte) i; }
From source file:com.gargoylesoftware.htmlunit.util.StringUtils.java
/** * Formats the specified color./*from w w w .ja va 2s . c o m*/ * * @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() + ")"; }