http://gwt-code-reviews.appspot.com/1082801/diff/1/10
File user/src/com/google/gwt/html5/canvas/client/CssColor.java (right):

http://gwt-code-reviews.appspot.com/1082801/diff/1/10#newcode23
user/src/com/google/gwt/html5/canvas/client/CssColor.java:23: public
class CssColor implements IsFillStyle, IsStrokeStyle {
On 2010/11/06 00:20:30, cromwellian wrote:
Perhaps a union-type scenario would be better. In my Chronoscope
library, I had
both a setStrokeStyle(String) and setStrokeStyle(StrokeStyle). The
problem is,
you can't just use strings, because patterns and gradients are also
allowed.  An
overload would give you the best of both worlds.

...and is already there, which is why I questioned the existence of this
CssColor class (the setStrokeStyle(IsStrokeStyle) has an explicit
"instanceof CssColor" check, which is what bothered me).
I missed (and didn't think about) the getters though: a union-type is
probably the best option, or maybe an added getStrokeStyleType or
isStrokeStyleACssColor and getStrokeStyleAsGradient,
getStrokeStyleAsPattern and getStrokeStyleAsString.
But the generic method doesn't look good as you have to know before hand
which type of value has been set, or you risk a ClassCastException (or
having issues using the returned object).

http://gwt-code-reviews.appspot.com/1082801/show

--
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to