xmlgraphics-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeremias Maerki <...@jeremias-maerki.ch>
Subject Re: [VOTE] Merge XGC color branch into Trunk
Date Mon, 13 Dec 2010 20:33:17 GMT
On 13.12.2010 20:43:43 Simon Pepping wrote:
> 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;
> }

That's about the same, isn't it?

> 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?

Because I know that a ColorWithAlternatives without actual alternatives
will behave exactly the same way as the corresponding Color object. But
I can't say the same about some subclass of ColorWithAlternatives. Maybe
such a subclass will add functionality that was not foreseen. In such a
case, isSameColor() will have to be updated. I guess I should just have
skipped this test to avoid more discussions, just considering the
objects of two different classes different. After all, this is just
about state checking and who cares about the rarest of rare cases where
two such color objects follow each other?

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

Do you feel strongly about that? I don't see the advantage, especially
since that would add a public method only used by ColorUtil.

Jeremias Maerki

PS: anyone want to write a master thesis on this?

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

View raw message