private static Color[] getAlternativeColors(Color color) { if (color instanceof ColorWithAlternatives) { ColorWithAlternatives cwa = (ColorWithAlternatives)color; if (cwa.hasAlternativeColors()) { return cwa.getAlternativeColors(); } } return null; }
/** * Indicates whether another instance has the same alternative colors. * @param col the color to compare the alternatives to * @return true if the same alternative colors are present */ public boolean hasSameAlternativeColors(ColorWithAlternatives col) { if (!hasAlternativeColors()) { return !col.hasAlternativeColors(); } // this.hasAlternativeColors() if (!col.hasAlternativeColors()) { return false; } // this.hasAlternativeColors() && col.hasAlternativeColors() Color[] alt1 = getAlternativeColors(); Color[] alt2 = col.getAlternativeColors(); if (alt1.length != alt2.length) { return false; } for (int i = 0, c = alt1.length; i < c; i++) { Color c1 = alt1[i]; Color c2 = alt2[i]; if (!ColorUtil.isSameColor(c1, c2)) { return false; } } return true; }
/** * 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 (Color alternativeColor : this.alternativeColors) { if (alternativeColor.getColorSpace().getType() == colorSpaceType) { return alternativeColor; } } } return null; }
&& !((ColorWithAlternatives) col1).hasAlternativeColors()) { cl1 = Color.class; && !((ColorWithAlternatives) col2).hasAlternativeColors()) { cl2 = Color.class;
if (cs.isCS_sRGB() && !color.hasAlternativeColors()) { return toRGBFunctionCall(color); if (color.hasAlternativeColors()) { Color alt = color.getAlternativeColors()[0]; if (ColorSpaces.isDeviceColorSpace(alt.getColorSpace())) {