From 39f5b053cc82f71efa6014c36c0de2f36534bd19 Mon Sep 17 00:00:00 2001 From: Adrian Cumiskey Date: Thu, 14 Aug 2008 13:37:33 +0000 Subject: Merged revisions 685573,685785,685879,685885 via svnmerge from https://svn.eu.apache.org/repos/asf/xmlgraphics/fop/trunk ........ r685573 | jeremias | 2008-08-13 15:34:03 +0100 (Wed, 13 Aug 2008) | 1 line Fixed border trait parsing for the area tree XML when CMYK or ICC colors were used. ........ r685785 | jeremias | 2008-08-14 07:32:52 +0100 (Thu, 14 Aug 2008) | 1 line Removed three unused classes in the traits package. ........ r685879 | jeremias | 2008-08-14 14:03:20 +0100 (Thu, 14 Aug 2008) | 2 lines Fixed the source for a NullPointerException when the content of an fo:leader with leader-pattern="use-content" collapses to zero width during layout. ........ r685885 | acumiskey | 2008-08-14 14:25:54 +0100 (Thu, 14 Aug 2008) | 1 line Moved static method lightenColor() from PrintRenderer to ColorUtil. Thats one less Renderer interface dependency to worry about :). ........ git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AFPGOCAResources@685891 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/fop/util/ColorUtil.java | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/java/org/apache/fop/util') diff --git a/src/java/org/apache/fop/util/ColorUtil.java b/src/java/org/apache/fop/util/ColorUtil.java index b85b0c017..9534bfba3 100644 --- a/src/java/org/apache/fop/util/ColorUtil.java +++ b/src/java/org/apache/fop/util/ColorUtil.java @@ -658,4 +658,27 @@ public final class ColorUtil { colorMap.put("transparent", new Color(0, 0, 0, 0)); } + /** + * Lightens up a color for groove, ridge, inset and outset border effects. + * @param col the color to lighten up + * @param factor factor by which to lighten up (negative values darken the color) + * @return the modified color + */ + public static Color lightenColor(Color col, float factor) { + // TODO: This function converts the color into the sRGB namespace. + // This should be avoided if possible. + float[] cols = new float[4]; + cols = col.getRGBComponents(cols); + if (factor > 0) { + cols[0] += (1.0 - cols[0]) * factor; + cols[1] += (1.0 - cols[1]) * factor; + cols[2] += (1.0 - cols[2]) * factor; + } else { + cols[0] -= cols[0] * -factor; + cols[1] -= cols[1] * -factor; + cols[2] -= cols[2] * -factor; + } + return new Color(cols[0], cols[1], cols[2], cols[3]); + } + } -- cgit v1.2.3