org.eclipse.birt.chart.device.svg_3.7.2.v20120213

16:41:24.297 INFO  jd.cli.Main - Decompiling org.eclipse.birt.chart.device.svg_3.7.2.v20120213.jar
package org.eclipse.birt.chart.device.svg;

import org.eclipse.birt.chart.event.StructureSource;
import org.eclipse.birt.chart.model.attribute.Cursor;
import org.eclipse.birt.chart.model.data.Trigger;
import org.w3c.dom.Element;

public class CacheEvent
{
  private Element elm;
  private StructureSource src;
  private Trigger[] triggers;
  private Cursor cursor;
  
  public CacheEvent(Element elm, StructureSource src, Trigger[] triggers, Cursor cursor)
  {
    this.elm = elm;
    this.src = src;
    this.triggers = triggers;
    this.cursor = cursor;
  }
  
  public Trigger[] getTriggers()
  {
    return triggers;
  }
  
  public Element getElement()
  {
    return elm;
  }
  
  public StructureSource getSource()
  {
    return src;
  }
  
  public Cursor getCursor()
  {
    return cursor;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.birt.chart.device.svg.CacheEvent
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.birt.chart.device.svg;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import org.eclipse.birt.chart.log.ILogger;
import org.eclipse.birt.chart.log.Logger;

public final class EventHandlers
{
  private static ILogger logger = Logger.getLogger("org.eclipse.birt.chart.device.svg/trace");
  public static final StringBuffer STYLES = new StringBuffer().append(".tooltip.text{ text-anchor:start;font-size:12pt;fill:black;}.tooltip{fill:rgb(244,245,235)}");
  public static String CONTENT;
  
  public static String getJSMenuLib()
  {
    if (CONTENT == null)
    {
      StringBuilder sb = new StringBuilder();
      try
      {
        InputStream is = EventHandlers.class.getResourceAsStream("/org/eclipse/birt/chart/device/svg/SVGActionMenu.js");
        BufferedReader br = new BufferedReader(new InputStreamReader(is));
        String s = null;
        for (;;)
        {
          s = br.readLine();
          if (s == null) {
            break;
          }
          sb.append(s);
          sb.append("\n");
        }
        br.close();
      }
      catch (FileNotFoundException e)
      {
        logger.log(e);
      }
      catch (IOException e)
      {
        logger.log(e);
      }
      CONTENT = sb.toString();
    }
    return CONTENT;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.birt.chart.device.svg.EventHandlers
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.birt.chart.device.svg;

public abstract interface ISVGConstants
{
  public static final String JAVASCRIPT_URL_REF_LIST = "javascript.ref.list";
  public static final String JAVASCRIPT_CODE_LIST = "javascript.code.list";
  public static final String RESIZE_SVG = "resize.svg";
  public static final String ENABLE_SCRIPT = "enable.scriptable";
}

/* Location:
 * Qualified Name:     org.eclipse.birt.chart.device.svg.ISVGConstants
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.birt.chart.device.svg;

import java.awt.Image;
import java.awt.font.FontRenderContext;
import java.net.URL;
import java.text.AttributedCharacterIterator.Attribute;
import java.util.Map;
import org.eclipse.birt.chart.device.ITextMetrics;
import org.eclipse.birt.chart.device.swing.SwingDisplayServer;
import org.eclipse.birt.chart.device.util.ChartTextLayout;
import org.eclipse.birt.chart.device.util.ChartTextMetrics;
import org.eclipse.birt.chart.exception.ChartException;
import org.eclipse.birt.chart.model.component.Label;

public class SVGDisplayServer
  extends SwingDisplayServer
{
  public Object loadImage(URL url)
    throws ChartException
  {
    URL urlFound = findResource(url);
    Image image = (Image)super.loadImage(urlFound);
    return new SVGImage(image, urlFound);
  }
  
  public ITextMetrics getTextMetrics(Label la, boolean autoReuse)
  {
    ChartTextMetrics tm = new ChartTextMetrics(this, la, autoReuse);
    return tm;
  }
  
  public ChartTextLayout createTextLayout(String value, Map<? extends AttributedCharacterIterator.Attribute, ?> fontAttributes, FontRenderContext frc)
  {
    return new SVGTextLayout(value, fontAttributes, frc);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.birt.chart.device.svg.SVGDisplayServer
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.birt.chart.device.svg;

import org.eclipse.birt.chart.device.util.HTMLEncoderAdapter;

public class SVGEncoderAdapter
  extends HTMLEncoderAdapter
{
  private static SVGEncoderAdapter instance;
  
  public static SVGEncoderAdapter getInstance()
  {
    if (instance == null) {
      instance = new SVGEncoderAdapter();
    }
    return instance;
  }
  
  public String escape(String s)
  {
    return s;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.birt.chart.device.svg.SVGEncoderAdapter
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.birt.chart.device.svg;

import java.awt.Color;
import java.awt.GradientPaint;
import java.awt.PaintContext;
import java.awt.Rectangle;
import java.awt.RenderingHints;
import java.awt.geom.AffineTransform;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.awt.image.ColorModel;

public class SVGGradientPaint
  extends GradientPaint
{
  private GradientPaint gradientPaint;
  protected String id;
  
  public SVGGradientPaint(GradientPaint gradientPaint)
  {
    super(gradientPaint.getPoint1(), gradientPaint.getColor1(), gradientPaint.getPoint2(), gradientPaint.getColor2(), gradientPaint.isCyclic());
    this.gradientPaint = gradientPaint;
  }
  
  public boolean equals(Object object)
  {
    if (object == null) {
      return false;
    }
    if ((object instanceof GradientPaint))
    {
      GradientPaint gp = (GradientPaint)object;
      
      return (gp.getColor1().equals(getColor1())) && (gp.getColor2().equals(getColor2())) && (gp.isCyclic() == gp.isCyclic()) && (gp.getPoint1().equals(getPoint1())) && (gp.getPoint2().equals(getPoint2()));
    }
    return false;
  }
  
  public int hashCode()
  {
    int result = 17;
    if (getColor1() != null) {
      result = 37 * result + getColor1().hashCode();
    }
    if (getColor2() != null) {
      result = 37 * result + getColor2().hashCode();
    }
    result = 37 * result + (isCyclic() ? 0 : 1);
    if (getPoint1() != null) {
      result = 37 * result + getPoint1().hashCode();
    }
    if (getPoint2() != null) {
      result = 37 * result + getPoint2().hashCode();
    }
    return result;
  }
  
  public PaintContext createContext(ColorModel arg0, Rectangle arg1, Rectangle2D arg2, AffineTransform arg3, RenderingHints arg4)
  {
    return gradientPaint.createContext(arg0, arg1, arg2, arg3, arg4);
  }
  
  public Color getColor1()
  {
    return gradientPaint.getColor1();
  }
  
  public Color getColor2()
  {
    return gradientPaint.getColor2();
  }
  
  public Point2D getPoint1()
  {
    return gradientPaint.getPoint1();
  }
  
  public Point2D getPoint2()
  {
    return gradientPaint.getPoint2();
  }
  
  public int getTransparency()
  {
    return gradientPaint.getTransparency();
  }
  
  public boolean isCyclic()
  {
    return gradientPaint.isCyclic();
  }
  
  public String getId()
  {
    return "gp" + hashCode();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.birt.chart.device.svg.SVGGradientPaint
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.birt.chart.device.svg;

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Composite;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.GraphicsConfiguration;
import java.awt.Image;
import java.awt.Paint;
import java.awt.Rectangle;
import java.awt.RenderingHints;
import java.awt.RenderingHints.Key;
import java.awt.Shape;
import java.awt.Stroke;
import java.awt.TexturePaint;
import java.awt.font.FontRenderContext;
import java.awt.font.GlyphVector;
import java.awt.font.TextAttribute;
import java.awt.geom.AffineTransform;
import java.awt.geom.PathIterator;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D.Double;
import java.awt.image.BufferedImage;
import java.awt.image.BufferedImageOp;
import java.awt.image.ImageObserver;
import java.awt.image.RenderedImage;
import java.awt.image.renderable.RenderableImage;
import java.text.AttributedCharacterIterator;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Stack;
import org.eclipse.birt.chart.device.svg.i18n.Messages;
import org.eclipse.birt.chart.device.util.ChartGraphics2D;
import org.eclipse.birt.chart.log.ILogger;
import org.eclipse.birt.chart.log.Logger;
import org.w3c.dom.Document;
import org.w3c.dom.Element;

public class SVGGraphics2D
  extends ChartGraphics2D
{
  protected Document dom;
  protected Paint paint;
  protected Color color;
  protected Font font;
  protected Shape clip;
  protected Stroke stroke;
  protected Color background;
  protected Element currentElement;
  protected Stack<Element> parentStack = new Stack();
  protected Element currentParent;
  protected FontRenderContext fontRenderContext;
  protected AffineTransform transforms;
  protected List<SVGGradientPaint> paints = new ArrayList();
  protected Set<TexturePaint> textures = new HashSet();
  protected Element definitions;
  protected Element styles;
  protected Element codeScript;
  protected String styleClass;
  protected String id;
  protected StringBuffer scriptBuffer = new StringBuffer();
  protected StringBuffer styleBuffer = new StringBuffer();
  protected Element deferStrokColor = null;
  protected String primitiveId = null;
  private RenderingHints renderingHints = new RenderingHints(null);
  protected boolean scriptable = true;
  protected static final String defaultStyles = "fill:none;stroke:none";
  protected static final char chRLE = '?';
  protected static final char chPDF = '?';
  protected static final String sStyleBidi = "direction:rtl; unicode-bidi:embed; ";
  private static ILogger logger = Logger.getLogger("org.eclipse.birt.chart.device.svg/trace");
  
  public SVGGraphics2D(Document dom)
  {
    this(dom, true);
  }
  
  public SVGGraphics2D(Document dom, boolean scriptable)
  {
    this.dom = dom;
    this.scriptable = scriptable;
    fontRenderContext = new FontRenderContext(new AffineTransform(), 
      true, 
      false);
    currentElement = dom.getDocumentElement();
    parentStack.push(currentElement);
    currentParent = currentElement;
    
    currentElement = dom.createElement("g");
    definitions = dom.createElement("defs");
    
    currentElement.setAttribute("id", "outerG");
    currentElement.appendChild(definitions);
    currentElement.setAttribute("style", "fill:none;stroke:none");
    pushParent(currentElement);
    
    transforms = new AffineTransform();
    initializeScriptStyles();
  }
  
  public void pushParent(Element parent)
  {
    appendChild(parent);
    parentStack.push(parent);
    currentParent = parent;
  }
  
  public Element popParent()
  {
    Element popElement = null;
    if (!parentStack.isEmpty()) {
      popElement = (Element)parentStack.pop();
    }
    if (!parentStack.isEmpty()) {
      currentParent = ((Element)parentStack.peek());
    }
    return popElement;
  }
  
  protected void appendChild(Element child)
  {
    currentParent.appendChild(child);
  }
  
  public void draw(Shape shape)
  {
    currentElement = createGeneralPath(shape);
    appendChild(currentElement);
    setStrokeStyle(currentElement);
  }
  
  public boolean drawImage(Image arg0, AffineTransform arg1, ImageObserver arg2)
  {
    logger.log(new Exception(Messages.getString("SVGGraphics2D.drawImage.image")));
    return false;
  }
  
  public void drawImage(BufferedImage arg0, BufferedImageOp arg1, int arg2, int arg3)
  {
    logger.log(new Exception(Messages.getString("SVGGraphics2D.drawImage.buffer")));
  }
  
  public void drawRenderedImage(RenderedImage arg0, AffineTransform arg1)
  {
    logger.log(new Exception(Messages.getString("SVGGraphics2D.drawRenderImage.RenderImage")));
  }
  
  public void drawRenderableImage(RenderableImage arg0, AffineTransform arg1)
  {
    logger.log(new Exception(Messages.getString("SVGGraphics2D.drawRenderableImage.RenderableImage")));
  }
  
  private void drawString(String arg0, String sX, String sY)
  {
    currentElement = createText(arg0);
    currentElement.setAttribute("x", sX);
    currentElement.setAttribute("y", sY);
    appendChild(currentElement);
  }
  
  public void drawString(String arg0, int arg1, int arg2)
  {
    drawString(arg0, Integer.toString(arg1), Integer.toString(arg2));
  }
  
  public void drawString(String arg0, float arg1, float arg2)
  {
    drawString(arg0, toString(arg1), toString(arg2));
  }
  
  public void drawString(AttributedCharacterIterator arg0, int arg1, int arg2)
  {
    logger.log(new Exception(Messages.getString("SVGGraphics2D.drawString.AttributeInt")));
  }
  
  public void drawString(AttributedCharacterIterator arg0, float arg1, float arg2)
  {
    logger.log(new Exception(Messages.getString("SVGGraphics2D.drawString.AttributeFloat")));
  }
  
  public void drawGlyphVector(GlyphVector glyph, float x, float y)
  {
    translate(x, y);
    Element currentElement = dom.createElement("g");
    Element transElement = createElement("g");
    currentElement.appendChild(transElement);
    
    setFillColor(transElement, true);
    for (int idx = 0; idx < glyph.getNumGlyphs(); idx++)
    {
      Element glyphElem = createShape(glyph.getGlyphOutline(idx));
      
      transElement.appendChild(glyphElem);
    }
    if (clip != null) {
      currentElement.setAttribute("clip-path", "url(#clip" + clip.hashCode() + ")");
    }
    appendChild(currentElement);
    translate(-x, -y);
  }
  
  public void fill(Shape shape, boolean defered)
  {
    Element tempDeferred = null;
    if (!defered)
    {
      tempDeferred = deferStrokColor;
      deferStrokColor = null;
    }
    currentElement = createGeneralPath(shape);
    appendChild(currentElement);
    setFillColor(currentElement);
    if (!defered) {
      deferStrokColor = tempDeferred;
    }
  }
  
  public void fill(Shape shape)
  {
    currentElement = createGeneralPath(shape);
    appendChild(currentElement);
    setFillColor(currentElement);
  }
  
  public boolean hit(Rectangle arg0, Shape arg1, boolean arg2)
  {
    logger.log(new Exception(Messages.getString("SVGGraphics2D.hit.Rectangle")));
    return false;
  }
  
  public GraphicsConfiguration getDeviceConfiguration()
  {
    logger.log(new Exception(Messages.getString("SVGGraphics2D.getDeviceConfig")));
    return null;
  }
  
  public void setComposite(Composite arg0)
  {
    logger.log(new Exception(Messages.getString("SVGGraphics2D.setComposite")));
  }
  
  public void setRenderingHint(RenderingHints.Key arg0, Object arg1)
  {
    renderingHints.put(arg0, arg1);
  }
  
  public Object getRenderingHint(RenderingHints.Key arg0)
  {
    return renderingHints.get(arg0);
  }
  
  public void setRenderingHints(Map arg0)
  {
    renderingHints = new RenderingHints(arg0);
  }
  
  public void addRenderingHints(Map arg0)
  {
    renderingHints.add(new RenderingHints(arg0));
  }
  
  public RenderingHints getRenderingHints()
  {
    return renderingHints;
  }
  
  public void translate(int arg0, int arg1)
  {
    String transform = currentElement.getAttribute("transform");
    if (transform == null) {
      transform = "";
    }
    currentElement.setAttribute("transform", transform + " translate(" + arg0 + " " + arg1 + ")");
  }
  
  public void translate(double arg0, double arg1)
  {
    transforms.translate(arg0, arg1);
  }
  
  public void rotate(double arg0)
  {
    transforms.rotate(arg0);
  }
  
  public void rotate(double arg0, double arg1, double arg2)
  {
    transforms.rotate(arg0, arg1, arg2);
  }
  
  public void scale(double arg0, double arg1)
  {
    transforms.scale(arg0, arg1);
  }
  
  public void shear(double arg0, double arg1)
  {
    transforms.shear(arg0, arg1);
  }
  
  public void transform(AffineTransform arg0)
  {
    transforms.concatenate((AffineTransform)arg0.clone());
  }
  
  public void setTransform(AffineTransform transform)
  {
    transforms = transform;
  }
  
  public AffineTransform getTransform()
  {
    return transforms;
  }
  
  public Paint getPaint()
  {
    return paint;
  }
  
  public Composite getComposite()
  {
    logger.log(new Exception(Messages.getString("SVGGraphics2D.getComposite")));
    return null;
  }
  
  public void clip(Shape shape)
  {
    setClip(shape);
  }
  
  public FontRenderContext getFontRenderContext()
  {
    return fontRenderContext;
  }
  
  public Graphics create()
  {
    return new SVGGraphics2D(dom);
  }
  
  public void setPaintMode()
  {
    logger.log(new Exception(Messages.getString("SVGGraphics2D.setPaintMode")));
  }
  
  public void setXORMode(Color xorColor)
  {
    if ((color == null) || (xorColor == null)) {
      return;
    }
    int newColor = (xorColor.getRed() << 16) + (
      xorColor.getGreen() << 8) + xorColor.getBlue() ^ 
      (color.getRed() << 16) + (color.getGreen() << 8) + color.getBlue();
    int r = newColor >> 16 & 0xFF;
    int g = (0xFF00 & newColor) >> 8;
    int b = 0xFF & newColor;
    color = new Color(r, g, b);
  }
  
  public FontMetrics getFontMetrics(Font arg0)
  {
    logger.log(new Exception(Messages.getString("SVGGraphics2D.getFontMetrics.Font")));
    return null;
  }
  
  public Rectangle getClipBounds()
  {
    return clip.getBounds();
  }
  
  public void clipRect(int arg0, int arg1, int arg2, int arg3)
  {
    Rectangle2D.Double rect = new Rectangle2D.Double(arg0, 
      arg1, 
      arg2, 
      arg3);
    setClip(rect);
  }
  
  public void setClip(int arg0, int arg1, int arg2, int arg3)
  {
    Rectangle2D.Double rect = new Rectangle2D.Double(arg0, 
      arg1, 
      arg2, 
      arg3);
    setClip(rect);
  }
  
  public void copyArea(int arg0, int arg1, int arg2, int arg3, int arg4, int arg5)
  {
    logger.log(new Exception(Messages.getString("SVGGraphics2D.CopyArea.Int")));
  }
  
  public void drawLine(int arg0, int arg1, int arg2, int arg3)
  {
    drawLine(arg0, arg1, arg2, arg3);
  }
  
  public void drawLine(double arg0, double arg1, double arg2, double arg3)
  {
    currentElement = createLine(arg0, arg1, arg2, arg3);
    appendChild(currentElement);
    setStrokeStyle(currentElement);
  }
  
  public void drawRect(int arg0, int arg1, int arg2, int arg3)
  {
    drawRect(arg0, arg1, arg2, arg3);
  }
  
  public void drawRect(double arg0, double arg1, double arg2, double arg3)
  {
    currentElement = createRect(arg0, arg1, arg2, arg3);
    appendChild(currentElement);
    setStrokeStyle(currentElement);
  }
  
  public void fillRect(int arg0, int arg1, int arg2, int arg3)
  {
    fillRect(arg0, arg1, arg2, arg3);
  }
  
  public void fillRect(double arg0, double arg1, double arg2, double arg3)
  {
    currentElement = createRect(arg0, arg1, arg2, arg3);
    appendChild(currentElement);
    setFillColor(currentElement);
  }
  
  public void clearRect(int arg0, int arg1, int arg2, int arg3)
  {
    logger.log(new Exception(Messages.getString("SVGGraphics2D.clearRect.Int")));
  }
  
  public void drawRoundRect(int arg0, int arg1, int arg2, int arg3, int arg4, int arg5)
  {
    currentElement = createRoundRect(arg0, arg1, arg2, arg3, arg4, arg5);
    appendChild(currentElement);
    setStrokeStyle(currentElement);
  }
  
  public void fillRoundRect(int arg0, int arg1, int arg2, int arg3, int arg4, int arg5)
  {
    currentElement = createRoundRect(arg0, arg1, arg2, arg3, arg4, arg5);
    appendChild(currentElement);
    setFillColor(currentElement);
  }
  
  public void drawOval(int arg0, int arg1, int arg2, int arg3)
  {
    drawOval(arg0, arg1, arg2, arg3);
  }
  
  public void drawOval(double arg0, double arg1, double arg2, double arg3)
  {
    currentElement = createOval(arg0, arg1, arg2, arg3);
    appendChild(currentElement);
    setStrokeStyle(currentElement);
  }
  
  public void fillOval(int arg0, int arg1, int arg2, int arg3)
  {
    fillOval(arg0, arg1, arg2, arg3);
  }
  
  public void fillOval(double arg0, double arg1, double arg2, double arg3)
  {
    currentElement = createOval(arg0, arg1, arg2, arg3);
    appendChild(currentElement);
    setFillColor(currentElement);
  }
  
  public void drawArc(int arg0, int arg1, int arg2, int arg3, int arg4, int arg5)
  {
    drawArc(arg0, 
      arg1, 
      arg2, 
      arg3, 
      arg4, 
      arg5);
  }
  
  public void drawArc(double arg0, double arg1, double arg2, double arg3, double arg4, double arg5)
  {
    currentElement = createArc(arg0, arg1, arg2, arg3, arg4, arg5);
    appendChild(currentElement);
    setStrokeStyle(currentElement);
  }
  
  protected void setStrokeStyle(Element currentElement)
  {
    setStrokeStyle(currentElement, false);
  }
  
  protected void setStrokeStyle(Element currentElement, boolean deferClipped)
  {
    Element element = currentElement;
    if (deferStrokColor != null) {
      element = deferStrokColor;
    }
    String style = element.getAttribute("style");
    if (style == null) {
      style = "";
    }
    if (color != null) {
      style = style + "stroke:" + serializeToString(color) + ";";
    }
    if ((stroke != null) && ((stroke instanceof BasicStroke)))
    {
      BasicStroke bs = (BasicStroke)stroke;
      if (bs.getLineWidth() > 0.0F) {
        style = style + "stroke-width:" + bs.getLineWidth() + ";";
      }
      if (bs.getDashArray() != null)
      {
        StringBuffer dashArrayStr = new StringBuffer();
        for (int x = 0; x < bs.getDashArray().length; x++) {
          dashArrayStr.append(" ").append(bs.getDashArray()[x]);
        }
        if (!dashArrayStr.toString().equals("")) {
          style = style + "stroke-dasharray:" + dashArrayStr + ";";
        }
      }
      style = style + "stroke-miterlimit:" + bs.getMiterLimit() + ";";
      switch (bs.getLineJoin())
      {
      case 2: 
        style = style + "stroke-linejoin:bevel;";
        break;
      case 1: 
        style = style + "stroke-linejoin:round;";
      }
      switch (bs.getEndCap())
      {
      case 1: 
        style = style + "stroke-linecap:round;";
        break;
      case 2: 
        style = style + "stroke-linecap:square;";
      }
    }
    element.setAttribute("style", style);
    if (styleClass != null) {
      element.setAttribute("class", styleClass);
    }
    if (id != null) {
      element.setAttribute("id", id);
    }
    if ((clip != null) && (!deferClipped)) {
      element.setAttribute("clip-path", "url(#clip" + clip.hashCode() + ")");
    }
  }
  
  protected void setFillColor(Element currentElement)
  {
    setFillColor(currentElement, false);
  }
  
  protected void setNoFillColor(Element currentElement)
  {
    String style = currentElement.getAttribute("style");
    if (style == null) {
      style = "";
    }
    currentElement.setAttribute("style", style + "fill:none;");
  }
  
  protected void setFillColor(Element currentElement, boolean deferClipped)
  {
    Element element = currentElement;
    if (deferStrokColor != null) {
      element = deferStrokColor;
    }
    String style = element.getAttribute("style");
    if (style == null) {
      style = "";
    }
    if (paint == null)
    {
      if (color == null) {
        return;
      }
      String alpha = alphaToString(color);
      if (alpha != null) {
        style = style + "fill-opacity:" + alpha + ";";
      }
      element.setAttribute("style", style + "fill:" + serializeToString(color) + ";stroke:none;");
    }
    else if ((paint instanceof SVGGradientPaint))
    {
      element.setAttribute("style", style + "fill:url(#" + ((SVGGradientPaint)paint).getId() + ");stroke:none;fill-opacity:1.0");
    }
    else if ((paint instanceof TexturePaint))
    {
      element.setAttribute("style", style + "fill:url(#" + getTextureId((TexturePaint)paint) + ");stroke:none;fill-opacity:1.0");
    }
    if (styleClass != null) {
      element.setAttribute("class", styleClass);
    }
    if (id != null) {
      element.setAttribute("id", id);
    }
    if ((clip != null) && (!deferClipped)) {
      element.setAttribute("clip-path", "url(#clip" + clip.hashCode() + ")");
    }
  }
  
  protected String serializeToString(Color color)
  {
    String r = Integer.toHexString(color.getRed());
    if (color.getRed() <= 15) {
      r = "0" + r;
    }
    String g = Integer.toHexString(color.getGreen());
    if (color.getGreen() <= 15) {
      g = "0" + g;
    }
    String b = Integer.toHexString(color.getBlue());
    if (color.getBlue() <= 15) {
      b = "0" + b;
    }
    String ret = "#" + r + g + b;
    return ret;
  }
  
  protected String alphaToString(Color color)
  {
    double a = 1.0D;
    if (color.getAlpha() < 255) {
      a = color.getAlpha() / 255.0D;
    }
    return toString(a);
  }
  
  public void fillArc(int arg0, int arg1, int arg2, int arg3, int arg4, int arg5)
  {
    fillArc(arg0, 
      arg1, 
      arg2, 
      arg3, 
      arg4, 
      arg5);
  }
  
  public void fillArc(double arg0, double arg1, double arg2, double arg3, double arg4, double arg5)
  {
    currentElement = createArc(arg0, arg1, arg2, arg3, arg4, arg5);
    appendChild(currentElement);
    setFillColor(currentElement);
  }
  
  public void drawPolyline(int[] arg0, int[] arg1, int arg2)
  {
    currentElement = createPolyline(arg0, arg1, arg2);
    appendChild(currentElement);
    setStrokeStyle(currentElement);
  }
  
  public void drawPolygon(int[] arg0, int[] arg1, int arg2)
  {
    currentElement = createPolygon(arg0, arg1, arg2);
    appendChild(currentElement);
    setStrokeStyle(currentElement);
  }
  
  public void fillPolygon(int[] arg0, int[] arg1, int arg2)
  {
    currentElement = createPolygon(arg0, arg1, arg2);
    appendChild(currentElement);
    setFillColor(currentElement);
  }
  
  public boolean drawImage(Image arg0, int arg1, int arg2, ImageObserver arg3)
  {
    SVGImage image = (SVGImage)arg0;
    
    Element currentElement = createElement("image");
    currentElement.setAttribute("xlink:href", image.getUrl());
    currentElement.setAttribute("x", toString(arg1));
    currentElement.setAttribute("y", toString(arg2));
    currentElement.setAttribute("width", Integer.toString(arg0.getWidth(arg3)));
    currentElement.setAttribute("height", Integer.toString(arg0.getHeight(arg3)));
    if (clip != null) {
      currentElement.setAttribute("clip-path", "url(#clip" + clip.hashCode() + ")");
    }
    appendChild(currentElement);
    
    return true;
  }
  
  public boolean drawImage(Image arg0, int arg1, int arg2, int arg3, int arg4, ImageObserver arg5)
  {
    SVGImage image = (SVGImage)arg0;
    Element currentElement = createElement("image");
    currentElement.setAttribute("xlink:href", image.getUrl());
    currentElement.setAttribute("x", toString(arg1));
    currentElement.setAttribute("y", toString(arg2));
    currentElement.setAttribute("width", toString(arg3));
    currentElement.setAttribute("height", toString(arg4));
    if (clip != null) {
      currentElement.setAttribute("clip-path", "url(#clip" + clip.hashCode() + ")");
    }
    appendChild(currentElement);
    
    return true;
  }
  
  public boolean drawImage(Image arg0, int arg1, int arg2, Color arg3, ImageObserver arg4)
  {
    SVGImage image = (SVGImage)arg0;
    image.getUrl();
    Element currentElement = createElement("image");
    currentElement.setAttribute("x", toString(arg1));
    currentElement.setAttribute("y", toString(arg2));
    currentElement.setAttribute("width", Integer.toString(arg0.getWidth(arg4)));
    currentElement.setAttribute("height", Integer.toString(arg0.getHeight(arg4)));
    currentElement.setAttribute("fill", serializeToString(arg3));
    if (clip != null) {
      currentElement.setAttribute("clip-path", "url(#clip" + clip.hashCode() + ")");
    }
    appendChild(currentElement);
    
    return true;
  }
  
  public boolean drawImage(Image arg0, int arg1, int arg2, int arg3, int arg4, Color arg5, ImageObserver arg6)
  {
    SVGImage image = (SVGImage)arg0;
    Element currentElement = createElement("image");
    currentElement.setAttribute("xlink:href", image.getUrl());
    currentElement.setAttribute("x", toString(arg1));
    currentElement.setAttribute("y", toString(arg2));
    currentElement.setAttribute("width", toString(arg3));
    currentElement.setAttribute("height", toString(arg4));
    currentElement.setAttribute("fill", serializeToString(arg5));
    if (clip != null) {
      currentElement.setAttribute("clip-path", "url(#clip" + clip.hashCode() + ")");
    }
    appendChild(currentElement);
    
    return true;
  }
  
  public boolean drawImage(Image arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, ImageObserver arg9)
  {
    SVGImage image = (SVGImage)arg0;
    Element currentElement = createElement("image");
    currentElement.setAttribute("xlink:href", image.getUrl());
    currentElement.setAttribute("x", toString(arg1));
    currentElement.setAttribute("y", toString(arg2));
    currentElement.setAttribute("width", toString(arg3));
    currentElement.setAttribute("height", toString(arg4));
    if (clip != null) {
      currentElement.setAttribute("clip-path", "url(#clip" + clip.hashCode() + ")");
    }
    appendChild(currentElement);
    
    return true;
  }
  
  public boolean drawImage(Image arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, Color arg9, ImageObserver arg10)
  {
    SVGImage image = (SVGImage)arg0;
    Element currentElement = createElement("image");
    currentElement.setAttribute("xlink:href", image.getUrl());
    currentElement.setAttribute("x", toString(arg1));
    currentElement.setAttribute("y", toString(arg2));
    currentElement.setAttribute("width", toString(arg3));
    currentElement.setAttribute("height", toString(arg4));
    currentElement.setAttribute("fill", serializeToString(arg9));
    if (clip != null) {
      currentElement.setAttribute("clip-path", "url(#clip" + clip.hashCode() + ")");
    }
    appendChild(currentElement);
    
    return true;
  }
  
  public void flush()
  {
    StringBuffer buffer = new StringBuffer(EventHandlers.getJSMenuLib());
    codeScript.appendChild(dom.createCDATASection(scriptBuffer));
    
    buffer = new StringBuffer(EventHandlers.STYLES.toString());
    styles.appendChild(dom.createCDATASection(styleBuffer));
    
    scriptBuffer = new StringBuffer();
    styleBuffer = new StringBuffer();
  }
  
  public void dispose()
  {
    paints.clear();
    textures.clear();
  }
  
  public Color getBackground()
  {
    return background;
  }
  
  public void setBackground(Color background)
  {
    this.background = background;
  }
  
  public Shape getClip()
  {
    return clip;
  }
  
  public void setClip(Shape clip)
  {
    this.clip = clip;
    if (clip != null)
    {
      Element clipPath = dom.createElement("clipPath");
      clipPath.setAttribute("id", "clip" + clip.hashCode());
      clipPath.appendChild(createGeneralPath(clip));
      definitions.appendChild(clipPath);
    }
  }
  
  public Color getColor()
  {
    return color;
  }
  
  public void setColor(Color color)
  {
    this.color = color;
    paint = null;
  }
  
  public Font getFont()
  {
    return font;
  }
  
  public void setFont(Font font)
  {
    this.font = font;
  }
  
  public Stroke getStroke()
  {
    return stroke;
  }
  
  public void setStroke(Stroke stroke)
  {
    this.stroke = stroke;
  }
  
  /* Error */
  private Element createEmbeddeImage(BufferedImage img)
  {
    // Byte code:
    //   0: aload_1
    //   1: ifnonnull +5 -> 6
    //   4: aconst_null
    //   5: areturn
    //   6: aload_1
    //   7: invokevirtual 1109	java/awt/image/BufferedImage:getWidth	()I
    //   10: istore_2
    //   11: aload_1
    //   12: invokevirtual 1108	java/awt/image/BufferedImage:getHeight	()I
    //   15: istore_3
    //   16: invokestatic 1158	org/eclipse/birt/chart/device/ImageWriterFactory:instance	()Lorg/eclipse/birt/chart/device/IImageWriterFactory;
    //   19: ldc_w 604
    //   22: invokeinterface 1229 2 0
    //   27: astore 4
    //   29: new 668	java/io/ByteArrayOutputStream
    //   32: dup
    //   33: sipush 16384
    //   36: invokespecial 1112	java/io/ByteArrayOutputStream:<init>	(I)V
    //   39: astore 5
    //   41: aconst_null
    //   42: astore 6
    //   44: aload 5
    //   46: invokestatic 1214	org/eclipse/birt/chart/util/SecurityUtil:newImageOutputStream	(Ljava/lang/Object;)Ljavax/imageio/stream/ImageOutputStream;
    //   49: astore 7
    //   51: aload 4
    //   53: invokevirtual 1155	javax/imageio/ImageWriter:getDefaultWriteParam	()Ljavax/imageio/ImageWriteParam;
    //   56: astore 8
    //   58: aload 4
    //   60: aload 7
    //   62: invokevirtual 1154	javax/imageio/ImageWriter:setOutput	(Ljava/lang/Object;)V
    //   65: aload 4
    //   67: aconst_null
    //   68: new 684	javax/imageio/IIOImage
    //   71: dup
    //   72: aload_1
    //   73: aconst_null
    //   74: aconst_null
    //   75: invokespecial 1152	javax/imageio/IIOImage:<init>	(Ljava/awt/image/RenderedImage;Ljava/util/List;Ljavax/imageio/metadata/IIOMetadata;)V
    //   78: aload 8
    //   80: invokevirtual 1156	javax/imageio/ImageWriter:write	(Ljavax/imageio/metadata/IIOMetadata;Ljavax/imageio/IIOImage;Ljavax/imageio/ImageWriteParam;)V
    //   83: aload_1
    //   84: invokevirtual 1110	java/awt/image/BufferedImage:flush	()V
    //   87: aload 7
    //   89: invokeinterface 1228 1 0
    //   94: new 677	java/lang/StringBuilder
    //   97: dup
    //   98: ldc_w 575
    //   101: invokespecial 1140	java/lang/StringBuilder:<init>	(Ljava/lang/String;)V
    //   104: new 675	java/lang/String
    //   107: dup
    //   108: aload 5
    //   110: invokevirtual 1111	java/io/ByteArrayOutputStream:toByteArray	()[B
    //   113: invokestatic 1157	org/apache/commons/codec/binary/Base64:encodeBase64	([B)[B
    //   116: invokespecial 1125	java/lang/String:<init>	([B)V
    //   119: invokevirtual 1144	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   122: invokevirtual 1139	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   125: astore 6
    //   127: goto +33 -> 160
    //   130: astore 7
    //   132: getstatic 1063	org/eclipse/birt/chart/device/svg/SVGGraphics2D:logger	Lorg/eclipse/birt/chart/log/ILogger;
    //   135: aload 7
    //   137: invokeinterface 1230 2 0
    //   142: aload 4
    //   144: invokevirtual 1153	javax/imageio/ImageWriter:dispose	()V
    //   147: goto +18 -> 165
    //   150: astore 9
    //   152: aload 4
    //   154: invokevirtual 1153	javax/imageio/ImageWriter:dispose	()V
    //   157: aload 9
    //   159: athrow
    //   160: aload 4
    //   162: invokevirtual 1153	javax/imageio/ImageWriter:dispose	()V
    //   165: aload_0
    //   166: getfield 1064	org/eclipse/birt/chart/device/svg/SVGGraphics2D:dom	Lorg/w3c/dom/Document;
    //   169: ldc 8
    //   171: invokeinterface 1233 2 0
    //   176: astore 7
    //   178: aload 7
    //   180: ldc 9
    //   182: new 677	java/lang/StringBuilder
    //   185: dup
    //   186: ldc_w 590
    //   189: invokespecial 1140	java/lang/StringBuilder:<init>	(Ljava/lang/String;)V
    //   192: aload_1
    //   193: invokevirtual 1121	java/lang/Object:hashCode	()I
    //   196: invokevirtual 1142	java/lang/StringBuilder:append	(I)Ljava/lang/StringBuilder;
    //   199: invokevirtual 1139	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   202: invokeinterface 1236 3 0
    //   207: aload_0
    //   208: getfield 1064	org/eclipse/birt/chart/device/svg/SVGGraphics2D:dom	Lorg/w3c/dom/Document;
    //   211: ldc_w 589
    //   214: invokeinterface 1233 2 0
    //   219: astore 8
    //   221: aload 8
    //   223: ldc_w 641
    //   226: ldc_w 546
    //   229: invokeinterface 1236 3 0
    //   234: aload 8
    //   236: ldc_w 646
    //   239: ldc_w 546
    //   242: invokeinterface 1236 3 0
    //   247: aload 8
    //   249: ldc_w 640
    //   252: iload_2
    //   253: invokestatic 1117	java/lang/Integer:toString	(I)Ljava/lang/String;
    //   256: invokeinterface 1236 3 0
    //   261: aload 8
    //   263: ldc_w 588
    //   266: iload_3
    //   267: invokestatic 1117	java/lang/Integer:toString	(I)Ljava/lang/String;
    //   270: invokeinterface 1236 3 0
    //   275: aload 8
    //   277: ldc_w 644
    //   280: aload 6
    //   282: invokeinterface 1236 3 0
    //   287: aload 7
    //   289: aload 8
    //   291: invokeinterface 1237 2 0
    //   296: pop
    //   297: aload 7
    //   299: areturn
    // Line number table:
    //   Java source line #1300	-> byte code offset #0
    //   Java source line #1302	-> byte code offset #4
    //   Java source line #1305	-> byte code offset #6
    //   Java source line #1306	-> byte code offset #11
    //   Java source line #1307	-> byte code offset #16
    //   Java source line #1308	-> byte code offset #19
    //   Java source line #1307	-> byte code offset #27
    //   Java source line #1309	-> byte code offset #29
    //   Java source line #1310	-> byte code offset #41
    //   Java source line #1313	-> byte code offset #44
    //   Java source line #1314	-> byte code offset #51
    //   Java source line #1315	-> byte code offset #58
    //   Java source line #1316	-> byte code offset #65
    //   Java source line #1317	-> byte code offset #83
    //   Java source line #1318	-> byte code offset #87
    //   Java source line #1319	-> byte code offset #94
    //   Java source line #1320	-> byte code offset #104
    //   Java source line #1319	-> byte code offset #122
    //   Java source line #1322	-> byte code offset #130
    //   Java source line #1324	-> byte code offset #132
    //   Java source line #1328	-> byte code offset #142
    //   Java source line #1327	-> byte code offset #150
    //   Java source line #1328	-> byte code offset #152
    //   Java source line #1329	-> byte code offset #157
    //   Java source line #1328	-> byte code offset #160
    //   Java source line #1331	-> byte code offset #165
    //   Java source line #1332	-> byte code offset #178
    //   Java source line #1333	-> byte code offset #207
    //   Java source line #1334	-> byte code offset #221
    //   Java source line #1335	-> byte code offset #234
    //   Java source line #1336	-> byte code offset #247
    //   Java source line #1337	-> byte code offset #261
    //   Java source line #1338	-> byte code offset #275
    //   Java source line #1339	-> byte code offset #287
    //   Java source line #1341	-> byte code offset #297
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	300	0	this	SVGGraphics2D
    //   0	300	1	img	BufferedImage
    //   10	243	2	width	int
    //   15	252	3	height	int
    //   27	134	4	iw	javax.imageio.ImageWriter
    //   39	70	5	baos	java.io.ByteArrayOutputStream
    //   42	239	6	sUrl	String
    //   49	39	7	ios	javax.imageio.stream.ImageOutputStream
    //   130	6	7	ex	Exception
    //   176	122	7	elemG	Element
    //   56	23	8	iwp	javax.imageio.ImageWriteParam
    //   219	71	8	elem	Element
    //   150	8	9	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   44	127	130	java/lang/Exception
    //   44	142	150	finally
  }
  
  public void setPaint(Paint paint)
  {
    if ((paint instanceof GradientPaint))
    {
      SVGGradientPaint gp = new SVGGradientPaint((GradientPaint)paint);
      int index = paints.indexOf(gp);
      if (index == -1)
      {
        paints.add(gp);
        definitions.appendChild(createGradientPaint(gp, false));
        definitions.appendChild(createGradientPaint(gp, true));
  
1 2 3 4

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