Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
     Licensed to the Apache Software Foundation (ASF) under one or more
     contributor license agreements.  See the NOTICE file distributed with
     this work for additional information regarding copyright ownership.
     The ASF licenses this file to You under the Apache License, Version 2.0
     (the "License"); you may not use this file except in compliance with
     the License.  You may obtain a copy of the License at
    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
 package org.apache.batik.svggen;
 import java.util.Map;
 import java.util.Set;
The DefaultStyleHandler class provides the default way to style an SVG Element.

Christophe Jolif
$Id: 479559 2006-11-27 09:46:16Z dvholten $
 public class DefaultStyleHandler implements StyleHandlerSVGConstants {
Static initializer for which attributes should be ignored on some elements. Map-key is a string like 'SVG_RECT_TAG' , map-entry is a set of strings, which denote font-attributes to ignore. The set is shared by all map-entries.
     static Map ignoreAttributes = new HashMap();
     static {
         // this is just used for read-only 'contains'-tests
         Set textAttributes = new HashSet( );

Sets the style described by styleMap on the given element. That is sets the xml attributes with their styled value.

element the SVG Element to be styled.
styleMap the Map containing pairs of style property names, style values.
     public void setStyle(Element elementMap styleMap,
                          SVGGeneratorContext generatorContext) {
         String tagName = element.getTagName();
         Iterator iter = styleMap.keySet().iterator();
         while (iter.hasNext()) {
             String styleName = (String);
             if (element.getAttributeNS(nullstyleName).length() == 0){
                 if (appliesTo(styleNametagName)) {

Controls whether or not a given attribute applies to a particular element.
     protected boolean appliesTo(String styleNameString tagName) {
         Set s = (Set).get(tagName);
         if (s == null) {
             return true;
         } else {
             return !s.contains(styleName);
New to GrepCode? Check out our FAQ X