You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-dev@xmlgraphics.apache.org by tk...@apache.org on 2001/03/28 08:51:25 UTC
cvs commit: xml-batik/sources/org/apache/batik/transcoder/svg2svg SVGTranscoder.java
tkormann 01/03/27 22:51:25
Modified: sources/org/apache/batik/transcoder AbstractTranscoder.java
TranscodingHints.java XMLAbstractTranscoder.java
sources/org/apache/batik/transcoder/image
ImageTranscoder.java JPEGTranscoder.java
sources/org/apache/batik/transcoder/print
PrintTranscoder.java
sources/org/apache/batik/transcoder/svg2svg
SVGTranscoder.java
Added: sources/org/apache/batik/transcoder/keys BooleanKey.java
DOMImplementationKey.java FloatKey.java
IntegerKey.java LengthKey.java PaintKey.java
Rectangle2DKey.java StringKey.java
Log:
- Move TranscodingHints.Key implementation to the transcoder.keys package.
- Transcoders can now reuse concrete Key implementation of generic types.
- Custom keys, typically those that could just have a range of
values, are still private to a specific transcoders).
Revision Changes Path
1.3 +2 -227 xml-batik/sources/org/apache/batik/transcoder/AbstractTranscoder.java
Index: AbstractTranscoder.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/transcoder/AbstractTranscoder.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- AbstractTranscoder.java 2001/03/07 01:20:20 1.2
+++ AbstractTranscoder.java 2001/03/28 06:51:23 1.3
@@ -8,243 +8,18 @@
package org.apache.batik.transcoder;
-import java.awt.geom.Rectangle2D;
-import java.awt.Paint;
-
/**
* This class can be the base class of a transcoder which may support
* transcoding hints and/or error handler.
*
* @author <a href="mailto:Thierry.Kormann@sophia.inria.fr">Thierry Kormann</a>
- * @version $Id: AbstractTranscoder.java,v 1.2 2001/03/07 01:20:20 vhardy Exp $
+ * @version $Id: AbstractTranscoder.java,v 1.3 2001/03/28 06:51:23 tkormann Exp $
*/
public abstract class AbstractTranscoder extends TranscoderSupport
implements Transcoder {
-
+
/**
* Constructs a new <tt>AbstractTranscoder</tt>.
*/
protected AbstractTranscoder() {}
-
- // --------------------------------------------------------------------
- // Keys definition
- // --------------------------------------------------------------------
-
- /**
- * The image width key.
- * <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1">
- * <TR>
- * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Key: </TH>
- * <TD VALIGN="TOP">KEY_WIDTH</TD></TR>
- * <TR>
- * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Value: </TH>
- * <TD VALIGN="TOP">Float</TD></TR>
- * <TR>
- * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Default: </TH>
- * <TD VALIGN="TOP">The width of the top most svg element</TD></TR>
- * <TR>
- * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Required: </TH>
- * <TD VALIGN="TOP">No</TD></TR>
- * <TR>
- * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Description: </TH>
- * <TD VALIGN="TOP">Specify the width of the image to create.</TD></TR>
- * </TABLE> */
- public static final TranscodingHints.Key KEY_WIDTH
- = new LengthKey(0);
- public static final String KEY_WIDTH_STR = "width";
-
- /**
- * The image height key.
- * <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1">
- * <TR>
- * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Key: </TH>
- * <TD VALIGN="TOP">KEY_HEIGHT</TD></TR>
- * <TR>
- * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Value: </TH>
- * <TD VALIGN="TOP">Float</TD></TR>
- * <TR>
- * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Default: </TH>
- * <TD VALIGN="TOP">The height of the top most svg element</TD></TR>
- * <TR>
- * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Required: </TH>
- * <TD VALIGN="TOP">No</TD></TR>
- * <TR>
- * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Description: </TH>
- * <TD VALIGN="TOP">Specify the height of the image to create.</TD></TR>
- * </TABLE> */
- public static final TranscodingHints.Key KEY_HEIGHT
- = new LengthKey(1);
- public static final String KEY_HEIGHT_STR = "height";
-
- /**
- * The area of interest key.
- * <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1">
- * <TR>
- * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Key: </TH>
- * <TD VALIGN="TOP">KEY_AOI</TD></TR>
- * <TR>
- * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Value: </TH>
- * <TD VALIGN="TOP">Rectangle2D</TD></TR>
- * <TR>
- * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Default: </TH>
- * <TD VALIGN="TOP">The document's size</TD></TR>
- * <TR>
- * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Required: </TH>
- * <TD VALIGN="TOP">No</TD></TR>
- * <TR>
- * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Description: </TH>
- * <TD VALIGN="TOP">Specify the area of interest to render. The
- * rectangle coordinates must be specified in pixels and in the
- * document coordinates system.</TD></TR>
- * </TABLE>
- */
- public static final TranscodingHints.Key KEY_AOI
- = new Rectangle2DKey(0);
- public static final String KEY_AOI_STR = "aoi";
-
- /**
- * The language key.
- * <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1">
- * <TR>
- * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Key: </TH>
- * <TD VALIGN="TOP">KEY_LANGUAGE</TD></TR>
- * <TR>
- * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Value: </TH>
- * <TD VALIGN="TOP">String</TD></TR>
- * <TR>
- * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Default: </TH>
- * <TD VALIGN="TOP">"en"</TD></TR>
- * <TR>
- * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Required: </TH>
- * <TD VALIGN="TOP">No</TD></TR>
- * <TR>
- * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Description: </TH>
- * <TD VALIGN="TOP">Specify the preferred language of the document.
- * </TD></TR>
- * </TABLE>
- */
- public static final TranscodingHints.Key KEY_LANGUAGE
- = new StringKey(0);
- public static final String KEY_LANGUAGE_STR = "language";
-
- /**
- * The user stylesheet URI key.
- * <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1">
- * <TR>
- * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Key: </TH>
- * <TD VALIGN="TOP">KEY_USER_STYLESHEET_URI</TD></TR>
- * <TR>
- * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Value: </TH>
- * <TD VALIGN="TOP">String</TD></TR>
- * <TR>
- * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Default: </TH>
- * <TD VALIGN="TOP">null</TD></TR>
- * <TR>
- * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Required: </TH>
- * <TD VALIGN="TOP">No</TD></TR>
- * <TR>
- * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Description: </TH>
- * <TD VALIGN="TOP">Specify the user style sheet.</TD></TR>
- * </TABLE>
- */
- public static final TranscodingHints.Key KEY_USER_STYLESHEET_URI
- = new StringKey(1);
- public static final String KEY_USER_STYLESHEET_URI_STR = "userStylesheet";
-
- /**
- * The pixel to millimeter conversion factor key.
- * <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1">
- * <TR>
- * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Key: </TH>
- * <TD VALIGN="TOP">KEY_PIXEL_TO_MM</TD></TR>
- * <TR>
- * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Value: </TH>
- * <TD VALIGN="TOP">Float</TD></TR>
- * <TR>
- * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Default: </TH>
- * <TD VALIGN="TOP">0.33</TD></TR>
- * <TR>
- * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Required: </TH>
- * <TD VALIGN="TOP">No</TD></TR>
- * <TR>
- * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Description: </TH>
- * <TD VALIGN="TOP">Specify the pixel to millimeter conversion factor.
- * </TD></TR>
- * </TABLE>
- */
- public static final TranscodingHints.Key KEY_PIXEL_TO_MM
- = new FloatKey(0);
- public static final String KEY_PIXEL_TO_MM_STR = "pixelToMm";
-
- /**
- * A transcoding Key represented as a string.
- */
- public static class StringKey extends TranscodingHints.Key {
- public StringKey(int privatekey) {
- super(privatekey);
- }
- public boolean isCompatibleValue(Object v) {
- return (v instanceof String);
- }
- }
-
- /**
- * A transcoding Key represented as a boolean.
- */
- public static class BooleanKey extends TranscodingHints.Key {
- public BooleanKey(int privatekey) {
- super(privatekey);
- }
- public boolean isCompatibleValue(Object v) {
- return (v != null && v instanceof Boolean);
- }
- }
-
- /**
- * A transcoding Key represented as a float.
- */
- public static class FloatKey extends TranscodingHints.Key {
- public FloatKey(int privatekey) {
- super(privatekey);
- }
- public boolean isCompatibleValue(Object v) {
- return (v instanceof Float);
- }
- }
-
- /**
- * A transcoding Key represented as a length.
- */
- public static class LengthKey extends TranscodingHints.Key {
- public LengthKey(int privatekey) {
- super(privatekey);
- }
- public boolean isCompatibleValue(Object v) {
- return (v instanceof Float && ((Float)v).floatValue() > 0);
- }
- }
-
- /**
- * A transcoding Key represented as a background paint.
- */
- public static class PaintKey extends TranscodingHints.Key {
- public PaintKey(int privatekey) {
- super(privatekey);
- }
- public boolean isCompatibleValue(Object v) {
- return (v instanceof Paint);
- }
- }
-
- /**
- * A transcoding Key represented as a rectangle.
- */
- public static class Rectangle2DKey extends TranscodingHints.Key {
- public Rectangle2DKey(int privatekey) {
- super(privatekey);
- }
- public boolean isCompatibleValue(Object v) {
- return (v instanceof Rectangle2D);
- }
- }
}
1.6 +4 -58 xml-batik/sources/org/apache/batik/transcoder/TranscodingHints.java
Index: TranscodingHints.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/transcoder/TranscodingHints.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- TranscodingHints.java 2001/01/31 04:18:17 1.5
+++ TranscodingHints.java 2001/03/28 06:51:23 1.6
@@ -20,7 +20,7 @@
* transcoding parameters or options to any transcoders.
*
* @author <a href="mailto:Thierry.Kormann@sophia.inria.fr">Thierry Kormann</a>
- * @version $Id: TranscodingHints.java,v 1.5 2001/01/31 04:18:17 tkormann Exp $
+ * @version $Id: TranscodingHints.java,v 1.6 2001/03/28 06:51:23 tkormann Exp $
*/
public class TranscodingHints extends HashMap {
@@ -132,73 +132,19 @@
/**
* Defines the base type of all keys used to control various
- * aspects of the transcoding operations. Instances of this class
- * are immutable and unique which means that tests for matches can
- * be made using the == operator instead of the more expensive
- * equals() method.
+ * aspects of the transcoding operations.
*/
public abstract static class Key {
- private static Map identitymap = new HashMap(17);
-
- private String getIdentity() {
- return "Instance("+privatekey+") of "+getClass().getName();
- }
-
- private synchronized static void recordIdentity(Key k) {
- Object identity = k.getIdentity();
- if (identitymap.containsKey(identity)) {
- throw new IllegalArgumentException(identity+
- " already registered");
- }
- identitymap.put(identity, k);
- }
-
- private int privatekey;
-
/**
- * Construcst a key using the indicated private key. Each
- * subclass of Key maintains its own unique domain of integer
- * keys. No two objects with the same integer key and of the
- * same specific subclass can be constructed. An exception
- * will be thrown if an attempt is made to construct another
- * object of a given class with the same integer key as a
- * pre-existing instance of that subclass of Key.
+ * Construcst a key.
*/
- protected Key(int privatekey) {
- this.privatekey = privatekey;
- recordIdentity(this);
- }
+ protected Key() { }
/**
* Returns true if the specified object is a valid value for
* this key, false otherwise.
*/
public abstract boolean isCompatibleValue(Object val);
-
- /**
- * Returns the private integer key that the subclass
- * instantiated this Key with.
- */
- protected final int intKey() {
- return privatekey;
- }
-
- /**
- * The hash code for all Key objects will be the same as the
- * system identity code of the object as defined by the
- * System.identityHashCode() method.
- */
- public final int hashCode() {
- return System.identityHashCode(this);
- }
-
- /**
- * The equals method for all Key objects will return the same
- * result as the equality operator '=='.
- */
- public final boolean equals(Object o) {
- return this == o;
- }
}
}
1.7 +9 -18 xml-batik/sources/org/apache/batik/transcoder/XMLAbstractTranscoder.java
Index: XMLAbstractTranscoder.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/transcoder/XMLAbstractTranscoder.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- XMLAbstractTranscoder.java 2001/03/07 01:20:21 1.6
+++ XMLAbstractTranscoder.java 2001/03/28 06:51:23 1.7
@@ -12,8 +12,12 @@
import java.io.InputStream;
import java.io.Reader;
import java.util.Map;
+
import org.apache.batik.dom.util.DocumentFactory;
import org.apache.batik.dom.util.SAXDocumentFactory;
+import org.apache.batik.transcoder.keys.DOMImplementationKey;
+import org.apache.batik.transcoder.keys.StringKey;
+
import org.w3c.dom.DOMException;
import org.w3c.dom.DOMImplementation;
import org.w3c.dom.Document;
@@ -37,7 +41,7 @@
* </ul>
*
* @author <a href="mailto:Thierry.Kormann@sophia.inria.fr">Thierry Kormann</a>
- * @version $Id: XMLAbstractTranscoder.java,v 1.6 2001/03/07 01:20:21 vhardy Exp $
+ * @version $Id: XMLAbstractTranscoder.java,v 1.7 2001/03/28 06:51:23 tkormann Exp $
*/
public abstract class XMLAbstractTranscoder extends AbstractTranscoder {
@@ -179,8 +183,7 @@
* </TABLE>
*/
public static final TranscodingHints.Key KEY_XML_PARSER_CLASSNAME
- = new StringKey(10);
- public static final String KEY_XML_PARSER_CLASSNAME_STR = "xmlParserClassName";
+ = new StringKey();
/**
* Document element key.
@@ -204,7 +207,7 @@
* </TABLE>
*/
public static final TranscodingHints.Key KEY_DOCUMENT_ELEMENT
- = new StringKey(12);
+ = new StringKey();
/**
* Document element namespace URI key.
@@ -229,7 +232,7 @@
* </TABLE>
*/
public static final TranscodingHints.Key KEY_DOCUMENT_ELEMENT_NAMESPACE_URI
- = new StringKey(13);
+ = new StringKey();
/**
* DOM Implementation key.
@@ -253,19 +256,7 @@
* </TABLE>
*/
public static final TranscodingHints.Key KEY_DOM_IMPLEMENTATION
- = new DOMImplKey(14);
-
- /**
- * A transcoding Key represented as a DOMImplementation.
- */
- public static class DOMImplKey extends TranscodingHints.Key {
- public DOMImplKey(int privatekey) {
- super(privatekey);
- }
- public boolean isCompatibleValue(Object v) {
- return (v instanceof DOMImplementation);
- }
- }
+ = new DOMImplementationKey();
}
1.18 +151 -2 xml-batik/sources/org/apache/batik/transcoder/image/ImageTranscoder.java
Index: ImageTranscoder.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/transcoder/image/ImageTranscoder.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- ImageTranscoder.java 2001/03/27 13:33:34 1.17
+++ ImageTranscoder.java 2001/03/28 06:51:24 1.18
@@ -47,6 +47,14 @@
import org.apache.batik.transcoder.XMLAbstractTranscoder;
import org.apache.batik.transcoder.image.resources.Messages;
+import org.apache.batik.transcoder.keys.BooleanKey;
+import org.apache.batik.transcoder.keys.FloatKey;
+import org.apache.batik.transcoder.keys.LengthKey;
+import org.apache.batik.transcoder.keys.PaintKey;
+import org.apache.batik.transcoder.keys.PaintKey;
+import org.apache.batik.transcoder.keys.Rectangle2DKey;
+import org.apache.batik.transcoder.keys.StringKey;
+
import org.apache.batik.util.SVGConstants;
import org.w3c.dom.DOMException;
@@ -84,7 +92,7 @@
* millimeter conversion factor.
*
* @author <a href="mailto:Thierry.Kormann@sophia.inria.fr">Thierry Kormann</a>
- * @version $Id: ImageTranscoder.java,v 1.17 2001/03/27 13:33:34 cjolif Exp $
+ * @version $Id: ImageTranscoder.java,v 1.18 2001/03/28 06:51:24 tkormann Exp $
*/
public abstract class ImageTranscoder extends XMLAbstractTranscoder {
@@ -383,6 +391,147 @@
// --------------------------------------------------------------------
// Keys definition
// --------------------------------------------------------------------
+
+ /**
+ * The image width key.
+ * <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1">
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Key: </TH>
+ * <TD VALIGN="TOP">KEY_WIDTH</TD></TR>
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Value: </TH>
+ * <TD VALIGN="TOP">Float</TD></TR>
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Default: </TH>
+ * <TD VALIGN="TOP">The width of the top most svg element</TD></TR>
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Required: </TH>
+ * <TD VALIGN="TOP">No</TD></TR>
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Description: </TH>
+ * <TD VALIGN="TOP">Specify the width of the image to create.</TD></TR>
+ * </TABLE> */
+ public static final TranscodingHints.Key KEY_WIDTH
+ = new LengthKey();
+
+ /**
+ * The image height key.
+ * <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1">
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Key: </TH>
+ * <TD VALIGN="TOP">KEY_HEIGHT</TD></TR>
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Value: </TH>
+ * <TD VALIGN="TOP">Float</TD></TR>
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Default: </TH>
+ * <TD VALIGN="TOP">The height of the top most svg element</TD></TR>
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Required: </TH>
+ * <TD VALIGN="TOP">No</TD></TR>
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Description: </TH>
+ * <TD VALIGN="TOP">Specify the height of the image to create.</TD></TR>
+ * </TABLE> */
+ public static final TranscodingHints.Key KEY_HEIGHT
+ = new LengthKey();
+
+ /**
+ * The area of interest key.
+ * <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1">
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Key: </TH>
+ * <TD VALIGN="TOP">KEY_AOI</TD></TR>
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Value: </TH>
+ * <TD VALIGN="TOP">Rectangle2D</TD></TR>
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Default: </TH>
+ * <TD VALIGN="TOP">The document's size</TD></TR>
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Required: </TH>
+ * <TD VALIGN="TOP">No</TD></TR>
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Description: </TH>
+ * <TD VALIGN="TOP">Specify the area of interest to render. The
+ * rectangle coordinates must be specified in pixels and in the
+ * document coordinates system.</TD></TR>
+ * </TABLE>
+ */
+ public static final TranscodingHints.Key KEY_AOI
+ = new Rectangle2DKey();
+
+ /**
+ * The language key.
+ * <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1">
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Key: </TH>
+ * <TD VALIGN="TOP">KEY_LANGUAGE</TD></TR>
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Value: </TH>
+ * <TD VALIGN="TOP">String</TD></TR>
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Default: </TH>
+ * <TD VALIGN="TOP">"en"</TD></TR>
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Required: </TH>
+ * <TD VALIGN="TOP">No</TD></TR>
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Description: </TH>
+ * <TD VALIGN="TOP">Specify the preferred language of the document.
+ * </TD></TR>
+ * </TABLE>
+ */
+ public static final TranscodingHints.Key KEY_LANGUAGE
+ = new StringKey();
+
+ /**
+ * The user stylesheet URI key.
+ * <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1">
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Key: </TH>
+ * <TD VALIGN="TOP">KEY_USER_STYLESHEET_URI</TD></TR>
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Value: </TH>
+ * <TD VALIGN="TOP">String</TD></TR>
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Default: </TH>
+ * <TD VALIGN="TOP">null</TD></TR>
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Required: </TH>
+ * <TD VALIGN="TOP">No</TD></TR>
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Description: </TH>
+ * <TD VALIGN="TOP">Specify the user style sheet.</TD></TR>
+ * </TABLE>
+ */
+ public static final TranscodingHints.Key KEY_USER_STYLESHEET_URI
+ = new StringKey();
+
+ /**
+ * The pixel to millimeter conversion factor key.
+ * <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1">
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Key: </TH>
+ * <TD VALIGN="TOP">KEY_PIXEL_TO_MM</TD></TR>
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Value: </TH>
+ * <TD VALIGN="TOP">Float</TD></TR>
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Default: </TH>
+ * <TD VALIGN="TOP">0.33</TD></TR>
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Required: </TH>
+ * <TD VALIGN="TOP">No</TD></TR>
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Description: </TH>
+ * <TD VALIGN="TOP">Specify the pixel to millimeter conversion factor.
+ * </TD></TR>
+ * </TABLE>
+ */
+ public static final TranscodingHints.Key KEY_PIXEL_TO_MM
+ = new FloatKey();
+
/**
* The image background paint key.
* <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1">
@@ -406,6 +555,6 @@
* </TABLE>
*/
public static final TranscodingHints.Key KEY_BACKGROUND_COLOR
- = new PaintKey(0);
+ = new PaintKey();
}
1.4 +2 -5 xml-batik/sources/org/apache/batik/transcoder/image/JPEGTranscoder.java
Index: JPEGTranscoder.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/transcoder/image/JPEGTranscoder.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- JPEGTranscoder.java 2001/01/17 13:35:23 1.3
+++ JPEGTranscoder.java 2001/03/28 06:51:24 1.4
@@ -24,7 +24,7 @@
* This class is an <tt>ImageTranscoder</tt> that produces a JPEG image.
*
* @author <a href="mailto:Thierry.Kormann@sophia.inria.fr">Thierry Kormann</a>
- * @version $Id: JPEGTranscoder.java,v 1.3 2001/01/17 13:35:23 tkormann Exp $
+ * @version $Id: JPEGTranscoder.java,v 1.4 2001/03/28 06:51:24 tkormann Exp $
*/
public class JPEGTranscoder extends ImageTranscoder {
@@ -100,15 +100,12 @@
* </TABLE>
*/
public static final TranscodingHints.Key KEY_QUALITY
- = new QualityKey(0);
+ = new QualityKey();
/**
* A transcoding Key represented the JPEG image quality.
*/
private static class QualityKey extends TranscodingHints.Key {
- public QualityKey(int privatekey) {
- super(privatekey);
- }
public boolean isCompatibleValue(Object v) {
if (v instanceof Float) {
float q = ((Float)v).floatValue();
1.1 xml-batik/sources/org/apache/batik/transcoder/keys/BooleanKey.java
Index: BooleanKey.java
===================================================================
/*****************************************************************************
* Copyright (C) The Apache Software Foundation. All rights reserved. *
* ------------------------------------------------------------------------- *
* This software is published under the terms of the Apache Software License *
* version 1.1, a copy of which has been included with this distribution in *
* the LICENSE file. *
*****************************************************************************/
package org.apache.batik.transcoder.keys;
import org.apache.batik.transcoder.TranscodingHints;
/**
* A transcoding Key represented as a boolean.
*
* @author <a href="mailto:Thierry.Kormann@sophia.inria.fr">Thierry Kormann</a>
* @version $Id: BooleanKey.java,v 1.1 2001/03/28 06:51:24 tkormann Exp $
*/
public class BooleanKey extends TranscodingHints.Key {
public boolean isCompatibleValue(Object v) {
return (v != null && v instanceof Boolean);
}
}
1.1 xml-batik/sources/org/apache/batik/transcoder/keys/DOMImplementationKey.java
Index: DOMImplementationKey.java
===================================================================
/*****************************************************************************
* Copyright (C) The Apache Software Foundation. All rights reserved. *
* ------------------------------------------------------------------------- *
* This software is published under the terms of the Apache Software License *
* version 1.1, a copy of which has been included with this distribution in *
* the LICENSE file. *
*****************************************************************************/
package org.apache.batik.transcoder.keys;
import org.apache.batik.transcoder.TranscodingHints;
import org.w3c.dom.DOMImplementation;
/**
* A transcoding Key represented as a DOMImplementation.
*
* @author <a href="mailto:Thierry.Kormann@sophia.inria.fr">Thierry Kormann</a>
* @version $Id: DOMImplementationKey.java,v 1.1 2001/03/28 06:51:24 tkormann Exp $
*/
public class DOMImplementationKey extends TranscodingHints.Key {
public boolean isCompatibleValue(Object v) {
return (v instanceof DOMImplementation);
}
}
1.1 xml-batik/sources/org/apache/batik/transcoder/keys/FloatKey.java
Index: FloatKey.java
===================================================================
/*****************************************************************************
* Copyright (C) The Apache Software Foundation. All rights reserved. *
* ------------------------------------------------------------------------- *
* This software is published under the terms of the Apache Software License *
* version 1.1, a copy of which has been included with this distribution in *
* the LICENSE file. *
*****************************************************************************/
package org.apache.batik.transcoder.keys;
import org.apache.batik.transcoder.TranscodingHints;
/**
* A transcoding Key represented as a float.
*
* @author <a href="mailto:Thierry.Kormann@sophia.inria.fr">Thierry Kormann</a>
* @version $Id: FloatKey.java,v 1.1 2001/03/28 06:51:24 tkormann Exp $
*/
public class FloatKey extends TranscodingHints.Key {
public boolean isCompatibleValue(Object v) {
return (v instanceof Float);
}
}
1.1 xml-batik/sources/org/apache/batik/transcoder/keys/IntegerKey.java
Index: IntegerKey.java
===================================================================
/*****************************************************************************
* Copyright (C) The Apache Software Foundation. All rights reserved. *
* ------------------------------------------------------------------------- *
* This software is published under the terms of the Apache Software License *
* version 1.1, a copy of which has been included with this distribution in *
* the LICENSE file. *
*****************************************************************************/
package org.apache.batik.transcoder.keys;
import org.apache.batik.transcoder.TranscodingHints;
/**
* A transcoding Key represented as an int.
*
* @author <a href="mailto:Thierry.Kormann@sophia.inria.fr">Thierry Kormann</a>
* @version $Id: IntegerKey.java,v 1.1 2001/03/28 06:51:24 tkormann Exp $
*/
public class IntegerKey extends TranscodingHints.Key {
public boolean isCompatibleValue(Object v) {
return (v instanceof Integer);
}
}
1.1 xml-batik/sources/org/apache/batik/transcoder/keys/LengthKey.java
Index: LengthKey.java
===================================================================
/*****************************************************************************
* Copyright (C) The Apache Software Foundation. All rights reserved. *
* ------------------------------------------------------------------------- *
* This software is published under the terms of the Apache Software License *
* version 1.1, a copy of which has been included with this distribution in *
* the LICENSE file. *
*****************************************************************************/
package org.apache.batik.transcoder.keys;
import org.apache.batik.transcoder.TranscodingHints;
/**
* A transcoding Key represented as a length.
*
* @author <a href="mailto:Thierry.Kormann@sophia.inria.fr">Thierry Kormann</a>
* @version $Id: LengthKey.java,v 1.1 2001/03/28 06:51:24 tkormann Exp $
*/
public class LengthKey extends TranscodingHints.Key {
public boolean isCompatibleValue(Object v) {
return (v instanceof Float && ((Float)v).floatValue() > 0);
}
}
1.1 xml-batik/sources/org/apache/batik/transcoder/keys/PaintKey.java
Index: PaintKey.java
===================================================================
/*****************************************************************************
* Copyright (C) The Apache Software Foundation. All rights reserved. *
* ------------------------------------------------------------------------- *
* This software is published under the terms of the Apache Software License *
* version 1.1, a copy of which has been included with this distribution in *
* the LICENSE file. *
*****************************************************************************/
package org.apache.batik.transcoder.keys;
import java.awt.Paint;
import org.apache.batik.transcoder.TranscodingHints;
/**
* A transcoding Key represented as a background paint.
*
* @author <a href="mailto:Thierry.Kormann@sophia.inria.fr">Thierry Kormann</a>
* @version $Id: PaintKey.java,v 1.1 2001/03/28 06:51:24 tkormann Exp $
*/
public class PaintKey extends TranscodingHints.Key {
public boolean isCompatibleValue(Object v) {
return (v instanceof Paint);
}
}
1.1 xml-batik/sources/org/apache/batik/transcoder/keys/Rectangle2DKey.java
Index: Rectangle2DKey.java
===================================================================
/*****************************************************************************
* Copyright (C) The Apache Software Foundation. All rights reserved. *
* ------------------------------------------------------------------------- *
* This software is published under the terms of the Apache Software License *
* version 1.1, a copy of which has been included with this distribution in *
* the LICENSE file. *
*****************************************************************************/
package org.apache.batik.transcoder.keys;
import java.awt.geom.Rectangle2D;
import org.apache.batik.transcoder.TranscodingHints;
/**
* A transcoding Key represented as a rectangle.
*
* @author <a href="mailto:Thierry.Kormann@sophia.inria.fr">Thierry Kormann</a>
* @version $Id: Rectangle2DKey.java,v 1.1 2001/03/28 06:51:24 tkormann Exp $
*/
public class Rectangle2DKey extends TranscodingHints.Key {
public boolean isCompatibleValue(Object v) {
return (v instanceof Rectangle2D);
}
}
1.1 xml-batik/sources/org/apache/batik/transcoder/keys/StringKey.java
Index: StringKey.java
===================================================================
/*****************************************************************************
* Copyright (C) The Apache Software Foundation. All rights reserved. *
* ------------------------------------------------------------------------- *
* This software is published under the terms of the Apache Software License *
* version 1.1, a copy of which has been included with this distribution in *
* the LICENSE file. *
*****************************************************************************/
package org.apache.batik.transcoder.keys;
import org.apache.batik.transcoder.TranscodingHints;
/**
* A transcoding Key represented as a string.
*
* @author <a href="mailto:Thierry.Kormann@sophia.inria.fr">Thierry Kormann</a>
* @version $Id: StringKey.java,v 1.1 2001/03/28 06:51:24 tkormann Exp $
*/
public class StringKey extends TranscodingHints.Key {
public boolean isCompatibleValue(Object v) {
return (v instanceof String);
}
}
1.4 +189 -30 xml-batik/sources/org/apache/batik/transcoder/print/PrintTranscoder.java
Index: PrintTranscoder.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/transcoder/print/PrintTranscoder.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- PrintTranscoder.java 2001/03/18 18:18:19 1.3
+++ PrintTranscoder.java 2001/03/28 06:51:25 1.4
@@ -10,8 +10,8 @@
import java.awt.Cursor;
import java.awt.Dimension;
-import java.awt.Graphics;
import java.awt.Graphics2D;
+import java.awt.Graphics;
import java.awt.Point;
import java.awt.RenderingHints;
import java.awt.Shape;
@@ -23,11 +23,11 @@
import java.awt.image.BufferedImage;
import java.awt.image.DataBufferInt;
import java.awt.image.SinglePixelPackedSampleModel;
-import java.awt.print.Printable;
import java.awt.print.PageFormat;
import java.awt.print.Paper;
-import java.awt.print.PrinterJob;
+import java.awt.print.Printable;
import java.awt.print.PrinterException;
+import java.awt.print.PrinterJob;
import java.io.File;
import java.io.IOException;
@@ -42,8 +42,8 @@
import org.apache.batik.dom.svg.SVGOMDocument;
import org.apache.batik.dom.util.DocumentFactory;
-import org.apache.batik.gvt.GraphicsNodeRenderContext;
import org.apache.batik.gvt.GraphicsNode;
+import org.apache.batik.gvt.GraphicsNodeRenderContext;
import org.apache.batik.gvt.TextPainter;
import org.apache.batik.gvt.filter.GraphicsNodeRableFactory;
@@ -64,6 +64,12 @@
import org.apache.batik.transcoder.TranscodingHints;
import org.apache.batik.transcoder.XMLAbstractTranscoder;
+import org.apache.batik.transcoder.keys.BooleanKey;
+import org.apache.batik.transcoder.keys.FloatKey;
+import org.apache.batik.transcoder.keys.LengthKey;
+import org.apache.batik.transcoder.keys.Rectangle2DKey;
+import org.apache.batik.transcoder.keys.StringKey;
+
import org.apache.batik.util.SVGConstants;
import org.w3c.dom.DOMException;
@@ -99,10 +105,32 @@
* </ul>
*
* @author <a href="mailto:vincent.hardy@eng.sun.com">Vincent Hardy</a>
- * @version $Id: PrintTranscoder.java,v 1.3 2001/03/18 18:18:19 vhardy Exp $
+ * @version $Id: PrintTranscoder.java,v 1.4 2001/03/28 06:51:25 tkormann Exp $
*/
public class PrintTranscoder extends XMLAbstractTranscoder
- implements Printable{
+ implements Printable {
+
+ public static final String KEY_AOI_STR = "aoi";
+ public static final String KEY_HEIGHT_STR = "height";
+ public static final String KEY_LANGUAGE_STR = "language";
+ public static final String KEY_MARGIN_BOTTOM_STR = "marginBottom";
+ public static final String KEY_MARGIN_LEFT_STR = "marginLeft";
+ public static final String KEY_MARGIN_RIGHT_STR = "marginRight";
+ public static final String KEY_MARGIN_TOP_STR = "marginTop";
+ public static final String KEY_PAGE_HEIGHT_STR = "pageHeight";
+ public static final String KEY_PAGE_ORIENTATION_STR = "pageOrientation";
+ public static final String KEY_PAGE_WIDTH_STR = "pageWidth";
+ public static final String KEY_PIXEL_TO_MM_STR = "pixelToMm";
+ public static final String KEY_SCALE_TO_PAGE_STR = "scaleToPage";
+ public static final String KEY_SHOW_PAGE_DIALOG_STR = "showPageDialog";
+ public static final String KEY_SHOW_PRINTER_DIALOG_STR = "showPrinterDialog";
+ public static final String KEY_USER_STYLESHEET_URI_STR = "userStylesheet";
+ public static final String KEY_WIDTH_STR = "width";
+ public static final String KEY_XML_PARSER_CLASSNAME_STR = "xmlParserClassName";
+ public static final String VALUE_PAGE_ORIENTATION_LANDSCAPE = "landscape";
+ public static final String VALUE_PAGE_ORIENTATION_PORTRAIT = "portrait";
+ public static final String VALUE_PAGE_ORIENTATION_REVERSE_LANDSCAPE = "reverseLandscape";
+
/**
* Set of inputs this transcoder has been requested to
* transcode so far
@@ -527,7 +555,151 @@
return nodeRenderContext;
}
+ // --------------------------------------------------------------------
+ // Keys definition
+ // --------------------------------------------------------------------
+
+ /**
+ * The image width key.
+ * <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1">
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Key: </TH>
+ * <TD VALIGN="TOP">KEY_WIDTH</TD></TR>
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Value: </TH>
+ * <TD VALIGN="TOP">Float</TD></TR>
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Default: </TH>
+ * <TD VALIGN="TOP">The width of the top most svg element</TD></TR>
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Required: </TH>
+ * <TD VALIGN="TOP">No</TD></TR>
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Description: </TH>
+ * <TD VALIGN="TOP">Specify the width of the image to create.</TD></TR>
+ * </TABLE> */
+ public static final TranscodingHints.Key KEY_WIDTH
+ = new LengthKey();
+
+ /**
+ * The image height key.
+ * <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1">
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Key: </TH>
+ * <TD VALIGN="TOP">KEY_HEIGHT</TD></TR>
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Value: </TH>
+ * <TD VALIGN="TOP">Float</TD></TR>
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Default: </TH>
+ * <TD VALIGN="TOP">The height of the top most svg element</TD></TR>
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Required: </TH>
+ * <TD VALIGN="TOP">No</TD></TR>
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Description: </TH>
+ * <TD VALIGN="TOP">Specify the height of the image to create.</TD></TR>
+ * </TABLE> */
+ public static final TranscodingHints.Key KEY_HEIGHT
+ = new LengthKey();
+
+ /**
+ * The area of interest key.
+ * <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1">
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Key: </TH>
+ * <TD VALIGN="TOP">KEY_AOI</TD></TR>
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Value: </TH>
+ * <TD VALIGN="TOP">Rectangle2D</TD></TR>
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Default: </TH>
+ * <TD VALIGN="TOP">The document's size</TD></TR>
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Required: </TH>
+ * <TD VALIGN="TOP">No</TD></TR>
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Description: </TH>
+ * <TD VALIGN="TOP">Specify the area of interest to render. The
+ * rectangle coordinates must be specified in pixels and in the
+ * document coordinates system.</TD></TR>
+ * </TABLE>
+ */
+ public static final TranscodingHints.Key KEY_AOI
+ = new Rectangle2DKey();
+
+ /**
+ * The language key.
+ * <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1">
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Key: </TH>
+ * <TD VALIGN="TOP">KEY_LANGUAGE</TD></TR>
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Value: </TH>
+ * <TD VALIGN="TOP">String</TD></TR>
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Default: </TH>
+ * <TD VALIGN="TOP">"en"</TD></TR>
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Required: </TH>
+ * <TD VALIGN="TOP">No</TD></TR>
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Description: </TH>
+ * <TD VALIGN="TOP">Specify the preferred language of the document.
+ * </TD></TR>
+ * </TABLE>
+ */
+ public static final TranscodingHints.Key KEY_LANGUAGE
+ = new StringKey();
+
+ /**
+ * The user stylesheet URI key.
+ * <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1">
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Key: </TH>
+ * <TD VALIGN="TOP">KEY_USER_STYLESHEET_URI</TD></TR>
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Value: </TH>
+ * <TD VALIGN="TOP">String</TD></TR>
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Default: </TH>
+ * <TD VALIGN="TOP">null</TD></TR>
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Required: </TH>
+ * <TD VALIGN="TOP">No</TD></TR>
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Description: </TH>
+ * <TD VALIGN="TOP">Specify the user style sheet.</TD></TR>
+ * </TABLE>
+ */
+ public static final TranscodingHints.Key KEY_USER_STYLESHEET_URI
+ = new StringKey();
+
/**
+ * The pixel to millimeter conversion factor key.
+ * <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1">
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Key: </TH>
+ * <TD VALIGN="TOP">KEY_PIXEL_TO_MM</TD></TR>
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Value: </TH>
+ * <TD VALIGN="TOP">Float</TD></TR>
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Default: </TH>
+ * <TD VALIGN="TOP">0.33</TD></TR>
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Required: </TH>
+ * <TD VALIGN="TOP">No</TD></TR>
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Description: </TH>
+ * <TD VALIGN="TOP">Specify the pixel to millimeter conversion factor.
+ * </TD></TR>
+ * </TABLE>
+ */
+ public static final TranscodingHints.Key KEY_PIXEL_TO_MM
+ = new FloatKey();
+
+ /**
* The showPageDialog key.
* <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1">
* <TR>
@@ -549,8 +721,7 @@
* the page format.</TD></TR>
* </TABLE> */
public static final TranscodingHints.Key KEY_SHOW_PAGE_DIALOG
- = new BooleanKey(1);
- public static final String KEY_SHOW_PAGE_DIALOG_STR = "showPageDialog";
+ = new BooleanKey();
/**
* The showPrinterDialog key.
@@ -576,8 +747,7 @@
* printer.</TD></TR>
* </TABLE> */
public static final TranscodingHints.Key KEY_SHOW_PRINTER_DIALOG
- = new BooleanKey(2);
- public static final String KEY_SHOW_PRINTER_DIALOG_STR = "showPrinterDialog";
+ = new BooleanKey();
/**
@@ -722,8 +892,7 @@
* <TD VALIGN="TOP">The width of the print page</TD></TR>
* </TABLE> */
public static final TranscodingHints.Key KEY_PAGE_WIDTH
- = new LengthKey(21);
- public static final String KEY_PAGE_WIDTH_STR = "pageWidth";
+ = new LengthKey();
/**
* The pageHeight key.
@@ -745,8 +914,7 @@
* <TD VALIGN="TOP">The height of the print page</TD></TR>
* </TABLE> */
public static final TranscodingHints.Key KEY_PAGE_HEIGHT
- = new LengthKey(22);
- public static final String KEY_PAGE_HEIGHT_STR = "pageHeight";
+ = new LengthKey();
/**
* The marginTop key.
@@ -768,10 +936,8 @@
* <TD VALIGN="TOP">The print page top margin</TD></TR>
* </TABLE> */
public static final TranscodingHints.Key KEY_MARGIN_TOP
- = new LengthKey(23);
- public static final String KEY_MARGIN_TOP_STR = "marginTop";
+ = new LengthKey();
-
/**
* The marginRight key.
* <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1">
@@ -792,8 +958,7 @@
* <TD VALIGN="TOP">The print page right margin</TD></TR>
* </TABLE> */
public static final TranscodingHints.Key KEY_MARGIN_RIGHT
- = new LengthKey(24);
- public static final String KEY_MARGIN_RIGHT_STR = "marginRight";
+ = new LengthKey();
/**
* The marginBottom key.
@@ -815,8 +980,7 @@
* <TD VALIGN="TOP">The print page bottom margin</TD></TR>
* </TABLE> */
public static final TranscodingHints.Key KEY_MARGIN_BOTTOM
- = new LengthKey(25);
- public static final String KEY_MARGIN_BOTTOM_STR = "marginBottom";
+ = new LengthKey();
/**
* The marginLeft key.
@@ -838,8 +1002,7 @@
* <TD VALIGN="TOP">The print page left margin</TD></TR>
* </TABLE> */
public static final TranscodingHints.Key KEY_MARGIN_LEFT
- = new LengthKey(26);
- public static final String KEY_MARGIN_LEFT_STR = "marginLeft";
+ = new LengthKey();
/**
* The pageOrientation key.
@@ -861,12 +1024,9 @@
* <TD VALIGN="TOP">The print page's orientation</TD></TR>
* </TABLE> */
public static final TranscodingHints.Key KEY_PAGE_ORIENTATION
- = new StringKey(27);
- public static final String KEY_PAGE_ORIENTATION_STR = "pageOrientation";
- public static final String VALUE_PAGE_ORIENTATION_PORTRAIT = "portrait";
- public static final String VALUE_PAGE_ORIENTATION_LANDSCAPE = "landscape";
- public static final String VALUE_PAGE_ORIENTATION_REVERSE_LANDSCAPE = "reverseLandscape";
+ = new StringKey();
+
/**
* The scaleToPage key.
* <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1">
@@ -888,8 +1048,7 @@
* fit into the printed page</TD></TR>
* </TABLE> */
public static final TranscodingHints.Key KEY_SCALE_TO_PAGE
- = new BooleanKey(28);
- public static final String KEY_SCALE_TO_PAGE_STR = "scaleToPage";
+ = new BooleanKey();
public static final String USAGE = "java org.apache.batik.transcoder.print.PrintTranscoder <svgFileToPrint>";
1.4 +18 -52 xml-batik/sources/org/apache/batik/transcoder/svg2svg/SVGTranscoder.java
Index: SVGTranscoder.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/transcoder/svg2svg/SVGTranscoder.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- SVGTranscoder.java 2001/02/15 15:57:52 1.3
+++ SVGTranscoder.java 2001/03/28 06:51:25 1.4
@@ -21,6 +21,9 @@
import org.apache.batik.transcoder.TranscoderInput;
import org.apache.batik.transcoder.TranscoderOutput;
import org.apache.batik.transcoder.TranscodingHints;
+import org.apache.batik.transcoder.keys.BooleanKey;
+import org.apache.batik.transcoder.keys.IntegerKey;
+import org.apache.batik.transcoder.keys.StringKey;
import org.apache.batik.xml.scanner.LexicalException;
@@ -30,7 +33,7 @@
* This class is a trancoder from SVG to SVG.
*
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
- * @version $Id: SVGTranscoder.java,v 1.3 2001/02/15 15:57:52 hillion Exp $
+ * @version $Id: SVGTranscoder.java,v 1.4 2001/03/28 06:51:25 tkormann Exp $
*/
public class SVGTranscoder extends AbstractTranscoder {
@@ -52,7 +55,7 @@
/**
* The key to specify the newline character sequence.
*/
- public final static TranscodingHints.Key KEY_NEWLINE = new NewlineKey(0);
+ public final static TranscodingHints.Key KEY_NEWLINE = new NewlineKey();
/**
* The "\r" newline value.
@@ -72,7 +75,7 @@
/**
* The key to specify whether to format the input.
*/
- public final static TranscodingHints.Key KEY_FORMAT = new BooleanKey(0);
+ public final static TranscodingHints.Key KEY_FORMAT = new BooleanKey();
/**
* The value to turn on formatting.
@@ -87,17 +90,20 @@
/**
* The key to specify the tabulation width.
*/
- public final static TranscodingHints.Key KEY_TABULATION_WIDTH = new IntegerKey(0);
+ public final static TranscodingHints.Key KEY_TABULATION_WIDTH
+ = new IntegerKey();
/**
* The key to specify the document width.
*/
- public final static TranscodingHints.Key KEY_DOCUMENT_WIDTH = new IntegerKey(1);
+ public final static TranscodingHints.Key KEY_DOCUMENT_WIDTH
+ = new IntegerKey();
/**
* The key to specify the doctype option.
*/
- public final static TranscodingHints.Key KEY_DOCTYPE = new DoctypeKey(0);
+ public final static TranscodingHints.Key KEY_DOCTYPE
+ = new DoctypeKey();
/**
* The doctype value to change the declaration.
@@ -120,17 +126,20 @@
/**
* The key to specify the public id.
*/
- public final static TranscodingHints.Key KEY_PUBLIC_ID = new StringKey(0);
+ public final static TranscodingHints.Key KEY_PUBLIC_ID
+ = new StringKey();
/**
* The key to specify the system id.
*/
- public final static TranscodingHints.Key KEY_SYSTEM_ID = new StringKey(1);
+ public final static TranscodingHints.Key KEY_SYSTEM_ID
+ = new StringKey();
/**
* The key to specify the XML declaration option.
*/
- public final static TranscodingHints.Key KEY_XML_DECLARATION = new StringKey(2);
+ public final static TranscodingHints.Key KEY_XML_DECLARATION
+ = new StringKey();
/**
* Creates a new SVGTranscoder.
@@ -221,9 +230,6 @@
* To represent a newline key.
*/
protected static class NewlineKey extends TranscodingHints.Key {
- public NewlineKey(int privatekey) {
- super(privatekey);
- }
public boolean isCompatibleValue(Object v) {
return v instanceof NewlineValue;
}
@@ -246,9 +252,6 @@
* To represent a doctype key.
*/
protected static class DoctypeKey extends TranscodingHints.Key {
- public DoctypeKey(int privatekey) {
- super(privatekey);
- }
public boolean isCompatibleValue(Object v) {
return v instanceof DoctypeValue;
}
@@ -266,41 +269,4 @@
return value;
}
}
-
- /**
- * To represent a boolean key.
- */
- protected static class BooleanKey extends TranscodingHints.Key {
- public BooleanKey(int privatekey) {
- super(privatekey);
- }
- public boolean isCompatibleValue(Object v) {
- return v instanceof Boolean;
- }
- }
-
- /**
- * To represent a integer key.
- */
- protected static class IntegerKey extends TranscodingHints.Key {
- public IntegerKey(int privatekey) {
- super(privatekey);
- }
- public boolean isCompatibleValue(Object v) {
- return v instanceof Integer;
- }
- }
-
- /**
- * To represent a string key.
- */
- protected static class StringKey extends TranscodingHints.Key {
- public StringKey(int privatekey) {
- super(privatekey);
- }
- public boolean isCompatibleValue(Object v) {
- return v instanceof String;
- }
- }
-
}
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-dev-help@xml.apache.org