org.apache.batik.svggen_1.6.0.v201011041432

16:40:55.244 INFO  jd.cli.Main - Decompiling org.apache.batik.svggen_1.6.0.v201011041432.jar
package org.apache.batik.svggen;

import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
import java.awt.image.RenderedImage;
import java.awt.image.renderable.RenderableImage;
import java.io.File;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URL;
import org.w3c.dom.Element;

public abstract class AbstractImageHandlerEncoder
  extends DefaultImageHandler
{
  private static final AffineTransform IDENTITY = new AffineTransform();
  private String imageDir = "";
  private String urlRoot = "";
  private static Method createGraphics = null;
  private static boolean initDone = false;
  private static final Class[] paramc = { BufferedImage.class };
  private static Object[] paramo = null;
  
  private static Graphics2D createGraphics(BufferedImage paramBufferedImage)
  {
    if (!initDone) {
      try
      {
        Class localClass = Class.forName("org.apache.batik.ext.awt.image.GraphicsUtil");
        createGraphics = localClass.getMethod("createGraphics", paramc);
        paramo = new Object[1];
      }
      catch (ThreadDeath localThreadDeath)
      {
        throw localThreadDeath;
      }
      catch (Throwable localThrowable) {}finally
      {
        initDone = true;
      }
    }
    if (createGraphics == null) {
      return paramBufferedImage.createGraphics();
    }
    paramo[0] = paramBufferedImage;
    Graphics2D localGraphics2D = null;
    try
    {
      localGraphics2D = (Graphics2D)createGraphics.invoke(null, paramo);
    }
    catch (Exception localException) {}
    return localGraphics2D;
  }
  
  public AbstractImageHandlerEncoder(String paramString1, String paramString2)
    throws SVGGraphics2DIOException
  {
    if (paramString1 == null) {
      throw new SVGGraphics2DRuntimeException("imageDir should not be null");
    }
    File localFile = new File(paramString1);
    if (!localFile.exists()) {
      throw new SVGGraphics2DRuntimeException("imageDir does not exist");
    }
    imageDir = paramString1;
    if (paramString2 != null) {
      urlRoot = paramString2;
    } else {
      try
      {
        urlRoot = localFile.toURL().toString();
      }
      catch (MalformedURLException localMalformedURLException)
      {
        throw new SVGGraphics2DIOException("cannot convert imageDir to a URL value : " + localMalformedURLException.getMessage(), localMalformedURLException);
      }
    }
  }
  
  protected void handleHREF(Image paramImage, Element paramElement, SVGGeneratorContext paramSVGGeneratorContext)
    throws SVGGraphics2DIOException
  {
    Dimension localDimension = new Dimension(paramImage.getWidth(null), paramImage.getHeight(null));
    BufferedImage localBufferedImage = buildBufferedImage(localDimension);
    Graphics2D localGraphics2D = createGraphics(localBufferedImage);
    localGraphics2D.drawImage(paramImage, 0, 0, null);
    localGraphics2D.dispose();
    saveBufferedImageToFile(paramElement, localBufferedImage, paramSVGGeneratorContext);
  }
  
  protected void handleHREF(RenderedImage paramRenderedImage, Element paramElement, SVGGeneratorContext paramSVGGeneratorContext)
    throws SVGGraphics2DIOException
  {
    Dimension localDimension = new Dimension(paramRenderedImage.getWidth(), paramRenderedImage.getHeight());
    BufferedImage localBufferedImage = buildBufferedImage(localDimension);
    Graphics2D localGraphics2D = createGraphics(localBufferedImage);
    localGraphics2D.drawRenderedImage(paramRenderedImage, IDENTITY);
    localGraphics2D.dispose();
    saveBufferedImageToFile(paramElement, localBufferedImage, paramSVGGeneratorContext);
  }
  
  protected void handleHREF(RenderableImage paramRenderableImage, Element paramElement, SVGGeneratorContext paramSVGGeneratorContext)
    throws SVGGraphics2DIOException
  {
    Dimension localDimension = new Dimension((int)Math.ceil(paramRenderableImage.getWidth()), (int)Math.ceil(paramRenderableImage.getHeight()));
    BufferedImage localBufferedImage = buildBufferedImage(localDimension);
    Graphics2D localGraphics2D = createGraphics(localBufferedImage);
    localGraphics2D.drawRenderableImage(paramRenderableImage, IDENTITY);
    localGraphics2D.dispose();
    saveBufferedImageToFile(paramElement, localBufferedImage, paramSVGGeneratorContext);
  }
  
  private void saveBufferedImageToFile(Element paramElement, BufferedImage paramBufferedImage, SVGGeneratorContext paramSVGGeneratorContext)
    throws SVGGraphics2DIOException
  {
    if (paramSVGGeneratorContext == null) {
      throw new SVGGraphics2DRuntimeException("generatorContext should not be null");
    }
    File localFile = null;
    while (localFile == null)
    {
      String str = idGenerator.generateID(getPrefix());
      localFile = new File(imageDir, str + getSuffix());
      if (localFile.exists()) {
        localFile = null;
      }
    }
    encodeImage(paramBufferedImage, localFile);
    paramElement.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:href", urlRoot + "/" + localFile.getName());
  }
  
  public abstract String getSuffix();
  
  public abstract String getPrefix();
  
  public abstract void encodeImage(BufferedImage paramBufferedImage, File paramFile)
    throws SVGGraphics2DIOException;
  
  public abstract BufferedImage buildBufferedImage(Dimension paramDimension);
}

