You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xmlgraphics.apache.org by je...@apache.org on 2010/07/08 16:11:39 UTC
svn commit: r961776 -
/xmlgraphics/commons/branches/Temp_Color/src/java/org/apache/xmlgraphics/java2d/color/ColorWithAlternatives.java
Author: jeremias
Date: Thu Jul 8 14:11:38 2010
New Revision: 961776
URL: http://svn.apache.org/viewvc?rev=961776&view=rev
Log:
Added convenience method to retrieve a certain alternative color.
Modified:
xmlgraphics/commons/branches/Temp_Color/src/java/org/apache/xmlgraphics/java2d/color/ColorWithAlternatives.java
Modified: xmlgraphics/commons/branches/Temp_Color/src/java/org/apache/xmlgraphics/java2d/color/ColorWithAlternatives.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/branches/Temp_Color/src/java/org/apache/xmlgraphics/java2d/color/ColorWithAlternatives.java?rev=961776&r1=961775&r2=961776&view=diff
==============================================================================
--- xmlgraphics/commons/branches/Temp_Color/src/java/org/apache/xmlgraphics/java2d/color/ColorWithAlternatives.java (original)
+++ xmlgraphics/commons/branches/Temp_Color/src/java/org/apache/xmlgraphics/java2d/color/ColorWithAlternatives.java Thu Jul 8 14:11:38 2010
@@ -134,6 +134,22 @@ public class ColorWithAlternatives exten
return this.alternativeColors != null && this.alternativeColors.length > 0;
}
+ /**
+ * Returns the first alternative color found with the given color space type.
+ * @param colorSpaceType the color space type ({@link ColorSpace}.TYPE_*).
+ * @return the requested alternative color or null, if no match was found
+ */
+ public Color getFirstAlternativeOfType(int colorSpaceType) {
+ if (hasAlternativeColors()) {
+ for (int i = 0, c = this.alternativeColors.length; i < c; i++) {
+ if (this.alternativeColors[i].getColorSpace().getType() == colorSpaceType) {
+ return this.alternativeColors[i];
+ }
+ }
+ }
+ return null;
+ }
+
/** {@inheritDoc} */
public boolean equals(Object obj) {
if (!(obj instanceof Color)) {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: commits-help@xmlgraphics.apache.org