net.sf.latexdraw.glib.views.latex
Class LaTeXGenerator

java.lang.Object
  extended by net.sf.latexdraw.glib.views.latex.LaTeXGenerator
All Implemented Interfaces:
Modifiable
Direct Known Subclasses:
PSTCodeGenerator

public abstract class LaTeXGenerator
extends java.lang.Object
implements Modifiable

Defines an abstract LaTeX generator.

This file is part of LaTeXDraw.
Copyright (c) 2005-2012 Arnaud BLOUIN

LaTeXDraw is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
LaTeXDraw is distributed without any warranty; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

05/23/2010

Since:
3.0
Author:
Arnaud BLOUIN

Nested Class Summary
static class LaTeXGenerator.VerticalPosition
          The different vertical positions.
 
Field Summary
protected  java.lang.String caption
          The caption of the drawing.
protected  java.lang.String comment
          The comment of the drawing.
protected  java.lang.String label
          The label of the drawing.
static int LGTH_START_LINE_COMMENT
          Defines the number of characters added at the beginning of each lines of the comment (these characters are "% ").
protected  boolean modified
          Defined if the instrument has been modified.
protected static IUnary<java.lang.String> PACKAGES
          The latex packages used when exporting using latex.
protected  boolean positionHoriCentre
          The horizontal position of the drawing
protected  LaTeXGenerator.VerticalPosition positionVertToken
          The token of the position of the drawing
 
Constructor Summary
LaTeXGenerator()
          Initialises the abstract generator.
 
Method Summary
static java.io.File createLatexFile(IDrawing drawing, java.lang.String pathExportTex, ViewsSynchroniserHandler synchronizer)
          Creates a latex file that contains the pstricks code of the given canvas.
static java.io.File createPDFFile(IDrawing drawing, java.lang.String pathExportPdf, ViewsSynchroniserHandler synchronizer, boolean crop)
          Create a .pdf file that corresponds to the compiled latex document containing the pstricks drawing.
static java.io.File createPSFile(IDrawing drawing, java.lang.String pathExportPs, ViewsSynchroniserHandler synchronizer)
          Create a .ps file that corresponds to the compiled latex document containing the pstricks drawing.
static java.io.File createPSFile(IDrawing drawing, java.lang.String pathExportPs, ViewsSynchroniserHandler synchronizer, java.io.File tmpDir)
          Create a .ps file that corresponds to the compiled latex document containing the pstricks drawing.
private static java.lang.String execute(java.lang.String[] cmd, java.io.File tmpdir)
           
 java.lang.String getCaption()
           
 java.lang.String getComment()
           
 java.lang.String getCommentsWithoutTag()
           
 java.lang.String getLabel()
           
static java.lang.String getLatexDocument(IDrawing drawing, ViewsSynchroniserHandler synchronizer)
          Generates a latex document that contains the pstricks code of the given canvas.
static java.lang.String getPackages()
           
static IUnary<java.lang.String> getPackagesUnary()
           
 LaTeXGenerator.VerticalPosition getPositionVertToken()
           
 boolean isModified()
           
 boolean isPositionHoriCentre()
           
 void setCaption(java.lang.String caption)
           
 void setComment(java.lang.String newComments)
           
 void setLabel(java.lang.String label)
           
 void setModified(boolean modified)
          Sets the Modifiable object as modified.
static void setPackages(java.lang.String packages)
           
 void setPositionHoriCentre(boolean positionHoriCentre)
           
 void setPositionVertToken(LaTeXGenerator.VerticalPosition positionVertToken)
           
abstract  void update()
          Updates the code cache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LGTH_START_LINE_COMMENT

public static final int LGTH_START_LINE_COMMENT
Defines the number of characters added at the beginning of each lines of the comment (these characters are "% ").

See Also:
Constant Field Values

PACKAGES

protected static final IUnary<java.lang.String> PACKAGES
The latex packages used when exporting using latex. These packages are defined for the current document but not for all documents.


comment

protected java.lang.String comment
The comment of the drawing.


label

protected java.lang.String label
The label of the drawing.


caption

protected java.lang.String caption
The caption of the drawing.


positionVertToken

protected LaTeXGenerator.VerticalPosition positionVertToken
The token of the position of the drawing


positionHoriCentre

protected boolean positionHoriCentre
The horizontal position of the drawing


modified

protected boolean modified
Defined if the instrument has been modified.

Constructor Detail

LaTeXGenerator

public LaTeXGenerator()
Initialises the abstract generator.

Since:
3.0
Method Detail

setPackages

public static void setPackages(java.lang.String packages)
Parameters:
packages - the packages to set.
Since:
3.0

getPackages

