hillion 2002/11/22 05:09:59 Modified: sources/org/apache/batik/css/engine/value RectManager.java Log: Added unit resolution to CSS rects. Revision Changes Path 1.2 +56 -2 xml-batik/sources/org/apache/batik/css/engine/value/RectManager.java Index: RectManager.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/css/engine/value/RectManager.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- RectManager.java 18 Mar 2002 10:28:22 -0000 1.1 +++ RectManager.java 22 Nov 2002 13:09:59 -0000 1.2 @@ -11,11 +11,14 @@ import org.apache.batik.util.CSSConstants; import org.apache.batik.css.engine.CSSEngine; +import org.apache.batik.css.engine.CSSStylableElement; +import org.apache.batik.css.engine.StyleMap; import org.w3c.css.sac.LexicalUnit; import org.w3c.dom.DOMException; import org.w3c.dom.css.CSSPrimitiveValue; +import org.w3c.dom.css.CSSValue; /** * This class provides a manager for the property with support for @@ -24,9 +27,14 @@ * @author <a href="mailto:[EMAIL PROTECTED]">Stephane Hillion</a> * @version $Id$ */ -public abstract class RectManager extends AbstractValueManager { +public abstract class RectManager extends LengthManager { /** + * The current orientation. + */ + protected int orientation; + + /** * Implements {@link ValueManager#createValue(LexicalUnit,CSSEngine)}. */ public Value createValue(LexicalUnit lu, CSSEngine engine) @@ -108,6 +116,52 @@ lu.getFloatValue()); } throw createMalformedRectDOMException(); + } + + /** + * Implements {@link + * ValueManager#computeValue(CSSStylableElement,String,CSSEngine,int,StyleMap,Value)}. + */ + public Value computeValue(CSSStylableElement elt, + String pseudo, + CSSEngine engine, + int idx, + StyleMap sm, + Value value) { + if (value.getCssValueType() != CSSValue.CSS_PRIMITIVE_VALUE) { + return value; + } + if (value.getPrimitiveType() != CSSPrimitiveValue.CSS_RECT) { + return value; + } + RectValue rect = (RectValue)value; + + orientation = VERTICAL_ORIENTATION; + Value top = super.computeValue(elt, pseudo, engine, idx, sm, + rect.getTop()); + Value bottom = super.computeValue(elt, pseudo, engine, idx, sm, + rect.getBottom()); + orientation = HORIZONTAL_ORIENTATION; + Value left = super.computeValue(elt, pseudo, engine, idx, sm, + rect.getLeft()); + Value right = super.computeValue(elt, pseudo, engine, idx, sm, + rect.getRight()); + if (top != rect.getTop() || + right != rect.getRight() || + bottom != rect.getBottom() || + left != rect.getLeft()) { + return new RectValue(top, right, bottom, left); + } else { + return value; + } + } + + /** + * Indicates the orientation of the property associated with + * this manager. + */ + protected int getOrientation() { + return orientation; } private DOMException createMalformedRectDOMException() {
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]