cox.jmatt.java.MathTools.markup.latex
Class LaDocument

java.lang.Object
  extended by cox.jmatt.java.MathTools.markup.latex.LaBaseTag
      extended by cox.jmatt.java.MathTools.markup.latex.LaDocument

public class LaDocument
extends LaBaseTag

This class represents the entire LaTeX document. It provides equipment to handle the preamble, the title and any other document-wide configuration that might be needed. When either toString() method is called the result is a complete LaTeX document, ready for rendering.

There are three basic types of methods here: document structure methods, editing methods and convenience methods. The structuring methods affect the preamble and the overall document. The editing methods add content to the document itself. The convenience methods present shortcuts to such things as changing font size or adding MathGenLatex.LaSymbols to the document body.

The document class is set by the setType() method, see it for the types available. This can be set any time before toString() as can any of the other structure methods. The editing (and convenience) methods all append to the end of the current content so order is important there. Since this class represents the final form of a LaTeX document there are no end-tag-suppressed options. Both copyOfSET() and toStringSET() return non-SET values.


Field Summary
 
Fields inherited from class cox.jmatt.java.MathTools.markup.latex.LaBaseTag
BS, DBS, DBSN, myAuthor, myDate, myEndTag, myEnvironment, myEnvParams, myOptions, myPicHasOrigin, myPicX, myPicXOrigin, myPicY, myPicYOrigin, mySectionLabel, myTagName, myTitle
 
Constructor Summary
LaDocument()
          Standard constructor.
 
Method Summary
 LaDocument add(LaBaseTag pTag)
          Add a LaBaseTag to the current content.
 LaDocument addChapter(java.lang.String pData)
          Add a '/chapter{}' tag.
 LaDocument addComment(java.lang.String pComment)
          Add a single-line comment to the document text.
 LaDocument addFS(java.lang.String pFontSize, java.lang.String pText)
          Convenience method to alter the font size of the text.
 LaDocument addLine(int pHeight)
          Add a blank line to the document.
 LaDocument addLine(java.lang.String pLine)
          Add a line of text to the content.
 LaDocument addParagraph(java.lang.String pData)
          Add a '/paragraph{}' tag.
 LaDocument addPParagraph(java.lang.String pData)
          Add a '/subparagraph{}' tag.
 LaDocument addRaw(java.lang.String pText)
          Add raw text to the current content.
 LaDocument addSection(java.lang.String pData)
          Add a '/section{}' tag.
 LaDocument addSSection(java.lang.String pData)
          Add a '/subsection{}' tag.
 LaDocument addSSSection(java.lang.String pData)
          Add a '/subsubsection{}' tag.
 LaDocument addSymbol(int pNumDS, java.lang.String pBefore, java.lang.String pAfter, java.lang.String pSymbol, java.lang.String... pParams)
          Add a MathGenLatex.LaSymbol to the current content.
 LaDocument addSymbol(java.lang.String pSymbol, java.lang.String... pParams)
          This is the quick version of addSymbol().
 LaDocument copyOf()
          Create and return a copy of this document.
 LaDocument copyOfSET()
          No document is ever without its end tag.
 LaDocument include(java.lang.String pFile, boolean pInclude)
          Include the contents of an external file in the document.
 LaDocument newline()
          Add a '/newline' to the document.
 LaDocument newPage()
          Add a '/newpage' directive to the document.
 void reset()
          Overridden to clear document-specific information: title, author, date, packages etc.
 LaDocument setDocOptions(java.lang.String pOptions)
          This method sets any options that appear with the '/documentclass[]...' tag.
 LaDocument setTitle(java.lang.String pTitle, java.lang.String pAuthor, java.lang.String pDate)
          Set all title information.
 LaDocument setType(char pType)
          Set the '/documentclass' of this document.
 java.lang.String toString()
          Overridden to include the preamble before the 'begin...' tag.
 java.lang.String toStringSET()
          This class always has its end tag.
 LaDocument usePackage(java.lang.String pPackage, java.lang.String pOpts)
          This method provides the '/usepackage...' commands.
 
Methods inherited from class cox.jmatt.java.MathTools.markup.latex.LaBaseTag
_addContent, _addRawContent, _getContent, _setEndTagEnabled, _setETEn, getEndTag, hasEndTag, isEndTagEnabled, setLabel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LaDocument

public LaDocument()
Standard constructor. Default document class is 'article.'

Method Detail

setTitle

public LaDocument setTitle(java.lang.String pTitle,
                           java.lang.String pAuthor,
                           java.lang.String pDate)
Set all title information. All parameters are optional but if 'pTitle' is null or blank no title information will be printed.

Parameters:
pTitle - The document title.
pAuthor - The document author.
pDate - The date for the document.

setType

public LaDocument setType(char pType)

Set the '/documentclass' of this document. Six options are available and each is represented by a single character:

Uppercase characters also work. Any character other than one of the ones above results in 'article' being set.


setDocOptions

public LaDocument setDocOptions(java.lang.String pOptions)
This method sets any options that appear with the '/documentclass[]...' tag. Setting this to null or blank suppresses them.

Parameters:
pOptions - The options String to set on the 'documentclass' tag.

