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;
 
 import java.awt.Image;
 
 
This class provides a default implementation of the ImageHandler interface simply puts a place holder in the xlink:href attribute and sets the width and height of the element.

Author(s):
Vincent Hardy
Version:
$Id: DefaultImageHandler.java 501495 2007-01-30 18:00:36Z dvholten $
See also:
SVGGraphics2D
 
 public class DefaultImageHandler
     implements ImageHandlerErrorConstantsXMLConstants {

    
Build a DefaultImageHandler.
 
     public DefaultImageHandler() {
     }

    
The handler should set the xlink:href tag and the width and height attributes.
 
     public void handleImage(Image imageElement imageElement,
                             SVGGeneratorContext generatorContext) {
         //
         // First, set the image width and height
         //
         imageElement.setAttributeNS(null,  String.valueOfimage.getWidthnull ) ) );
         imageElement.setAttributeNS(null, String.valueOfimage.getHeightnull ) ) );
 
         //
         // Now, set the href
         //
         try {
             handleHREF(imageimageElementgeneratorContext);
         } catch (SVGGraphics2DIOException e) {
             try {
                 generatorContext.errorHandler.handleError(e);
             } catch (SVGGraphics2DIOException io) {
                 // we need a runtime exception because
                 // java.awt.Graphics2D method doesn't throw exceptions..
                 throw new SVGGraphics2DRuntimeException(io);
             }
         }
     }

    
The handler should set the xlink:href tag and the width and height attributes.
 
     public void handleImage(RenderedImage imageElement imageElement,
                             SVGGeneratorContext generatorContext) {
         //
         // First, set the image width and height
         //
         imageElement.setAttributeNS(null,  String.valueOfimage.getWidth() ) );
         imageElement.setAttributeNS(null, String.valueOfimage.getHeight() ) );
 
         //
         // Now, set the href
         //
         try {
             handleHREF(imageimageElementgeneratorContext);
         } catch (SVGGraphics2DIOException e) {
             try {
                 generatorContext.errorHandler.handleError(e);
             } catch (SVGGraphics2DIOException io) {
                 // we need a runtime exception because
                 // java.awt.Graphics2D method doesn't throw exceptions..
                 throw new SVGGraphics2DRuntimeException(io);
             }
        }
    }

    
The handler should set the xlink:href tag and the width and height attributes.
    public void handleImage(RenderableImage imageElement imageElement,
                            SVGGeneratorContext generatorContext) {
        //
        // First, set the image width and height
        //
        imageElement.setAttributeNS(null,  String.valueOfimage.getWidth() ) );
        imageElement.setAttributeNS(null, String.valueOfimage.getHeight() ) );
        //
        // Now, set the href
        //
        try {
            handleHREF(imageimageElementgeneratorContext);
        } catch (SVGGraphics2DIOException e) {
            try {
                generatorContext.errorHandler.handleError(e);
            } catch (SVGGraphics2DIOException io) {
                // we need a runtime exception because
                // java.awt.Graphics2D method doesn't throw exceptions..
                throw new SVGGraphics2DRuntimeException(io);
            }
        }
    }

    
This template method should set the xlink:href attribute on the input Element parameter
    protected void handleHREF(Image imageElement imageElement,
                              SVGGeneratorContext generatorContext)
        throws SVGGraphics2DIOException {
        // Simply write a placeholder
        imageElement.setAttributeNS(,
                                    image.toString());
    }

    
This template method should set the xlink:href attribute on the input Element parameter
    protected void handleHREF(RenderedImage imageElement imageElement,
                              SVGGeneratorContext generatorContext)
        throws SVGGraphics2DIOException {
        // Simply write a placeholder
        imageElement.setAttributeNS(,
                                    image.toString());
    }

    
This template method should set the xlink:href attribute on the input Element parameter
    protected void handleHREF(RenderableImage imageElement imageElement,
                              SVGGeneratorContext generatorContext)
        throws SVGGraphics2DIOException {
        // Simply write a placeholder
        imageElement.setAttributeNS(,
                                    image.toString());
    }
New to GrepCode? Check out our FAQ X