ContactCenters
V. 0.9.9.

umontreal.iro.lecuyer.util
Class LaTeXDoubleFormatter

java.lang.Object
  extended by umontreal.iro.lecuyer.util.LaTeXDoubleFormatter
All Implemented Interfaces:
DoubleFormatter

public class LaTeXDoubleFormatter
extends Object
implements DoubleFormatter

Represents a double formatter formatting strings for insertion into a LATEX document. This formatter uses an ordinary double formatter, and calls String) on the returned strings. This method processes strings to be formatted in LATEX, e.g., convert scientific notation.


Constructor Summary
LaTeXDoubleFormatter(DoubleFormatter df)
          Constructs a new double formatter using df.
LaTeXDoubleFormatter(DoubleFormatter df, String ensureMathCmd)
          Constructs a new double formatter using df, and the LATEX command given by ensureMathCmd to ensure math mode when necessary.
 
Method Summary
 String format(double x)
          Formats the double x as a string, and returns the resulting string.
 DoubleFormatter getDoubleFormatter()
          Returns the double formatter used by this formatter.
 String getEnsureMathCommand()
          Returns the name of the math-ensuring LATEX command.
static String processForLaTeX(String str, String ensureMathCmd)
          Prepares the string str to be formatted in LATEX, and returns the processed string.
 void setDoubleFormatter(DoubleFormatter df)
          Sets the double formatter used by this formatter to df.
 void setEnsureMathCommand(String ensureMathCmd)
          Sets the name of the math-ensuring LATEX command to ensureMathCmd.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LaTeXDoubleFormatter

public LaTeXDoubleFormatter(DoubleFormatter df)
Constructs a new double formatter using df.

Parameters:
df - the double formatter being used.

LaTeXDoubleFormatter

public LaTeXDoubleFormatter(DoubleFormatter df,
                            String ensureMathCmd)
Constructs a new double formatter using df, and the LATEX command given by ensureMathCmd to ensure math mode when necessary. The default value for ensureMathCmd is ensuremath.

Parameters:
df - the double formatter being used.
ensureMathCmd - the name of the ensure-math command.
Method Detail

getDoubleFormatter

public DoubleFormatter getDoubleFormatter()
Returns the double formatter used by this formatter.

Returns:
the double formatter being used.

setDoubleFormatter

public void setDoubleFormatter(DoubleFormatter df)
Sets the double formatter used by this formatter to df.

Parameters:
df - the new double formatter.

getEnsureMathCommand

public String getEnsureMathCommand()
Returns the name of the math-ensuring LATEX command.

Returns:
the math-ensuring command.

setEnsureMathCommand

public void setEnsureMathCommand(String ensureMathCmd)
Sets the name of the math-ensuring LATEX command to ensureMathCmd.

Parameters:
ensureMathCmd - the new name of the math-ensuring command.

format

public String format(double x)
Description copied from interface: DoubleFormatter
Formats the double x as a string, and returns the resulting string.

Specified by:
format in interface DoubleFormatter
Parameters:
x - the value being formatted.
Returns:
the formatted value.

processForLaTeX

public static String processForLaTeX(String str,
                                     String ensureMathCmd)
Prepares the string str to be formatted in LATEX, and returns the processed string. This method converts E and e to 10ˆ. When math mode needs to be ensured, e.g., when the string contains ˆ, the string is prepended with a backslash, the string returned by ensureMathCmd, and an opening brace, and A matching closing brace is added at the end of the string.

Parameters:
str - the string being processed.
ensureMathCmd - the command to ensure math mode.
Returns:
the processed string.

ContactCenters
V. 0.9.9.

To submit a bug or ask questions, send an e-mail to Richard Simard.