Refine search
/** Convers a color to a string. */ static public String toString (Color color) { if (color == null) throw new IllegalArgumentException("color cannot be null."); String r = Integer.toHexString(color.getRed()); if (r.length() == 1) r = "0" + r; String g = Integer.toHexString(color.getGreen()); if (g.length() == 1) g = "0" + g; String b = Integer.toHexString(color.getBlue()); if (b.length() == 1) b = "0" + b; return r + g + b; }
/** Convers a color to a string. */ static public String toString (Color color) { if (color == null) throw new IllegalArgumentException("color cannot be null."); String r = Integer.toHexString(color.getRed()); if (r.length() == 1) r = "0" + r; String g = Integer.toHexString(color.getGreen()); if (g.length() == 1) g = "0" + g; String b = Integer.toHexString(color.getBlue()); if (b.length() == 1) b = "0" + b; return r + g + b; }
private void exportLogLevelColorXMLElement(String label, Color color, StringBuffer xml) { xml.append("\t\t<").append(COLORLEVEL).append(" ").append(NAME); xml.append("=\"").append(label).append("\" "); xml.append(RED).append("=\"").append(color.getRed()).append("\" "); xml.append(GREEN).append("=\"").append(color.getGreen()).append("\" "); xml.append(BLUE).append("=\"").append(color.getBlue()); xml.append("\"/>\r\n"); }
public static Color buildPercentageColor(Color floorColor, Color ceilColor, double shadePercentage) { return new Color( floorColor.getRed() + (int) (shadePercentage * (ceilColor.getRed() - floorColor.getRed())), floorColor.getGreen() + (int) (shadePercentage * (ceilColor.getGreen() - floorColor.getGreen())), floorColor.getBlue() + (int) (shadePercentage * (ceilColor.getBlue() - floorColor.getBlue()))); }
private static double getDistance(Color c1, Color c2) { double rmean = (c1.getRed() + c2.getRed()) / 2.0; double r = c1.getRed() - c2.getRed(); double g = c1.getGreen() - c2.getGreen(); int b = c1.getBlue() - c2.getBlue(); double weightR = 2 + rmean / 256.0; double weightG = 4.0; double weightB = 2 + (255 - rmean) / 256.0; return weightR * r * r + weightG * g * g + weightB * b * b; }
public static String colorToHTML(Color color) { String r = Integer.toHexString(color.getRed()); if (r.length() == 0) { r = "00"; } else if (r.length() == 1) { r = "0" + r; } else if (r.length() > 2) { throw new IllegalArgumentException("invalid hex color for red"+r); } String g = Integer.toHexString(color.getGreen()); if (g.length() == 0) { g = "00"; } else if (g.length() == 1) { g = "0" + g; } else if (g.length() > 2) { throw new IllegalArgumentException("invalid hex color for green"+g); } String b = Integer.toHexString(color.getBlue()); if (b.length() == 0) { b = "00"; } else if (b.length() == 1) { b = "0" + b; } else if (b.length() > 2) { throw new IllegalArgumentException("invalid hex color for blue"+b); } return "#"+r+g+b; }
public static String colorToHTML(Color color) { String r = Integer.toHexString(color.getRed()); if (r.isEmpty()) { r = "00"; } else if (r.length() == 1) { r = "0" + r; } else if (r.length() > 2) { throw new IllegalArgumentException("invalid hex color for red"+r); } String g = Integer.toHexString(color.getGreen()); if (g.isEmpty()) { g = "00"; } else if (g.length() == 1) { g = "0" + g; } else if (g.length() > 2) { throw new IllegalArgumentException("invalid hex color for green"+g); } String b = Integer.toHexString(color.getBlue()); if (b.isEmpty()) { b = "00"; } else if (b.length() == 1) { b = "0" + b; } else if (b.length() > 2) { throw new IllegalArgumentException("invalid hex color for blue"+b); } return "#"+r+g+b; }
private void renderPoly(Graphics2D graphics, Color color, Polygon polygon) { if (polygon != null) { graphics.setColor(color); graphics.setStroke(new BasicStroke(2)); graphics.draw(polygon); graphics.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), 20)); graphics.fill(polygon); } } }