com.sun.electric.tool.io.output
Class Output

java.lang.Object
  extended by com.sun.electric.tool.io.output.Output
Direct Known Subclasses:
ArchSim, DXF, Eagle, ECAD, ELIB, FastHenry, Geometry, HPGL, IRSIM, JELIB, L, LEF, Maxwell, Pads, PAL, PNG, PostScript, Sim, Topology

public class Output
extends java.lang.Object

This class manages writing files in different formats. The class is subclassed by the different file writers.


Nested Class Summary
static class Output.OutputPreferences
           
static class Output.WriteJELIB
          Class to write a library in a CHANGE Job.
 
Field Summary
protected  java.io.DataOutputStream dataOutputStream
          for writing binary files
protected  ErrorLogger errorLogger
          for storing generated errors
protected  java.lang.String filePath
          file path
protected  java.io.PrintWriter printWriter
          for writing text files
protected  boolean quiet
          True to write with less information displayed
protected  java.io.StringWriter stringWriter
          for writing text arrays
 
Constructor Summary
Output()
           
 
Method Summary
protected  boolean closeBinaryOutputStream()
          Close output for writing binary to a file.
protected  java.util.List<java.lang.String> closeStringsOutputStream()
          Close output for collecting a list of strings.
protected  boolean closeTextOutputStream()
          Close output for writing text to a file.
protected  void emitCopyright(java.lang.String prefix, java.lang.String postfix)
          Method to write copyright header information to the output.
static void exportCellCommand(Cell cell, VarContext context, java.lang.String fileP, FileType type, java.util.List<PolyBase> override)
          This is the non-interactive version of exportCellCommand
protected  Output finishWrite()
          Method to terminate the logging process in the ErrorLogger
static java.awt.geom.Rectangle2D getAreaToPrint(Cell cell, boolean reduce, EditWindow_ wnd)
          Method to determine the area of a cell that is to be printed.
 int getNumErrors()
          Method to retrieve number of errors during the writing process
 int getNumWarnings()
          Method to retrieve number of warnings during the writting process
static Output.OutputPreferences getOutputPreferences(FileType type, Cell cell, boolean factory, java.util.List<PolyBase> override)
          Return OutputPreferences for a specified FileType.
protected  boolean openBinaryOutputStream(java.lang.String filePath)
          Opens output for writing binary files.
protected  void openStringsOutputStream()
          Open output for collecting a list of strings.
protected  boolean openTextOutputStream(java.lang.String fileP)
          Open output for writing text to a file.
 void reportError(java.lang.String msg)
          Method to report errors during the output process.
protected  void reportWarning(java.lang.String msg)
          Method to report errors during the output process
static boolean saveJelib(java.lang.String newName, Library lib)
          Method to write an entire Library in JELIB format.
protected  void setContinuationString(java.lang.String str)
          Method to set the string that will be emitted at the start of a "continuation line".
protected  void setOutputWidth(int width, boolean strict)
          Method to set the size of a line of output.
protected  boolean writeCell(Cell cell, VarContext context)
          Method to write a cell.
static boolean writeLibrary(Library lib, FileType type, boolean compatibleWith6, boolean thisQuiet, boolean delibHeaderOnly, int backupScheme)
          Method to write an entire Library with a particular format.
static boolean writeLibrary(Library lib, FileType type, boolean compatibleWith6, boolean thisQuiet, boolean delibHeaderOnly, int backupScheme, java.util.List<java.lang.String> deletedCellFiles, java.util.List<java.lang.String> writtenCellFiles)
          Method to write an entire Library with a particular format.
static boolean writePanicSnapshot(Snapshot panicSnapshot, java.io.File panicDir, boolean oldRevision)
          Method to write all Libraries in Snapsht into a panic directory.
protected  void writeWidthLimited(java.lang.String str)
          Method to add a string to the output, limited by the maximum width of an output line.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

filePath

protected java.lang.String filePath
file path


printWriter

protected java.io.PrintWriter printWriter
for writing text files


stringWriter

protected java.io.StringWriter stringWriter
for writing text arrays


dataOutputStream

protected java.io.DataOutputStream dataOutputStream
for writing binary files


quiet

protected boolean quiet
True to write with less information displayed


errorLogger

protected ErrorLogger errorLogger
for storing generated errors

Constructor Detail

Output

public Output()
Method Detail

exportCellCommand

public static void exportCellCommand(Cell cell,
                                     VarContext context,
                                     java.lang.String fileP,
                                     FileType type,
                                     java.util.List<PolyBase> override)
This is the non-interactive version of exportCellCommand

Parameters:
cell - the Cell to be written.
context - the VarContext of the Cell (its position in the hierarchy above it).
fileP - the path to the disk file to be written.
type - the format of the output file.
override - a list of Polys to draw instead of the cell contents.

getOutputPreferences

public static Output.OutputPreferences getOutputPreferences(FileType type,
                                                            Cell cell,
                                                            boolean factory,
                                                            java.util.List<PolyBase> override)
Return OutputPreferences for a specified FileType. This includes currnet default values of IO ProjectSettings and either factory default or current default values of Prefs Current default value of Prefs can be obtained only from client thread

Parameters:
type - specified file type.
factory - get factory default values of Prefs
override - the list of Polys to write instead of cell contents.
Returns:
an OutputPreferences object for the given file type.
Throws:
InvalidStateException - on attemt to get current default values of Prefs from server thread

