easik.sketch.util.Tex
Class TexFile

java.lang.Object
  extended by java.io.File
      extended by easik.sketch.util.Tex.TexFile
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<java.io.File>

public class TexFile
extends java.io.File

Class to convert a JGraph object to a tex file. This class generates an output file containing a description of the graph using formatting for GasTex. The file contains no header information, and thus cannot be converted into a TeX file as is.
To convert the file into a readable TeX file, the user must add relevant header information, including a call to use the package GasTeX. This package is freely available on the web.

Since:
2006-07-10 William Belanger
Version:
2006-07-12 Vera Ranieri
Author:
William Belanger 2006, Vera Ranieri 2006
See Also:
Serialized Form

Field Summary
private  java.awt.Point _flip
          A point to flip
private  java.awt.Point _transform
          A point to transform
private static int BOXLENGTH
          The size of the box for an entity
private static int CONSTRAINT_LENGTH
          The size of the constraint box
private static java.lang.String DESCRIPTION
          The description of the file
private static java.lang.String EXTENSION
          The TeX file extension
 
Fields inherited from class java.io.File
pathSeparator, pathSeparatorChar, separator, separatorChar
 
Constructor Summary
TexFile(java.io.File aFile)
          Construtor that calls TexFile(String fileLoc) constructor by determining the absolute path of the file passed.
TexFile(java.lang.String fileLoc)
          Constructor that calls the super constructor.
 
Method Summary
private  void beginWrite(java.io.BufferedWriter bw)
          Sets the initial conditions of the image.
private  void finishWrite(java.io.BufferedWriter bw)
          Sets the final conditions of the image.
static java.lang.String getDescription()
          Gets the description of this file
static java.lang.String getExtension()
          Returns the extension of this file
private static java.awt.Point getMax(org.jgraph.JGraph graph)
          Determines the maximum point on the graph, to set the bounds of the GasTeX image.
private static java.awt.Point getMin(org.jgraph.JGraph graph)
          Determines the minimum point on the graph, to set the bounds of the GasTeX image.
static boolean isCorrectExtension(java.lang.String extension)
          Determines whether the file has the correct extension
static boolean isOfType(java.io.File file)
          Determines whether the file is of the proper type.
static boolean isOfType(java.lang.String fileName)
          Determines whether the file has the proper extension appeneded to the file
 void save(org.jgraph.JGraph toSave)
          Saves the graph as a \.tex file by converting all elements to strings formatted for GasTex.
private  void writeEdge(java.io.BufferedWriter bw, org.jgraph.graph.DefaultEdge edge, org.jgraph.JGraph graph)
          Writes the information about an edge to the output file.
private  void writeVertex(java.io.BufferedWriter bw, org.jgraph.graph.DefaultGraphCell vertex, org.jgraph.JGraph graph)
          Writes the information about a vertex to the output file.
 
Methods inherited from class java.io.File
canRead, canWrite, compareTo, createNewFile, createTempFile, createTempFile, delete, deleteOnExit, equals, exists, getAbsoluteFile, getAbsolutePath, getCanonicalFile, getCanonicalPath, getName, getParent, getParentFile, getPath, hashCode, isAbsolute, isDirectory, isFile, isHidden, lastModified, length, list, list, listFiles, listFiles, listFiles, listRoots, mkdir, mkdirs, renameTo, setLastModified, setReadOnly, toString, toURI, toURL
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

EXTENSION

private static final java.lang.String EXTENSION
The TeX file extension

See Also:
Constant Field Values

DESCRIPTION

private static final java.lang.String DESCRIPTION
The description of the file

See Also:
Constant Field Values

BOXLENGTH

private static final int BOXLENGTH
The size of the box for an entity

See Also:
Constant Field Values

CONSTRAINT_LENGTH

private static final int CONSTRAINT_LENGTH
The size of the constraint box

See Also:
Constant Field Values

_transform

private java.awt.Point _transform
A point to transform


_flip

private java.awt.Point _flip
A point to flip

Constructor Detail

TexFile

public TexFile(java.lang.String fileLoc)
Constructor that calls the super constructor. It also sets each constraint to have a unique name

