List of usage examples for java.awt Color getGreen
public int getGreen()
From source file:Main.java
public static Color shiftHue(Color color) { float[] hsl = new float[3]; Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), hsl); hsl[0] += 0.33f % 1.0f;/*from ww w. j av a 2 s .com*/ return Color.getHSBColor(hsl[0], hsl[1], hsl[2]); }
From source file:Main.java
/** * A utility to set the attribute on the given node as the * String representation of the given color * * @param node The node/*from w w w.ja v a 2 s.c o m*/ * @param name The attr name * @param value The color */ public static void setAttribute(Element node, String name, Color value) { node.setAttribute(name, "" + value.getRed() + "," + value.getGreen() + "," + value.getBlue()); }
From source file:com.technofovea.packbsp.gui2.jung.DependencyVisualizer.java
static Color trans(Color c) { return new Color(c.getRed(), c.getGreen(), c.getBlue(), 128); }
From source file:Main.java
/** * Make the color brighter by the specified factor. * <p/>/* w w w . ja v a 2 s. c o m*/ * This code is adapted from java.awt.Color to take in a factor. * Therefore, it inherits its quirks. Most importantly, * a smaller factor makes the color more bright. * * @param c a color * @param factor the smaller the factor, the brighter. * @return a brighter color */ private static Color brighter(Color c, double factor) { int r = c.getRed(); int g = c.getGreen(); int b = c.getBlue(); /* From 2D group: * 1. black.brighter() should return grey * 2. applying brighter to blue will always return blue, brighter * 3. non pure color (non zero rgb) will eventually return white */ int i = (int) (1.0 / (1.0 - factor)); if (r == 0 && g == 0 && b == 0) { return new Color(i, i, i); } if (r > 0 && r < i) r = i; if (g > 0 && g < i) g = i; if (b > 0 && b < i) b = i; return new Color(Math.min((int) (r / factor), 255), Math.min((int) (g / factor), 255), Math.min((int) (b / factor), 255)); }
From source file:Utils.java
public static String getHTMLColorString(Color color) { String red = Integer.toHexString(color.getRed()); String green = Integer.toHexString(color.getGreen()); String blue = Integer.toHexString(color.getBlue()); return "#" + (red.length() == 1 ? "0" + red : red) + (green.length() == 1 ? "0" + green : green) + (blue.length() == 1 ? "0" + blue : blue); }
From source file:Main.java
/** * attach (append to child) RGB to the element, in the format <red>12</red> etc * @param rgb/*from w ww . j a v a 2s.c o m*/ * @param elem * @param doc */ public static void attachRGB(Color rgb, Element elem, Document doc) { int r = rgb.getRed(); int g = rgb.getGreen(); int b = rgb.getBlue(); //create element Element red = doc.createElement(TAG_NAME_RED); Element green = doc.createElement(TAG_NAME_GREEN); Element blue = doc.createElement(TAG_NAME_BLUE); //fill the content red.appendChild(doc.createTextNode(Integer.toString(r))); green.appendChild(doc.createTextNode(Integer.toString(g))); blue.appendChild(doc.createTextNode(Integer.toString(b))); //structure the content elem.appendChild(red); elem.appendChild(green); elem.appendChild(blue); }
From source file:Main.java
/** * Returns color copy./*from w ww . ja va 2 s . c o m*/ * * @param color * color to copy * @return color copy */ public static Color copy(final Color color) { return new Color(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()); }
From source file:ColorUtil.java
public static Color copy(Color c) { return c == null ? null : new Color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha()); }
From source file:Main.java
/** * @param color/*from ww w .ja v a2 s . c om*/ * @param factor * @return a new color, darker than the one passed as argument by a percentage factor * * <br>author Cyril Gambis - [Mar 17, 2005] */ public static Color darker(Color color, double factor) { return new Color(Math.max((int) (color.getRed() * factor), 0), Math.max((int) (color.getGreen() * factor), 0), Math.max((int) (color.getBlue() * factor), 0)); }
From source file:ColorUtils.java
/** * Darkens a color by a given amount//from w w w . ja v a2 s. c o m * * @param color The color to darken * @param amount The amount to darken the color. 0 will leave the color unchanged; 1 will make * the color completely black * @return The stained color */ public static Color stain(Color color, float amount) { int red = (int) ((color.getRed() * (1 - amount) / 255) * 255); int green = (int) ((color.getGreen() * (1 - amount) / 255) * 255); int blue = (int) ((color.getBlue() * (1 - amount) / 255) * 255); return new Color(red, green, blue); }