reset

public void reset()
Overridden to clear document-specific information: title, author, date, packages etc. The document class is also reset to 'article.'

Overrides:
reset in class LaBaseTag

usePackage

public LaDocument usePackage(java.lang.String pPackage,
                             java.lang.String pOpts)
This method provides the '/usepackage...' commands. The 'pOpts' parameter is optional. If not null the package options appear in square brackets at the proper place. If the package name is null or blank it is silently ignored.

Parameters:
pPackage - The package to use.
pOpts - The package options to include, or null for none.

add

public LaDocument add(LaBaseTag pTag)
Add a LaBaseTag to the current content. Any tag except LaDocument or a subclass of it can be added. The tag is added as-is via its toString() method so changing it after adding it has no effect on this content. A single newline is added at the end.

Parameters:
pTag - The tag to be added.

addLine

public LaDocument addLine(java.lang.String pLine)
Add a line of text to the content. A newline is supplied automatically. If 'pLine' is null or blank LaBaseTag.DBSN is added for a blank line.


addLine

public LaDocument addLine(int pHeight)
Add a blank line to the document.

Parameters:
pHeight - The height of the blank line in points (pt.). An extra newline is added for a blank line in the generated document.

newline

public LaDocument newline()
Add a '/newline' to the document. A newline character is appended to the end of the sequence.


newPage

public LaDocument newPage()
Add a '/newpage' directive to the document.


addComment

public LaDocument addComment(java.lang.String pComment)
Add a single-line comment to the document text. The supplied string cannot contain a newline and the comment character ('%') is prepended automatically. Null or blank comments are silently ignored.

Parameters:
pComment - A String comment to add. It must contain NO newline characters.

include

public LaDocument include(java.lang.String pFile,
                          boolean pInclude)

Include the contents of an external file in the document. Ignored if 'pFile' is null or blank. A newline is appended at the end.

The 'pInclude' parameter determines which LaTeX directive is issued: '/include' (true) or '/input' (false). In the former case LaTeX places a page break before the included material. In the latter case it does not. IMPORTANT NOTE: This method does not itself copy the file contents, it merely issues the appropriate LaTeX directive.

Parameters:
pFile - The filename containing the markup to be included.
pInclude - true to 'include,' false to 'input.'

addRaw

public LaDocument addRaw(java.lang.String pText)
Add raw text to the current content. Null or blank Strings are ignored but no other validation is performed. No newline is supplied.


addSymbol

public LaDocument addSymbol(int pNumDS,
                            java.lang.String pBefore,
                            java.lang.String pAfter,
                            java.lang.String pSymbol,
                            java.lang.String... pParams)
Add a MathGenLatex.LaSymbol to the current content. A newline is included afterward automatically. If the symbol requested is null or blank nothing happens.

Parameters:
pNumDS - The number of dollar signs to wrap around the result.
pSymbol - The symbol to add.
pParams - Any parameters required by the symbol.
pBefore - The prefix String; after the initial dollar sign(s) and before the symbol starts.
pAfter - The suffix String, after the Symbol and before the ending dollar signs and newline.

addSymbol

public LaDocument addSymbol(java.lang.String pSymbol,
                            java.lang.String... pParams)
This is the quick version of addSymbol(). It takes ONLY the symbol name and parameters. NO dollar signs, prefix or suffix.


addChapter

public LaDocument addChapter(java.lang.String pData)
Add a '/chapter{}' tag. 'pData' is the chapter name.


addSection

public LaDocument addSection(java.lang.String pData)
Add a '/section{}' tag. 'pData' is the section name.


addSSection

public LaDocument addSSection(java.lang.String pData)
Add a '/subsection{}' tag. 'pData' is the subsection name.


addSSSection

public LaDocument addSSSection(java.lang.String pData)
Add a '/subsubsection{}' tag. 'pData' is the name.


addParagraph

public LaDocument addParagraph(java.lang.String pData)
Add a '/paragraph{}' tag. 'pData' is the name.


addPParagraph

public LaDocument addPParagraph(java.lang.String pData)
Add a '/subparagraph{}' tag. 'pData' is the name.


addFS

public LaDocument addFS(java.lang.String pFontSize,
                        java.lang.String pText)

Convenience method to alter the font size of the text. This method uses the MathGenLatex.LaSymbol 'FS...' constants internally. It supplies the 'FS' so only the font style desired is needed. DO NOT include the 'FS' otherwise it will be repeated! A single newline is appended.

If either argument is null or blank nothing happens.

Parameters:
pFontSize - The ('FS'-less) name of the font effect.
pText - The text to be modified.

toString

public java.lang.String toString()
Overridden to include the preamble before the 'begin...' tag.

Overrides:
toString in class LaBaseTag

toStringSET

public java.lang.String toStringSET()
This class always has its end tag. This method echoes toString().

Overrides:
toStringSET in class LaBaseTag

copyOf

public LaDocument copyOf()
Create and return a copy of this document.

Specified by:
copyOf in class LaBaseTag

copyOfSET

public LaDocument copyOfSET()
No document is ever without its end tag. This method simply calls copyOf().

Specified by:
copyOfSET in class LaBaseTag