getNumErrors

public int getNumErrors()
Method to retrieve number of errors during the writing process


getNumWarnings

public int getNumWarnings()
Method to retrieve number of warnings during the writting process


writeCell

protected boolean writeCell(Cell cell,
                            VarContext context)
Method to write a cell. This method is never called. Instead, it is always overridden by the appropriate write subclass.

Parameters:
cell - the Cell to be written.
context - the VarContext of the cell (for parameter evaluation)
Returns:
true on error.

writePanicSnapshot

public static boolean writePanicSnapshot(Snapshot panicSnapshot,
                                         java.io.File panicDir,
                                         boolean oldRevision)
Method to write all Libraries in Snapsht into a panic directory.

Parameters:
panicSnapshot - Snapshot to save.
panicDir - panic directory to save.
Returns:
true on error.

saveJelib

public static boolean saveJelib(java.lang.String newName,
                                Library lib)
Method to write an entire Library in JELIB format. This method doesn't modifiy library, so it can be run out of Job.

Parameters:
newName - name which is used to prepare file name of the library.
lib - library to save

writeLibrary

public static boolean writeLibrary(Library lib,
                                   FileType type,
                                   boolean compatibleWith6,
                                   boolean thisQuiet,
                                   boolean delibHeaderOnly,
                                   int backupScheme)
Method to write an entire Library with a particular format. This is used for output formats that capture the entire library (only the ELIB and Readable Dump formats). The alternative to writing the entire library is writing a single cell and the hierarchy below it (use "writeCell").

Parameters:
lib - the Library to be written.
type - the format of the output file.
compatibleWith6 - true to write a library that is compatible with version 6 Electric.
thisQuiet - true to save with less information displayed.
delibHeaderOnly - true to write only the header for a DELIB type library
backupScheme - controls how older files are backed-up.
Returns:
true on error.

writeLibrary

public static boolean writeLibrary(Library lib,
                                   FileType type,
                                   boolean compatibleWith6,
                                   boolean thisQuiet,
                                   boolean delibHeaderOnly,
                                   int backupScheme,
                                   java.util.List<java.lang.String> deletedCellFiles,
                                   java.util.List<java.lang.String> writtenCellFiles)
Method to write an entire Library with a particular format. This is used for output formats that capture the entire library (only the ELIB and Readable Dump formats). The alternative to writing the entire library is writing a single cell and the hierarchy below it (use "writeCell").

Parameters:
lib - the Library to be written.
type - the format of the output file.
compatibleWith6 - true to write a library that is compatible with version 6 Electric.
thisQuiet - true to save with less information displayed.
delibHeaderOnly - true to write only the header for a DELIB type library
backupScheme - controls how older files are backed-up.
deletedCellFiles - output list of deleted cell files of DELIB library
writtenCellFiles - output list of written cell files of DELIB library
Returns:
true on error.

openBinaryOutputStream

protected boolean openBinaryOutputStream(java.lang.String filePath)
Opens output for writing binary files.

Parameters:
filePath - the name of the file.
Returns:
true on error.

closeBinaryOutputStream

protected boolean closeBinaryOutputStream()
Close output for writing binary to a file.

Returns:
true on error.

openTextOutputStream

protected boolean openTextOutputStream(java.lang.String fileP)
Open output for writing text to a file.

Parameters:
fileP - the name of the file.
Returns:
true on error.

closeTextOutputStream

protected boolean closeTextOutputStream()
Close output for writing text to a file.

Returns:
true on error.

openStringsOutputStream

protected void openStringsOutputStream()
Open output for collecting a list of strings.


closeStringsOutputStream

protected java.util.List<java.lang.String> closeStringsOutputStream()
Close output for collecting a list of strings.

Returns:
the list of strings.

finishWrite

protected Output finishWrite()
Method to terminate the logging process in the ErrorLogger


reportWarning

protected void reportWarning(java.lang.String msg)
Method to report errors during the output process

Parameters:
msg -

reportError

public void reportError(java.lang.String msg)
Method to report errors during the output process. It must be public because it is used in parent package

Parameters:
msg -

emitCopyright

protected void emitCopyright(java.lang.String prefix,
                             java.lang.String postfix)
Method to write copyright header information to the output.

Parameters:
prefix - the characters that start a line of commented output.
postfix - the characters that end a line of commented output.

setOutputWidth

protected void setOutputWidth(int width,
                              boolean strict)
Method to set the size of a line of output.

Parameters:
width - the maximum number of characters on a line of output (default is 80).
strict - true to strictly enforce the line-width limit, even if it means breaking a symbol in the middle. When false, very long names may exceed the width limit.

setContinuationString

protected void setContinuationString(java.lang.String str)
Method to set the string that will be emitted at the start of a "continuation line". The continuation line is the line that follows a line which is broken up because of width limits.

Parameters:
str - the string that will be emitted at the start of a "continuation line".

writeWidthLimited

protected void writeWidthLimited(java.lang.String str)
Method to add a string to the output, limited by the maximum width of an output line.

Parameters:
str - the string to add to the output.

getAreaToPrint

public static java.awt.geom.Rectangle2D getAreaToPrint(Cell cell,
                                                       boolean reduce,
                                                       EditWindow_ wnd)
Method to determine the area of a cell that is to be printed. Returns null if the area cannot be determined.