public static java.lang.String getPackages()
Returns:
the packages.
Since:
3.0

getPackagesUnary

public static IUnary<java.lang.String> getPackagesUnary()
Returns:
The unary relation that contains the packages value.
Since:
3.0

getComment

public java.lang.String getComment()
Returns:
the comment.
Since:
3.0

getCommentsWithoutTag

public java.lang.String getCommentsWithoutTag()
Returns:
The comments without any characters like "%" at the start of each lines. (these characters are used like comment symbol by LaTeX).

isModified

public boolean isModified()
Specified by:
isModified in interface Modifiable
Returns:
True: the object has been modified. False otherwise.

setModified

public void setModified(boolean modified)
Description copied from interface: Modifiable
Sets the Modifiable object as modified.

Specified by:
setModified in interface Modifiable
Parameters:
modified - True: the element is will tagged as modified.

setComment

public void setComment(java.lang.String newComments)
Parameters:
newComments - the comment to set.
Since:
3.0

getPositionVertToken

public LaTeXGenerator.VerticalPosition getPositionVertToken()
Returns:
The latex token corresponding to the specified vertical position.
Since:
3.0

setPositionVertToken

public void setPositionVertToken(LaTeXGenerator.VerticalPosition positionVertToken)
Parameters:
positionVertToken - The new vertical position token. Must not be null.
Since:
3.0

isPositionHoriCentre

public boolean isPositionHoriCentre()
Returns:
True: the latex drawing will be horizontally centred.
Since:
3.0

getLabel

public java.lang.String getLabel()
Returns:
the label of the latex drawing.
Since:
3.0

setLabel

public void setLabel(java.lang.String label)
Parameters:
label - the new label of the drawing. Must not be null.
Since:
3.0

getCaption

public java.lang.String getCaption()
Returns:
the caption of the drawing.
Since:
3.0

setCaption

public void setCaption(java.lang.String caption)
Parameters:
caption - the new caption of the drawing. Must not be null.
Since:
3.0

setPositionHoriCentre

public void setPositionHoriCentre(boolean positionHoriCentre)
Parameters:
positionHoriCentre - True: the latex drawing will be horizontally centred.
Since:
3.0

update

public abstract void update()
Updates the code cache.

Since:
3.0

getLatexDocument

public static java.lang.String getLatexDocument(IDrawing drawing,
                                                ViewsSynchroniserHandler synchronizer)
Generates a latex document that contains the pstricks code of the given canvas.

Parameters:
drawing - The shapes to export.
synchronizer - The object that synchronises the view and the model.
Returns:
The latex document or an empty string.
Since:
3.0

createLatexFile

public static java.io.File createLatexFile(IDrawing drawing,
                                           java.lang.String pathExportTex,
                                           ViewsSynchroniserHandler synchronizer)
Creates a latex file that contains the pstricks code of the given canvas.

Parameters:
drawing - The shapes to export.
pathExportTex - The location where the file must be created.
synchronizer - The object that synchronises the view and the model.
Returns:
The latex file or null.
Since:
3.0

createPSFile

public static java.io.File createPSFile(IDrawing drawing,
                                        java.lang.String pathExportPs,
                                        ViewsSynchroniserHandler synchronizer)
Create a .ps file that corresponds to the compiled latex document containing the pstricks drawing.

Parameters:
drawing - The shapes to export.
pathExportPs - The path of the .ps file to create (MUST ends with .ps).
synchronizer - The object that synchronises the view and the model.
Returns:
The create file or null.
Since:
3.0

createPSFile

public static java.io.File createPSFile(IDrawing drawing,
                                        java.lang.String pathExportPs,
                                        ViewsSynchroniserHandler synchronizer,
                                        java.io.File tmpDir)
Create a .ps file that corresponds to the compiled latex document containing the pstricks drawing.

Parameters:
drawing - The shapes to export.
pathExportPs - The path of the .ps file to create (MUST ends with .ps).
synchronizer - The object that synchronises the view and the model.
tmpDir - The temporary directory used for the compilation.
Returns:
The create file or null.
Since:
3.0

createPDFFile

public static java.io.File createPDFFile(IDrawing drawing,
                                         java.lang.String pathExportPdf,
                                         ViewsSynchroniserHandler synchronizer,
                                         boolean crop)
Create a .pdf file that corresponds to the compiled latex document containing the pstricks drawing.

Parameters:
drawing - The shapes to export.
pathExportPdf - The path of the .pdf file to create (MUST ends with .pdf).
synchronizer - The object that synchronises the view and the model.
crop - if true, the output document will be cropped.
Returns:
The create file or null.
Since:
3.0

execute

private static java.lang.String execute(java.lang.String[] cmd,
                                        java.io.File tmpdir)