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

Last change on this file since 6002 was 6002, checked in by Don-vip, 11 years ago

fix #8742 - update svgsalamander to release 0.1.18+patch (fix bug SVGSALAMANDER-26) -> allow to open more SVG files

File size: 1.7 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 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.