Package org.apache.batik.gvt.renderer

Source Code of org.apache.batik.gvt.renderer.StaticRendererFactory

/*****************************************************************************
* Copyright (C) The Apache Software Foundation. All rights reserved.        *
* ------------------------------------------------------------------------- *
* This software is published under the terms of the Apache Software License *
* version 1.1, a copy of which has been included with this distribution in  *
* the LICENSE file.                                                         *
*****************************************************************************/

package org.apache.batik.gvt.renderer;

import java.awt.RenderingHints;
import java.awt.geom.AffineTransform;
import java.awt.font.FontRenderContext;

import org.apache.batik.gvt.GraphicsNodeRenderContext;
import org.apache.batik.gvt.TextPainter;
import org.apache.batik.gvt.filter.GraphicsNodeRableFactory;

import org.apache.batik.gvt.renderer.Renderer;
import org.apache.batik.gvt.renderer.RendererFactory;

import org.apache.batik.gvt.filter.ConcreteGraphicsNodeRableFactory;

/**
* This class is a factory for StaticRenderers.
*
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
* @version $Id: StaticRendererFactory.java,v 1.3 2001/03/05 22:57:45 vhardy Exp $
*/
public class StaticRendererFactory implements ImageRendererFactory {

    private GraphicsNodeRenderContext nodeRenderContext = null;

    /**
     * Creates a new renderer.
     */
    public Renderer createRenderer() {
        return createImageRenderer();
    }

    /**
     * Creates a new renderer
     */
    public ImageRenderer createImageRenderer(){
        return new StaticRenderer(getRenderContext());
    }

    /**
     * @return a GraphicsNodeRenderContext suitable for use
     * with this factory's Renderers.
     */
    public GraphicsNodeRenderContext getRenderContext() {
        if (nodeRenderContext == null) {
            RenderingHints hints = new RenderingHints(null);
            hints.put(RenderingHints.KEY_ANTIALIASING,
                  RenderingHints.VALUE_ANTIALIAS_ON);

            hints.put(RenderingHints.KEY_INTERPOLATION,
                  RenderingHints.VALUE_INTERPOLATION_BILINEAR);

            FontRenderContext fontRenderContext =
                new FontRenderContext(new AffineTransform(), true, true);

            TextPainter textPainter = new StrokingTextPainter();

            GraphicsNodeRableFactory gnrFactory =
                new ConcreteGraphicsNodeRableFactory();

            nodeRenderContext =
                new GraphicsNodeRenderContext(new AffineTransform(),
                                          null,
                                          hints,
                                          fontRenderContext,
                                          textPainter,
                                          gnrFactory);
            }

        return nodeRenderContext;
    }

}
TOP

Related Classes of org.apache.batik.gvt.renderer.StaticRendererFactory

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.