diff --git a/Source/Core/src/ca/uqac/lif/mtnp/table/HardTable.java b/Source/Core/src/ca/uqac/lif/mtnp/table/HardTable.java index 43ff178..71957e5 100644 --- a/Source/Core/src/ca/uqac/lif/mtnp/table/HardTable.java +++ b/Source/Core/src/ca/uqac/lif/mtnp/table/HardTable.java @@ -288,17 +288,26 @@ protected String toHtml(String[] sort_order) */ protected void toHtml(TableNode cur_node, StringBuilder out, int depth, int total_depth) { + if (depth > 0) { out.append("
tabular
- * environment in LaTeX must specify the alignment of each column
- * before the keys are listed, and so in our case before
- * we know how many keys there are.
+ * A buffer to hold the column headers until we know how many columns there are.
+ * This is due to the fact that a tabular environment in LaTeX must
+ * specify the alignment of each column before the keys are listed, and
+ * so in our case before we know how many keys there are.
*/
protected final transient StringBuilder m_keyBuffer = new StringBuilder();
@@ -75,7 +73,9 @@ public LatexTableRenderer(Table t)
/**
* The name of the LaTeX environment that displays the table
*/
- public static enum EnvironmentName {TABULAR, LONGTABLE};
+ public static enum EnvironmentName {
+ TABULAR, LONGTABLE
+ };
/**
* The name of the LaTeX environment that displays the table
@@ -83,8 +83,7 @@ public static enum EnvironmentName {TABULAR, LONGTABLE};
protected EnvironmentName m_environmentName = EnvironmentName.TABULAR;
@Override
- public void reset()
- {
+ public void reset() {
m_numColumns = 0;
m_keyBuffer.setLength(0);
m_repeatedCells = 0;
@@ -92,73 +91,69 @@ public void reset()
/**
* Sets the name of the LaTeX environment that displays the table
- * @param name The name
+ *
+ * @param name
+ * The name
*/
- public void setEnvironmentName(EnvironmentName name)
- {
+ public void setEnvironmentName(EnvironmentName name) {
m_environmentName = name;
}
/**
* Sets whether the table's column headers are printed in bold
- * @param b Set to true to put the headers in bold,
- * (the default), false otherwise
+ *
+ * @param b
+ * Set to true to put the headers in bold, (the
+ * default), false otherwise
*/
- public void setBoldKeys(boolean b)
- {
+ public void setBoldKeys(boolean b) {
m_boldKeys = b;
}
/**
- * Sets whether the data points in the table will be enclosed in
- * hyperlinks containing their ID
- * @param b Set to true to enable hyperlinks,
- * false otherwise
+ * Sets whether the data points in the table will be enclosed in hyperlinks
+ * containing their ID
+ *
+ * @param b
+ * Set to true to enable hyperlinks, false
+ * otherwise
*/
- public void setDatapointHyperlinks(boolean b)
- {
+ public void setDatapointHyperlinks(boolean b) {
m_datapointHyperlinks = b;
}
/**
* Gets the LaTeX name associated to each value of EnvironmentName
- * @param name The name
+ *
+ * @param name
+ * The name
* @return The LaTeX string
*/
- protected static String getLatexEnvironmentName(EnvironmentName name)
- {
- if (name == EnvironmentName.LONGTABLE)
- {
+ protected static String getLatexEnvironmentName(EnvironmentName name) {
+ if (name == EnvironmentName.LONGTABLE) {
return "longtable";
}
return "tabular";
}
@Override
- public void startStructure(StringBuilder out)
- {
+ public void startStructure(StringBuilder out) {
out.append("\\begin{").append(getLatexEnvironmentName(m_environmentName)).append("}");
}
@Override
- public void startKeys(StringBuilder out)
- {
+ public void startKeys(StringBuilder out) {
// Do nothing
}
@Override
- public void printKey(StringBuilder out, String key)
- {
- if (m_keyBuffer.length() > 0)
- {
+ public void printKey(StringBuilder out, String key) {
+ if (m_keyBuffer.length() > 0) {
m_keyBuffer.append(" & ");
}
- if (m_boldKeys)
- {
+ if (m_boldKeys) {
m_keyBuffer.append("\\textbf{");
- }
- else
- {
+ } else {
m_keyBuffer.append("{");
}
m_keyBuffer.append(escape(key)).append("}");
@@ -166,127 +161,103 @@ public void printKey(StringBuilder out, String key)
}
@Override
- public void endKeys(StringBuilder out)
- {
+ public void endKeys(StringBuilder out) {
out.append("{|");
- for (int i = 0; i < m_numColumns; i++)
- {
+ for (int i = 0; i < m_numColumns; i++) {
out.append("c|");
}
out.append("}").append(CRLF);
out.append("\\hline").append(CRLF).append(m_keyBuffer).append("\\\\").append(CRLF);
- if (m_environmentName == EnvironmentName.LONGTABLE)
- {
+ if (m_environmentName == EnvironmentName.LONGTABLE) {
out.append("\\endfirsthead").append(CRLF);
- }
- else
- {
+ } else {
out.append("\\hline");
}
}
@Override
- public void startBody(StringBuilder out)
- {
+ public void startBody(StringBuilder out) {
// Do nothing
}
@Override
- public void startRow(StringBuilder out, int max_depth)
- {
+ public void startRow(StringBuilder out, int max_depth) {
m_keyBuffer.setLength(0); // Clear
m_repeatedCells = 0;
}
@Override
- public void printCell(StringBuilder out, List