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
  
        http://www.apache.org/licenses/LICENSE-2.0
 
    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;
 
 
Utility class that converts a RenderingHints object into a set of SVG properties. Here is how individual hints are converted. + RENDERING -> sets all other hints to initial value. + FRACTIONAL_METRICS -> sets initial values for text-rendering and shape-rendering. + ALPHA_INTERPOLATION -> Not mapped + ANTIALIASING -> shape-rendering and text-rendering + COLOR_RENDERING -> color-rendering + DITHERING -> not mapped + INTERPOLATION -> image-rendering + TEXT_ANTIALIASING -> text-rendering

Author(s):
Vincent Hardy
Version:
$Id: SVGRenderingHints.java 475477 2006-11-15 22:44:28Z cam $
 
 public class SVGRenderingHints extends AbstractSVGConverter{
    

Parameters:
generatorContext used by converter to handle precision or to create elements.
 
     public SVGRenderingHints(SVGGeneratorContext generatorContext) {
         super(generatorContext);
     }

    
Converts part or all of the input GraphicContext into a set of attribute/value pairs and related definitions

Parameters:
gc GraphicContext to be converted
Returns:
descriptor of the attributes required to represent some or all of the GraphicContext state, along with the related definitions
See also:
SVGDescriptor
 
     public SVGDescriptor toSVG(GraphicContext gc){
         return toSVG(gc.getRenderingHints());
     }

    

Parameters:
hints RenderingHints object which should be converted to a set of SVG attributes.
Returns:
map Map of attribute values that describe the hints
 
     public static SVGHintsDescriptor toSVG(RenderingHints hints){
         // no hints should mean default
         String colorInterpolation = ;
         String colorRendering = ;
         String textRendering = ;
         String shapeRendering = ;
         String imageRendering = ;
 
         //
         // RENDERING
         //
         if(hints != null){
             Object rendering = hints.get(.);
             if(rendering == .){
                 colorInterpolation = ;
                 colorRendering = ;
                 textRendering = ;
                 shapeRendering = ;
                 imageRendering = ;
             }
             else if(rendering == .){
                 colorInterpolation = ;
                 colorRendering = ;
                 textRendering = ;
                 shapeRendering = ;
                 imageRendering = ;
             }
             else if(rendering == .){
                 colorInterpolation = ;
                colorRendering = ;
                textRendering = ;
                shapeRendering = ;
                imageRendering = ;
            }
            //
            // Fractional Metrics
            //
            Object fractionalMetrics = hints.get(.);
            if(fractionalMetrics == .){
                textRendering = ;
                shapeRendering = ;
            }
            else if(fractionalMetrics == .){
                textRendering = ;
                shapeRendering = ;
            }
            else if(fractionalMetrics == .){
                textRendering = ;
                shapeRendering = ;
            }
            //
            // Antialiasing
            //
            Object antialiasing = hints.get(.);
            if(antialiasing == .){
                textRendering = ;
                shapeRendering = ;
            }
            else if(antialiasing == .){
                textRendering = ;
                shapeRendering = ;
            }
            else if(antialiasing == .){
                textRendering = ;
                shapeRendering = ;
            }
            //
            // Text Antialiasing
            //
            Object textAntialiasing = hints.get(.);
            if(textAntialiasing == .)
                textRendering = ;
            else if(textAntialiasing == .)
                textRendering = ;
            else if(textAntialiasing == .)
                textRendering = ;
            //
            // Color Rendering
            //
            Object colorRenderingHint = hints.get(.);
            if(colorRenderingHint == .)
                colorRendering = ;
            else if(colorRenderingHint == .)
                colorRendering = ;
            else if(colorRenderingHint == .)
                colorRendering = ;
            //
            // Interpolation
            //
            Object interpolation = hints.get(.);
            if(interpolation == .)
                imageRendering = ;
            else if(interpolation == .
                    ||
                    interpolation == .)
                imageRendering = ;
        } // if(hints != null)
        return new SVGHintsDescriptor(colorInterpolation,
                                      colorRendering,
                                      textRendering,
                                      shapeRendering,
                                      imageRendering);
    }
New to GrepCode? Check out our FAQ X