You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-commits@xmlgraphics.apache.org by de...@apache.org on 2005/09/25 20:00:07 UTC

svn commit: r291451 [2/22] - in /xmlgraphics/batik/branches/svg11: ./ samples/tests/resources/wmf/ samples/tests/spec/text/ sources/org/apache/batik/ext/awt/geom/ sources/org/apache/batik/svggen/ sources/org/apache/batik/transcoder/ sources/org/apache/...

Modified: xmlgraphics/batik/branches/svg11/sources/org/apache/batik/svggen/XmlWriter.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg11/sources/org/apache/batik/svggen/XmlWriter.java?rev=291451&r1=291450&r2=291451&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg11/sources/org/apache/batik/svggen/XmlWriter.java (original)
+++ xmlgraphics/batik/branches/svg11/sources/org/apache/batik/svggen/XmlWriter.java Sun Sep 25 10:58:29 2005
@@ -46,7 +46,7 @@
 class XmlWriter implements SVGConstants {
 
     static private String EOL;
-    static private final String TAG_END = " />";
+    static private final String TAG_END = "/>";
     static private final String TAG_START = "</";
     static private final String SPACE = " ";
 
@@ -69,7 +69,8 @@
 
         public IndentWriter(Writer proxied){
             if (proxied == null)
-                throw new SVGGraphics2DRuntimeException(ErrorConstants.ERR_PROXY);
+                throw new SVGGraphics2DRuntimeException
+                    (ErrorConstants.ERR_PROXY);
 
             this.proxied = proxied;
         }
@@ -138,19 +139,21 @@
         }
     }
 
-    private static void writeXml(Attr attr, IndentWriter out) 
+    private static void writeXml(Attr attr, IndentWriter out, 
+                                 boolean escaped) 
         throws IOException{
         String name = attr.getName();
         out.write (name);
         out.write ("=\"");
-        writeChildrenXml(attr, out);
+        writeChildrenXml(attr, out, escaped);
         out.write ('"');
     }
 
     /**
      * Writes the attribute's value.
      */
-    private static void writeChildrenXml(Attr attr, IndentWriter out)
+    private static void writeChildrenXml(Attr attr, IndentWriter out, 
+                                         boolean escaped)
         throws IOException {
         char data[] = attr.getValue().toCharArray();
         if (data == null) return;
@@ -185,7 +188,14 @@
                 start = last + 1;
                 out.write ("&quot;"); 
                 break;
-            default:
+            default: // to be able to escape characters if allowed
+                if (escaped && (c > 0x007F)) {
+                    out.write (data, start, last - start);                    
+                    String hex = "0000"+Integer.toHexString(c);
+                    out.write("&#x"+hex.substring(hex.length()-4)+";");
+                    start = last + 1;
+                }
+                break;
             }
             last++;
         }
@@ -197,7 +207,8 @@
      * prevent illegal comments:  between consecutive dashes ("--")
      * or if the last character of the comment is a dash.
      */
-    private static void writeXml(Comment comment, IndentWriter out)
+    private static void writeXml(Comment comment, IndentWriter out, 
+                                 boolean escaped)
         throws IOException {
 
         char data[] = comment.getData().toCharArray();
@@ -233,12 +244,13 @@
         out.write ("-->");
     }
 
-    private static void writeXml(Text text, IndentWriter out) 
+    private static void writeXml(Text text, IndentWriter out, boolean escaped)
         throws IOException {
-        writeXml(text, out, false);
+        writeXml(text, out, false, escaped);
     }
 
-    private static void writeXml(Text text, IndentWriter out, boolean trimWS)
+    private static void writeXml(Text text, IndentWriter out, boolean trimWS, 
+                                 boolean escaped)
         throws IOException {
         char data[] = text.getData().toCharArray();
 
@@ -306,13 +318,22 @@
                 start = last + 1;
                 out.write ("&amp;");
                 break;
+            default: // to be able to escape characters if allowed
+                if (escaped && (c > 0x007F)) {
+                    out.write (data, start, last - start);
+                    String hex = "0000"+Integer.toHexString(c);
+                    out.write("&#x"+hex.substring(hex.length()-4)+";");
+                    start = last + 1;
+                }
+                break;
             }
             last++;
         }
         out.write (data, start, last - start);
     }
 