/* Location:
 * Qualified Name:     org.apache.batik.svggen.AbstractImageHandlerEncoder
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.batik.svggen;

import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import org.apache.batik.ext.awt.g2d.GraphicContext;

public abstract class AbstractSVGConverter
  implements SVGConverter, ErrorConstants
{
  protected SVGGeneratorContext generatorContext;
  protected Map descMap = new HashMap();
  protected List defSet = new LinkedList();
  
  public AbstractSVGConverter(SVGGeneratorContext paramSVGGeneratorContext)
  {
    if (paramSVGGeneratorContext == null) {
      throw new SVGGraphics2DRuntimeException("generatorContext should not be null");
    }
    generatorContext = paramSVGGeneratorContext;
  }
  
  public List getDefinitionSet()
  {
    return defSet;
  }
  
  public final String doubleString(double paramDouble)
  {
    return generatorContext.doubleString(paramDouble);
  }
  
  public abstract SVGDescriptor toSVG(GraphicContext paramGraphicContext);
}

/* Location:
 * Qualified Name:     org.apache.batik.svggen.AbstractSVGConverter
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.batik.svggen;

import java.awt.Rectangle;
import java.awt.image.BufferedImageOp;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

public abstract class AbstractSVGFilterConverter
  implements SVGFilterConverter, ErrorConstants
{
  protected SVGGeneratorContext generatorContext;
  protected Map descMap = new HashMap();
  protected List defSet = new LinkedList();
  
  public AbstractSVGFilterConverter(SVGGeneratorContext paramSVGGeneratorContext)
  {
    if (paramSVGGeneratorContext == null) {
      throw new SVGGraphics2DRuntimeException("generatorContext should not be null");
    }
    generatorContext = paramSVGGeneratorContext;
  }
  
  public List getDefinitionSet()
  {
    return defSet;
  }
  
  public final String doubleString(double paramDouble)
  {
    return generatorContext.doubleString(paramDouble);
  }
  
  public abstract SVGFilterDescriptor toSVG(BufferedImageOp paramBufferedImageOp, Rectangle paramRectangle);
}

/* Location:
 * Qualified Name:     org.apache.batik.svggen.AbstractSVGFilterConverter
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.batik.svggen;

public abstract interface CachedImageHandler
  extends GenericImageHandler
{
  public abstract ImageCacher getImageCacher();
}

/* Location:
 * Qualified Name:     org.apache.batik.svggen.CachedImageHandler
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.batik.svggen;

import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.OutputStream;
import org.apache.batik.ext.awt.image.codec.ImageEncoder;
import org.apache.batik.ext.awt.image.codec.PNGImageEncoder;
import org.apache.batik.util.Base64EncoderStream;
import org.w3c.dom.Document;
import org.w3c.dom.Element;

public class CachedImageHandlerBase64Encoder
  extends DefaultCachedImageHandler
{
  public CachedImageHandlerBase64Encoder()
  {
    setImageCacher(new ImageCacher.Embedded());
  }
  
  public Element createElement(SVGGeneratorContext paramSVGGeneratorContext)
  {
    Element localElement = paramSVGGeneratorContext.getDOMFactory().createElementNS("http://www.w3.org/2000/svg", "use");
    return localElement;
  }
  
  public String getRefPrefix()
  {
    return "";
  }
  
  protected AffineTransform handleTransform(Element paramElement, double paramDouble1, double paramDouble2, double paramDouble3, double paramDouble4, double paramDouble5, double paramDouble6, SVGGeneratorContext paramSVGGeneratorContext)
  {
    AffineTransform localAffineTransform = new AffineTransform();
    double d1 = paramDouble5 / paramDouble3;
    double d2 = paramDouble6 / paramDouble4;
    localAffineTransform.translate(paramDouble1, paramDouble2);
    if ((d1 != 1.0D) || (d2 != 1.0D)) {
      localAffineTransform.scale(d1, d2);
    }
    if (!localAffineTransform.isIdentity()) {
      return localAffineTransform;
    }
    return null;
  }
  
  public void encodeImage(BufferedImage paramBufferedImage, OutputStream paramOutputStream)
    throws IOException
  {
    Base64EncoderStream localBase64EncoderStream = new Base64EncoderStream(paramOutputStream);
    PNGImageEncoder localPNGImageEncoder = new PNGImageEncoder(localBase64EncoderStream, null);
    localPNGImageEncoder.encode(paramBufferedImage);
    localBase64EncoderStream.close();
  }
  
  public int getBufferedImageType()
  {
    return 2;
  }
}

/* Location:
 * Qualified Name:     org.apache.batik.svggen.CachedImageHandlerBase64Encoder
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.batik.svggen;

import com.sun.image.codec.jpeg.JPEGCodec;
import com.sun.image.codec.jpeg.JPEGEncodeParam;
import com.sun.image.codec.jpeg.JPEGImageEncoder;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.OutputStream;

public class CachedImageHandlerJPEGEncoder
  extends DefaultCachedImageHandler
{
  public static final String CACHED_JPEG_PREFIX = "jpegImage";
  public static final String CACHED_JPEG_SUFFIX = ".jpg";
  protected String refPrefix = "";
  
  public CachedImageHandlerJPEGEncoder(String paramString1, String paramString2)
    throws SVGGraphics2DIOException
  {
    refPrefix = (paramString2 + "/");
    setImageCacher(new ImageCacher.External(paramString1, "jpegImage", ".jpg"));
  }
  
  public void encodeImage(BufferedImage paramBufferedImage, OutputStream paramOutputStream)
    throws IOException
  {
    JPEGImageEncoder localJPEGImageEncoder = JPEGCodec.createJPEGEncoder(paramOutputStream);
    JPEGEncodeParam localJPEGEncodeParam = localJPEGImageEncoder.getDefaultJPEGEncodeParam(paramBufferedImage);
    localJPEGEncodeParam.setQuality(1.0F, false);
    localJPEGImageEncoder.encode(paramBufferedImage, localJPEGEncodeParam);
  }
  
  public int getBufferedImageType()
  {
    return 1;
  }
  
  public String getRefPrefix()
  {
    return refPrefix;
  }
}

/* Location:
 * Qualified Name:     org.apache.batik.svggen.CachedImageHandlerJPEGEncoder
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.batik.svggen;

import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.OutputStream;
import org.apache.batik.ext.awt.image.codec.ImageEncoder;
import org.apache.batik.ext.awt.image.codec.PNGImageEncoder;

public class CachedImageHandlerPNGEncoder
  extends DefaultCachedImageHandler
{
  public static final String CACHED_PNG_PREFIX = "pngImage";
  public static final String CACHED_PNG_SUFFIX = ".png";
  protected String refPrefix = "";
  
  public CachedImageHandlerPNGEncoder(String paramString1, String paramString2)
    throws SVGGraphics2DIOException
  {
    refPrefix = (paramString2 + "/");
    setImageCacher(new ImageCacher.External(paramString1, "pngImage", ".png"));
  }
  
  public void encodeImage(BufferedImage paramBufferedImage, OutputStream paramOutputStream)
    throws IOException
  {
    PNGImageEncoder localPNGImageEncoder = new PNGImageEncoder(paramOutputStream, null);
    localPNGImageEncoder.encode(paramBufferedImage);
  }
  
  public int getBufferedImageType()
  {
    return 2;
  }
  
  public String getRefPrefix()
  {
    return refPrefix;
  }
}

/* Location:
 * Qualified Name:     org.apache.batik.svggen.CachedImageHandlerPNGEncoder
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.batik.svggen;

import java.awt.geom.GeneralPath;

class ClipKey
{
  int hashCodeValue = 0;
  
  public ClipKey(GeneralPath paramGeneralPath, SVGGeneratorContext paramSVGGeneratorContext)
  {
    String str = SVGPath.toSVGPathData(paramGeneralPath, paramSVGGeneratorContext);
    hashCodeValue = str.hashCode();
  }
  
  public int hashCode()
  {
    return hashCodeValue;
  }
  
  public boolean equals(Object paramObject)
  {
    boolean bool = false;
    if ((paramObject != null) && ((paramObject instanceof ClipKey))) {
      bool = hashCodeValue == hashCodeValue;
    }
    return bool;
  }
}

/* Location:
 * Qualified Name:     org.apache.batik.svggen.ClipKey
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.batik.svggen;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import org.apache.batik.ext.awt.g2d.GraphicContext;
import org.apache.batik.ext.awt.g2d.TransformStackElement;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;

public class DOMGroupManager
  implements SVGSyntax, ErrorConstants
{
  public static final short DRAW = 1;
  public static final short FILL = 16;
  protected GraphicContext gc;
  protected DOMTreeManager domTreeManager;
  protected SVGGraphicContext groupGC;
  protected Element currentGroup;
  
  public DOMGroupManager(GraphicContext paramGraphicContext, DOMTreeManager paramDOMTreeManager)
  {
    if (paramGraphicContext == null) {
      throw new SVGGraphics2DRuntimeException("gc should not be null");
    }
    if (paramDOMTreeManager == null) {
      throw new SVGGraphics2DRuntimeException("domTreeManager should not be null");
    }
    gc = paramGraphicContext;
    domTreeManager = paramDOMTreeManager;
    recycleCurrentGroup();
    groupGC = gcConverter.toSVG(paramGraphicContext);
  }
  
  void recycleCurrentGroup()
  {
    currentGroup = domTreeManager.getDOMFactory().createElementNS("http://www.w3.org/2000/svg", "g");
  }
  
  public void addElement(Element paramElement)
  {
    addElement(paramElement, (short)17);
  }
  
  public void addElement(Element paramElement, short paramShort)
  {
    SVGGraphicContext localSVGGraphicContext1;
    if (!currentGroup.hasChildNodes())
    {
      currentGroup.appendChild(paramElement);
      groupGC = domTreeManager.gcConverter.toSVG(gc);
      localSVGGraphicContext1 = processDeltaGC(groupGC, domTreeManager.defaultGC);
      domTreeManager.getStyleHandler().setStyle(currentGroup, localSVGGraphicContext1.getGroupContext(), domTreeManager.getGeneratorContext());
      if ((paramShort & 0x1) == 0) {
        localSVGGraphicContext1.getGraphicElementContext().put("stroke", "none");
      }
      if ((paramShort & 0x10) == 0) {
        localSVGGraphicContext1.getGraphicElementContext().put("fill", "none");
      }
      domTreeManager.getStyleHandler().setStyle(paramElement, localSVGGraphicContext1.getGraphicElementContext(), domTreeManager.getGeneratorContext());
      setTransform(currentGroup, localSVGGraphicContext1.getTransformStack());
      domTreeManager.appendGroup(currentGroup, this);
    }
    else if (gc.isTransformStackValid())
    {
      localSVGGraphicContext1 = domTreeManager.gcConverter.toSVG(gc);
      SVGGraphicContext localSVGGraphicContext2 = processDeltaGC(localSVGGraphicContext1, groupGC);
      trimContextForElement(localSVGGraphicContext2, paramElement);
      if (countOverrides(localSVGGraphicContext2) <= domTreeManager.maxGCOverrides)
      {
        currentGroup.appendChild(paramElement);
        if ((paramShort & 0x1) == 0) {
          localSVGGraphicContext2.getContext().put("stroke", "none");
        }
        if ((paramShort & 0x10) == 0) {
          localSVGGraphicContext2.getContext().put("fill", "none");
        }
        domTreeManager.getStyleHandler().setStyle(paramElement, localSVGGraphicContext2.getContext(), domTreeManager.getGeneratorContext());
        setTransform(paramElement, localSVGGraphicContext2.getTransformStack());
      }
      else
      {
        currentGroup = domTreeManager.getDOMFactory().createElementNS("http://www.w3.org/2000/svg", "g");
        addElement(paramElement, paramShort);
      }
    }
    else
    {
      currentGroup = domTreeManager.getDOMFactory().createElementNS("http://www.w3.org/2000/svg", "g");
      gc.validateTransformStack();
      addElement(paramElement, paramShort);
    }
  }
  
  protected int countOverrides(SVGGraphicContext paramSVGGraphicContext)
  {
    return paramSVGGraphicContext.getGroupContext().size();
  }
  
  protected void trimContextForElement(SVGGraphicContext paramSVGGraphicContext, Element paramElement)
  {
    String str1 = paramElement.getTagName();
    Map localMap = paramSVGGraphicContext.getGroupContext();
    if (str1 != null)
    {
      Iterator localIterator = localMap.keySet().iterator();
      while (localIterator.hasNext())
      {
        String str2 = (String)localIterator.next();
        SVGAttribute localSVGAttribute = SVGAttributeMap.get(str2);
        if ((localSVGAttribute != null) && (!localSVGAttribute.appliesTo(str1))) {
          localMap.remove(str2);
        }
      }
    }
  }
  
  protected void setTransform(Element paramElement, TransformStackElement[] paramArrayOfTransformStackElement)
  {
    String str = domTreeManager.gcConverter.toSVG(paramArrayOfTransformStackElement).trim();
    if (str.length() > 0) {
      paramElement.setAttributeNS(null, "transform", str);
    }
  }
  
  protected SVGGraphicContext processDeltaGC(SVGGraphicContext paramSVGGraphicContext1, SVGGraphicContext paramSVGGraphicContext2)
  {
    Map localMap1 = processDeltaMap(paramSVGGraphicContext1.getGroupContext(), paramSVGGraphicContext2.getGroupContext());
    Map localMap2 = paramSVGGraphicContext1.getGraphicElementContext();
    TransformStackElement[] arrayOfTransformStackElement1 = paramSVGGraphicContext1.getTransformStack();
    TransformStackElement[] arrayOfTransformStackElement2 = paramSVGGraphicContext2.getTransformStack();
    int i = arrayOfTransformStackElement1.length - arrayOfTransformStackElement2.length;
    TransformStackElement[] arrayOfTransformStackElement3 = new TransformStackElement[i];
    System.arraycopy(arrayOfTransformStackElement1, arrayOfTransformStackElement2.length, arrayOfTransformStackElement3, 0, i);
    SVGGraphicContext localSVGGraphicContext = new SVGGraphicContext(localMap1, localMap2, arrayOfTransformStackElement3);
    return localSVGGraphicContext;
  }
  
  protected Map processDeltaMap(Map paramMap1, Map paramMap2)
  {
    HashMap localHashMap = new HashMap();
    Iterator localIterator = paramMap1.keySet().iterator();
    while (localIterator.hasNext())
    {
      String str1 = (String)localIterator.next();
      String str2 = (String)paramMap1.get(str1);
      String str3 = (String)paramMap2.get(str1);
      if (!str2.equals(str3)) {
        localHashMap.put(str1, str2);
      }
    }
    return localHashMap;
  }
}

/* Location:
 * Qualified Name:     org.apache.batik.svggen.DOMGroupManager
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.batik.svggen;

import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Vector;
import org.apache.batik.ext.awt.g2d.GraphicContext;
import org.w3c.dom.Comment;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

public class DOMTreeManager
  implements SVGSyntax, ErrorConstants
{
  int maxGCOverrides;
  protected Vector groupManagers = new Vector();
  protected List genericDefSet = new LinkedList();
  SVGGraphicContext defaultGC;
  protected Element topLevelGroup;
  SVGGraphicContextConverter gcConverter;
  protected SVGGeneratorContext generatorContext;
  protected SVGBufferedImageOp filterConverter;
  protected List otherDefs;
  
  public DOMTreeManager(GraphicContext paramGraphicContext, SVGGeneratorContext paramSVGGeneratorContext, int paramInt)
  {
    if (paramGraphicContext == null) {
      throw new SVGGraphics2DRuntimeException("gc should not be null");
    }
    if (paramInt <= 0) {
      throw new SVGGraphics2DRuntimeException("maxGcOverrides should be greater than zero");
    }
    if (paramSVGGeneratorContext == null) {
      throw new SVGGraphics2DRuntimeException("generatorContext should not be null");
    }
    generatorContext = paramSVGGeneratorContext;
    maxGCOverrides = paramInt;
    recycleTopLevelGroup();
    defaultGC = gcConverter.toSVG(paramGraphicContext);
  }
  
  public void addGroupManager(DOMGroupManager paramDOMGroupManager)
  {
    if (paramDOMGroupManager != null) {
      groupManagers.addElement(paramDOMGroupManager);
    }
  }
  
  public void removeGroupManager(DOMGroupManager paramDOMGroupManager)
  {
    if (paramDOMGroupManager != null) {
      groupManagers.removeElement(paramDOMGroupManager);
    }
  }
  
  public void appendGroup(Element paramElement, DOMGroupManager paramDOMGroupManager)
  {
    topLevelGroup.appendChild(paramElement);
    int i = groupManagers.size();
    for (int j = 0; j < i; j++)
    {
      DOMGroupManager localDOMGroupManager = (DOMGroupManager)groupManagers.elementAt(j);
      if (localDOMGroupManager != paramDOMGroupManager) {
        localDOMGroupManager.recycleCurrentGroup();
      }
    }
  }
  
  protected void recycleTopLevelGroup()
  {
    recycleTopLevelGroup(true);
  }
  
  protected void recycleTopLevelGroup(boolean paramBoolean)
  {
    int i = groupManagers.size();
    for (int j = 0; j < i; j++)
    {
      DOMGroupManager localDOMGroupManager = (DOMGroupManager)groupManagers.elementAt(j);
      localDOMGroupManager.recycleCurrentGroup();
    }
    topLevelGroup = generatorContext.domFactory.createElementNS("http://www.w3.org/2000/svg", "g");
    if (paramBoolean)
    {
      filterConverter = new SVGBufferedImageOp(generatorContext);
      gcConverter = new SVGGraphicContextConverter(generatorContext);
    }
  }
  
  public void setTopLevelGroup(Element paramElement)
  {
    if (paramElement == null) {
      throw new SVGGraphics2DRuntimeException("topLevelGroup should not be null");
    }
    if (!"g".equalsIgnoreCase(paramElement.getTagName())) {
      throw new SVGGraphics2DRuntimeException("topLevelGroup should be a group <g>");
    }
    recycleTopLevelGroup(false);
    topLevelGroup = paramElement;
  }
  
  public Element getRoot()
  {
    return getRoot(null);
  }
  
  public Element getRoot(Element paramElement)
  {
    Element localElement = paramElement;
    if (localElement == null) {
      localElement = generatorContext.domFactory.createElementNS("http://www.w3.org/2000/svg", "svg");
    }
    if (gcConverter.getCompositeConverter().getAlphaCompositeConverter().requiresBackgroundAccess()) {
      localElement.setAttributeNS(null, "enable-background", "new");
    }
    if (generatorContext.generatorComment != null)
    {
      Comment localComment = generatorContext.domFactory.createComment(generatorContext.generatorComment);
      localElement.appendChild(localComment);
    }
    applyDefaultRenderingStyle(localElement);
    localElement.appendChild(getGenericDefinitions());
    localElement.appendChild(getTopLevelGroup());
    return localElement;
  }
  
  public void applyDefaultRenderingStyle(Element paramElement)
  {
    Map localMap = defaultGC.getGroupContext();
    generatorContext.styleHandler.setStyle(paramElement, localMap, generatorContext);
  }
  
  public Element getGenericDefinitions()
  {
    Element localElement = generatorContext.domFactory.createElementNS("http://www.w3.org/2000/svg", "defs");
    Iterator localIterator = genericDefSet.iterator();
    while (localIterator.hasNext()) {
      localElement.appendChild((Element)localIterator.next());
    }
    localElement.setAttributeNS(null, "id", "genericDefs");
    return localElement;
  }
  
  public ExtensionHandler getExtensionHandler()
  {
    return generatorContext.getExtensionHandler();
  }
  
  void setExtensionHandler(ExtensionHandler paramExtensionHandler)
  {
    generatorContext.setExtensionHandler(paramExtensionHandler);
  }
  
  public List getDefinitionSet()
  {
    List localList = gcConverter.getDefinitionSet();
    localList.removeAll(genericDefSet);
    localList.addAll(filterConverter.getDefinitionSet());
    if (otherDefs != null)
    {
      localList.addAll(otherDefs);
      otherDefs = null;
    }
    filterConverter = new SVGBufferedImageOp(generatorContext);
    gcConverter = new SVGGraphicContextConverter(generatorContext);
    return localList;
  }
  
  public void addOtherDef(Element paramElement)
  {
    if (otherDefs == null) {
      otherDefs = new LinkedList();
    }
    otherDefs.add(paramElement);
  }
  
  public Element getTopLevelGroup()
  {
    boolean bool = true;
    return getTopLevelGroup(bool);
  }
  
  public Element getTopLevelGroup(boolean paramBoolean)
  {
    Element localElement1 = topLevelGroup;
    if (paramBoolean)
    {
      List localList = getDefinitionSet();
      if (localList.size() > 0)
      {
        Element localElement2 = null;
        NodeList localNodeList = localElement1.getElementsByTagName("defs");
        if (localNodeList.getLength() > 0) {
          localElement2 = (Element)localNodeList.item(0);
        }
        if (localElement2 == null)
        {
          localElement2 = generatorContext.domFactory.createElementNS("http://www.w3.org/2000/svg", "defs");
          localElement2.setAttributeNS(null, "id", generatorContext.idGenerator.generateID("defs"));
          localElement1.insertBefore(localElement2, localElement1.getFirstChild());
        }
        Iterator localIterator = localList.iterator();
        while (localIterator.hasNext()) {
          localElement2.appendChild((Element)localIterator.next());
        }
      }
    }
    recycleTopLevelGroup(false);
    return localElement1;
  }
  
  public SVGBufferedImageOp getFilterConverter()
  {
    return filterConverter;
  }
  
  public SVGGraphicContextConverter getGraphicContextConverter()
  {
    return gcConverter;
  }
  
  SVGGeneratorContext getGeneratorContext()
  {
    return generatorContext;
  }
  
  Document getDOMFactory()
  {
    return generatorContext.domFactory;
  }
  
  StyleHandler getStyleHandler()
  {
    return generatorContext.styleHandler;
  }
}

/* Location:
 * Qualified Name:     org.apache.batik.svggen.DOMTreeManager
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.batik.svggen;

import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
import java.awt.image.RenderedImage;
import java.awt.image.renderable.RenderableImage;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.lang.reflect.Method;
import org.w3c.dom.Document;
import org.w3c.dom.Element;

public abstract class DefaultCachedImageHandler
  implements CachedImageHandler, SVGSyntax, ErrorConstants
{
  static final String XLINK_NAMESPACE_URI = "http://www.w3.org/1999/xlink";
  static final AffineTransform IDENTITY = new AffineTransform();
  private static Method createGraphics = null;
  private static boolean initDone = false;
  private static final Class[] paramc = { BufferedImage.class };
  private static Object[] paramo = null;
  protected ImageCacher imageCacher;
  
  public ImageCacher getImageCacher()
  {
    return imageCacher;
  }
  
  void setImageCacher(ImageCacher paramImageCacher)
  {
    if (paramImageCacher == null) {
      throw new IllegalArgumentException();
    }
    DOMTreeManager localDOMTreeManager = null;
    if (imageCacher != null) {
      localDOMTreeManager = imageCacher.getDOMTreeManager();
    }
    imageCacher = paramImageCacher;
    if (localDOMTreeManager != null) {
      imageCacher.setDOMTreeManager(localDOMTreeManager);
    }
  }
  
  public void setDOMTreeManager(DOMTreeManager paramDOMTreeManager)
  {
    imageCacher.setDOMTreeManager(paramDOMTreeManager);
  }
  
  private static Graphics2D createGraphics(BufferedImage paramBufferedImage)
  {
    if (!initDone) {
      try
      {
        Class localClass = Class.forName("org.apache.batik.ext.awt.image.GraphicsUtil");
        createGraphics = localClass.getMethod("createGraphics", paramc);
        paramo = new Object[1];
      }
      catch (Throwable localThrowable) {}finally
      {
        initDone = true;
      }
    }
    if (createGraphics == null) {
      return paramBufferedImage.createGraphics();
    }
    paramo[0] = paramBufferedImage;
    Graphics2D localGraphics2D = null;
    try
    {
      localGraphics2D = (Graphics2D)createGraphics.invoke(null, paramo);
    }
    catch (Exception localException) {}
    return localGraphics2D;
  }
  
  public Element createElement(SVGGeneratorContext paramSVGGeneratorContext)
  {
    Element localElement = paramSVGGeneratorContext.getDOMFactory().createElementNS("http://www.w3.org/2000/svg", "image");
    return localElement;
  }
  
  public AffineTransform handleImage(Image paramImage, Element paramElement, int paramInt1, int paramInt2, int paramInt3, int paramInt4, SVGGeneratorContext paramSVGGeneratorContext)
  {
    int i = paramImage.getWidth(null);
    int j = paramImage.getHeight(null);
    AffineTransform localAffineTransform = null;
    if ((i == 0) || (j == 0) || (paramInt3 == 0) || (paramInt4 == 0))
    {
      handleEmptyImage(paramElement);
    }
    else
    {
      try
      {
        handleHREF(paramImage, paramElement, paramSVGGeneratorContext);
      }
      catch (SVGGraphics2DIOException localSVGGraphics2DIOException1)
      {
        try
        {
          errorHandler.handleError(localSVGGraphics2DIOException1);
        }
        catch (SVGGraphics2DIOException localSVGGraphics2DIOException2)
        {
          throw new SVGGraphics2DRuntimeException(localSVGGraphics2DIOException2);
        }
      }
      localAffineTransform = handleTransform(paramElement, paramInt1, paramInt2, i, j, paramInt3, paramInt4, paramSVGGeneratorContext);
    }
    return localAffineTransform;
  }
  
  public AffineTransform handleImage(RenderedImage paramRenderedImage, Element paramElement, int paramInt1, int paramInt2, int paramInt3, int paramInt4, SVGGeneratorContext paramSVGGeneratorContext)
  {
    int i = paramRenderedImage.getWidth();
    int j = paramRenderedImage.getHeight();
    AffineTransform localAffineTransform = null;
    if ((i == 0) || (j == 0) || (paramInt3 == 0) || (paramInt4 == 0))
    {
      handleEmptyImage(paramElement);
    }
    else
    {
      try
      {
        handleHREF(paramRenderedImage, paramElement, paramSVGGeneratorContext);
      }
      catch (SVGGraphics2DIOException localSVGGraphics2DIOException1)
      {
        try
        {
          errorHandler.handleError(localSVGGraphics2DIOException1);
        }
        catch (SVGGraphics2DIOException localSVGGraphics2DIOException2)
        {
          throw new SVGGraphics2DRuntimeException(localSVGGraphics2DIOException2);
        }
      }
      localAffineTransform = handleTransform(paramElement, paramInt1, paramInt2, i, j, paramInt3, paramInt4, paramSVGGeneratorContext);
    }
    return localAffineTransform;
  }
  
  public AffineTransform handleImage(RenderableImage paramRenderableImage, Element paramElement, double paramDouble1, double paramDouble2, double paramDouble3, double paramDouble4, SVGGeneratorContext paramSVGGeneratorContext)
  {
    double d1 = paramRenderableImage.getWidth();
    double d2 = paramRenderableImage.getHeight();
    AffineTransform localAffineTransform = null;
    if ((d1 == 0.0D) || (d2 == 0.0D) || (paramDouble3 == 0.0D) || (paramDouble4 == 0.0D))
    {
      handleEmptyImage(paramElement);
    }
    else
    {
      try
      {
        handleHREF(paramRenderableImage, paramElement, paramSVGGeneratorContext);
      }
      catch (SVGGraphics2DIOException localSVGGraphics2DIOException1)
      {
        try
        {
          errorHandler.handleError(localSVGGraphics2DIOException1);
        }
        catch (SVGGraphics2DIOException localSVGGraphics2DIOException2)
        {
          throw new SVGGraphics2DRuntimeException(localSVGGraphics2DIOException2);
        }
      }
      localAffineTransform = handleTransform(paramElement, paramDouble1, paramDouble2, d1, d2, paramDouble3, paramDouble4, paramSVGGeneratorContext);
    }
    return localAffineTransform;
  }
  
  protected AffineTransform handleTransform(Element paramElement, double paramDouble1, double paramDouble2, double paramDouble3, double paramDouble4, double paramDouble5, double paramDouble6, SVGGeneratorContext paramSVGGeneratorContext)
  {
    paramElement.setAttributeNS(null, "x", paramSVGGeneratorContext.doubleString(paramDouble1));
    paramElement.setAttributeNS(null, "y", paramSVGGeneratorContext.doubleString(paramDouble2));
    paramElement.setAttributeNS(null, "width", paramSVGGeneratorContext.doubleString(paramDouble5));
    paramElement.setAttributeNS(null, "height", paramSVGGeneratorContext.doubleString(paramDouble6));
    return null;
  }
  
  protected void handleEmptyImage(Element paramElement)
  {
    paramElement.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:href", "");
    paramElement.setAttributeNS(null, "width", "0");
    paramElement.setAttributeNS(null, "height", "0");
  }
  
  public void handleHREF(Image paramImage, Element paramElement, SVGGeneratorContext paramSVGGeneratorContext)
    throws SVGGraphics2DIOException
  {
    if (paramImage == null) {
      throw new SVGGraphics2DRuntimeException("image should not be null");
    }
    int i = paramImage.getWidth(null);
    int j = paramImage.getHeight(null);
    if ((i == 0) || (j == 0))
    {
      handleEmptyImage(paramElement);
    }
    else if ((paramImage instanceof RenderedImage))
    {
      handleHREF((RenderedImage)paramImage, paramElement, paramSVGGeneratorContext);
    }
    else
    {
      BufferedImage localBufferedImage = buildBufferedImage(new Dimension(i, j));
      Graphics2D localGraphics2D = createGraphics(localBufferedImage);
      localGraphics2D.drawImage(paramImage, 0, 0, null);
      localGraphics2D.dispose();
      handleHREF(localBufferedImage, paramElement, paramSVGGeneratorContext);
    }
  }
  
  public BufferedImage buildBufferedImage(Dimension paramDimension)
  {
    return new BufferedImage(width, height, getBufferedImageType());
  }
  
  protected void handleHREF(RenderedImage paramRenderedImage, Element paramElement, SVGGeneratorContext paramSVGGeneratorContext)
    throws SVGGraphics2DIOException
  {
    BufferedImage localBufferedImage = null;
    if (((paramRenderedImage instanceof BufferedImage)) && (((BufferedImage)paramRenderedImage).getType() == getBufferedImageType()))
    {
      localBufferedImage = (BufferedImage)paramRenderedImage;
    }
    else
    {
      Dimension localDimension = new Dimension(paramRenderedImage.getWidth(), paramRenderedImage.getHeight());
      localBufferedImage = buildBufferedImage(localDimension);
      Graphics2D localGraphics2D = createGraphics(localBufferedImage);
      localGraphics2D.drawRenderedImage(paramRenderedImage, IDENTITY);
      localGraphics2D.dispose();
    }
    cacheBufferedImage(paramElement, localBufferedImage, paramSVGGeneratorContext);
  }
  
  protected void handleHREF(RenderableImage paramRenderableImage, Element paramElement, SVGGeneratorContext paramSVGGeneratorContext)
    throws SVGGraphics2DIOException
  {
    Dimension localDimension = new Dimension((int)Math.ceil(paramRenderableImage.getWidth()), (int)Math.ceil(paramRenderableImage.getHeight()));
    BufferedImage localBufferedImage = buildBufferedImage(localDimension);
    Graphics2D localGraphics2D = createGraphics(localBufferedImage);
    localGraphics2D.drawRenderableImage(paramRenderableImage, IDENTITY);
    localGraphics2D.dispose();
    handleHREF(localBufferedImage, paramElement, paramSVGGeneratorContext);
  }
  
  protected void cacheBufferedImage(Element paramElement, BufferedImage paramBufferedImage, SVGGeneratorContext paramSVGGeneratorContext)
    throws SVGGraphics2DIOException
  {
    if (paramSVGGeneratorContext == null) {
      throw new SVGGraphics2DRuntimeException("generatorContext should not be null");
    }
    ByteArrayOutputStream localByteArrayOutputStream;
    try
    {
      localByteArrayOutputStream = new ByteArrayOutputStream();
      encodeImage(paramBufferedImage, localByteArrayOutputStream);
      localByteArrayOutputStream.flush();
      localByteArrayOutputStream.close();
    }
    catch (IOException localIOException)
    {
      throw new SVGGraphics2DIOException("unexpected exception", localIOException);
    }
    String str = imageCacher.lookup(localByteArrayOutputStream, paramBufferedImage.getWidth(), paramBufferedImage.getHeight(), paramSVGGeneratorContext);
    paramElement.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:href", getRefPrefix() + str);
  }
  
  public abstract String getRefPrefix();
  
  public abstract void encodeImage(BufferedImage paramBufferedImage, OutputStream paramOutputStream)
    throws IOException;
  
  public abstract int getBufferedImageType();
}

/* Location:
 * Qualified Name:     org.apache.batik.svggen.DefaultCachedImageHandler
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.batik.svggen;

import java.io.PrintStream;

public class DefaultErrorHandler
  implements ErrorHandler
{
  public void handleError(SVGGraphics2DIOException paramSVGGraphics2DIOException)
    throws SVGGraphics2DIOException
  {
    throw paramSVGGraphics2DIOException;
  }
  
  public void handleError(SVGGraphics2DRuntimeException paramSVGGraphics2DRuntimeException)
    throws SVGGraphics2DRuntimeException
  {
    System.err.println(paramSVGGraphics2DRuntimeException.getMessage());
  }
}

/* Location:
 * Qualified Name:     org.apache.batik.svggen.DefaultErrorHandler
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.batik.svggen;

import java.awt.Composite;
import java.awt.Paint;
import java.awt.Rectangle;
import java.awt.image.BufferedImageOp;

public class DefaultExtensionHandler
  implements ExtensionHandler
{
  public SVGPaintDescriptor handlePaint(Paint paramPaint, SVGGeneratorContext paramSVGGeneratorContext)
  {
    return null;
  }
  
  public SVGCompositeDescriptor handleComposite(Composite paramComposite, SVGGeneratorContext paramSVGGeneratorContext)
  {
    return null;
  }
  
  public SVGFilterDescriptor handleFilter(BufferedImageOp paramBufferedImageOp, Rectangle paramRectangle, SVGGeneratorContext paramSVGGeneratorContext)
  {
    return null;
  }
}

/* Location:
 * Qualified Name:     org.apache.batik.svggen.Defa
1 2 3 4 5 6 7 8 9 10

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd