source: josm/trunk/src/com/kitfox/svg/xml/StyleSheet.java@ 14082

Last change on this file since 14082 was 11525, checked in by Don-vip, 8 years ago

see #14319 - update to latest version of svgSalamander (2017-01-07, patched)

  • Property svn:eol-style set to native
File size: 1.6 KB
Line 
1/*
2 * To change this template, choose Tools | Templates
3 * and open the template in the editor.
4 */
5package com.kitfox.svg.xml;
6
7import com.kitfox.svg.SVGConst;
8import java.util.HashMap;
9import java.util.logging.Level;
10import java.util.logging.Logger;
11
12/**
13 *
14 * @author kitfox
15 */
16public class StyleSheet
17{
18 HashMap<StyleSheetRule, String> ruleMap = new HashMap<>();
19
20 public static StyleSheet parseSheet(String src)
21 {
22 //Implement CS parser later
23 Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING,
24 "CSS parser not implemented yet");
25 return null;
26 }
27
28 public void addStyleRule(StyleSheetRule rule, String value)
29 {
30 ruleMap.put(rule, value);
31 }
32
33 public boolean getStyle(StyleAttribute attrib, String tagName, String cssClass)
34 {
35 StyleSheetRule rule = new StyleSheetRule(attrib.getName(), tagName, cssClass);
36 String value = (String)ruleMap.get(rule);
37
38 if (value != null)
39 {
40 attrib.setStringValue(value);
41 return true;
42 }
43
44 //Try again using just class name
45 rule = new StyleSheetRule(attrib.getName(), null, cssClass);
46 value = (String)ruleMap.get(rule);
47
48 if (value != null)
49 {
50 attrib.setStringValue(value);
51 return true;
52 }
53
54 //Try again using just tag name
55 rule = new StyleSheetRule(attrib.getName(), tagName, null);
56 value = (String)ruleMap.get(rule);
57
58 if (value != null)
59 {
60 attrib.setStringValue(value);
61 return true;
62 }
63
64 return false;
65 }
66
67}
Note: See TracBrowser for help on using the repository browser.