org.extex.backend.documentWriter.postscript
Class AbstractPostscriptWriter

java.lang.Object
  extended by org.extex.backend.documentWriter.postscript.AbstractPostscriptWriter
All Implemented Interfaces:
DocumentWriter, MultipleDocumentStream, ColorAware, FontAware, Configurable, ResourceAware
Direct Known Subclasses:
EpsWriter, PsWriter

public abstract class AbstractPostscriptWriter
extends java.lang.Object
implements DocumentWriter, Configurable, MultipleDocumentStream, ResourceAware, FontAware, ColorAware

This is the abstract base class for document writers producing PostScript code. Here some utility methods of general nature are collected.

Version:
$Revision: 5923 $
Author:
Gerd Neugebauer

Field Summary
protected static byte[] COMMENT
          The constant COMMENT contains two percent signs as start of a comment.
protected static java.text.DateFormat DF
          The field DF contains the formatter for the date.
 
Constructor Summary
AbstractPostscriptWriter(java.lang.String extension)
          Creates a new object.
 
Method Summary
 void configure(Configuration config)
          Configure an object according to a given Configuration.
protected  PsConverter getConverter()
          Create a PostScript converter.
 java.lang.String getExtension()
          Getter for the extension associated with this kind of output.
 CoreFontFactory getFontFactory()
          Getter for fontFactory.
protected  FontManager getFontManager()
          Getter for fontManager.
protected  java.lang.String getParameter(java.lang.String name)
          Getter for a named parameter.
protected  java.io.PrintStream newOutputStream(java.lang.String type)
          Acquire a new output stream.
 void setColorConverter(ColorConverter converter)
          Setter for the color converter.
protected  void setExtension(java.lang.String extension)
          Setter for extension.
 void setFontFactory(CoreFontFactory factory)
          Setter for the font factory.
 void setOutputStreamFactory(OutputStreamFactory factory)
          Setter for the output stream.
 void setParameter(java.lang.String name, java.lang.String value)
          Setter for a named parameter.
 void setResourceFinder(ResourceFinder resourceFinder)
          Setter for the resource finder.
protected  void startFile(java.io.PrintStream out, java.lang.String magicVersion)
          Fill the initial segment of a PostScript file.
protected  void writeBoundingBox(java.io.PrintStream stream, FixedDimen width, FixedDimen height)
          Write a BoundingBox DSC to an output stream.
protected  void writeDsc(java.io.PrintStream stream, java.lang.String name, java.lang.String... values)
          Write a meta comment according to the Document Structuring Conventions.
protected  void writeFonts(java.io.PrintStream stream, FontManager fontManager)
          Write a meta comment according to the Document Structuring Conventions containing the DocumentFonts.
protected  void writeHighResBoundingBox(java.io.PrintStream stream, NodeList nodes)
          Write a HiResBoundingBox DSC to an output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.extex.backend.documentWriter.DocumentWriter
close, shipout
 

Field Detail

COMMENT

protected static final byte[] COMMENT
The constant COMMENT contains two percent signs as start of a comment.


DF

protected static final java.text.DateFormat DF
The field DF contains the formatter for the date.

Constructor Detail

AbstractPostscriptWriter

public AbstractPostscriptWriter(java.lang.String extension)
Creates a new object.

Parameters:
extension - the default extension
Method Detail

configure

public void configure(Configuration config)
               throws ConfigurationException
Configure an object according to a given Configuration.

Specified by:
configure in interface Configurable
Parameters:
config - the configuration object to consider
Throws:
ConfigurationException - in case that something went wrong
See Also:
Configurable.configure( org.extex.framework.configuration.Configuration)

getConverter

protected PsConverter getConverter()
                            throws java.io.IOException
Create a PostScript converter.

Returns:
the new converter
Throws:
java.io.IOException - in case of an IO error

getExtension

public java.lang.String getExtension()
Getter for the extension associated with this kind of output. For instance pdf is the expected value for PDF files and dvi is the expected value for DVI files.

Specified by:
getExtension in interface DocumentWriter
Returns:
the appropriate extension for file names
See Also:
DocumentWriter.getExtension()

getFontFactory

public CoreFontFactory getFontFactory()
Getter for fontFactory.

Returns:
the fontFactory

getFontManager

protected FontManager getFontManager()
Getter for fontManager.

