001/* 002 * To change this template, choose Tools | Templates 003 * and open the template in the editor. 004 */ 005package com.kitfox.svg.xml; 006 007import com.kitfox.svg.SVGConst; 008import java.util.HashMap; 009import java.util.logging.Level; 010import java.util.logging.Logger; 011 012/** 013 * 014 * @author kitfox 015 */ 016public class StyleSheet 017{ 018 HashMap ruleMap = new HashMap(); 019 020 public static StyleSheet parseSheet(String src) 021 { 022 //Implement CS parser later 023 Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, 024 "CSS parser not implemented yet"); 025 return null; 026 } 027 028 public void addStyleRule(StyleSheetRule rule, String value) 029 { 030 ruleMap.put(rule, value); 031 } 032 033 public boolean getStyle(StyleAttribute attrib, String tagName, String cssClass) 034 { 035 StyleSheetRule rule = new StyleSheetRule(attrib.getName(), tagName, cssClass); 036 String value = (String)ruleMap.get(rule); 037 038 if (value != null) 039 { 040 attrib.setStringValue(value); 041 return true; 042 } 043 044 //Try again using just class name 045 rule = new StyleSheetRule(attrib.getName(), null, cssClass); 046 value = (String)ruleMap.get(rule); 047 048 if (value != null) 049 { 050 attrib.setStringValue(value); 051 return true; 052 } 053 054 //Try again using just tag name 055 rule = new StyleSheetRule(attrib.getName(), tagName, null); 056 value = (String)ruleMap.get(rule); 057 058 if (value != null) 059 { 060 attrib.setStringValue(value); 061 return true; 062 } 063 064 return false; 065 } 066 067}