- From: Yves Lafon via cvs-syncmail <cvsmail@w3.org>
- Date: Tue, 23 Aug 2005 16:33:53 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2002/css-validator/org/w3c/css/properties/css2/user In directory hutz:/tmp/cvs-serv9948/user Added Files: Css2Style.java Cursor.java CursorATSC.java CursorCSS2.java Outline.java OutlineATSC.java OutlineColor.java OutlineColorATSC.java OutlineStyle.java OutlineStyleATSC.java OutlineWidth.java OutlineWidthATSC.java UserProperties.java UserProperty.java Log Message: major reorganization of property files --- NEW FILE: CursorCSS2.java --- // // $Id: CursorCSS2.java,v 1.1 2005/08/23 16:33:51 ylafon Exp $ // From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr) // // (c) COPYRIGHT MIT and INRIA, 1997. // Please first read the full copyright statement in file COPYRIGHT.html /* */ package org.w3c.css.properties.css2.user; import java.util.Vector; import org.w3c.css.parser.CssStyle; import org.w3c.css.properties.css1.CssProperty; import org.w3c.css.util.ApplContext; import org.w3c.css.util.InvalidParamException; import org.w3c.css.values.CssExpression; import org.w3c.css.values.CssIdent; import org.w3c.css.values.CssOperator; import org.w3c.css.values.CssURL; import org.w3c.css.values.CssValue; /** * @version $Revision: 1.1 $ */ public class CursorCSS2 extends CssProperty implements CssOperator { int value; Vector uris = new Vector(); boolean inheritedValue; private static String CURSOR[] = { "auto", "crosshair", "default", "pointer", "move", "e-resize", "ne-resize", "nw-resize", "n-resize", "se-resize", "sw-resize", "s-resize", "w-resize", "text", "wait", "help" }; private static int[] hash_values; /** * Create a new Cursor */ public CursorCSS2() { value = 0; } /** * Create a new Cursor * * @param expression The expression for this property * @exception InvalidParamException Values are incorrect */ public CursorCSS2(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { CssValue val = expression.getValue(); char op = expression.getOperator(); setByUser(); if (val.equals(inherit)) { if(expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } inheritedValue = true; expression.next(); return; } while ((op == COMMA) && (val instanceof CssURL)) { if(val != null && val.equals(inherit)) { throw new InvalidParamException("unrecognize", ac); } uris.addElement(val); expression.next(); val = expression.getValue(); op = expression.getOperator(); } if (val instanceof CssURL) { throw new InvalidParamException("comma", val.toString(), getPropertyName(), ac); } if (val instanceof CssIdent) { int hash = val.hashCode(); for (int i = 0; i < CURSOR.length; i++) { if (hash_values[i] == hash) { value = i; expression.next(); if(check && !expression.end()) { throw new InvalidParamException("unrecognize", ac); } return; } } } throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } public CursorCSS2(ApplContext ac, CssExpression expression) throws InvalidParamException { this(ac, expression, false); } /** * Returns the value of this property */ public Object get() { return null; } /** * Returns the name of this property */ public String getPropertyName() { return "cursor"; } /** * Returns true if this property is "softly" inherited * e.g. his value equals inherit */ public boolean isSoftlyInherited() { return inheritedValue; } /** * Returns a string representation of the object. */ public String toString() { if (inheritedValue) { return inherit.toString(); } else { int i = 0; int l = uris.size(); String ret = ""; while (i != l) { ret += uris.elementAt(i++) + (new Character(COMMA)).toString() + " "; } ret += " " + CURSOR[value]; return ret; } } /** * Add this property to the CssStyle. * * @param style The CssStyle */ public void addToStyle(ApplContext ac, CssStyle style) { Css2Style style0 = (Css2Style) style; if (style0.cursorCSS2 != null) style0.addRedefinitionWarning(ac, this); style0.cursorCSS2 = this; } /** * Get this property in the style. * * @param style The style where the property is * @param resolve if true, resolve the style to find this property */ public CssProperty getPropertyInStyle(CssStyle style, boolean resolve) { if (resolve) { return ((Css2Style) style).getCursorCSS2(); } else { return ((Css2Style) style).cursor; } } /** * Compares two properties for equality. * * @param value The other property. */ public boolean equals(CssProperty property) { return (property instanceof Cursor && value == ((Cursor) property).value); } /** * Is the value of this property is a default value. * It is used by all macro for the function <code>print</code> */ public boolean isDefault() { return value == 0; } static { hash_values = new int[CURSOR.length]; for (int i=0; i<CURSOR.length; i++) hash_values[i] = CURSOR[i].hashCode(); } } --- NEW FILE: Css2Style.java --- // // $Id: Css2Style.java,v 1.1 2005/08/23 16:33:51 ylafon Exp $ // From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr) // // (c) COPYRIGHT MIT and INRIA, 1997. // Please first read the full copyright statement in file COPYRIGHT.html /* */ package org.w3c.css.properties.css2.user; import org.w3c.css.parser.CssPrinterStyle; /** * @version $Revision: 1.1 $ */ public class Css2Style extends org.w3c.css.properties.css2.table.Css2Style { CursorCSS2 cursorCSS2; Cursor cursor; CursorATSC cursorATSC; Outline outline = new Outline(); OutlineATSC outlineATSC = new OutlineATSC(); /** * Get the cursor property */ public final CursorCSS2 getCursorCSS2() { if (cursorCSS2 == null) { cursorCSS2 = (CursorCSS2) style.CascadingOrder(new CursorCSS2(), style, selector); } return cursorCSS2; } public final Cursor getCursor() { if (cursor == null) { cursor = (Cursor) style.CascadingOrder(new Cursor(), style, selector); } return cursor; } public final CursorATSC getCursorATSC() { if (cursorATSC == null) { cursorATSC = (CursorATSC) style.CascadingOrder(new CursorATSC(), style, selector); } return cursorATSC; } /** * Get the outline-style property */ public final OutlineStyle getOutlineStyle() { if (outline.style == null) { outline.style = (OutlineStyle) style.CascadingOrder(new OutlineStyle(), style, selector); } return outline.style; } public final OutlineStyleATSC getOutlineStyleATSC() { if (outlineATSC.style == null) { outlineATSC.style = (OutlineStyleATSC) style.CascadingOrder(new OutlineStyleATSC(), style, selector); } return outlineATSC.style; } /** * Get the outline-width property */ public final OutlineWidth getOutlineWidth() { if (outline.width == null) { outline.width = (OutlineWidth) style.CascadingOrder(new OutlineWidth(), style, selector); } return outline.width; } public final OutlineWidthATSC getOutlineWidthATSC() { if (outlineATSC.width == null) { outlineATSC.width = (OutlineWidthATSC) style.CascadingOrder(new OutlineWidthATSC(), style, selector); } return outlineATSC.width; } /** * Get the outline-color property */ public final OutlineColor getOutlineColor() { if (outline.color == null) { outline.color = (OutlineColor) style.CascadingOrder(new OutlineColor(), style, selector); } return outline.color; } public final OutlineColorATSC getOutlineColorATSC() { if (outlineATSC.color == null) { outlineATSC.color = (OutlineColorATSC) style.CascadingOrder(new OutlineColorATSC(), style, selector); } return outlineATSC.color; } /** * Get the outline property */ public final Outline getOutline() { if (outline.style == null) { outline.style = getOutlineStyle(); } if (outline.width == null) { outline.width = getOutlineWidth(); } if (outline.color == null) { outline.color = getOutlineColor(); } return outline; } public final OutlineATSC getOutlineATSC() { if (outlineATSC.style == null) { outlineATSC.style = getOutlineStyleATSC(); } if (outlineATSC.width == null) { outlineATSC.width = getOutlineWidthATSC(); } if (outlineATSC.color == null) { outlineATSC.color = getOutlineColorATSC(); } return outlineATSC; } /** * Print this style. * * @param printer The printer interface. */ public void print(CssPrinterStyle printer) { super.print(printer); if (cursor != null) { cursor.print(printer); } if (cursorATSC != null) { cursorATSC.print(printer); } if (cursorCSS2 != null) { cursorCSS2.print(printer); } if (outline != null) { outline.print(printer); } if (outlineATSC != null) { outlineATSC.print(printer); } } } --- NEW FILE: CursorATSC.java --- // // $Id: CursorATSC.java,v 1.1 2005/08/23 16:33:51 ylafon Exp $ // From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr) // // (c) COPYRIGHT MIT and INRIA, 1997. // Please first read the full copyright statement in file COPYRIGHT.html /* */ package org.w3c.css.properties.css2.user; import java.util.Vector; import org.w3c.css.parser.CssStyle; import org.w3c.css.properties.css1.CssProperty; import org.w3c.css.util.ApplContext; import org.w3c.css.util.InvalidParamException; import org.w3c.css.values.CssExpression; import org.w3c.css.values.CssIdent; import org.w3c.css.values.CssOperator; import org.w3c.css.values.CssURL; import org.w3c.css.values.CssValue; /** * @version $Revision: 1.1 $ */ public class CursorATSC extends CssProperty implements CssOperator { int value; Vector uris = new Vector(); boolean inheritedValue; private static String CURSOR[] = { "auto", "crosshair", "default", "pointer", "move", "e-resize", "ne-resize", "nw-resize", "n-resize", "se-resize", "sw-resize", "s-resize", "w-resize", "text", "wait", "help" }; private static int[] hash_values; /** * Create a new Cursor */ public CursorATSC() { value = 0; } /** * Create a new Cursor * * @param expression The expression for this property * @exception InvalidParamException Values are incorrect */ public CursorATSC(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { CssValue val = expression.getValue(); char op = expression.getOperator(); setByUser(); ac.getFrame().addWarning("atsc", val.toString()); if (val.equals(inherit)) { if(expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } inheritedValue = true; expression.next(); return; } while ((op == COMMA)&& (val instanceof CssURL)) { if(val != null && val.equals(inherit)) { throw new InvalidParamException("unrecognize", ac); } uris.addElement(val); expression.next(); val = expression.getValue(); op = expression.getOperator(); } if (val instanceof CssURL) { throw new InvalidParamException("comma", val.toString(), getPropertyName(), ac); } if (val instanceof CssIdent) { int hash = val.hashCode(); for (int i = 0; i < CURSOR.length; i++) { if (hash_values[i] == hash) { value = i; expression.next(); if(check && !expression.end()) { throw new InvalidParamException("unrecognize", ac); } return; } } } throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } public CursorATSC(ApplContext ac, CssExpression expression) throws InvalidParamException { this(ac, expression, false); } /** * Returns the value of this property */ public Object get() { return null; } /** * Returns the name of this property */ public String getPropertyName() { return "cursor"; } /** * Returns true if this property is "softly" inherited * e.g. his value equals inherit */ public boolean isSoftlyInherited() { return inheritedValue; } /** * Returns a string representation of the object. */ public String toString() { if (inheritedValue) { return inherit.toString(); } else { int i = 0; int l = uris.size(); String ret = ""; while (i != l) { ret += uris.elementAt(i++) + (new Character(COMMA)).toString() + " "; } ret += " " + CURSOR[value]; return ret; } } /** * Add this property to the CssStyle. * * @param style The CssStyle */ public void addToStyle(ApplContext ac, CssStyle style) { Css2Style style0 = (Css2Style) style; if (style0.cursorATSC != null) style0.addRedefinitionWarning(ac, this); style0.cursorATSC = this; } /** * Get this property in the style. * * @param style The style where the property is * @param resolve if true, resolve the style to find this property */ public CssProperty getPropertyInStyle(CssStyle style, boolean resolve) { if (resolve) { return ((Css2Style) style).getCursorATSC(); } else { return ((Css2Style) style).cursorATSC; } } /** * Compares two properties for equality. * * @param value The other property. */ public boolean equals(CssProperty property) { return (property instanceof CursorATSC && value == ((CursorATSC) property).value); } /** * Is the value of this property is a default value. * It is used by all macro for the function <code>print</code> */ public boolean isDefault() { return value == 0; } static { hash_values = new int[CURSOR.length]; for (int i=0; i<CURSOR.length; i++) hash_values[i] = CURSOR[i].hashCode(); } } --- NEW FILE: OutlineColor.java --- // // $Id: OutlineColor.java,v 1.1 2005/08/23 16:33:51 ylafon Exp $ // From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr) // // (c) COPYRIGHT MIT and INRIA, 1997. // Please first read the full copyright statement in file COPYRIGHT.html /** * */ package org.w3c.css.properties.css2.user; import org.w3c.css.parser.CssStyle; import org.w3c.css.properties.css1.CssProperty; import org.w3c.css.util.ApplContext; import org.w3c.css.util.InvalidParamException; import org.w3c.css.values.CssColor; import org.w3c.css.values.CssExpression; import org.w3c.css.values.CssIdent; import org.w3c.css.values.CssValue; /** * @version $Revision: 1.1 $ */ public class OutlineColor extends UserProperty { CssValue color; private static final CssIdent invert = new CssIdent("invert"); /** * Create a new OutlineColor */ public OutlineColor() { color = invert; } /** * Set the value of the property * @param expression The expression for this property * @exception InvalidParamException Values are incorrect */ public OutlineColor(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { if(check && expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } CssValue val = expression.getValue(); setByUser(); if (val.equals(inherit)) { color = inherit; expression.next(); } else if (val.equals(invert)) { color = invert; expression.next(); } else if (val instanceof CssColor) { color = val; expression.next(); } else if (val instanceof CssIdent) { color = new CssColor(ac, (String) val.get()); expression.next(); } else { throw new InvalidParamException("value", val, getPropertyName(), ac); } } public OutlineColor(ApplContext ac, CssExpression expression) throws InvalidParamException { this(ac, expression, false); } /** * Returns the value of this property */ public Object get() { return color; } /** * Returns true if this property is "softly" inherited * e.g. his value equals inherit */ public boolean isSoftlyInherited() { return color.equals(inherit); } /** * Returns a string representation of the object. */ public String toString() { return color.toString(); } /** * Add this property to the CssStyle. * * @param style The CssStyle */ public void addToStyle(ApplContext ac, CssStyle style) { Outline outline = ((Css2Style) style).outline; if (outline.color != null) { style.addRedefinitionWarning(ac, this); } outline.color = this; } /** * Get this property in the style. * * @param style The style where the property is * @param resolve if true, resolve the style to find this property */ public CssProperty getPropertyInStyle(CssStyle style, boolean resolve) { if (resolve) { return ((Css2Style) style).getOutlineColor(); } else { return ((Css2Style) style).outline.color; } } /** * Compares two properties for equality. * * @param value The other property. */ public boolean equals(CssProperty property) { return (property instanceof OutlineColor && color.equals(((OutlineColor) property).color)); } /** * Returns the name of this property */ public String getPropertyName() { return "outline-color"; } } --- NEW FILE: OutlineATSC.java --- // // $Id: OutlineATSC.java,v 1.1 2005/08/23 16:33:51 ylafon Exp $ // From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr) // // (c) COPYRIGHT MIT and INRIA, 1997. // Please first read the full copyright statement in file COPYRIGHT.html /* */ package org.w3c.css.properties.css2.user; import org.w3c.css.parser.CssPrinterStyle; import org.w3c.css.parser.CssSelectors; import org.w3c.css.parser.CssStyle; import org.w3c.css.properties.css1.CssProperty; import org.w3c.css.util.ApplContext; import org.w3c.css.util.InvalidParamException; import org.w3c.css.values.CssExpression; import org.w3c.css.values.CssOperator; import org.w3c.css.values.CssValue; /** * @version $Revision: 1.1 $ */ public class OutlineATSC extends UserProperty implements CssOperator { OutlineColorATSC color; OutlineWidthATSC width; OutlineStyleATSC style; boolean same; /** * Create a new OutlineATSC */ public OutlineATSC() { } /** * Create a new OutlineATSC * * @param expression The expression for this property * @exception InvalidParamException Values are incorrect */ public OutlineATSC(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { if(check && expression.getCount() > 3) { throw new InvalidParamException("unrecognize", ac); } CssValue val = expression.getValue(); char op = SPACE; boolean find = true; int max_values = 3; ac.getFrame().addWarning("atsc", val.toString()); if (val.equals(inherit)) { if(expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } this.same = true; color = new OutlineColorATSC(ac, expression); width = new OutlineWidthATSC(); width.value = inherit; style = new OutlineStyleATSC(); style.value = OutlineStyleATSC.BORDERSTYLE.length - 1; return; } while (find && max_values-- > 0) { find = false; val = expression.getValue(); op = expression.getOperator(); if(val != null && val.equals(inherit)) { throw new InvalidParamException("unrecognize", ac); } if (val == null) { break; } if (op != SPACE) { throw new InvalidParamException("operator", ((new Character(op)).toString()), ac); } if (style == null) { try { style = new OutlineStyleATSC(ac, expression); find = true; } catch (InvalidParamException e) { } } if (!find && color == null) { try { color = new OutlineColorATSC(ac, expression); find = true; } catch (InvalidParamException e) { } } if (!find && width == null) { width = new OutlineWidthATSC(ac, expression); find = true; } if(val != null && !find) { throw new InvalidParamException("unrecognize", ac); } } if (max_values >= 2) { throw new InvalidParamException("few-value", getPropertyName(), ac); } /* if (color == null) { color = new OutlineColorATSC(); } if (width == null) { width = new OutlineWidthATSC(); } if (style == null) { style = new OutlineStyleATSC(); } */ } public OutlineATSC(ApplContext ac, CssExpression expression) throws InvalidParamException { this(ac, expression, false); } /** * Returns the value of this property * not useful */ public Object get() { return color; } /** * Returns the name of this property */ public String getPropertyName() { return "outline"; } /** * Returns a string representation of the object. */ public String toString() { // outlineColor and outlineWidth must be not null ! if (same) { return color.toString(); } else { String ret =""; if (color != null) { ret += " " + color; } if (width != null) { ret += " " + width; } if (style != null) { ret += " " + style; } return ret.substring(1); } } /** * Set this property to be important. * Overrides this method for a macro */ public void setImportant() { super.setImportant(); if(color != null) color.setImportant(); if(width != null) width.setImportant(); if(style != null) style.setImportant(); } /** * Returns true if this property is important. * Overrides this method for a macro */ public boolean getImportant() { return ((width == null || width.getImportant()) && (color == null || color.getImportant()) && (style == null || style.getImportant())); } /** * Print this property. * * @param printer The printer. * @see #toString() * @see #getPropertyName() */ public void print(CssPrinterStyle printer) { if ((color != null && width != null && style != null) && (getImportant() || (!color.getImportant() && !style.getImportant() && !width.getImportant()))) { printer.print(this); } else { if (color != null) { color.print(printer); } if (width != null) { width.print(printer); } if (style != null) { style.print(printer); } } } /** * Add this property to the CssStyle * * @param style The CssStyle */ public void addToStyle(ApplContext ac, CssStyle style0) { // outlineColor and outlineWidth can't be null ... ((Css2Style) style0).outline.same = same; if(color != null) color.addToStyle(ac, style0); if(width != null) width.addToStyle(ac, style0); if(style != null) style.addToStyle(ac, style0); } /** * Update the source file and the line. * Overrides this method for a macro * * @param line The line number where this property is defined * @param source The source file where this property is defined */ public void setInfo(int line, String source) { super.setInfo(line, source); if(color != null) color.setInfo(line, source); if(width != null) width.setInfo(line, source); if(style != null) style.setInfo(line, source); } /** * Compares two properties for equality. * * @param value The other property. */ public boolean equals(CssProperty property) { return false; // @FIXME } /** * Set the context. * Overrides this method for a macro * * @see org.w3c.css.css.CssCascadingOrder#order * @see org.w3c.css.css.StyleSheetParser#handleRule */ public void setSelectors(CssSelectors selector) { super.setSelectors(selector); if (color != null) { color.setSelectors(selector); } if (width != null) { width.setSelectors(selector); } if (style != null) { style.setSelectors(selector); } } /** * Get this property in the style. * * @param style The style where the property is * @param resolve if true, resolve the style to find this property */ public CssProperty getPropertyInStyle(CssStyle style, boolean resolve) { if (resolve) { return ((Css2Style) style).getOutlineATSC(); } else { return ((Css2Style) style).outlineATSC; } } } --- NEW FILE: OutlineStyleATSC.java --- // // $Id: OutlineStyleATSC.java,v 1.1 2005/08/23 16:33:51 ylafon Exp $ // From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr) // // (c) COPYRIGHT MIT and INRIA, 1997. // Please first read the full copyright statement in file COPYRIGHT.html /** * */ package org.w3c.css.properties.css2.user; import org.w3c.css.parser.CssStyle; import org.w3c.css.properties.css1.CssProperty; import org.w3c.css.util.ApplContext; import org.w3c.css.util.InvalidParamException; import org.w3c.css.values.CssExpression; import org.w3c.css.values.CssIdent; import org.w3c.css.values.CssValue; /** * @version $Revision: 1.1 $ */ public class OutlineStyleATSC extends UserProperty { int value = -1; static String[] BORDERSTYLE = { "none", "dotted", "dashed", "solid", "double", "groove", "ridge", "inset", "outset", "inherit" }; private static int[] hash_values; /** * Create a new OutlineStyleATSC */ public OutlineStyleATSC() { // nothing to do } /** * Create a new OutlineStyleATSC * * @param expression The expression for this face * @exception InvalidParamException The expression is incorrect */ public OutlineStyleATSC(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { if(check && expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } CssValue val = expression.getValue(); setByUser(); ac.getFrame().addWarning("atsc", val.toString()); if (val instanceof CssIdent) { int hash = val.hashCode(); for (int i = 0; i < BORDERSTYLE.length; i++) { if (hash_values[i] == hash) { value = i; expression.next(); return; } } } throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } public OutlineStyleATSC(ApplContext ac, CssExpression expression) throws InvalidParamException { this(ac, expression, false); } /** * Returns the internal value */ public Object get() { return BORDERSTYLE[value]; } /** * Returns true if this property is "softly" inherited * e.g. his value equals inherit */ public boolean isSoftlyInherited() { return value == (BORDERSTYLE.length - 1); } /** * Returns a string representation of the object. */ public String toString() { return BORDERSTYLE[value]; } /** * Add this property to the CssStyle. * * @param style The CssStyle */ public void addToStyle(ApplContext ac, CssStyle style) { OutlineATSC outline = ((Css2Style) style).outlineATSC; if (outline.style != null) { style.addRedefinitionWarning(ac, this); } outline.style = this; } /** * Get this property in the style. * * @param style The style where the property is * @param resolve if true, resolve the style to find this property */ public CssProperty getPropertyInStyle(CssStyle style, boolean resolve) { if (resolve) { return ((Css2Style) style).getOutlineStyleATSC(); } else { return ((Css2Style) style).outlineATSC.style; } } /** * Compares two properties for equality. * * @param value The other property. */ public boolean equals(CssProperty property) { return ((property instanceof OutlineStyleATSC) && (value == ((OutlineStyleATSC) property).value)); } /** * Returns the name of this property */ public String getPropertyName() { return "outline-style"; } static { hash_values = new int[BORDERSTYLE.length]; for (int i=0; i<BORDERSTYLE.length; i++) hash_values[i] = BORDERSTYLE[i].hashCode(); } } --- NEW FILE: OutlineColorATSC.java --- // // $Id: OutlineColorATSC.java,v 1.1 2005/08/23 16:33:51 ylafon Exp $ // From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr) // // (c) COPYRIGHT MIT and INRIA, 1997. // Please first read the full copyright statement in file COPYRIGHT.html /** * */ package org.w3c.css.properties.css2.user; import org.w3c.css.parser.CssStyle; import org.w3c.css.properties.css1.CssProperty; import org.w3c.css.util.ApplContext; import org.w3c.css.util.InvalidParamException; import org.w3c.css.values.CssColor; import org.w3c.css.values.CssExpression; import org.w3c.css.values.CssIdent; import org.w3c.css.values.CssValue; /** * @version $Revision: 1.1 $ */ public class OutlineColorATSC extends UserProperty { CssValue color; private static final CssIdent invert = new CssIdent("invert"); /** * Create a new OutlineColorATSC */ public OutlineColorATSC() { color = invert; } /** * Set the value of the property * @param expression The expression for this property * @exception InvalidParamException Values are incorrect */ public OutlineColorATSC(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { if(check && expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } CssValue val = expression.getValue(); setByUser(); ac.getFrame().addWarning("atsc", val.toString()); if (val.equals(inherit)) { color = inherit; expression.next(); } else if (val.equals(invert)) { color = invert; expression.next(); } else if (val instanceof CssColor) { color = val; expression.next(); } else if (val instanceof CssIdent) { color = new CssColor(ac, (String) val.get()); expression.next(); } else { throw new InvalidParamException("value", val, getPropertyName(), ac); } } public OutlineColorATSC(ApplContext ac, CssExpression expression) throws InvalidParamException { this(ac, expression, false); } /** * Returns the value of this property */ public Object get() { return color; } /** * Returns true if this property is "softly" inherited * e.g. his value equals inherit */ public boolean isSoftlyInherited() { return color.equals(inherit); } /** * Returns a string representation of the object. */ public String toString() { return color.toString(); } /** * Add this property to the CssStyle. * * @param style The CssStyle */ public void addToStyle(ApplContext ac, CssStyle style) { OutlineATSC outline = ((Css2Style) style).outlineATSC; if (outline.color != null) { style.addRedefinitionWarning(ac, this); } outline.color = this; } /** * Get this property in the style. * * @param style The style where the property is * @param resolve if true, resolve the style to find this property */ public CssProperty getPropertyInStyle(CssStyle style, boolean resolve) { if (resolve) { return ((Css2Style) style).getOutlineColorATSC(); } else { return ((Css2Style) style).outlineATSC.color; } } /** * Compares two properties for equality. * * @param value The other property. */ public boolean equals(CssProperty property) { return (property instanceof OutlineColorATSC && color.equals(((OutlineColorATSC) property).color)); } /** * Returns the name of this property */ public String getPropertyName() { return "outline-color"; } } --- NEW FILE: OutlineStyle.java --- // // $Id: OutlineStyle.java,v 1.1 2005/08/23 16:33:51 ylafon Exp $ // From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr) // // (c) COPYRIGHT MIT and INRIA, 1997. // Please first read the full copyright statement in file COPYRIGHT.html /** * */ package org.w3c.css.properties.css2.user; import org.w3c.css.parser.CssStyle; import org.w3c.css.properties.css1.CssProperty; import org.w3c.css.util.ApplContext; import org.w3c.css.util.InvalidParamException; import org.w3c.css.values.CssExpression; import org.w3c.css.values.CssIdent; import org.w3c.css.values.CssValue; /** * @version $Revision: 1.1 $ */ public class OutlineStyle extends UserProperty { int value = -1; static String[] BORDERSTYLE = { "none", "hidden", "dotted", "dashed", "solid", "double", "groove", "ridge", "inset", "outset", "inherit" }; private static int[] hash_values; /** * Create a new OutlineStyle */ public OutlineStyle() { // nothing to do } /** * Create a new OutlineStyle * * @param expression The expression for this face * @exception InvalidParamException The expression is incorrect */ public OutlineStyle(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { if(check && expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } CssValue val = expression.getValue(); setByUser(); if (val instanceof CssIdent) { int hash = val.hashCode(); for (int i = 0; i < BORDERSTYLE.length; i++) { if (hash_values[i] == hash) { value = i; expression.next(); return; } } } throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } public OutlineStyle(ApplContext ac, CssExpression expression) throws InvalidParamException { this(ac, expression, false); } /** * Returns the internal value */ public Object get() { return BORDERSTYLE[value]; } /** * Returns true if this property is "softly" inherited * e.g. his value equals inherit */ public boolean isSoftlyInherited() { return value == (BORDERSTYLE.length - 1); } /** * Returns a string representation of the object. */ public String toString() { return BORDERSTYLE[value]; } /** * Add this property to the CssStyle. * * @param style The CssStyle */ public void addToStyle(ApplContext ac, CssStyle style) { Outline outline = ((Css2Style) style).outline; if (outline.style != null) { style.addRedefinitionWarning(ac, this); } outline.style = this; } /** * Get this property in the style. * * @param style The style where the property is * @param resolve if true, resolve the style to find this property */ public CssProperty getPropertyInStyle(CssStyle style, boolean resolve) { if (resolve) { return ((Css2Style) style).getOutlineStyle(); } else { return ((Css2Style) style).outline.style; } } /** * Compares two properties for equality. * * @param value The other property. */ public boolean equals(CssProperty property) { return ((property instanceof OutlineStyle) && (value == ((OutlineStyle) property).value)); } /** * Returns the name of this property */ public String getPropertyName() { return "outline-style"; } static { hash_values = new int[BORDERSTYLE.length]; for (int i=0; i<BORDERSTYLE.length; i++) hash_values[i] = BORDERSTYLE[i].hashCode(); } } --- NEW FILE: OutlineWidth.java --- // // $Id: OutlineWidth.java,v 1.1 2005/08/23 16:33:51 ylafon Exp $ // From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr) // // (c) COPYRIGHT MIT and INRIA, 1997. // Please first read the full copyright statement in file COPYRIGHT.html /* * */ package org.w3c.css.properties.css2.user; import org.w3c.css.parser.CssStyle; import org.w3c.css.properties.css1.CssProperty; import org.w3c.css.util.ApplContext; import org.w3c.css.util.InvalidParamException; import org.w3c.css.values.CssExpression; import org.w3c.css.values.CssIdent; import org.w3c.css.values.CssLength; import org.w3c.css.values.CssNumber; import org.w3c.css.values.CssValue; /** * @version $Revision: 1.1 $ */ public class OutlineWidth extends UserProperty { CssValue value; private static CssIdent thin = new CssIdent("thin"); private static CssIdent medium = new CssIdent("medium"); private static CssIdent thick = new CssIdent("thick"); /** * Create a new OutlineWidth */ public OutlineWidth() { value = medium; } /** * Create a new OutlineWidth from an another OutlineWidth * * @param another The another side. */ public OutlineWidth(OutlineWidth another) { value = another.value; } /** * Create a new OutlineWidth * * @param expression The expression for this property * @exception InvalidParamException Values are incorrect */ public OutlineWidth(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { if(check && expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } CssValue val = expression.getValue(); setByUser(); if (val instanceof CssLength) { float f = ((Float) val.get()).floatValue(); if (f >= 0) { this.value = val; } else { throw new InvalidParamException("negative-value", val.toString(), ac); } } else if (val instanceof CssNumber) { value = ((CssNumber) val).getLength(); } else if (val.equals(thin)) { value = thin; } else if (val.equals(medium)) { value = medium; } else if (val.equals(thick)) { value = thick; } else if (val.equals(inherit)) { value = CssProperty.inherit; } else { throw new InvalidParamException("value", val.toString(), "width", ac); } expression.next(); } public OutlineWidth(ApplContext ac, CssExpression expression) throws InvalidParamException { this(ac, expression, false); } /** * Returns the internal value */ public Object get() { return value; } /** * Returns true if this property is "softly" inherited * e.g. his value equals inherit */ public boolean isSoftlyInherited() { return value.equals(inherit); } /** * Returns a string representation of the object. */ public String toString() { return value.toString(); } /** * Add this property to the CssStyle. * * @param style The CssStyle */ public void addToStyle(ApplContext ac, CssStyle style) { Outline outline = ((Css2Style) style).outline; if (outline.width != null) { style.addRedefinitionWarning(ac, this); } outline.width = this; } /** * Get this property in the style. * * @param style The style where the property is * @param resolve if true, resolve the style to find this property */ public CssProperty getPropertyInStyle(CssStyle style, boolean resolve) { if (resolve) { return ((Css2Style) style).getOutlineWidth(); } else { return ((Css2Style) style).outline.width; } } /** * Compares two properties for equality. * * @param value The other property. */ public boolean equals(CssProperty property) { return (property instanceof OutlineWidth && value.equals(((OutlineWidth) property).value)); } /** * Returns the name of this property */ public String getPropertyName() { return "outline-width"; } } --- NEW FILE: Outline.java --- // // $Id: Outline.java,v 1.1 2005/08/23 16:33:51 ylafon Exp $ // From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr) // // (c) COPYRIGHT MIT and INRIA, 1997. // Please first read the full copyright statement in file COPYRIGHT.html /* */ package org.w3c.css.properties.css2.user; import org.w3c.css.parser.CssPrinterStyle; import org.w3c.css.parser.CssSelectors; import org.w3c.css.parser.CssStyle; import org.w3c.css.properties.css1.CssProperty; import org.w3c.css.util.ApplContext; import org.w3c.css.util.InvalidParamException; import org.w3c.css.values.CssExpression; import org.w3c.css.values.CssOperator; import org.w3c.css.values.CssValue; /** * @version $Revision: 1.1 $ */ public class Outline extends UserProperty implements CssOperator { OutlineColor color; OutlineWidth width; OutlineStyle style; boolean same; /** * Create a new Outline */ public Outline() { } /** * Create a new Outline * * @param expression The expression for this property * @exception InvalidParamException Values are incorrect */ public Outline(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { if(check && expression.getCount() > 3) { throw new InvalidParamException("unrecognize", ac); } CssValue val = expression.getValue(); char op = SPACE; boolean find = true; int max_values = 3; if (val.equals(inherit)) { if(expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } this.same = true; color = new OutlineColor(ac, expression); width = new OutlineWidth(); width.value = inherit; style = new OutlineStyle(); style.value = OutlineStyle.BORDERSTYLE.length - 1; return; } while (find && max_values-- > 0) { find = false; val = expression.getValue(); op = expression.getOperator(); if(val != null && val.equals(inherit)) { throw new InvalidParamException("unrecognize", ac); } if (val == null) { break; } if (op != SPACE) { throw new InvalidParamException("operator", ((new Character(op)).toString()), ac); } if (style == null) { try { style = new OutlineStyle(ac, expression); find = true; } catch (InvalidParamException e) { } } if (!find && color == null) { try { color = new OutlineColor(ac, expression); find = true; } catch (InvalidParamException e) { } } if (!find && width == null) { width = new OutlineWidth(ac, expression); find = true; } if(val != null && !find) { throw new InvalidParamException("unrecognize", ac); } } if (max_values >= 2) { throw new InvalidParamException("few-value", getPropertyName(), ac); } /* if (color == null) { color = new OutlineColor(); } if (width == null) { width = new OutlineWidth(); } if (style == null) { style = new OutlineStyle(); }*/ } public Outline(ApplContext ac, CssExpression expression) throws InvalidParamException { this(ac, expression, false); } /** * Returns the value of this property * not useful */ public Object get() { return color; } /** * Returns the name of this property */ public String getPropertyName() { return "outline"; } /** * Returns a string representation of the object. */ public String toString() { // outlineColor and outlineWidth must be not null ! if (same) { return color.toString(); } else { String ret =""; if (color != null) { ret += " " + color; } if (width != null) { ret += " " + width; } if (style != null) { ret += " " + style; } return ret.substring(1); } } /** * Set this property to be important. * Overrides this method for a macro */ public void setImportant() { super.setImportant(); if(color != null) color.setImportant(); if(width != null) width.setImportant(); if(style != null) style.setImportant(); } /** * Returns true if this property is important. * Overrides this method for a macro */ public boolean getImportant() { return ((width == null || width.getImportant()) && (color == null || color.getImportant()) && (style == null || style.getImportant())); } /** * Print this property. * * @param printer The printer. * @see #toString() * @see #getPropertyName() */ public void print(CssPrinterStyle printer) { if ((color != null && width != null && style != null) && (getImportant() || (!color.getImportant() && !style.getImportant() && !width.getImportant()))) { printer.print(this); } else { if (color != null) { color.print(printer); } if (width != null) { width.print(printer); } if (style != null) { style.print(printer); } } } /** * Add this property to the CssStyle * * @param style The CssStyle */ public void addToStyle(ApplContext ac, CssStyle style0) { // outlineColor and outlineWidth can't be null ... ((Css2Style) style0).outline.same = same; if(color != null) color.addToStyle(ac, style0); if(width != null) width.addToStyle(ac, style0); if(style != null) style.addToStyle(ac, style0); } /** * Update the source file and the line. * Overrides this method for a macro * * @param line The line number where this property is defined * @param source The source file where this property is defined */ public void setInfo(int line, String source) { super.setInfo(line, source); if(color != null) color.setInfo(line, source); if(width != null) width.setInfo(line, source); if(style != null) style.setInfo(line, source); } /** * Compares two properties for equality. * * @param value The other property. */ public boolean equals(CssProperty property) { return false; // @FIXME } /** * Set the context. * Overrides this method for a macro * * @see org.w3c.css.css.CssCascadingOrder#order * @see org.w3c.css.css.StyleSheetParser#handleRule */ public void setSelectors(CssSelectors selector) { super.setSelectors(selector); if (color != null) { color.setSelectors(selector); } if (width != null) { width.setSelectors(selector); } if (style != null) { style.setSelectors(selector); } } /** * Get this property in the style. * * @param style The style where the property is * @param resolve if true, resolve the style to find this property */ public CssProperty getPropertyInStyle(CssStyle style, boolean resolve) { if (resolve) { return ((Css2Style) style).getOutline(); } else { return ((Css2Style) style).outline; } } } --- NEW FILE: Cursor.java --- // // $Id: Cursor.java,v 1.1 2005/08/23 16:33:51 ylafon Exp $ // From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr) // Updated september 14th 2000 by Sijtsche de Jong (sy.de.jong@let.rug.nl) // // (c) COPYRIGHT MIT and INRIA, 1997. // Please first read the full copyright statement in file COPYRIGHT.html /* */ package org.w3c.css.properties.css2.user; import java.util.Vector; import org.w3c.css.parser.CssStyle; import org.w3c.css.properties.css1.CssProperty; import org.w3c.css.util.ApplContext; import org.w3c.css.util.InvalidParamException; import org.w3c.css.values.CssExpression; import org.w3c.css.values.CssIdent; import org.w3c.css.values.CssOperator; import org.w3c.css.values.CssURL; import org.w3c.css.values.CssValue; /** * @version $Revision: 1.1 $ */ public class Cursor extends CssProperty implements CssOperator { int value; Vector uris = new Vector(); boolean inheritedValue; private static String CURSOR[] = { "auto", "crosshair", "default", "pointer", "move", "e-resize", "ne-resize", "nw-resize", "n-resize", "se-resize", "sw-resize", "s-resize", "w-resize", "text", "wait", "help", "progress", "copy", "alias", "context-menu", "cell", "all-scroll", "col-resize", "row-resize", "no-drop", "not-allowed", "vertical-text" }; private static int[] hash_values; /** * Create a new CssCursor */ public Cursor() { value = 0; } /** * Create a new CssCursor * * @param expression The expression for this property * @exception InvalidParamException Values are incorrect */ public Cursor(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { CssValue val = expression.getValue(); char op = expression.getOperator(); setByUser(); if (val.equals(inherit)) { if(expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } inheritedValue = true; expression.next(); return; } while ((op == COMMA)&& (val instanceof CssURL)) { if(val != null && val.equals(inherit)) { throw new InvalidParamException("unrecognize", ac); } uris.addElement(val); expression.next(); val = expression.getValue(); op = expression.getOperator(); } if (val instanceof CssURL) { throw new InvalidParamException("comma", val.toString(), getPropertyName(), ac); } if (val instanceof CssIdent) { int hash = val.hashCode(); for (int i = 0; i < CURSOR.length; i++) { if (hash_values[i] == hash) { value = i; expression.next(); if(check && !expression.end()) { throw new InvalidParamException("unrecognize", ac); } return; } } } throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } public Cursor(ApplContext ac, CssExpression expression) throws InvalidParamException { this(ac, expression, false); } /** * Returns the value of this property */ public Object get() { return null; } /** * Returns the name of this property */ public String getPropertyName() { return "cursor"; } /** * Returns true if this property is "softly" inherited * e.g. his value equals inherit */ public boolean isSoftlyInherited() { return inheritedValue; } /** * Returns a string representation of the object. */ public String toString() { if (inheritedValue) { return inherit.toString(); } else { int i = 0; int l = uris.size(); String ret = ""; while (i != l) { ret += uris.elementAt(i++) + (new Character(COMMA)).toString() + " "; } ret += " " + CURSOR[value]; return ret; } } /** * Add this property to the CssStyle. * * @param style The CssStyle */ public void addToStyle(ApplContext ac, CssStyle style) { Css2Style style0 = (Css2Style) style; if (style0.cursor != null) style0.addRedefinitionWarning(ac, this); style0.cursor = this; } /** * Get this property in the style. * * @param style The style where the property is * @param resolve if true, resolve the style to find this property */ public CssProperty getPropertyInStyle(CssStyle style, boolean resolve) { if (resolve) { return ((Css2Style) style).getCursor(); } else { return ((Css2Style) style).cursor; } } /** * Compares two properties for equality. * * @param value The other property. */ public boolean equals(CssProperty property) { return (property instanceof Cursor && value == ((Cursor) property).value); } /** * Is the value of this property is a default value. * It is used by all macro for the function <code>print</code> */ public boolean isDefault() { return value == 0; } static { hash_values = new int[CURSOR.length]; for (int i=0; i<CURSOR.length; i++) hash_values[i] = CURSOR[i].hashCode(); } } --- NEW FILE: UserProperty.java --- // // $Id: UserProperty.java,v 1.1 2005/08/23 16:33:51 ylafon Exp $ // From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr) // // (c) COPYRIGHT MIT and INRIA, 1997. // Please first read the full copyright statement in file COPYRIGHT.html /* */ package org.w3c.css.properties.css2.user; import org.w3c.css.properties.css1.CssProperty; /** * @version $Revision: 1.1 $ */ public abstract class UserProperty extends CssProperty { /** * Returns true if the property is inherited */ public boolean Inherited() { return UserProperties.getInheritance(this); } } --- NEW FILE: OutlineWidthATSC.java --- // // $Id: OutlineWidthATSC.java,v 1.1 2005/08/23 16:33:51 ylafon Exp $ // From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr) // // (c) COPYRIGHT MIT and INRIA, 1997. // Please first read the full copyright statement in file COPYRIGHT.html /* * */ package org.w3c.css.properties.css2.user; import org.w3c.css.parser.CssStyle; import org.w3c.css.properties.css1.CssProperty; import org.w3c.css.util.ApplContext; import org.w3c.css.util.InvalidParamException; import org.w3c.css.values.CssExpression; import org.w3c.css.values.CssIdent; import org.w3c.css.values.CssLength; import org.w3c.css.values.CssNumber; import org.w3c.css.values.CssValue; /** * @version $Revision: 1.1 $ */ public class OutlineWidthATSC extends UserProperty { CssValue value; private static CssIdent thin = new CssIdent("thin"); private static CssIdent medium = new CssIdent("medium"); private static CssIdent thick = new CssIdent("thick"); /** * Create a new OutlineWidthATSC */ public OutlineWidthATSC() { value = medium; } /** * Create a new OutlineWidthATSC from an another OutlineWidthATSC * * @param another The another side. */ public OutlineWidthATSC(OutlineWidthATSC another) { value = another.value; } /** * Create a new OutlineWidthATSC * * @param expression The expression for this property * @exception InvalidParamException Values are incorrect */ public OutlineWidthATSC(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { if(check && expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } CssValue val = expression.getValue(); setByUser(); ac.getFrame().addWarning("atsc", val.toString()); if (val instanceof CssLength) { float f = ((Float) val.get()).floatValue(); if (f >= 0) { this.value = val; } else { throw new InvalidParamException("negative-value", val.toString(), ac); } } else if (val instanceof CssNumber) { value = ((CssNumber) val).getLength(); } else if (val.equals(thin)) { value = thin; } else if (val.equals(medium)) { value = medium; } else if (val.equals(thick)) { value = thick; } else if (val.equals(inherit)) { value = CssProperty.inherit; } else { throw new InvalidParamException("value", val.toString(), "width", ac); } expression.next(); } public OutlineWidthATSC(ApplContext ac, CssExpression expression) throws InvalidParamException { this(ac, expression, false); } /** * Returns the internal value */ public Object get() { return value; } /** * Returns true if this property is "softly" inherited * e.g. his value equals inherit */ public boolean isSoftlyInherited() { return value.equals(inherit); } /** * Returns a string representation of the object. */ public String toString() { return value.toString(); } /** * Add this property to the CssStyle. * * @param style The CssStyle */ public void addToStyle(ApplContext ac, CssStyle style) { OutlineATSC outline = ((Css2Style) style).outlineATSC; if (outline.width != null) { style.addRedefinitionWarning(ac, this); } outline.width = this; } /** * Get this property in the style. * * @param style The style where the property is * @param resolve if true, resolve the style to find this property */ public CssProperty getPropertyInStyle(CssStyle style, boolean resolve) { if (resolve) { return ((Css2Style) style).getOutlineWidthATSC(); } else { return ((Css2Style) style).outlineATSC.width; } } /** * Compares two properties for equality. * * @param value The other property. */ public boolean equals(CssProperty property) { return (property instanceof OutlineWidthATSC && value.equals(((OutlineWidthATSC) property).value)); } /** * Returns the name of this property */ public String getPropertyName() { return "outline-width"; } } --- NEW FILE: UserProperties.java --- // // $Id: UserProperties.java,v 1.1 2005/08/23 16:33:51 ylafon Exp $ // From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr) // // (c) COPYRIGHT MIT and INRIA, 1997. // Please first read the full copyright statement in file COPYRIGHT.html package org.w3c.css.properties.css2.user; import java.net.URL; import org.w3c.css.properties.css1.CssProperty; import org.w3c.css.util.Utf8Properties; /** * @version $Revision: 1.1 $ */ public class UserProperties { public static Utf8Properties properties; public static String getString(CssProperty property, String prop) { return properties.getProperty(property.getPropertyName() + "." + prop); } public static boolean getInheritance(CssProperty property) { return getString(property, "inherited").equals("true"); } static { properties = new Utf8Properties(); try { URL url = UserProperties.class .getResource("UserDefault.properties"); properties.load(url.openStream()); } catch (Exception e) { System.err .println("org.w3c.css.properties.css2.user.UserProperties: couldn't load properties "); System.err.println(" " + e.toString()); } } }
Received on Tuesday, 23 August 2005 16:34:59 UTC