-    private static void writeXml(CDATASection cdataSection, IndentWriter out)
+    private static void writeXml(CDATASection cdataSection, IndentWriter out, 
+                                 boolean escaped)
         throws IOException {
         char[] data = cdataSection.getData().toCharArray();
         if (data == null) {
@@ -344,7 +365,8 @@
         out.write ("]]>");
     }
 
-    private static void writeXml(Element element, IndentWriter out)
+    private static void writeXml(Element element, IndentWriter out, 
+                                 boolean escaped)
         throws IOException, SVGGraphics2DIOException {
         out.write (TAG_START, 0, 1);    // "<"
         out.write (element.getTagName());
@@ -355,48 +377,49 @@
             for(int i=0; i<nAttr; i++){
                 Attr attr = (Attr)attributes.item(i);
                 out.write(' ');
-                writeXml(attr, out);
+                writeXml(attr, out, escaped);
             }
         }
 
+        boolean lastElem = (element.getParentNode().getLastChild()==element);
+
         //
         // Write empty nodes as "<EMPTY />" to make sure version 3
         // and 4 web browsers can read empty tag output as HTML.
         // XML allows "<EMPTY/>" too, of course.
         //
-        if (!element.hasChildNodes())
-            out.write(TAG_END, 0, 3);   // " />"
-        else  {
-            out.write(TAG_END, 2, 1);   // ">"
-            writeChildrenXml(element, out);
-            out.write (TAG_START, 0, 2);        // "</"
-            out.write (element.getTagName());
-            out.write (TAG_END, 2, 1);  // ">"
+        if (!element.hasChildNodes()) {
+            if (lastElem) 
+                out.setIndentLevel(out.getIndentLevel()-2);
+            out.printIndent ();
+            out.write(TAG_END, 0, 2);   // "/>"
+            return;
+        } 
+        Node child = element.getFirstChild();
+        out.printIndent ();
+        out.write(TAG_END, 1, 1);   // ">"
+        if ((child.getNodeType() != Node.TEXT_NODE) ||
+            (element.getLastChild() != child)) { // one text node child..
+            out.setIndentLevel(out.getIndentLevel()+2);
         }
+
+        writeChildrenXml(element, out, escaped);
+
+        out.write (TAG_START, 0, 2);        // "</"
+        out.write (element.getTagName());
+        if (lastElem) 
+            out.setIndentLevel(out.getIndentLevel()-2);
+        out.printIndent ();
+        out.write (TAG_END, 1, 1);  // ">"
     }
 
-    private static void writeChildrenXml(Element element, IndentWriter out)
+    private static void writeChildrenXml(Element element, IndentWriter out, 
+                                         boolean escaped)
         throws IOException, SVGGraphics2DIOException {
-        NodeList children = element.getChildNodes();
-        if (children == null)
-            return;
-
-        int length = children.getLength();
-        int     oldIndent = 0;
-        oldIndent = out.getIndentLevel();
-        try {
-            out.setIndentLevel(oldIndent + 2);
-            for(int i = 0; i < length; i++) {
-                if(children.item(i).getNodeType () != Node.TEXT_NODE) {
-                    out.printIndent ();
-                }
-                writeXml(children.item(i), out);
-            }
-        } finally {
-            out.setIndentLevel(oldIndent);
-            if (length > 0 && children.item(length-1).getNodeType() != Node.TEXT_NODE){
-                out.printIndent();          // for ETag
-            }
+        Node child = element.getFirstChild();
+        while (child != null) {
+            writeXml(child, out, escaped);
+            child = child.getNextSibling();
         }
     }
 
@@ -404,9 +427,10 @@
         throws IOException {
         String  encoding = null;
 
-        if (out.getProxied() instanceof OutputStreamWriter)
-            encoding =
-                java2std(((OutputStreamWriter)out.getProxied()).getEncoding());
+        if (out.getProxied() instanceof OutputStreamWriter) {
+            OutputStreamWriter osw = (OutputStreamWriter)out.getProxied();
+            encoding = java2std(osw.getEncoding());
+        }
 
         out.write ("<?xml version=\"1.0\"");
         if (encoding != null) {
@@ -416,27 +440,27 @@
         }
         out.write ("?>");
         out.write (EOL);
-        out.write (EOL);
 
         // Write DOCTYPE declaration here. Skip until specification is released.
         out.write ("<!DOCTYPE svg PUBLIC '");
         out.write (SVG_PUBLIC_ID);
-        out.write ("' '");
-        out.write (SVG_SYSTEM_ID);
-        out.write ("'");
+        out.write ("'"); out.write (EOL); 
 
-        out.write (">");
-        out.write (EOL);
+        out.write ("          '");
+        out.write (SVG_SYSTEM_ID);
+        out.write ("'"); out.write (">"); out.write (EOL);
     }
 
-    private static void writeXml(Document document, IndentWriter out)
+    private static void writeXml(Document document, IndentWriter out, 
+                                 boolean escaped)
         throws IOException, SVGGraphics2DIOException {
         writeDocumentHeader(out);
         NodeList childList = document.getChildNodes();
-        writeXml(childList, out);
+        writeXml(childList, out, escaped);
     }
 
-    private static void writeXml(NodeList childList, IndentWriter out)
+    private static void writeXml(NodeList childList, IndentWriter out, 
+                                 boolean escaped)
         throws IOException, SVGGraphics2DIOException {
         int     length = childList.getLength ();
 
@@ -444,7 +468,7 @@
             return;
         for (int i = 0; i < length; i++) {
             Node child = childList.item(i);
-            writeXml(child, out);
+            writeXml(child, out, escaped);
             out.write (EOL);
         }
     }
@@ -488,12 +512,12 @@
             return "ISO-2022-JP";
         if ("EUCJIS".equalsIgnoreCase (encodingName))
             return "EUC-JP";
-
-        // else we can't really do anything
-        return encodingName;
+                
+        // else we force UTF-8 encoding, better than nothing...
+        return "UTF-8";
     }
 
-    public static void writeXml(Node node, Writer writer)
+    public static void writeXml(Node node, Writer writer, boolean escaped)
         throws SVGGraphics2DIOException {
         try {
             IndentWriter out = null;
@@ -504,33 +528,31 @@
 
             switch (node.getNodeType()) {
             case Node.ATTRIBUTE_NODE:
-                writeXml((Attr)node, out);
+                writeXml((Attr)node, out, escaped);
                 break;
             case Node.COMMENT_NODE:
-                writeXml((Comment)node, out);
+                writeXml((Comment)node, out, escaped);
                 break;
             case Node.TEXT_NODE:
-                writeXml((Text)node, out);
+                writeXml((Text)node, out, escaped);
                 break;
             case Node.CDATA_SECTION_NODE:
-                writeXml((CDATASection)node, out);
+                writeXml((CDATASection)node, out, escaped);
                 break;
             case Node.DOCUMENT_NODE:
-                writeXml((Document)node, out);
+                writeXml((Document)node, out, escaped);
                 break;
             case Node.DOCUMENT_FRAGMENT_NODE:
                 writeDocumentHeader(out);
                 NodeList childList = node.getChildNodes();
-                writeXml(childList, out);
+                writeXml(childList, out, escaped);
                 break;
             case Node.ELEMENT_NODE:
-                writeXml((Element)node, out);
+                writeXml((Element)node, out, escaped);
                 break;
             default:
-                throw
-                    new SVGGraphics2DRuntimeException(ErrorConstants.INVALID_NODE+
-                                                      node.getClass().
-                                                      getName());
+                throw new SVGGraphics2DRuntimeException
+                    (ErrorConstants.INVALID_NODE+node.getClass().getName());
             }
         } catch (IOException io) {
             throw new SVGGraphics2DIOException(io);

Added: xmlgraphics/batik/branches/svg11/sources/org/apache/batik/transcoder/ToSVGAbstractTranscoder.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg11/sources/org/apache/batik/transcoder/ToSVGAbstractTranscoder.java?rev=291451&view=auto
==============================================================================
--- xmlgraphics/batik/branches/svg11/sources/org/apache/batik/transcoder/ToSVGAbstractTranscoder.java (added)
+++ xmlgraphics/batik/branches/svg11/sources/org/apache/batik/transcoder/ToSVGAbstractTranscoder.java Sun Sep 25 10:58:29 2005
@@ -0,0 +1,219 @@
+/*
+ 
+   Copyright 2001  The Apache Software Foundation
+ 
+   Licensed 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.transcoder;
+
+import org.apache.batik.dom.svg.SVGDOMImplementation;
+import org.apache.batik.transcoder.AbstractTranscoder;
+import org.apache.batik.transcoder.TranscoderException;
+import org.apache.batik.transcoder.TranscoderInput;
+import org.apache.batik.transcoder.TranscoderOutput;
+import org.apache.batik.transcoder.TranscodingHints;
+import org.apache.batik.transcoder.keys.*;
+import org.apache.batik.util.SVGConstants;
+import org.w3c.dom.DOMImplementation;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.xml.sax.XMLFilter;
+
+import java.net.*;
+import java.awt.Toolkit;
+import java.io.*;
+import org.apache.batik.svggen.SVGGraphics2D;
+
+/** This class allows to simplify the creation of a transcoder which transcodes to
+ *  SVG content.
+ *  <p>To use this class, you just have to implement the <i>transcode</i> method of
+ *  the <i>AbstractTranscoder</i> class :
+ *  <ul>
+ *  <li>first get  the associated Document from the <i>TranscoderOutput</i> :
+ *  {@link #createDocument(TranscoderOutput)}, then create a new 
+ *  {@link org.apache.batik.svggen.SVGGraphics2D} with this Document</li>
+ *  <pre>
+ *    Document doc = this.createDocument(output);
+ *    svgGenerator = new SVGGraphics2D(doc);
+ *  </pre>
+ *  <li>Perform the effective transcoding, using the 
+ *  {@link org.apache.batik.svggen.SVGGraphics2D} previously created</li>
+ *  <li>then call the 
+ *  {@link #writeSVGToOutput(SVGGraphics2D, Element, TranscoderOutput)} to create the
+ *  effective output file (if the output is set to be a File or URI)</li>
+ *  <pre>
+ *    Element svgRoot = svgGenerator.getRoot();
+ *    writeSVGToOutput(svgGenerator, svgRoot, output);
+ *  </pre>
+ *  </ul>
+ *  </p>
+ *
+ *  <p>Several transcoding hints are defined for this abstract transcoder, but no default 
+ *  implementation is provided. Subclasses must implement which keys are relevant to them :</p>
+ *  <ul>
+ *  <li>KEY_INPUT_WIDTH, KEY_INPUT_HEIGHT, KEY_XOFFSET, KEY_YOFFSET : this Integer keys allows to 
+ *  set the  portion of the image to transcode, defined by the width, height, and offset 
+ *  of this portion in Metafile units.
+ *  <li>KEY_ESCAPED : this Boolean ley allow to escape XML characters in the output</li> 
+ *  </ul>
+ *  <pre>
+ *     transcoder.addTranscodingHint(ToSVGAbstractTranscoder.KEY_INPUT_WIDTH, new Integer(input_width));
+ *  </pre>
+ *  </li>
+ *  <li>KEY_WIDTH, KEY_HEIGHT : this Float values allows to force the width and height of the output:
+ *  </ul>
+ *  <pre>
+ *     transcoder.addTranscodingHint(ToSVGAbstractTranscoder.KEY_WIDTH, new Float(width));
+ *  </pre>
+ *  </li>
+ *  </li>
+ *  </ul>
+ *
+ */
+public abstract class ToSVGAbstractTranscoder extends AbstractTranscoder 
+    implements SVGConstants {
+        
+    public static float PIXEL_TO_MILLIMETERS;
+    public static float PIXEL_PER_INCH;    
+    static {
+        PIXEL_TO_MILLIMETERS = 25.4f /  (float)Toolkit.getDefaultToolkit().getScreenResolution();
+        PIXEL_PER_INCH = Toolkit.getDefaultToolkit().getScreenResolution();        
+    }
+        
+    public static final int TRANSCODER_ERROR_BASE = 0xff00;
+    public static final int ERROR_NULL_INPUT = TRANSCODER_ERROR_BASE + 0;
+    public static final int ERROR_INCOMPATIBLE_INPUT_TYPE = TRANSCODER_ERROR_BASE + 1;
+    public static final int ERROR_INCOMPATIBLE_OUTPUT_TYPE = TRANSCODER_ERROR_BASE + 2;
+    
+    /* Keys definition : width value for the output (in pixels).
+     */
+    public static final TranscodingHints.Key KEY_WIDTH
+        = new FloatKey();    
+
+    /* Keys definition : height value for the output (in pixels).
+     */
+    public static final TranscodingHints.Key KEY_HEIGHT
+        = new FloatKey();        
+
+    /* Keys definition : width value for the input (in pixels).
+     */
+    public static final TranscodingHints.Key KEY_INPUT_WIDTH
+        = new IntegerKey();    
+
+    /* Keys definition : height value for the input (in pixels).
+     */
+    public static final TranscodingHints.Key KEY_INPUT_HEIGHT
+        = new IntegerKey();        
+    
+    /* Keys definition : x offset value for the output (in pixels).
+     */
+    public static final TranscodingHints.Key KEY_XOFFSET
+        = new IntegerKey();            
+
+    /* Keys definition : y offset value for the output (in pixels).
+     */
+    public static final TranscodingHints.Key KEY_YOFFSET
+        = new IntegerKey();                    
+    
+    /* Keys definition : Define if the characters will be escaped in the output.
+     */
+    public static final TranscodingHints.Key KEY_ESCAPED
+        = new BooleanKey();            
+    
+    protected  SVGGraphics2D svgGenerator;
+    
+    /** Create an empty Document from a TranscoderOutput.
+     *  <ul>
+     *  <li>If the TranscoderOutput already contains an empty Document : returns this
+     *  Document</li>
+     *  <li>else create a new empty DOM Document</li>
+     *  </ul>
+     */
+    protected Document createDocument(TranscoderOutput output) {
+        // Use SVGGraphics2D to generate SVG content
+        Document doc;
+        if (output.getDocument() == null) {
+           DOMImplementation domImpl = SVGDOMImplementation.getDOMImplementation();
+
+           doc = domImpl.createDocument(SVG_NAMESPACE_URI, SVG_SVG_TAG, null);
+        } else doc = output.getDocument();
+        
+        return doc;
+    }
+    
+    /** Get the {@link org.apache.batik.svggen.SVGGraphics2D} associated 
+     *  with this transcoder.
+     */
+    public SVGGraphics2D getGraphics2D() {
+        return svgGenerator;
+    }    
+    
+    /** Writes the SVG content held by the svgGenerator to the
+     * <tt>TranscoderOutput</tt>. This method does nothing if the output already
+     * contains a Document.
+     */
+    protected void writeSVGToOutput(SVGGraphics2D svgGenerator, Element svgRoot,
+        TranscoderOutput output) throws TranscoderException {
+            
+        Document doc = output.getDocument();
+        
+        if (doc != null) return;
+        
+        // XMLFilter
+        XMLFilter xmlFilter = output.getXMLFilter();
+        if (xmlFilter != null) {
+            handler.fatalError(new TranscoderException("" + ERROR_INCOMPATIBLE_OUTPUT_TYPE));
+        }
+
+        try {
+            boolean escaped = false;
+            if (hints.containsKey(KEY_ESCAPED)) 
+                escaped = ((Boolean)hints.get(KEY_ESCAPED)).booleanValue();
+            // Output stream
+            OutputStream os = output.getOutputStream();
+            if (os != null) {
+                svgGenerator.stream(svgRoot, new OutputStreamWriter(os), false, escaped);
+                return;
+            }
+
+            // Writer
+            Writer wr = output.getWriter();
+            if (wr != null) {
+                svgGenerator.stream(svgRoot, wr, false, escaped);
+                return;
+            }
+
+            // URI
+            String uri = output.getURI();
+            if ( uri != null ){
+                try{
+                    URL url = new URL(uri);
+                    URLConnection urlCnx = url.openConnection();
+                    os = urlCnx.getOutputStream();
+                    svgGenerator.stream(svgRoot, new OutputStreamWriter(os), false, escaped);
+                    return;
+                } catch (MalformedURLException e){
+                    handler.fatalError(new TranscoderException(e));
+                } catch (IOException e){
+                    handler.fatalError(new TranscoderException(e));
+                }
+            }
+        } catch(IOException e){
+            throw new TranscoderException(e);
+        }
+
+        throw new TranscoderException("" + ERROR_INCOMPATIBLE_OUTPUT_TYPE);
+
+    }    
+}

Modified: xmlgraphics/batik/branches/svg11/sources/org/apache/batik/transcoder/wmf/WMFConstants.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg11/sources/org/apache/batik/transcoder/wmf/WMFConstants.java?rev=291451&r1=291450&r2=291451&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg11/sources/org/apache/batik/transcoder/wmf/WMFConstants.java (original)
+++ xmlgraphics/batik/branches/svg11/sources/org/apache/batik/transcoder/wmf/WMFConstants.java Sun Sep 25 10:58:29 2005
@@ -103,7 +103,7 @@
     public static final int META_CREATEBRUSH		  = 0x00F8;
     public static final int META_CREATEBITMAPINDIRECT	  = 0x02FD;
     public static final int META_CREATEBITMAP		  = 0x06FE;
-
+    
     public static final int META_OBJ_WHITE_BRUSH        = 0;
     public static final int META_OBJ_LTGRAY_BRUSH       = 1;
     public static final int META_OBJ_GRAY_BRUSH         = 2;
@@ -121,4 +121,209 @@
     public static final int META_OBJ_DEVICE_DEFAULT_FONT = 14;
     public static final int META_OBJ_DEFAULT_PALETTE    = 15;
     public static final int META_OBJ_SYSTEM_FIXED_FONT  = 16;
+    
+/* New StretchBlt() Modes */    
+    public static final int STRETCH_BLACKONWHITE = 1;
+    public static final int STRETCH_WHITEONBLACK = 2;
+    public static final int STRETCH_COLORONCOLOR = 3;
+    public static final int STRETCH_HALFTONE = 4;
+    public static final int STRETCH_ANDSCANS = 1;
+    public static final int STRETCH_ORSCANS = 2;
+    public static final int STRETCH_DELETESCANS = 3;    
+    
+    // new values for PATBLT value
+
+    /** new constant for PATBLT. 
+     */  
+    public static final int META_PATCOPY                = 0x00F00021;
+    /** new constant for PATBLT. 
+     */    
+    public static final int META_PATINVERT              = 0x005A0049;
+    /** new constant for PATBLT. 
+     */    
+    public static final int META_DSTINVERT              = 0x00550009;
+    /** new constant for PATBLT. 
+     */    
+    public static final int META_BLACKNESS              = 0x00000042;
+    /** new constant for PATBLT. 
+     */    
+    public static final int META_WHITENESS              = 0x00FF0062;
+    
+    // new constants for pen styles 
+    public static final int META_PS_SOLID = 0;
+    public static final int META_PS_DASH = 1;
+    public static final int META_PS_DOT = 2;
+    public static final int META_PS_DASHDOT = 3;
+    public static final int META_PS_DASHDOTDOT = 4;
+    public static final int META_PS_NULL = 5;
+    public static final int META_PS_INSIDEFRAME = 6;
+
+    // new constants for charsets 
+    
+    /** ANSI charset WMF ID.
+     */
+    public static final int META_CHARSET_ANSI = 0;
+
+    /** DEFAULT charset WMF ID.
+     */
+    public static final int META_CHARSET_DEFAULT = 1;
+
+    /** SYMBOL charset WMF ID.
+     */
+    public static final int META_CHARSET_SYMBOL = 2;
+
+    /** GREEK charset WMF ID.
+     */
+    public static final int META_CHARSET_GREEK = 161;
+
+    /** HEBREW charset WMF ID.
+     */
+    public static final int META_CHARSET_HEBREW = 177;
+
+    /** ARABIC charset WMF ID.
+     */
+    public static final int META_CHARSET_ARABIC = 178;
+
+    /** RUSSIAN (CYRILLIC) charset WMF ID.
+     */
+    public static final int META_CHARSET_RUSSIAN = 204;
+    
+    // new constants for charset names, useful for decoding and encoding text.
+
+    /** ANSI charset Java name, ie "ISO-8859-1" charset.
+     */
+    public static final String CHARSET_ANSI = "ISO-8859-1";
+
+    /** DEFAULT charset Java name, by default taken as "US-ASCII" charset.
+     */    
+    public static final String CHARSET_DEFAULT = "US-ASCII";
+
+    /** GREEK charset Java name, ie "windows-1253" charset.
+     */    
+    public static final String CHARSET_GREEK = "windows-1253";
+
+    /** CYRILLIC charset Java name, ie "windows-1251" charset.
+     */        
+    public static final String CHARSET_CYRILLIC = "windows-1251";
+
+    /** HEBREW charset Java name, ie "windows-1255" charset.
+     */            
+    public static final String CHARSET_HEBREW = "windows-1255";
+
+    /** ARABIC charset Java name, ie "windows-1256" charset.
+     */                
+    public static final String CHARSET_ARABIC = "windows-1256";    
+    
+    /** conversion from inches to Millimeters
+     */
+    public static final float INCH_TO_MM = 25.4f;
+        
+    /** number of inches default values
+     */
+    public static final int DEFAULT_INCH_VALUE = 576;
+    
+    // constants concerning map modes
+    public static final int MM_TEXT = 1;
+    public static final int MM_LOMETRIC = 2;
+    public static final int MM_HIMETRIC = 3;
+    public static final int MM_LOENGLISH = 4;
+    public static final int MM_HIENGLISH = 5;
+    public static final int MM_HITWIPS = 6;
+    public static final int MM_ISOTROPIC = 7;
+    public static final int MM_ANISOTROPIC = 8;
+    
+    // other WMF constants.
+    public static final int BS_SOLID = 0;
+    public static final int BS_HOLLOW = 1;
+    public static final int BS_NULL = 1;
+    public static final int BS_HATCHED = 2;
+    public static final int BS_PATTERN = 3;
+    public static final int BS_DIBPATTERN = 5;
+    public static final int HS_HORIZONTAL = 0;
+    public static final int HS_VERTICAL = 1;
+    public static final int HS_FDIAGONAL = 2;
+    public static final int HS_BDIAGONAL = 3;
+    public static final int HS_CROSS = 4;
+    public static final int HS_DIAGCROSS = 5;
+    public static final int DIB_RGB_COLORS = 0;
+    public static final int DIB_PAL_COLORS = 1;
+    public static final int FW_DONTCARE = 100;
+    public static final int FW_THIN = 100;
+    public static final int FW_NORMAL = 400;
+    public static final int FW_BOLD = 700;
+    public static final int FW_BLACK = 900;
+    public static final byte ANSI_CHARSET = 0;
+    public static final byte DEFAULT_CHARSET = 1;
+    public static final byte SYMBOL_CHARSET = 2;
+    public static final byte SHIFTJIS_CHARSET = -128;
+    public static final byte OEM_CHARSET = -1;
+    public static final byte OUT_DEFAULT_PRECIS = 0;
+    public static final byte OUT_STRING_PRECIS = 1;
+    public static final byte OUT_CHARACTER_PRECIS = 2;
+    public static final byte OUT_STROKE_PRECIS = 3;
+    public static final byte OUT_TT_PRECIS = 4;
+    public static final byte OUT_DEVICE_PRECIS = 5;
+    public static final byte OUT_RASTER_PRECIS = 6;
+    public static final byte CLIP_DEFAULT_PRECIS = 0;
+    public static final byte CLIP_CHARACTER_PRECIS = 1;
+    public static final byte CLIP_STROKE_PRECIS = 2;
+    public static final byte CLIP_MASK = 15;
+    public static final byte CLIP_LH_ANGLES = 16;
+    public static final byte CLIP_TT_ALWAYS = 32;
+    public static final byte DEFAULT_QUALITY = 0;
+    public static final byte DRAFT_QUALITY = 1;
+    public static final byte PROOF_QUALITY = 2;
+    public static final byte DEFAULT_PITCH = 0;
+    public static final byte FIXED_PITCH = 1;
+    public static final byte VARIABLE_PITCH = 2;
+    public static final byte FF_DONTCARE = 0;
+    public static final byte FF_ROMAN = 16;
+    public static final byte FF_SWISS = 32;
+    public static final byte FF_MODERN = 48;
+    public static final byte FF_SCRIPT = 64;
+    public static final byte FF_DECORATIVE = 80;
+    public static final int TRANSPARENT = 1;
+    public static final int OPAQUE = 2;
+    public static final int ALTERNATE = 1;
+    public static final int WINDING = 2;
+    public static final int TA_TOP = 0;
+    public static final int TA_BOTTOM = 8;
+    public static final int TA_BASELINE = 24;
+    public static final int TA_LEFT = 0;
+    public static final int TA_RIGHT = 2;
+    public static final int TA_CENTER = 6;
+    public static final int TA_NOUPDATECP = 0;
+    public static final int TA_UPDATECP = 1;
+    public static final int R2_BLACK = 1;
+    public static final int R2_NOTMERGEPEN = 2;
+    public static final int R2_MASKNOTPENNOT = 3;
+    public static final int R2_NOTCOPYPEN = 4;
+    public static final int R2_MASKPENNOT = 5;
+    public static final int R2_NOT = 6;
+    public static final int R2_XORPEN = 7;
+    public static final int R2_NOTMASKPEN = 8;
+    public static final int R2_MASKPEN = 9;
+    public static final int R2_NOTXORPEN = 10;
+    public static final int R2_NOP = 11;
+    public static final int R2_MERGENOTPEN = 12;
+    public static final int R2_COPYPEN = 13;
+    public static final int R2_MERGEPENNOT = 14;
+    public static final int R2_MERGEPEN = 15;
+    public static final int R2_WHITE = 16;
+    public static final int ETO_OPAQUE = 2;
+    public static final int ETO_CLIPPED = 4;
+    public static final int BLACKNESS = 66;
+    public static final int NOTSRCERASE = 0x1100a6;
+    public static final int NOTSRCCOPY = 0x330008;
+    public static final int SRCERASE = 0x440328;
+    public static final int DSTINVERT = 0x550009;
+    public static final int PATINVERT = 0x5a0049;
+    public static final int SRCINVERT = 0x660046;
+    public static final int SRCAND = 0x8800c6;
+    public static final int MERGEPAINT = 0xbb0226;
+    public static final int SRCCOPY = 0xcc0020;
+    public static final int SRCPAINT = 0xee0086;
+    public static final int PATCOPY = 0xf00021;
+    public static final int PATPAINT = 0xfb0a09;
+    public static final int WHITENESS = 0xff0062;        
 }

Added: xmlgraphics/batik/branches/svg11/sources/org/apache/batik/transcoder/wmf/tosvg/AbstractWMFPainter.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg11/sources/org/apache/batik/transcoder/wmf/tosvg/AbstractWMFPainter.java?rev=291451&view=auto
==============================================================================
--- xmlgraphics/batik/branches/svg11/sources/org/apache/batik/transcoder/wmf/tosvg/AbstractWMFPainter.java (added)
+++ xmlgraphics/batik/branches/svg11/sources/org/apache/batik/transcoder/wmf/tosvg/AbstractWMFPainter.java Sun Sep 25 10:58:29 2005
@@ -0,0 +1,287 @@
+/*
+
+   Copyright 2005 The Apache Software Foundation 
+
+   Licensed 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.transcoder.wmf.tosvg;
+
+import java.io.BufferedInputStream;
+import java.io.UnsupportedEncodingException;
+import java.awt.Font;
+import java.awt.Dimension;
+import java.awt.Graphics2D;
+import java.awt.font.TextAttribute;
+import java.text.AttributedString;
+import java.text.AttributedCharacterIterator;
+import java.awt.image.BufferedImage;
+import java.awt.image.WritableRaster;
+
+import org.apache.batik.transcoder.wmf.WMFConstants;
+
+/** This class provides generic methods that must be used by a particular WMFPainter.
+ */
+public class AbstractWMFPainter {
+    
+    public static final String WMF_FILE_EXTENSION = ".wmf";
+    protected WMFFont wmfFont = null;
+    protected int currentAlign = 0;
+    
+    public static final int PEN = 1;
+    public static final int BRUSH = 2;
+    public static final int FONT = 3;
+    public static final int NULL_PEN = 4;
+    public static final int NULL_BRUSH = 5;
+    public static final int PALETTE = 6;
+    public static final int OBJ_BITMAP = 7;
+    public static final int OBJ_REGION = 8;
+    
+    protected WMFRecordStore currentStore;
+    transient protected boolean bReadingWMF = true;
+    transient protected BufferedInputStream bufStream = null;
+    
+    /** Return the image associated with a bitmap in a Metafile.
+     *  24 bits and 8 bits bitmaps are handled.
+     *  @param bit the bitmap byte array
+     *  @param width the bitmap assumed width
+     *  @param height the bitmap assumed height
+     *  @return the Image associated with the bitmap (null if the dimensions detected in the
+     *     header are not consistent with the assumed dimensions)
+     */ 
+    protected BufferedImage getImage(byte[] bit, int width, int height) {       
+        BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
+        WritableRaster raster = img.getRaster();                  
+        // get the header of the bitmap, first the width and height
+        int _width = (((int)bit[7] & 0x00ff) << 24) | (((int)bit[6] & 0x00ff) << 16)
+                    | (((int)bit[5] & 0x00ff) << 8) | (int)bit[4] & 0x00ff;
+        int _height = (((int)bit[11] & 0x00ff) << 24) | (((int)bit[10] & 0x00ff) << 16)
+                    | (((int)bit[9] & 0x00ff) <<8) | (int)bit[8] & 0x00ff;
+        
+        // if width and height of the bitmap are different from advertised, we abort
+        if ((width != _width) || (height != _height)) return null;
+        return getImage(bit);
+    }
+    
+    protected Dimension getImageDimension(byte[] bit) {
+        // get the header of the bitmap, first the width and height
+        int _width = (((int)bit[7] & 0x00ff) << 24) | (((int)bit[6] & 0x00ff) << 16)
+                    | (((int)bit[5] & 0x00ff) << 8) | (int)bit[4] & 0x00ff;
+        int _height = (((int)bit[11] & 0x00ff) << 24) | (((int)bit[10] & 0x00ff) << 16)
+                    | (((int)bit[9] & 0x00ff) << 8) | (int)bit[8] & 0x00ff;
+        return new Dimension(_width, _height);
+    }
+    
+    /** Return the image associated with a bitmap in a Metafile.
+     *  24 bits and 8 bits bitmaps are handled.
+     *  @param bit the bitmap byte array
+     *  @return the Image associated with the bitmap (null if the dimensions detected in the
+     *     header are not consistent with the assumed dimensions)
+     */ 
+    protected BufferedImage getImage(byte[] bit) {       
+        // get the header of the bitmap, first the width and height
+        int _width = (((int)bit[7] & 0x00ff) << 24) | (((int)bit[6] & 0x00ff) << 16)
+                    | (((int)bit[5] & 0x00ff) << 8) | (int)bit[4] & 0x00ff;
+        int _height = (((int)bit[11] & 0x00ff) << 24) | (((int)bit[10] & 0x00ff) << 16)
+                    | (((int)bit[9] & 0x00ff) << 8) | (int)bit[8] & 0x00ff;
+                        
+        // OK, we can safely create the data array now
+        int[] bitI = new int[_width * _height];
+        BufferedImage img = new BufferedImage(_width, _height, BufferedImage.TYPE_INT_RGB);
+        WritableRaster raster = img.getRaster();
+        
+        // retrieve useful informations in bitmap header
+        // size of header
+        int _headerSize = (((int)bit[3] & 0x00ff) << 24) | (((int)bit[2] & 0x00ff)<<16)
+                            | (((int)bit[1] & 0x00ff) << 8) | (int)bit[0] & 0x00ff;        
+        // number of planes
+        int _planes = (((int)bit[13] & 0x00ff) << 8) | (int)bit[12] & 0x00ff;
+        // number of bits per pixel
+        int _nbit = (((int)bit[15] & 0x00ff) << 8) | (int)bit[14] & 0x00ff;
+        // compression factor : unused
+        // size of the image
+        int _size = (((int)bit[23] & 0x00ff) << 24) | (((int)bit[22] & 0x00ff) << 16)
+                        | (((int)bit[21] & 0x00ff) << 8) | (int)bit[20] & 0x00ff;
+        // infer the size of image if it is not given in the file
+        if (_size == 0) _size = ((((_width * _nbit) + 31) & ~31 ) >> 3) * _height;     
+
+        // number of used colors
+        int _clrused = (((int)bit[35] & 0x00ff) << 24) | (((int)bit[34]&0x00ff) << 16)
+                        | (((int)bit[33] & 0x00ff) << 8) | (int)bit[32]&0x00ff;        
+
+        // 24 bit image
+        if (_nbit == 24) {
+            // read the scan lines
+            int pad = (_size / _height) - _width * 3;
+            int offset = _headerSize; // begin to read data after header
+            // populate the int array
+            for (int j = 0; j < _height; j++) {
+                for (int i = 0; i < _width; i++) {
+                    bitI[_width * (_height - j - 1) + i] = 
+                        (255 & 0x00ff) << 24 | (((int)bit[offset+2] & 0x00ff) << 16)
+                        | (((int)bit[offset+1] & 0x00ff) << 8) | (int)bit[offset] & 0x00ff;
+                    offset += 3;
+                }
+                offset += pad;
+            }
+        // 8 bit image            
+        } else if (_nbit == 8) {
+            // Determine the number of colors
+            int nbColors = 0;
+            if (_clrused > 0) nbColors = _clrused;
+            else nbColors = (1 & 0x00ff) << 8;
+            // Read the palette colors.
+            int offset = _headerSize;
+            int  palette[] = new int[nbColors];
+            for (int i = 0; i < nbColors; i++) {
+                palette[i] = (255 & 0x00ff) << 24 | (((int)bit[offset+2] & 0x00ff) << 16)
+                            | (((int)bit[offset+1] & 0x00ff) << 8) 
+                            | (int)bit[offset] & 0x00ff;
+                offset += 4;
+            }
+
+            // populate the int array
+            int pad = (_size / _height) - _width;
+            for (int j = 0; j < _height; j++) {
+                for (int i = 0; i < _width; i++) {
+                    bitI[_width*(_height-j-1)+i] = palette [((int)bit[offset] & 0x00ff)];
+                    offset++;
+                }
+                offset += pad;
+            }
+        // black and white image
+        } else if (_nbit == 1) {
+            // 2 colors only (black and white image)
+            int nbColors = 2;
+            // Read the palette colors.
+            int offset = _headerSize;
+            int  palette[] = new int[nbColors];
+            for (int i = 0; i < nbColors; i++) {
+                palette[i] = (255 & 0x00ff) << 24 | (((int)bit[offset+2] & 0x00ff) << 16)
+                            | (((int)bit[offset+1] & 0x00ff) << 8) 
+                            | (int)bit[offset] & 0x00ff;
+                offset += 4;
+            }            
+
+            // populate the int array : each pixel correspond to a bit in the byte array
+            int pos = 7;
+            byte currentByte = bit[offset];
+            // padded to long words
+            int pad = (_size / _height) - _width/8;
+            for (int j = 0; j < _height; j++) {
+                for (int i = 0; i < _width; i++) {
+                    if ((currentByte & (1 << pos)) != 0) bitI[_width*(_height-j-1)+i] = palette[1];
+                    else bitI[_width*(_height-j-1)+i] = palette[0];
+                    pos--;
+                    if (pos == -1) {
+                        pos = 7;
+                        offset++;
+                        currentByte = bit[offset];
+                    }
+                }
+                offset +=pad;
+                pos = 7;
+                if (offset < bit.length) currentByte = bit[offset];
+            }
+        }
+        raster.setDataElements(0, 0, _width, _height, bitI);                    
+        return img;
+    } 
+    
+    /** Create an AttributedCharacterIterator with the current definition of the WMF Font, and
+     * the input String.
+     */
+    protected AttributedCharacterIterator getCharacterIterator(Graphics2D g2d, String sr, WMFFont wmffont) {
+        return getAttributedString(g2d, sr, wmffont).getIterator();
+    }
+
+    /** Create an AttributedCharacterIterator with the current definition of the WMF Font, and
+     * the input String.
+     */
+    protected AttributedCharacterIterator getCharacterIterator(Graphics2D g2d, String sr, 
+        WMFFont wmffont, int align) {
+        AttributedString ats = getAttributedString(g2d, sr, wmffont);
+        
+        return ats.getIterator();
+    }    
+    
+    protected AttributedString getAttributedString(Graphics2D g2d, String sr, WMFFont wmffont) { 
+        AttributedString ats = new AttributedString(sr);
+        Font font = g2d.getFont();
+        ats.addAttribute(TextAttribute.SIZE, new Float(font.getSize2D()));
+        ats.addAttribute(TextAttribute.FONT, font);
+        if (wmfFont.underline != 0) 
+            ats.addAttribute(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
+        if (wmfFont.italic != 0) 
+            ats.addAttribute(TextAttribute.POSTURE, TextAttribute.POSTURE_OBLIQUE);
+        else ats.addAttribute(TextAttribute.POSTURE, TextAttribute.POSTURE_REGULAR);
+        if (wmfFont.weight > 400)
+            ats.addAttribute(TextAttribute.WEIGHT, TextAttribute.WEIGHT_BOLD);
+        else ats.addAttribute(TextAttribute.WEIGHT, TextAttribute.WEIGHT_REGULAR);
+        
+        return ats;
+    }    
+    
+    /** Decode a byte array in a String, considering the last selected charset.
+     */
+    protected String decodeString(byte[] bstr) {
+        // manage the charset encoding
+        String str;
+        try {
+            if (wmfFont.charset == WMFConstants.META_CHARSET_ANSI) {
+                str = new String(bstr);
+            } else if (wmfFont.charset == WMFConstants.META_CHARSET_DEFAULT) {
+                str = new String(bstr, WMFConstants.CHARSET_DEFAULT);
+            } else if (wmfFont.charset == WMFConstants.META_CHARSET_GREEK) {
+                str = new String(bstr, WMFConstants.CHARSET_GREEK);
+            } else if (wmfFont.charset == WMFConstants.META_CHARSET_RUSSIAN) {
+                str = new String(bstr, WMFConstants.CHARSET_CYRILLIC);
+            } else if (wmfFont.charset == WMFConstants.META_CHARSET_HEBREW) {
+                str = new String(bstr, WMFConstants.CHARSET_HEBREW);
+            } else if (wmfFont.charset == WMFConstants.META_CHARSET_ARABIC) {
+                str = new String(bstr, WMFConstants.CHARSET_ARABIC);
+            } else str = new String(bstr);
+        } catch (UnsupportedEncodingException e) {
+            str = new String(bstr);
+        }
+        
+        return str;
+    }
+    
+    /**
+     * Sets the WMFRecordStore this WMFPainter should use to render
+     */
+    public void setRecordStore(WMFRecordStore currentStore){
+        if (currentStore == null){
+            throw new IllegalArgumentException();
+        }
+        
+        this.currentStore = currentStore;
+    }
+    
+    /**
+     * Returns the WMFRecordStore this WMFPainter renders
+     */
+    public WMFRecordStore getRecordStore(){
+        return currentStore;
+    }
+    
+    protected int addObject( WMFRecordStore store, int type, Object obj ) {
+        return currentStore.addObject( type, obj );
+    }
+    
+    protected int addObjectAt( WMFRecordStore store, int type, Object obj, int idx ) {
+        return currentStore.addObjectAt( type, obj, idx );
+    }
+}
\ No newline at end of file

Added: xmlgraphics/batik/branches/svg11/sources/org/apache/batik/transcoder/wmf/tosvg/AbstractWMFReader.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg11/sources/org/apache/batik/transcoder/wmf/tosvg/AbstractWMFReader.java?rev=291451&view=auto
==============================================================================
--- xmlgraphics/batik/branches/svg11/sources/org/apache/batik/transcoder/wmf/tosvg/AbstractWMFReader.java (added)
+++ xmlgraphics/batik/branches/svg11/sources/org/apache/batik/transcoder/wmf/tosvg/AbstractWMFReader.java Sun Sep 25 10:58:29 2005
@@ -0,0 +1,423 @@
+/*
+
+   Copyright 2005  The Apache Software Foundation 
+
+   Licensed 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.transcoder.wmf.tosvg;
+
+import java.io.DataInputStream;
+import java.io.IOException;
+import java.net.URL;
+import java.util.Vector;
+import java.awt.Font;
+import java.awt.Toolkit;
+import java.awt.Rectangle;
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Rectangle2D;
+
+import org.apache.batik.transcoder.wmf.WMFConstants;
+
+/** This class provides a general framework to read WMF Metafiles.
+ */
+public abstract class AbstractWMFReader {
+    public static final float PIXEL_PER_INCH = Toolkit.getDefaultToolkit().getScreenResolution();  
+    public static final float MM_PER_PIXEL = 25.4f / Toolkit.getDefaultToolkit().getScreenResolution(); 
+    protected int left, right, top, bottom, width, height, inch;
+    protected float scaleX, scaleY;
+    protected int vpW, vpH, vpX, vpY;
+    transient protected boolean bReading = false;
+    protected int mtType, mtHeaderSize, mtVersion, mtSize, mtNoObjects;
+    protected int mtMaxRecord, mtNoParameters;
+    protected int windowWidth, windowHeight;
+    transient protected int numObjects;
+    transient protected Vector	objectVector;
+    transient public int lastObjectIdx;    
+    
+    public AbstractWMFReader() {
+        scaleX = 1;
+        scaleY = 1;
+        left = 0;
+        top = 0;
+        width = 1;
+        height = 1;
+        right = left + width;
+        bottom = top + height;
+        numObjects = 0;
+        objectVector = new Vector();        
+    }
+    
+    public AbstractWMFReader(int width, int height) {
+        this();
+        this.width = width;
+        this.height = height;
+    }
+    
+    /** read the next short ( 2 bytes) value in the DataInputStream.
+     */
+    protected short readShort(DataInputStream is ) throws IOException {
+        byte js[] = new byte[ 2 ];
+        is.read( js );
+        int iTemp = ((0xff) & js[ 1 ] ) << 8;
+        short i = (short)(0xffff & iTemp);
+        i |= ((0xff) & js[ 0 ] );
+        return i;
+    }
+
+    /** read the next int ( 4 bytes) value in the DataInputStream.
+     */    
+    protected int readInt( DataInputStream is  ) throws IOException {
+        byte js[] = new byte[ 4 ];
+        is.read( js );
+        int i = ((0xff) & js[ 3 ] ) << 24;
+        i |= ((0xff) & js[ 2 ] ) << 16;
+        i |= ((0xff) & js[ 1 ] ) << 8;
+        i |= ((0xff) & js[ 0 ] );
+        return i;
+    }
+    
+    /**
+     * Returns the viewport width, in Metafile Units
+     */
+    public float getViewportWidthUnits() {
+      return vpW;
+    }
+
+    /**
+     * Returns the viewport height, in Metafile Units
+     */
+    public float getViewportHeightUnits() {
+        return vpH;
+    }    
+
+    /**
+     * Returns the viewport width, in inches.
+     */
+    public float getViewportWidthInch() {
+      return (float)vpW / (float)inch;
+    }
+
+    /**
+     * Returns the viewport height, in inches.
+     */
+    public float getViewportHeightInch() {
+      return PIXEL_PER_INCH * (float)vpH / (float)inch;
+    }        
+    
+    /** Return the number of pixels per unit.
+     */
+    public float getPixelsPerUnit() {
+        return PIXEL_PER_INCH / (float)inch;
+    }
+
+    /**
+     * Returns the viewport width, in pixels.
+     */
+    public int getVpW() {
+      return (int)(PIXEL_PER_INCH * (float)vpW / (float)inch);
+    }
+
+    /**
+     * Returns the viewport height, in pixels.
+     */
+    public int getVpH() {
+      return (int)(PIXEL_PER_INCH * (float)vpH / (float)inch);
+    }            
+    
+    /** get the left units in the WMF Metafile. This value is given
+     * in the Aldus Placable Metafile.
+     */        
+    public int getLeftUnits() {
+        return left;
+    }
+
+    /** get the right units in the WMF Metafile. This value is given
+     * in the Aldus Placable Header.
+     */        
+    public int getRightUnits() {
+        return right;
+    }
+
+    /** get the top units in the WMF Metafile. This value is given
+     * in the Aldus Placable Header.
+     */        
+    public int getTopUnits() {
+        return top;
+    }
+
+    /** get the width units in the WMF Metafile. This value is given
+     * in the Aldus Placable Header.
+     */        
+    public int getWidthUnits() {
+        return width;
+    }
+
+    /** get the height units in the WMF Metafile. This value is given
+     * in the Aldus Placable Header.
+     */        
+    public int getHeightUnits() {
+        return height;
+    }
+
+    /** get the bottom units in the WMF Metafile. This value is given
+     * in the Aldus Placable Header.
+     */    
+    public int getBottomUnits() {
+        return bottom;
+    }
+    
+    /** get the number of Metafile units per inch in the WMF Metafile. 
+     * This value is given in the Aldus Placable Header.
+     */
+    public int getMetaFileUnitsPerInch() {
+        return inch;
+    }
+    
+    /** get the Rectangle defining the viewport of the WMF Metafile, in Metafile units. 
+     * This viewport is defined in the Aldus Placable Header, by its left, top, bottom, right 
+     * components.
+     * @see #getRightUnits()
+     * @see #getLeftUnits()
+     * @see #getTopUnits()
+     * @see #getBottomUnits()
+     */
+    public Rectangle getRectangleUnits() {
+        Rectangle rec = new Rectangle(left, top, width, height);
+        return rec;
+    }
+    
+    /** get the Rectangle defining the viewport of the WMF Metafile, in pixels.
+     */
+    public Rectangle2D getRectanglePixel() {
+        float _left = PIXEL_PER_INCH * (float)left / (float)inch;
+        float _right = PIXEL_PER_INCH * (float)right / (float)inch;
+        float _top = PIXEL_PER_INCH * (float)top / (float)inch;
+        float _bottom = PIXEL_PER_INCH * (float)bottom / (float)inch;
+        
+        Rectangle2D.Float rec = new Rectangle2D.Float(_left, _top, _right - _left, _bottom - _top);
+        
+        return rec;
+    }
+
+    /** get the Rectangle defining the viewport of the WMF Metafile, in inchs.
+     */
+    public Rectangle2D getRectangleInch() {
+        float _left = (float)left / (float)inch;
+        float _right = (float)right / (float)inch;
+        float _top = (float)top / (float)inch;
+        float _bottom = (float)bottom / (float)inch;
+        
+        Rectangle2D.Float rec = new Rectangle2D.Float(_left, _top, _right - _left, _bottom - _top);
+        
+        return rec;
+    }    
+    
+    /** get the width of the WMF Metafile, in pixels.
+     */            
+    public int getWidthPixels() {
+        return (int)(PIXEL_PER_INCH * (float)width / (float)inch);
+    }
+    
+    /** get the factor to transform Metafile dimensions in pixels
+     */            
+    public float getUnitsToPixels() {
+        return (PIXEL_PER_INCH / (float)inch);
+    }        
+
+    /** get the factor to transform logical units width in pixels
+     */            
+    public float getVpWFactor() {
+        return (PIXEL_PER_INCH * (float)width / (float)inch) / (float)vpW;
+    }    
+
+    /** get the factor to transform logical units height in pixels
+     */            
+    public float getVpHFactor() {
+        return (PIXEL_PER_INCH * (float)height / (float)inch) / (float)vpH;
+    }            
+    
+    /** get the height of the WMF Metafile, in pixels.
+     */                
+    public int getHeightPixels() {
+        return (int)(PIXEL_PER_INCH * (float)height / (float)inch);
+    }
+        
+    synchronized protected void setReading( boolean state ){
+      bReading = state;
+    }
+
+    /** @return true if the reader is currently reading an InputStream.
+     */
+    synchronized public boolean isReading(){
+      return bReading;
+    }    
+    
+    /** resets this WMFReader.
+     */
+    public abstract void reset();
+    
+    /** Read this InputStream records. The aldus placeable header have already been
+     * read (see {@link #read(DataInputStream)}). The behavior of this method is left
+     * to the subclass.
+     * <p>Each Metafile record is composed of :
+     * <ul>
+     * <li>the size of the Record in int (32 bits)</li>
+     * <li>the function ID for the Record on a short word (16 bits)</li>
+     * <li>the function parameters, according to the WMF Metafile specification.
+     * the remaining size in short words (16 bits) for the parameters is equal to
+     * the total size for the record minus 3 short words (= 16 + 32 bits)</li>
+     * </ul> 
+     * </p>
+     * <p>Example :</p>
+     * <pre>while (functionId > 0) {
+     *        recSize = readInt( is );
+     *        // Subtract size in 16-bit words of recSize and functionId;
+     *        recSize -= 3;
+     *        functionId = readShort( is );
+     *        if ( functionId <= 0 )
+     *          break;
+     *        switch ( functionId ) {       
+     *          case WMFConstants.&lt;a WMF function ID&gt; {
+     *            do something when this function is encountered
+     *          }
+     *          break;
+     *
+     *          default:
+     *             for ( int j = 0; j < recSize; j++ )
+     *               readShort(is);
+     *          break;
+     * </pre>
+     * @see svglab.encoding.wmf.WMFConstants
+     */
+    protected abstract boolean readRecords(DataInputStream is) throws IOException;
+    
+    /** Reads the WMF file from the specified Stream. This method read the 
+     * aldus placeable header and set the corresponding properties :
+     * <ul>
+     * <li>{@link #mtType} : File type (0 : memory, 1 : disk)</li> 
+     * <li>{@link #mtHeaderSize} : Size of header in WORDS (always 9)</li> 
+     * <li>{@link #mtVersion} : Version of Microsoft Windows used</li> 
+     * <li>{@link #mtSize} : Total size of the metafile in WORDs</li> 
+     * <li>{@link #mtNoObjects} : Number of objects in the file</li> 
+     * <li>{@link #mtMaxRecord} : The size of largest record in WORDs</li> 
+     * <li>{@link #mtNoParameters} : Not Used (always 0)</li> 
+     * <li>{@link #left} : Left coordinate in metafile units</li> 
+     * <li>{@link #right} : Right coordinate in metafile units</li> 
+     * <li>{@link #top} : Top coordinate in metafile units</li> 
+     * <li>{@link #bottom} : Bottom coordinate in metafile units</li> 
+     * <li>{@link #inch} : Number of metafile units per inch</li> 
+     * </ul>
+     * <p>Then it calls the {@link #readRecords(DataInputStream)} abstract method,
+     * whose behavior is left to the subclass</p>.
+     */
+    public void read(DataInputStream is) throws IOException {
+        reset();
+
+        setReading( true );
+        int dwIsAldus = readInt( is );
+        if ( dwIsAldus == WMFConstants.META_ALDUS_APM ) {
+            // Read the aldus placeable header.
+            int   key = dwIsAldus;
+            readShort( is ); // metafile handle, always zero
+            left = readShort( is );
+            top = readShort( is );
+            right = readShort( is );
+            bottom = readShort( is );
+            inch = readShort( is );
+            int   reserved = readInt( is );
+            short checksum = readShort( is );
+            width = right - left;
+            height = bottom - top;            
+        } else {
+            setReading( false );   
+            is.close();
+            throw new IOException( "Unable to read file, it is not a Aldus Placable Metafile" );
+        }
+
+        mtType = readShort( is );
+        mtHeaderSize = readShort( is );
+        mtVersion = readShort( is );
+        mtSize = readInt( is );
+        mtNoObjects = readShort( is );
+        mtMaxRecord = readInt( is );
+        mtNoParameters = readShort( is ); 
+        
+        numObjects = mtNoObjects;
+        objectVector.ensureCapacity( numObjects );
+        for ( int i = 0; i < numObjects; i++ ) {
+            objectVector.addElement( new GdiObject( i, false ));
+        }        
+        
+        boolean ret = readRecords(is);
+        is.close();
+        if (!ret) throw new IOException("Unhandled exception while reading records");
+    }
+    
+    public int addObject( int type, Object obj ){
+        int startIdx = 0;
+        //     if ( type == Wmf.PEN ) {
+        //       startIdx = 2;
+        //     }
+        for ( int i = startIdx; i < numObjects; i++ ) {
+            GdiObject gdi = (GdiObject)objectVector.elementAt( i );
+            if ( gdi.used == false ) {
+                gdi.Setup( type, obj );
+                lastObjectIdx = i;
+                break;
+            }
+        }
+        
+        return lastObjectIdx;
+    }
+
+    /**
+     * Adds a GdiObject to the internal handle table.
+     * Wmf files specify the index as given in EMF records such as
+     * EMRCREATEPENINDIRECT whereas WMF files always use 0.
+     *
+     * This function should not normally be called by an application.
+     *  @return the object index
+     */
+    public int addObjectAt( int type, Object obj, int idx ) {
+      if (( idx == 0 ) || ( idx > numObjects )) {
+        addObject( type, obj );
+        return lastObjectIdx;
+      }
+      lastObjectIdx = idx;
+      for ( int i = 0; i < numObjects; i++ ) {
+        GdiObject gdi = (GdiObject)objectVector.elementAt( i );
+        if ( i == idx ) {
+          gdi.Setup( type, obj );
+          break;
+        }
+      }
+      
+      return idx;
+    }
+    
+    /**
+     * Returns a GdiObject from the handle table
+     */
+    public GdiObject getObject( int idx ) {
+        return (GdiObject)objectVector.elementAt( idx );
+    } 
+    
+    /**
+     * Returns the number of GdiObjects in the handle table
+     */
+    public int getNumObjects() {
+      return numObjects;
+    }    
+}
\ No newline at end of file

Added: xmlgraphics/batik/branches/svg11/sources/org/apache/batik/transcoder/wmf/tosvg/GdiObject.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg11/sources/org/apache/batik/transcoder/wmf/tosvg/GdiObject.java?rev=291451&view=auto
==============================================================================
--- xmlgraphics/batik/branches/svg11/sources/org/apache/batik/transcoder/wmf/tosvg/GdiObject.java (added)
+++ xmlgraphics/batik/branches/svg11/sources/org/apache/batik/transcoder/wmf/tosvg/GdiObject.java Sun Sep 25 10:58:29 2005
@@ -0,0 +1,82 @@
+/*
+
+   Copyright 2001-2004  The Apache Software Foundation 
+
+   Licensed 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.transcoder.wmf.tosvg;
+
+/** Represents GDI Objects encountred in WMF Files.
+ */
+public class GdiObject {
+    GdiObject( int _id, boolean _used ) {
+        id = _id;
+        used = _used;
+        type = 0;
+    }
+    
+    public void clear() {
+        used = false;
+        type = 0;
+    }
+    
+    /** Setup this Object, which means that it is used and associated with an Object.
+     *  <p>The Object can be any Java <i>Object</i> that is useful for an implementation of
+     *  {@link AbstractWMFPainter} that uses this GdiObject.</p>
+     *  <p>For example, if the painter paints in a Java <i>Graphics2D</i> :</p>
+     *  <ul>
+     *  <li>For a PEN or BRUSH GdiObject : the Object will be a <i>Color</i></li>
+     *  <li>For a FONT GdiObject : the Object can be a <i>Font</i> (in fact, the actual
+     *  {@link WMFPainter} implementation uses a more sophisticated kind of Object in order to keep
+     *  track of the associated charset)</li>
+     *  </ul>
+     *  @param _type the type of this object
+     *  @param _obj the associated Object
+     */
+    public void Setup( int _type, Object _obj ) {
+        obj = _obj;
+        type = _type;
+        used = true;
+    }
+    
+    /** Return true if this GdiObject is used.
+     */
+    public boolean isUsed() {
+        return used;
+    }
+    
+    /** Return the type of this GdiObject.
+     */
+    public int getType() {
+        return type;
+    }
+    
+    /** Return the Object associated with this GdiObject.
+     */ 
+    public Object getObject() {
+        return obj;
+    }
+    
+    /** Return the identification of this GdiObject.
+     */
+    public int getID() {
+        return id;
+    }
+    
+    int id;
+    boolean used;
+    Object obj;
+    int type = 0;
+}

Added: xmlgraphics/batik/branches/svg11/sources/org/apache/batik/transcoder/wmf/tosvg/MetaRecord.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg11/sources/org/apache/batik/transcoder/wmf/tosvg/MetaRecord.java?rev=291451&view=auto
==============================================================================
--- xmlgraphics/batik/branches/svg11/sources/org/apache/batik/transcoder/wmf/tosvg/MetaRecord.java (added)
+++ xmlgraphics/batik/branches/svg11/sources/org/apache/batik/transcoder/wmf/tosvg/MetaRecord.java Sun Sep 25 10:58:29 2005
@@ -0,0 +1,64 @@
+/*
+
+   Copyright 2001-2004  The Apache Software Foundation 
+
+   Licensed 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.transcoder.wmf.tosvg;
+
+import java.util.Vector;
+
+public class MetaRecord /*implements Serializable*/ {
+    public int	functionId;
+    public int	numPoints;
+
+    private Vector ptVector;
+
+    public MetaRecord() {
+        ptVector = new Vector();
+    }
+
+    public void EnsureCapacity( int cc ) {
+        ptVector.ensureCapacity( cc );
+    }
+
+    public void AddElement( Object obj ) {
+        ptVector.addElement( obj );
+    }
+
+    public Integer ElementAt( int offset ) {
+        return (Integer)ptVector.elementAt( offset );
+    }
+    
+    /** A record that contain byte arrays elements.
+     */
+    public static class ByteRecord extends MetaRecord {
+        public byte[] bstr;
+        
+        public ByteRecord(byte[] bstr) {
+            this.bstr = bstr;
+        }
+    }
+    
+    public static class StringRecord extends MetaRecord /*implements Serializable*/ {
+        public String text;
+        
+        public StringRecord( String newText ) {
+            text = new String( newText );
+        }
+    }    
+}
+    
+

Modified: xmlgraphics/batik/branches/svg11/sources/org/apache/batik/transcoder/wmf/tosvg/RecordStore.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg11/sources/org/apache/batik/transcoder/wmf/tosvg/RecordStore.java?rev=291451&r1=291450&r2=291451&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg11/sources/org/apache/batik/transcoder/wmf/tosvg/RecordStore.java (original)
+++ xmlgraphics/batik/branches/svg11/sources/org/apache/batik/transcoder/wmf/tosvg/RecordStore.java Sun Sep 25 10:58:29 2005
@@ -14,7 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 
- */
+*/
 
 package org.apache.batik.transcoder.wmf.tosvg;
 
@@ -98,7 +98,7 @@
                     b[ i ] = is.readByte();
                 }
                 String str = new String( b );
-                mr = new StringRecord( str );
+                mr = new MetaRecord.StringRecord( str );
             }
             break;
 

Added: xmlgraphics/batik/branches/svg11/sources/org/apache/batik/transcoder/wmf/tosvg/TextureFactory.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg11/sources/org/apache/batik/transcoder/wmf/tosvg/TextureFactory.java?rev=291451&view=auto
==============================================================================
--- xmlgraphics/batik/branches/svg11/sources/org/apache/batik/transcoder/wmf/tosvg/TextureFactory.java (added)
+++ xmlgraphics/batik/branches/svg11/sources/org/apache/batik/transcoder/wmf/tosvg/TextureFactory.java Sun Sep 25 10:58:29 2005
@@ -0,0 +1,179 @@
+/*
+
+   Copyright 2005  The Apache Software Foundation 
+
+   Licensed 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.transcoder.wmf.tosvg;
+
+import java.awt.Paint;
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.TexturePaint;
+import java.awt.image.BufferedImage;
+import java.awt.geom.*;
+import java.util.Hashtable;
+import org.apache.batik.transcoder.wmf.WMFConstants;
+
+/** This class generate Paints from WMF hatch definitions. All generated
+ *  Paints are cached for future use.
+ *
+ */ 
+public class TextureFactory {
+    private static TextureFactory fac = null;
+    private Hashtable textures = new Hashtable(1);
+    private static final int SIZE = 10;
+    private float scale = 1f;
+    
+    private TextureFactory(float scale) {        
+    }
+    
+    /** Get the unique instance of the class.
+     */
+    public static TextureFactory getInstance() {
+        if (fac == null) fac = new TextureFactory(1f);
+        return fac;
+    }
+
+    /** Get the unique instance of the class, setting the scale of the pattern.
+     *  TODO : scale is not handled for now
+     */
+    public static TextureFactory getInstance(float scale) {
+        if (fac == null) fac = new TextureFactory(scale);
+        return fac;
+    }    
+    
+    /** Rest the factory. It empties all the previouly cached Paints are 
+     * disposed of.
+     */
+    public void reset() {
+        textures = new Hashtable(1);
+    }
+    
+    /** Get a texture from a WMF hatch definition (in black Color). This
+     *  texture will be cached, so the Paint will only be created once.
+     */
+    public Paint getTexture(int textureId) {
+        Integer _itexture = new Integer(textureId);
+        if (textures.contains(_itexture)) {
+            Paint paint = (Paint)(textures.get(_itexture));
+            return paint;
+        } else {
+            Paint paint = createTexture(textureId, null, null);
+            if (paint != null) textures.put(_itexture, paint);
+            return paint;
+        }
+    }
+
+    /** Get a texture from a WMF hatch definition, with a foreground color. This
+     *  texture will be cached, so the Paint will only be created once.
+     */    
+    public Paint getTexture(int textureId, Color foreground) {
+        ColoredTexture _ctexture = new ColoredTexture(textureId, foreground, null);
+        if (textures.contains(_ctexture)) {
+            Paint paint = (Paint)(textures.get(_ctexture));
+            return paint;
+        } else {
+            Paint paint = createTexture(textureId, foreground, null);
+            if (paint != null) textures.put(_ctexture, paint);
+            return paint;
+        }
+    }        
+
+    /** Get a texture from a WMF hatch definition, with a foreground and a
+     *  background color. This texture will be cached, so the Paint will 
+     * only be created once.
+     */        
+    public Paint getTexture(int textureId, Color foreground, Color background) {
+        ColoredTexture _ctexture = new ColoredTexture(textureId, foreground, background);
+        if (textures.contains(_ctexture)) {
+            Paint paint = (Paint)(textures.get(_ctexture));
+            return paint;
+        } else {
+            Paint paint = createTexture(textureId, foreground, background);
+            if (paint != null) textures.put(_ctexture, paint);
+            return paint;
+        }
+    }    
+    
+    /** Called internally if the Paint does not exist in the cache and must
+     *  be created.
+     */
+    private Paint createTexture(int textureId, Color foreground, Color background) {
+        BufferedImage img = new BufferedImage(SIZE, SIZE, BufferedImage.TYPE_INT_ARGB);
+        Graphics2D g2d = img.createGraphics();
+        Rectangle2D rec = new Rectangle2D.Float(0, 0, SIZE, SIZE);
+        Paint paint = null;
+        boolean ok = false;
+        if (background != null) {
+            g2d.setColor(background);
+            g2d.fillRect(0, 0, SIZE, SIZE);
+        }
+        if (foreground == null) g2d.setColor(Color.black);
+        else g2d.setColor(foreground);
+        
+        if (textureId == WMFConstants.HS_VERTICAL) {
+            for (int i = 0; i < 5; i++) {
+                g2d.drawLine(i*10, 0, i*10, SIZE);
+            }            
+            ok = true;
+        } else if (textureId == WMFConstants.HS_HORIZONTAL) {
+            for (int i = 0; i < 5; i++) {
+                g2d.drawLine(0, i*10, SIZE, i*10);
+            }            
+            ok = true;            
+        } else if (textureId == WMFConstants.HS_BDIAGONAL) {
+            for (int i = 0; i < 5; i++) {
+                g2d.drawLine(0, i*10, i*10, 0);
+            }            
+            ok = true;                        
+        } else if (textureId == WMFConstants.HS_FDIAGONAL) {
+            for (int i = 0; i < 5; i++) {
+                g2d.drawLine(0, i*10, SIZE - i*10, SIZE);
+            }            
+            ok = true;                                    
+        } else if (textureId == WMFConstants.HS_DIAGCROSS) {
+            for (int i = 0; i < 5; i++) {
+                g2d.drawLine(0, i*10, i*10, 0);                
+                g2d.drawLine(0, i*10, SIZE - i*10, SIZE);                
+            }         
+            ok = true;                                                
+        } else if (textureId == WMFConstants.HS_CROSS) {
+            for (int i = 0; i < 5; i++) {
+                g2d.drawLine(i*10, 0, i*10, SIZE);
+                g2d.drawLine(0, i*10, SIZE, i*10);                
+            }            
+            ok = true;                        
+        }
+        img.flush();
+        if (ok) paint = new TexturePaint(img, rec);
+        return paint;
+    }
+    
+    /** Contain a handle to a Colored texture, with optional foreground and
+     * background colors.
+     */
+    private class ColoredTexture {
+        int textureId = 0;
+        Color foreground = null;
+        Color background = null;
+        
+        ColoredTexture(int textureId, Color foreground, Color background) {
+            this.textureId = textureId;
+            this.foreground = foreground;
+            this.background = background;
+        }
+    }
+}

Propchange: xmlgraphics/batik/branches/svg11/sources/org/apache/batik/transcoder/wmf/tosvg/TextureFactory.java
------------------------------------------------------------------------------
    svn:executable = *

Added: xmlgraphics/batik/branches/svg11/sources/org/apache/batik/transcoder/wmf/tosvg/WMFFont.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg11/sources/org/apache/batik/transcoder/wmf/tosvg/WMFFont.java?rev=291451&view=auto
==============================================================================
--- xmlgraphics/batik/branches/svg11/sources/org/apache/batik/transcoder/wmf/tosvg/WMFFont.java (added)
+++ xmlgraphics/batik/branches/svg11/sources/org/apache/batik/transcoder/wmf/tosvg/WMFFont.java Sun Sep 25 10:58:29 2005
@@ -0,0 +1,52 @@
+/*
+
+   Copyright 2005  The Apache Software Foundation 
+
+   Licensed 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.transcoder.wmf.tosvg;
+
+import java.awt.Font;
+
+/** Represent a WMF Font, encountered in a Metafile.
+ */
+public class WMFFont {
+    public Font font;
+    public int charset;
+    public int underline = 0;
+    public int strikeOut = 0;
+    public int italic = 0;
+    public int weight = 0;
+    public int orientation = 0;
+    public int escape = 0;
+
+    public WMFFont(Font font, int charset) {
+        this.font = font;
+        this.charset = charset;
+    }
+
+    public WMFFont(Font font, int charset, int underline, int strikeOut, 
+        int italic, int weight, int orient, int escape) {
+
+        this.font = font;
+        this.charset = charset;
+        this.underline = underline;
+        this.strikeOut = strikeOut;
+        this.italic = italic;
+        this.weight = weight;
+        this.orientation = orient;
+        this.escape = escape;
+    }
+}