- From: Yves Lafon via cvs-syncmail <cvsmail@w3.org>
- Date: Thu, 05 Mar 2009 22:45:20 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2002/css-validator/org/w3c/css/values In directory hutz:/tmp/cvs-serv4610 Modified Files: HSL.java Log Message: revamped to match RGB and RGBA Index: HSL.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/values/HSL.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- HSL.java 14 Sep 2005 15:15:33 -0000 1.4 +++ HSL.java 5 Mar 2009 22:45:18 -0000 1.5 @@ -13,11 +13,13 @@ */ package org.w3c.css.values; +import org.w3c.css.util.Util; + public class HSL { String output = null; - Object h; - Object s; - Object l; + float fh; + float fs; + float fl; /** * Create a new HSL @@ -25,13 +27,25 @@ public HSL() { } - /** - * Create a new HSL with default values - */ - public HSL(Object h, Object s, Object l) { - this.h = h; - this.s = s; - this.l = l; + public void setHue(float hue) { + this.fh = (float)((((double)hue%360.0)+360.0)%360.0); + } + public void setHue(CssNumber hue) { + setHue(hue.getValue()); + } + + public void setSaturation(float sat) { + this.fs = sat; + } + public void setSaturation(CssNumber sat) { + setSaturation(sat.getValue()); + } + + public void setLightness(float light) { + this.fl = light; + } + public void setLightness(CssNumber light) { + setLightness(light.getValue()); } /** @@ -39,9 +53,12 @@ */ public String toString() { if (output == null) { - return "hsl(" + h + ", " + s + ", " + l + ")"; - } else { - return output; + StringBuilder sb = new StringBuilder("hsl("); + sb.append(Util.displayFloat(fh)).append(", "); + sb.append(Util.displayFloat(fs)).append("%, "); + sb.append(Util.displayFloat(fl)).append("%)"); + output = sb.toString(); } + return output; } }
Received on Thursday, 5 March 2009 22:45:32 UTC