Returns:
the fontManager

getParameter

protected java.lang.String getParameter(java.lang.String name)
Getter for a named parameter.

Parameters:
name - the name of the parameter
Returns:
the value of the parameter or null if none exists

newOutputStream

protected java.io.PrintStream newOutputStream(java.lang.String type)
                                       throws DocumentWriterException
Acquire a new output stream.

Parameters:
type - the type for the reference to the configuration file
Returns:
the new output stream
Throws:
DocumentWriterException - in case of an error

setColorConverter

public void setColorConverter(ColorConverter converter)
Setter for the color converter.

Specified by:
setColorConverter in interface ColorAware
Parameters:
converter - the color converter
See Also:
ColorAware.setColorConverter( org.extex.color.ColorConverter)

setExtension

protected void setExtension(java.lang.String extension)
Setter for extension.

Parameters:
extension - the extension to set

setFontFactory

public void setFontFactory(CoreFontFactory factory)
Setter for the font factory.

Specified by:
setFontFactory in interface FontAware
Parameters:
factory - the font factory
See Also:
FontAware.setFontFactory(org.extex.font.CoreFontFactory)

setOutputStreamFactory

public void setOutputStreamFactory(OutputStreamFactory factory)
Setter for the output stream.

Specified by:
setOutputStreamFactory in interface MultipleDocumentStream
Parameters:
factory - the output stream
See Also:
MultipleDocumentStream.setOutputStreamFactory( org.extex.backend.outputStream.OutputStreamFactory)

setParameter

public void setParameter(java.lang.String name,
                         java.lang.String value)
Setter for a named parameter. Parameters are a general mechanism to influence the behavior of the document writer. Any parameter not known by the document writer has to be ignored.

This document writer uses the following parameters:

Creator
This is the identifier of the creating component. The default value is ExTeX-Backend-ps.
Title
This is the title of the document. The default is empty.
PageOrder
This parameter denotes the order in which pages are contained. The default is Ascend. It denotes ascending order of pages. Alternately the value Descend can e used to denote descending order. Any other value is silently interpreted to be the same as Ascend

Specified by:
setParameter in interface DocumentWriter
Parameters:
name - the name of the parameter
value - the value of the parameter
See Also:
DocumentWriter.setParameter( java.lang.String, java.lang.String)

setResourceFinder

public void setResourceFinder(ResourceFinder resourceFinder)
Setter for the resource finder.

Specified by:
setResourceFinder in interface ResourceAware
Parameters:
resourceFinder - the resource finder
See Also:
ResourceAware.setResourceFinder( org.extex.resource.ResourceFinder)

startFile

protected void startFile(java.io.PrintStream out,
                         java.lang.String magicVersion)
                  throws java.io.IOException
Fill the initial segment of a PostScript file.

Parameters:
out - the output stream
magicVersion - the version string
Throws:
java.io.IOException - in case of an I/O error

writeBoundingBox

protected void writeBoundingBox(java.io.PrintStream stream,
                                FixedDimen width,
                                FixedDimen height)
                         throws java.io.IOException
Write a BoundingBox DSC to an output stream.

Parameters:
stream - the target stream to write to
width - the width
height - the height (including the depth)
Throws:
java.io.IOException - in case of an error during writing

writeDsc

protected void writeDsc(java.io.PrintStream stream,
                        java.lang.String name,
                        java.lang.String... values)
                 throws java.io.IOException
Write a meta comment according to the Document Structuring Conventions.

Parameters:
stream - the target stream to write to
name - the name of the DSC comment
values - the value of the DSC comment
Throws:
java.io.IOException - in case of an error during writing

writeFonts

protected void writeFonts(java.io.PrintStream stream,
                          FontManager fontManager)
                   throws java.io.IOException
Write a meta comment according to the Document Structuring Conventions containing the DocumentFonts.

Parameters:
stream - the target stream to write to
fontManager - the font manager to ask for the fonts
Throws:
java.io.IOException - in case of an error during writing

writeHighResBoundingBox

protected void writeHighResBoundingBox(java.io.PrintStream stream,
                                       NodeList nodes)
                                throws java.io.IOException
Write a HiResBoundingBox DSC to an output stream.

Parameters:
stream - the target stream to write to
nodes - the nodes to extract the dimensions from
Throws:
java.io.IOException - in case of an error during writing