1 18 package org.apache.batik.css.engine.value.svg12; 19 20 import org.apache.batik.css.engine.CSSEngine; 21 import org.apache.batik.css.engine.value.AbstractValueFactory; 22 import org.apache.batik.css.engine.value.ShorthandManager; 23 import org.apache.batik.css.engine.value.ValueManager; 24 import org.apache.batik.util.SVG12CSSConstants; 25 import org.w3c.css.sac.LexicalUnit; 26 import org.w3c.dom.DOMException ; 27 28 35 public class MarginShorthandManager 36 extends AbstractValueFactory 37 implements ShorthandManager { 38 39 public MarginShorthandManager() { } 40 41 44 public String getPropertyName() { 45 return SVG12CSSConstants.CSS_MARGIN_PROPERTY; 46 } 47 48 51 public void setValues(CSSEngine eng, 52 ShorthandManager.PropertyHandler ph, 53 LexicalUnit lu, 54 boolean imp) 55 throws DOMException { 56 if (lu.getLexicalUnitType() == LexicalUnit.SAC_INHERIT) 57 return; 58 59 LexicalUnit []lus = new LexicalUnit[4]; 60 int cnt=0; 61 while (lu != null) { 62 if (cnt == 4) 63 throw createInvalidLexicalUnitDOMException 64 (lu.getLexicalUnitType()); 65 lus[cnt++] = lu; 66 lu = lu.getNextLexicalUnit(); 67 } 68 switch (cnt) { 69 case 1: lus[3] = lus[2] = lus[1] = lus[0]; break; 70 case 2: lus[2] = lus[0]; lus[3] = lus[1]; break; 71 case 3: lus[3] = lus[1]; break; 72 default: 73 } 74 75 ph.property(SVG12CSSConstants.CSS_MARGIN_TOP_PROPERTY, lus[0], imp); 76 ph.property(SVG12CSSConstants.CSS_MARGIN_RIGHT_PROPERTY, lus[1], imp); 77 ph.property(SVG12CSSConstants.CSS_MARGIN_BOTTOM_PROPERTY, lus[2], imp); 78 ph.property(SVG12CSSConstants.CSS_MARGIN_LEFT_PROPERTY, lus[3], imp); 79 } 80 } 81 | Popular Tags |