Parameters:
fileLoc - The absolute path of the file.

TexFile

public TexFile(java.io.File aFile)
Construtor that calls TexFile(String fileLoc) constructor by determining the absolute path of the file passed.

Parameters:
aFile - The file to be made into a TexFile.
Method Detail

getExtension

public static final java.lang.String getExtension()
Returns the extension of this file

Returns:
The extension .tex

getDescription

public static final java.lang.String getDescription()
Gets the description of this file

Returns:
The description 'TEX image file'.

isOfType

public static final boolean isOfType(java.lang.String fileName)
Determines whether the file has the proper extension appeneded to the file

Parameters:
fileName - The name of the file
Returns:
True if it ends in the extension .tex, false otherwise.

isOfType

public static final boolean isOfType(java.io.File file)
Determines whether the file is of the proper type.

Parameters:
file - The file to be investigated.
Returns:
true if the file is has .tex as its extension, false otherwise

isCorrectExtension

public static final boolean isCorrectExtension(java.lang.String extension)
Determines whether the file has the correct extension

Parameters:
extension - The current extension of the file
Returns:
true if the extension is the proper extension, false otherwise

getMin

private static java.awt.Point getMin(org.jgraph.JGraph graph)
Determines the minimum point on the graph, to set the bounds of the GasTeX image.

Parameters:
graph - The graph being converted into a GasTeX image
Returns:
A Point of the minimum point on the graph object.

getMax

private static java.awt.Point getMax(org.jgraph.JGraph graph)
Determines the maximum point on the graph, to set the bounds of the GasTeX image.

Parameters:
graph - The graph being converted into a GasTeX image.
Returns:
A point of the maximum point on the graph object

save

public void save(org.jgraph.JGraph toSave)
          throws java.io.IOException
Saves the graph as a \.tex file by converting all elements to strings formatted for GasTex. Overloads the save function in the File class.

Parameters:
toSave - The graph to convert to a GasTex image
Throws:
java.io.IOException - Write error

beginWrite

private void beginWrite(java.io.BufferedWriter bw)
                 throws java.io.IOException
Sets the initial conditions of the image.

Parameters:
bw - The buffered writer being used to write to the output file
Throws:
java.io.IOException - Write error

finishWrite

private void finishWrite(java.io.BufferedWriter bw)
                  throws java.io.IOException
Sets the final conditions of the image.

Parameters:
bw - The buffered writer being used to write to the output file
Throws:
java.io.IOException - Write error

writeVertex

private void writeVertex(java.io.BufferedWriter bw,
                         org.jgraph.graph.DefaultGraphCell vertex,
                         org.jgraph.JGraph graph)
                  throws java.io.IOException
Writes the information about a vertex to the output file. Vertices are defined as either an EntityNode, or a Constraint. Depending on which class the vertex belongs to, the write is done to distinguish between the two objects.
EntityNodes are written as standard rectangles which have a minimum length of BOXLENGTH. Constraints are drawn as standard rectangles shaded in gray, with the outline being dashed.

Parameters:
bw - The BufferedWriter being used to write to this file
vertex - The vertex to addd to the output file
graph - The graph which is being converted to a GasTeX image
Throws:
java.io.IOException - Write error

writeEdge

private void writeEdge(java.io.BufferedWriter bw,
                       org.jgraph.graph.DefaultEdge edge,
                       org.jgraph.JGraph graph)
                throws java.io.IOException
Writes the information about an edge to the output file. Edges are defined as either a SketchEdge, or a GuideEdge. Depending on which class the edge belongs to, the write is done to distinguish between the two objects.
SketchEdges are written as standard lines leading from the source to the target. If the SketchEdge is injective, the edge is drawn appropriately. GuideEdges are drawn as dashed lines leading from the source (the Constraint) to the target (the EntitiyNode involved in the constraint).

Parameters:
bw - The BufferedWriter being used to write to this file.
edge - The edge which is being added to the GasTeX file
graph - The graph which is being converted to a GasTeX image.
Throws:
java.io.IOException - Write Error