Example usage for java.util Formatter toString

List of usage examples for java.util Formatter toString

Introduction

In this page you can find the example usage for java.util Formatter toString.

Prototype

public String toString() 

Source Link

Document

Returns the result of invoking toString() on the destination for the output.

Usage

From source file:umontreal.ssj.charts.EmpiricalChart.java

/**
 * @name LaTeX-specific method/*from  w w w  . ja va2  s. c om*/
 * @{
 */
public String toLatex(double width, double height) {
    double xunit, yunit;
    double[] save = new double[4];

    if (dataset.getSeriesCollection().getSeriesCount() == 0)
        throw new IllegalArgumentException("Empty chart");

    //Calcul des parametres d'echelle et de decalage
    double XScale = computeXScale(XAxis.getTwinAxisPosition());
    double YScale = computeYScale(YAxis.getTwinAxisPosition());

    xunit = width / ((Math.max(XAxis.getAxis().getRange().getUpperBound(), XAxis.getTwinAxisPosition())
            * XScale)
            - (Math.min(XAxis.getAxis().getRange().getLowerBound(), XAxis.getTwinAxisPosition()) * XScale));
    //taille d'une unite en x et en cm dans l'objet "tikzpicture"
    yunit = height / ((Math.max(YAxis.getAxis().getRange().getUpperBound(), YAxis.getTwinAxisPosition())
            * YScale)
            - (Math.min(YAxis.getAxis().getRange().getLowerBound(), YAxis.getTwinAxisPosition()) * YScale));
    //taille d'une unite en y et en cm dans l'objet "tikzpicture"

    Formatter formatter = new Formatter(Locale.US);

    /*Entete du document*/
    if (latexDocFlag) {
        formatter.format("\\documentclass[12pt]{article}%n%n");
        formatter.format("\\usepackage{tikz}%n\\usetikzlibrary{plotmarks}%n\\begin{document}%n%n");
    }
    if (chart.getTitle() != null)
        formatter.format("%% PGF/TikZ picture from SSJ : %s%n", chart.getTitle().getText());
    else
        formatter.format("%% PGF/TikZ picture from SSJ %n");
    formatter.format("%% XScale = %s,  YScale = %s,  XShift = %s,  YShift = %s%n", XScale, YScale,
            XAxis.getTwinAxisPosition(), YAxis.getTwinAxisPosition());
    formatter.format("%% Therefore, thisFileXValue = (originalSeriesXValue+XShift)*XScale%n");
    formatter.format("%%        and thisFileYValue = (originalSeriesYValue+YShift)*YScale%n%n");
    if (chart.getTitle() != null)
        formatter.format("\\begin{figure}%n");
    formatter.format("\\begin{center}%n");
    formatter.format("\\begin{tikzpicture}[x=%scm, y=%scm]%n", xunit, yunit);
    formatter.format("\\footnotesize%n");
    if (grid)
        formatter.format("\\draw[color=lightgray] (%s, %s) grid[xstep = %s, ystep=%s] (%s, %s);%n",
                (Math.min(XAxis.getAxis().getRange().getLowerBound(), XAxis.getTwinAxisPosition())
                        - XAxis.getTwinAxisPosition()) * XScale,
                (Math.min(YAxis.getAxis().getRange().getLowerBound(), YAxis.getTwinAxisPosition())
                        - YAxis.getTwinAxisPosition()) * YScale,
                xstepGrid * XScale, ystepGrid * YScale,
                (Math.max(XAxis.getAxis().getRange().getUpperBound(), XAxis.getTwinAxisPosition())
                        - XAxis.getTwinAxisPosition()) * XScale,
                (Math.max(YAxis.getAxis().getRange().getUpperBound(), YAxis.getTwinAxisPosition())
                        - YAxis.getTwinAxisPosition()) * YScale);
    setTick0Flags();
    formatter.format("%s", XAxis.toLatex(XScale));
    formatter.format("%s", YAxis.toLatex(YScale));

    formatter.format("%s",
            dataset.toLatex(XScale, YScale, XAxis.getTwinAxisPosition(), YAxis.getTwinAxisPosition(),
                    XAxis.getAxis().getLowerBound(), XAxis.getAxis().getUpperBound(),
                    YAxis.getAxis().getLowerBound(), YAxis.getAxis().getUpperBound()));

    formatter.format("\\end{tikzpicture}%n");
    formatter.format("\\end{center}%n");
    if (chart.getTitle() != null) {
        formatter.format("\\caption{");
        formatter.format(chart.getTitle().getText());
        formatter.format("}%n\\end{figure}%n");
    }
    if (latexDocFlag)
        formatter.format("\\end{document}%n");
    return formatter.toString();
}

From source file:com.flexoodb.common.FlexUtils.java

/**
* computes the SHA1 hashcode for the passed byte array.
*
* @param  ba byte array.//from   ww w  . j  a va2 s . c om
* @return SHA1 string.
*/
public static String computeSHA1(byte[] ba) {
    String hash = null;
    try {

        MessageDigest sha1 = MessageDigest.getInstance("SHA1");
        InputStream is = new ByteArrayInputStream(ba);
        BufferedInputStream bis = new BufferedInputStream(is);

        DigestInputStream dis = new DigestInputStream(bis, sha1);

        while (dis.read() != -1) {
        }
        ;

        byte[] h = sha1.digest();

        Formatter formatter = new Formatter();

        for (byte b : h) {
            formatter.format("%02x", b);
        }

        hash = formatter.toString();

    } catch (Exception e) {
        e.printStackTrace();
    }
    return hash;
}

From source file:umontreal.iro.lecuyer.charts.EmpiricalChart.java

public String toLatex(double width, double height) {
    double xunit, yunit;
    double[] save = new double[4];

    if (dataset.getSeriesCollection().getSeriesCount() == 0)
        throw new IllegalArgumentException("Empty chart");

    //Calcul des parametres d'echelle et de decalage
    double XScale = computeXScale(XAxis.getTwinAxisPosition());
    double YScale = computeYScale(YAxis.getTwinAxisPosition());

    xunit = width / ((Math.max(XAxis.getAxis().getRange().getUpperBound(), XAxis.getTwinAxisPosition())
            * XScale)/*from w  ww  .j  a va2  s. c  o m*/
            - (Math.min(XAxis.getAxis().getRange().getLowerBound(), XAxis.getTwinAxisPosition()) * XScale));
    //taille d'une unite en x et en cm dans l'objet "tikzpicture"
    yunit = height / ((Math.max(YAxis.getAxis().getRange().getUpperBound(), YAxis.getTwinAxisPosition())
            * YScale)
            - (Math.min(YAxis.getAxis().getRange().getLowerBound(), YAxis.getTwinAxisPosition()) * YScale));
    //taille d'une unite en y et en cm dans l'objet "tikzpicture"

    Formatter formatter = new Formatter(Locale.US);

    /*Entete du document*/
    if (latexDocFlag) {
        formatter.format("\\documentclass[12pt]{article}%n%n");
        formatter.format("\\usepackage{tikz}%n\\usetikzlibrary{plotmarks}%n\\begin{document}%n%n");
    }
    if (chart.getTitle() != null)
        formatter.format("%% PGF/TikZ picture from SSJ : %s%n", chart.getTitle().getText());
    else
        formatter.format("%% PGF/TikZ picture from SSJ %n");
    formatter.format("%% XScale = %s,  YScale = %s,  XShift = %s,  YShift = %s%n", XScale, YScale,
            XAxis.getTwinAxisPosition(), YAxis.getTwinAxisPosition());
    formatter.format("%% Therefore, thisFileXValue = (originalSeriesXValue+XShift)*XScale%n");
    formatter.format("%%        and thisFileYValue = (originalSeriesYValue+YShift)*YScale%n%n");
    if (chart.getTitle() != null)
        formatter.format("\\begin{figure}%n");
    formatter.format("\\begin{center}%n");
    formatter.format("\\begin{tikzpicture}[x=%scm, y=%scm]%n", xunit, yunit);
    formatter.format("\\footnotesize%n");
    if (grid)
        formatter.format("\\draw[color=lightgray] (%s, %s) grid[xstep = %s, ystep=%s] (%s, %s);%n",
                (Math.min(XAxis.getAxis().getRange().getLowerBound(), XAxis.getTwinAxisPosition())
                        - XAxis.getTwinAxisPosition()) * XScale,
                (Math.min(YAxis.getAxis().getRange().getLowerBound(), YAxis.getTwinAxisPosition())
                        - YAxis.getTwinAxisPosition()) * YScale,
                xstepGrid * XScale, ystepGrid * YScale,
                (Math.max(XAxis.getAxis().getRange().getUpperBound(), XAxis.getTwinAxisPosition())
                        - XAxis.getTwinAxisPosition()) * XScale,
                (Math.max(YAxis.getAxis().getRange().getUpperBound(), YAxis.getTwinAxisPosition())
                        - YAxis.getTwinAxisPosition()) * YScale);
    setTick0Flags();
    formatter.format("%s", XAxis.toLatex(XScale));
    formatter.format("%s", YAxis.toLatex(YScale));

    formatter.format("%s",
            dataset.toLatex(XScale, YScale, XAxis.getTwinAxisPosition(), YAxis.getTwinAxisPosition(),
                    XAxis.getAxis().getLowerBound(), XAxis.getAxis().getUpperBound(),
                    YAxis.getAxis().getLowerBound(), YAxis.getAxis().getUpperBound()));

    formatter.format("\\end{tikzpicture}%n");
    formatter.format("\\end{center}%n");
    if (chart.getTitle() != null) {
        formatter.format("\\caption{");
        formatter.format(chart.getTitle().getText());
        formatter.format("}%n\\end{figure}%n");
    }
    if (latexDocFlag)
        formatter.format("\\end{document}%n");
    return formatter.toString();
}

From source file:com.zimbra.cs.util.ProxyConfOverride.java

public String formatString(Object o) {
    Formatter f = new Formatter();
    f.format("%s", o);
    return f.toString();
}

From source file:com.zimbra.cs.util.ProxyConfOverride.java

public String formatTime(Object o) {
    Formatter f = new Formatter();
    f.format("%dms", (Long) o);
    return f.toString();
}

From source file:com.zimbra.cs.util.ProxyConfOverride.java

public String formatInteger(Object o) {
    Formatter f = new Formatter();
    f.format("%d", (Integer) o);
    return f.toString();
}

From source file:umontreal.ssj.charts.HistogramChart.java

/**
 * @name LaTeX-specific method/*from   ww w. ja  va 2 s. c o m*/
 * @{
 */
public String toLatex(double width, double height) {
    double xunit, yunit;
    double[] save = new double[4];

    if (dataset.getSeriesCollection().getSeriesCount() == 0)
        throw new IllegalArgumentException("Empty chart");
    if (YAxis.getTwinAxisPosition() < 0)
        YAxis.setTwinAxisPosition(0);

    // Calcul des parametres d'echelle et de decalage
    double XScale = computeXScale(XAxis.getTwinAxisPosition());
    double YScale = computeYScale(YAxis.getTwinAxisPosition());

    // taille d'une unite en x et en cm dans l'objet "tikzpicture"
    xunit = width / ((Math.max(XAxis.getAxis().getRange().getUpperBound(), XAxis.getTwinAxisPosition())
            * XScale)
            - (Math.min(XAxis.getAxis().getRange().getLowerBound(), XAxis.getTwinAxisPosition()) * XScale));
    // taille d'une unite en y et en cm dans l'objet "tikzpicture"
    yunit = height / ((Math.max(YAxis.getAxis().getRange().getUpperBound(), YAxis.getTwinAxisPosition())
            * YScale)
            - (Math.min(YAxis.getAxis().getRange().getLowerBound(), YAxis.getTwinAxisPosition()) * YScale));

    Formatter formatter = new Formatter(Locale.US);

    /*Entete du document*/
    if (latexDocFlag) {
        formatter.format("\\documentclass[12pt]{article}%n%n");
        formatter.format("\\usepackage{tikz}%n\\usetikzlibrary{plotmarks}%n\\begin{document}%n%n");
    }
    if (chart.getTitle() != null)
        formatter.format("%% PGF/TikZ picture from SSJ: %s%n", chart.getTitle().getText());
    else
        formatter.format("%% PGF/TikZ picture from SSJ %n");
    formatter.format("%% XScale = %s,  YScale = %s,  XShift = %s,  YShift = %s%n", XScale, YScale,
            XAxis.getTwinAxisPosition(), YAxis.getTwinAxisPosition());
    formatter.format("%% Therefore, thisFileXValue = (originalSeriesXValue+XShift)*XScale%n");
    formatter.format("%%        and thisFileYValue = (originalSeriesYValue+YShift)*YScale%n%n");
    if (chart.getTitle() != null)
        formatter.format("\\begin{figure}%n");
    formatter.format("\\begin{center}%n");
    formatter.format("\\begin{tikzpicture}[x=%scm, y=%scm]%n", xunit, yunit);
    formatter.format("\\footnotesize%n");
    if (grid)
        formatter.format("\\draw[color=lightgray] (%s, %s) grid[xstep = %s, ystep=%s] (%s, %s);%n",
                (Math.min(XAxis.getAxis().getRange().getLowerBound(), XAxis.getTwinAxisPosition())
                        - XAxis.getTwinAxisPosition()) * XScale,
                (Math.min(YAxis.getAxis().getRange().getLowerBound(), YAxis.getTwinAxisPosition())
                        - YAxis.getTwinAxisPosition()) * YScale,
                xstepGrid * XScale, ystepGrid * YScale,
                (Math.max(XAxis.getAxis().getRange().getUpperBound(), XAxis.getTwinAxisPosition())
                        - XAxis.getTwinAxisPosition()) * XScale,
                (Math.max(YAxis.getAxis().getRange().getUpperBound(), YAxis.getTwinAxisPosition())
                        - YAxis.getTwinAxisPosition()) * YScale);
    setTick0Flags();
    formatter.format("%s", XAxis.toLatex(XScale));
    formatter.format("%s", YAxis.toLatex(YScale));

    formatter.format("%s",
            dataset.toLatex(XScale, YScale, XAxis.getTwinAxisPosition(), YAxis.getTwinAxisPosition(),
                    XAxis.getAxis().getLowerBound(), XAxis.getAxis().getUpperBound(),
                    YAxis.getAxis().getLowerBound(), YAxis.getAxis().getUpperBound()));

    formatter.format("\\end{tikzpicture}%n");
    formatter.format("\\end{center}%n");
    if (chart.getTitle() != null) {
        formatter.format("\\caption{");
        formatter.format(chart.getTitle().getText());
        formatter.format("}%n\\end{figure}%n");
    }
    if (latexDocFlag)
        formatter.format("\\end{document}%n");
    return formatter.toString();
}

From source file:umontreal.ssj.charts.ScatterChart.java

/**
 * @name LaTex-specific method/*from   www. j  a va 2s .  co m*/
 * @{
 */
public String toLatex(double width, double height) {
    double xunit = 0, yunit = 0;
    double[] save = new double[4];

    if (dataset.getSeriesCollection().getSeriesCount() == 0)
        throw new IllegalArgumentException("Empty chart");

    //Calcul des parametres d'echelle et de decalage
    double XScale = computeXScale(XAxis.getTwinAxisPosition());
    double YScale = computeYScale(YAxis.getTwinAxisPosition());

    //taille d'une unite en x et en cm dans l'objet "tikzpicture"
    xunit = width / ((Math.max(XAxis.getAxis().getRange().getUpperBound(), XAxis.getTwinAxisPosition())
            * XScale)
            - (Math.min(XAxis.getAxis().getRange().getLowerBound(), XAxis.getTwinAxisPosition()) * XScale));
    //taille d'une unite en y et en cm dans l'objet "tikzpicture"
    yunit = height / ((Math.max(YAxis.getAxis().getRange().getUpperBound(), YAxis.getTwinAxisPosition())
            * YScale)
            - (Math.min(YAxis.getAxis().getRange().getLowerBound(), YAxis.getTwinAxisPosition()) * YScale));

    Formatter formatter = new Formatter(Locale.US);

    /*Entete du document*/
    if (latexDocFlag) {
        formatter.format("\\documentclass[12pt]{article}%n%n");
        formatter.format("\\usepackage{tikz}%n\\usetikzlibrary{plotmarks}%n\\begin{document}%n%n");
    }
    if (chart.getTitle() != null)
        formatter.format("%% PGF/TikZ picture from SSJ: %s%n", chart.getTitle().getText());
    else
        formatter.format("%% PGF/TikZ picture from SSJ %n");
    formatter.format("%% XScale = %s,  YScale = %s,  XShift = %s,  YShift = %s%n", XScale, YScale,
            XAxis.getTwinAxisPosition(), YAxis.getTwinAxisPosition());
    formatter.format("%% Therefore, thisFileXValue = (originalSeriesXValue+XShift)*XScale%n");
    formatter.format("%%        and thisFileYValue = (originalSeriesYValue+YShift)*YScale%n%n");
    if (chart.getTitle() != null)
        formatter.format("\\begin{figure}%n");
    formatter.format("\\begin{center}%n");
    formatter.format("\\begin{tikzpicture}[x=%scm, y=%scm]%n", xunit, yunit);
    formatter.format("\\footnotesize%n");
    if (grid)
        formatter.format("\\draw[color=lightgray] (%s, %s) grid[xstep = %s, ystep=%s] (%s, %s);%n",
                (Math.min(XAxis.getAxis().getRange().getLowerBound(), XAxis.getTwinAxisPosition())
                        - XAxis.getTwinAxisPosition()) * XScale,
                (Math.min(YAxis.getAxis().getRange().getLowerBound(), YAxis.getTwinAxisPosition())
                        - YAxis.getTwinAxisPosition()) * YScale,
                xstepGrid * XScale, ystepGrid * YScale,
                (Math.max(XAxis.getAxis().getRange().getUpperBound(), XAxis.getTwinAxisPosition())
                        - XAxis.getTwinAxisPosition()) * XScale,
                (Math.max(YAxis.getAxis().getRange().getUpperBound(), YAxis.getTwinAxisPosition())
                        - YAxis.getTwinAxisPosition()) * YScale);
    setTick0Flags();
    formatter.format("%s", XAxis.toLatex(XScale));
    formatter.format("%s", YAxis.toLatex(YScale));

    formatter.format("%s",
            dataset.toLatex(XScale, YScale, XAxis.getTwinAxisPosition(), YAxis.getTwinAxisPosition(),
                    XAxis.getAxis().getLowerBound(), XAxis.getAxis().getUpperBound(),
                    YAxis.getAxis().getLowerBound(), YAxis.getAxis().getUpperBound()));

    formatter.format("\\end{tikzpicture}%n");
    formatter.format("\\end{center}%n");
    if (chart.getTitle() != null) {
        formatter.format("\\caption{");
        formatter.format(chart.getTitle().getText());
        formatter.format("}%n\\end{figure}%n");
    }
    if (latexDocFlag)
        formatter.format("\\end{document}%n");
    return formatter.toString();
}

From source file:umontreal.iro.lecuyer.charts.ScatterChart.java

public String toLatex(double width, double height) {
    double xunit = 0, yunit = 0;
    double[] save = new double[4];

    if (dataset.getSeriesCollection().getSeriesCount() == 0)
        throw new IllegalArgumentException("Empty chart");

    //Calcul des parametres d'echelle et de decalage
    double XScale = computeXScale(XAxis.getTwinAxisPosition());
    double YScale = computeYScale(YAxis.getTwinAxisPosition());

    //taille d'une unite en x et en cm dans l'objet "tikzpicture"
    xunit = width / ((Math.max(XAxis.getAxis().getRange().getUpperBound(), XAxis.getTwinAxisPosition())
            * XScale)//  w  ww . jav a2s.c  o m
            - (Math.min(XAxis.getAxis().getRange().getLowerBound(), XAxis.getTwinAxisPosition()) * XScale));
    //taille d'une unite en y et en cm dans l'objet "tikzpicture"
    yunit = height / ((Math.max(YAxis.getAxis().getRange().getUpperBound(), YAxis.getTwinAxisPosition())
            * YScale)
            - (Math.min(YAxis.getAxis().getRange().getLowerBound(), YAxis.getTwinAxisPosition()) * YScale));

    Formatter formatter = new Formatter(Locale.US);

    /*Entete du document*/
    if (latexDocFlag) {
        formatter.format("\\documentclass[12pt]{article}%n%n");
        formatter.format("\\usepackage{tikz}%n\\usetikzlibrary{plotmarks}%n\\begin{document}%n%n");
    }
    if (chart.getTitle() != null)
        formatter.format("%% PGF/TikZ picture from SSJ: %s%n", chart.getTitle().getText());
    else
        formatter.format("%% PGF/TikZ picture from SSJ %n");
    formatter.format("%% XScale = %s,  YScale = %s,  XShift = %s,  YShift = %s%n", XScale, YScale,
            XAxis.getTwinAxisPosition(), YAxis.getTwinAxisPosition());
    formatter.format("%% Therefore, thisFileXValue = (originalSeriesXValue+XShift)*XScale%n");
    formatter.format("%%        and thisFileYValue = (originalSeriesYValue+YShift)*YScale%n%n");
    if (chart.getTitle() != null)
        formatter.format("\\begin{figure}%n");
    formatter.format("\\begin{center}%n");
    formatter.format("\\begin{tikzpicture}[x=%scm, y=%scm]%n", xunit, yunit);
    formatter.format("\\footnotesize%n");
    if (grid)
        formatter.format("\\draw[color=lightgray] (%s, %s) grid[xstep = %s, ystep=%s] (%s, %s);%n",
                (Math.min(XAxis.getAxis().getRange().getLowerBound(), XAxis.getTwinAxisPosition())
                        - XAxis.getTwinAxisPosition()) * XScale,
                (Math.min(YAxis.getAxis().getRange().getLowerBound(), YAxis.getTwinAxisPosition())
                        - YAxis.getTwinAxisPosition()) * YScale,
                xstepGrid * XScale, ystepGrid * YScale,
                (Math.max(XAxis.getAxis().getRange().getUpperBound(), XAxis.getTwinAxisPosition())
                        - XAxis.getTwinAxisPosition()) * XScale,
                (Math.max(YAxis.getAxis().getRange().getUpperBound(), YAxis.getTwinAxisPosition())
                        - YAxis.getTwinAxisPosition()) * YScale);
    setTick0Flags();
    formatter.format("%s", XAxis.toLatex(XScale));
    formatter.format("%s", YAxis.toLatex(YScale));

    formatter.format("%s",
            dataset.toLatex(XScale, YScale, XAxis.getTwinAxisPosition(), YAxis.getTwinAxisPosition(),
                    XAxis.getAxis().getLowerBound(), XAxis.getAxis().getUpperBound(),
                    YAxis.getAxis().getLowerBound(), YAxis.getAxis().getUpperBound()));

    formatter.format("\\end{tikzpicture}%n");
    formatter.format("\\end{center}%n");
    if (chart.getTitle() != null) {
        formatter.format("\\caption{");
        formatter.format(chart.getTitle().getText());
        formatter.format("}%n\\end{figure}%n");
    }
    if (latexDocFlag)
        formatter.format("\\end{document}%n");
    return formatter.toString();
}

From source file:umontreal.ssj.charts.XYLineChart.java

/**
 * @name Latex-specific method//from w  ww  .jav  a 2 s. com
 * @{
 */
public String toLatex(double width, double height) {
    double xunit = 0, yunit = 0;
    double[] save = new double[4];

    if (dataset.getSeriesCollection().getSeriesCount() == 0)
        throw new IllegalArgumentException("Empty chart");

    //Calcul des parametres d'echelle et de decalage
    double XScale = computeXScale(XAxis.getTwinAxisPosition());
    double YScale = computeYScale(YAxis.getTwinAxisPosition());

    // taille d'une unite en x et en cm dans l'objet "tikzpicture"
    xunit = width / ((Math.max(XAxis.getAxis().getRange().getUpperBound(), XAxis.getTwinAxisPosition())
            * XScale)
            - (Math.min(XAxis.getAxis().getRange().getLowerBound(), XAxis.getTwinAxisPosition()) * XScale));
    // taille d'une unite en y et en cm dans l'objet "tikzpicture"
    yunit = height / ((Math.max(YAxis.getAxis().getRange().getUpperBound(), YAxis.getTwinAxisPosition())
            * YScale)
            - (Math.min(YAxis.getAxis().getRange().getLowerBound(), YAxis.getTwinAxisPosition()) * YScale));

    Formatter formatter = new Formatter(Locale.US);

    /*Entete du document*/
    if (latexDocFlag) {
        formatter.format("\\documentclass[12pt]{article}%n%n");
        formatter.format("\\usepackage{tikz}%n\\usetikzlibrary{plotmarks}%n\\begin{document}%n%n");
    }
    if (chart.getTitle() != null)
        formatter.format("%% PGF/TikZ picture from SSJ: %s%n", chart.getTitle().getText());
    else
        formatter.format("%% PGF/TikZ picture from SSJ %n");
    formatter.format("%% XScale = %s,  YScale = %s,  XShift = %s,  YShift = %s%n", XScale, YScale,
            XAxis.getTwinAxisPosition(), YAxis.getTwinAxisPosition());
    formatter.format("%% Therefore, thisFileXValue = (originalSeriesXValue+XShift)*XScale%n");
    formatter.format("%%        and thisFileYValue = (originalSeriesYValue+YShift)*YScale%n%n");
    if (chart.getTitle() != null)
        formatter.format("\\begin{figure}%n");
    formatter.format("\\begin{center}%n");
    formatter.format("\\begin{tikzpicture}[x=%scm, y=%scm]%n", xunit, yunit);
    formatter.format("\\footnotesize%n");
    if (grid)
        formatter.format("\\draw[color=lightgray] (%s, %s) grid[xstep = %s, ystep=%s] (%s, %s);%n",
                (Math.min(XAxis.getAxis().getRange().getLowerBound(), XAxis.getTwinAxisPosition())
                        - XAxis.getTwinAxisPosition()) * XScale,
                (Math.min(YAxis.getAxis().getRange().getLowerBound(), YAxis.getTwinAxisPosition())
                        - YAxis.getTwinAxisPosition()) * YScale,
                xstepGrid * XScale, ystepGrid * YScale,
                (Math.max(XAxis.getAxis().getRange().getUpperBound(), XAxis.getTwinAxisPosition())
                        - XAxis.getTwinAxisPosition()) * XScale,
                (Math.max(YAxis.getAxis().getRange().getUpperBound(), YAxis.getTwinAxisPosition())
                        - YAxis.getTwinAxisPosition()) * YScale);
    setTick0Flags();
    formatter.format("%s", XAxis.toLatex(XScale));
    formatter.format("%s", YAxis.toLatex(YScale));

    formatter.format("%s",
            dataset.toLatex(XScale, YScale, XAxis.getTwinAxisPosition(), YAxis.getTwinAxisPosition(),
                    XAxis.getAxis().getLowerBound(), XAxis.getAxis().getUpperBound(),
                    YAxis.getAxis().getLowerBound(), YAxis.getAxis().getUpperBound()));

    formatter.format("\\end{tikzpicture}%n");
    formatter.format("\\end{center}%n");
    if (chart.getTitle() != null) {
        formatter.format("\\caption{");
        formatter.format(chart.getTitle().getText());
        formatter.format("}%n\\end{figure}%n");
    }
    if (latexDocFlag)
        formatter.format("\\end{document}%n");
    return formatter.toString();
}