xmlgraphics-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simon Pepping <spepp...@leverkruid.eu>
Subject Re: [VOTE] Merge XGC color branch into Trunk
Date Mon, 13 Dec 2010 19:43:43 GMT
On Mon, Dec 13, 2010 at 03:54:44PM +0100, Jeremias Maerki wrote:
> I think I have addressed all concerns now. I've switched from using
> equals() to ColorUtil.isSameColor(Color, Color). That should take care
> of the equals contract problem. If the color branch is now in a state
> that everybody is happy with, I'll restart the vote.

Don't you mean the following with the class test:

//Consider same-ness only between colors of the same class (not subclasses)
//but consider a ColorWithAlternatives without alternatives to be the same as a Color.
Class<?> cl1 = col1.getClass();
if (cl1 == ColorWithAlternatives.class
        && !((ColorWithAlternatives)col1).hasAlternativeColors()) {
    cl1 = Color.class;
}
Class<?> cl2 = col2.getClass();
if (cl2 == ColorWithAlternatives.class
        && !((ColorWithAlternatives)col2).hasAlternativeColors()) {
    cl2 = Color.class;
}
if (cl1 != cl2) {
    return false;
}

Even so, subclasses of ColorWithAlternatives may come out
unexpectedly: An object of ColorWithAlternatives with no alternative
colors, and a Color object will be equal. In contrast, an object of a
Subclass of ColorWithAlternatives with no alternative colors, and a
Color object will not be equal. Why is that so?

The part where alternative colors are compared, could well be a method
of ColorWithAlternatives, putting the logic in the right class.

Simon
 

---------------------------------------------------------------------
To unsubscribe, e-mail: general-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: general-help@xmlgraphics.apache.org


Mime
View raw message