List of usage examples for java.awt Color getRed
public int getRed()
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 ww . ja v a 2 s . co m }
From source file:Main.java
/** * Adjusts a preset color to a roughness value. * @param orig The original color/*from www.j a va2 s. c om*/ * @param a The roughness value. * @param maxmin The maximum and minimum differential. * @return A color that has been adjust to match the original and roughness. */ public static Color adjust(Color orig, double a, int maxmin) { if (a > 1) a = 1; if (a < 0) a = 0; int r = orig.getRed(); int g = orig.getGreen(); int b = orig.getBlue(); r = (int) (r - (a * maxmin)); g = (int) (g - (a * maxmin)); b = (int) (b - (a * maxmin)); r = colorSnap(r); g = colorSnap(g); b = colorSnap(b); return new Color(r, g, b, orig.getAlpha()); }
From source file:edu.scripps.fl.curves.plot.CurvePlotDrawingSupplier.java
private static Color toGreyScale(Color c) { int rgb = (int) (((double) c.getRed() * 0.299) + ((double) c.getGreen() * 0.587) + ((double) c.getBlue() * 0.114)); if (rgb > 255) rgb = 255;/*w w w. j av a 2s .c om*/ return new Color(rgb, rgb, rgb); }
From source file:ColorUtils.java
private static float[] toHSB(Color aColor) { return Color.RGBtoHSB(aColor.getRed(), aColor.getGreen(), aColor.getBlue(), null); }
From source file:imageprocessingproject.ImageHistogram.java
private static int getGrayValue(int rgb) { Color c = new Color(rgb); return (c.getRed() + c.getGreen() + c.getBlue()) / 3; }
From source file:modelo.HTMLUtils.java
private static String colorToHex(Color color) { String hex = String.format("#%02x%02x%02x", color.getRed(), color.getGreen(), color.getBlue()); return hex;/*from w w w .j av a2 s . c om*/ }
From source file:org.onexus.website.api.widgets.tableviewer.decorators.scale.ColorDecorator.java
public static double lum(Color color) { int r = color.getRed(); int g = color.getGreen(); int b = color.getBlue(); return .299 * r + .587 * g + .114 * b; }
From source file:Main.java
public static Color adjust2(Color original, double value, int maximumrange) { if (value > 1) value = 1;// ww w .java 2 s. c om if (value < 0) value = 0; int r = original.getRed(); int g = original.getGreen(); int b = original.getBlue(); double nah = value * maximumrange; r += (int) nah; g += (int) nah; b += (int) nah; r = colorSnap(r); g = colorSnap(g); b = colorSnap(b); return new Color(r, g, b, original.getAlpha()); }
From source file:ColorUtil.java
public static final Color add(Color c1, Color c2) { return c1 == null ? c2 : c2 == null ? c1/*from w ww. j a v a2s. c om*/ : new Color(Math.min(255, c1.getRed() + c2.getRed()), Math.min(255, c1.getGreen() + c2.getGreen()), Math.min(255, c1.getBlue() + c2.getBlue()), c1.getAlpha()); }
From source file:JavaTron.JTP.java
/** * Parses a Color type to a CSV type RGB string * @param c A Color Object/*from ww w . j a v a2 s. co m*/ * @return A String in the form of R,G,B i.e '0,255,127' */ public static String parseColor(Color c) { int red = c.getRed(); int green = c.getGreen(); int blue = c.getBlue(); String csv = Integer.toString(red) + "," + Integer.toString(green) + "," + Integer.toString(blue); return csv; }