From 6776ed9f1a81e517139d85eb6d2e28911fd0fc35 Mon Sep 17 00:00:00 2001 From: kitfox Date: Tue, 19 Mar 2013 05:20:37 +0000 Subject: Adding support for style sheets. git-svn-id: https://svn.java.net/svn/svgsalamander~svn/trunk/svg-core@153 7dc7fa77-23fb-e6ad-8e2e-c86bd48ed22b --- src/main/java/com/kitfox/svg/xml/StyleSheet.java | 56 ++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 src/main/java/com/kitfox/svg/xml/StyleSheet.java (limited to 'src/main/java/com/kitfox/svg/xml/StyleSheet.java') diff --git a/src/main/java/com/kitfox/svg/xml/StyleSheet.java b/src/main/java/com/kitfox/svg/xml/StyleSheet.java new file mode 100644 index 0000000..da3db2e --- /dev/null +++ b/src/main/java/com/kitfox/svg/xml/StyleSheet.java @@ -0,0 +1,56 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.kitfox.svg.xml; + +import java.util.HashMap; + +/** + * + * @author kitfox + */ +public class StyleSheet +{ + HashMap ruleMap = new HashMap(); + + public void addStyleRule(StyleSheetRule rule, String value) + { + ruleMap.put(rule, value); + } + + public boolean getStyle(StyleAttribute attrib, String tagName, String cssClass) + { + StyleSheetRule rule = new StyleSheetRule(attrib.getName(), tagName, cssClass); + String value = (String)ruleMap.get(rule); + + if (value != null) + { + attrib.setStringValue(value); + return true; + } + + //Try again using just class name + rule = new StyleSheetRule(attrib.getName(), null, cssClass); + value = (String)ruleMap.get(rule); + + if (value != null) + { + attrib.setStringValue(value); + return true; + } + + //Try again using just tag name + rule = new StyleSheetRule(attrib.getName(), tagName, null); + value = (String)ruleMap.get(rule); + + if (value != null) + { + attrib.setStringValue(value); + return true; + } + + return false; + } + +} -- cgit v1.2.3-55-g7522