@Test public void testFormat() { AbstractTextFormatter formatter = newInstance(); GameMatrix gameMatrix = gameMatrixFactory.newGameMatrix(); String actual = formatter.format(gameMatrix); assertTrue(actual.contains("\\begin")); }
@Override public String format(final GameMatrix matrix) { StringBuilder sb = new StringBuilder(); sb.append("\\begin{center}"); sb.append("\\huge"); sb.append(getLineSeparator()); sb.append("\\begin{tabular}{"); for (int i = 0; i < GameMatrix.SIZE; i++) { if (i % GameMatrix.BLOCK_SIZE == 0 && i != 0) { sb.append("|"); } sb.append("|C{1.1em}"); } sb.append("|"); sb.append("}"); sb.append(getLineSeparator()); for (int row = 0; row < GameMatrix.SIZE; row++) { if (row % GameMatrix.BLOCK_SIZE == 0) { sb.append("\\hline"); sb.append(getLineSeparator()); } for (int column = 0; column < GameMatrix.SIZE; column++) { byte val = matrix.get(row, column); String str; if (val == GameMatrix.UNSET) { str = getUnknownCellContentCharacter(); } else { str = Integer.toString(val); } if (column != 0) { sb.append(TABLE_CELL_SEPARATOR); } sb.append(" "); sb.append(str); sb.append(" "); } sb.append("\\\\"); sb.append(getLineSeparator()); sb.append("\\hline"); sb.append(getLineSeparator()); } sb.append("\\end{tabular}"); sb.append(getLineSeparator()); sb.append("\\end{center}"); sb.append(getLineSeparator()); sb.append("\\vspace{25 mm}"); sb.append(getLineSeparator()); return sb.toString(); }
LatexTableFormatter extends AbstractTextFormatter { @Override public String format(final GameMatrix matrix) { StringBuilder sb = new StringBuilder(); sb.append("\\begin{center}"); sb.append("\\huge"); sb.append(getLineSeparator()); sb.append("\\begin{tabular}{"); for (int i = 0; i < GameMatrix.SIZE; i++) { if (i % GameMatrix.BLOCK_SIZE == 0 && i != 0) { sb.append("|"); } sb.append("|C{1.1em}"); } sb.append("|"); sb.append("}"); sb.append(getLineSeparator()); for (int row = 0; row < GameMatrix.SIZE; row++) { if (row % GameMatrix.BLOCK_SIZE == 0) { sb.append("\\hline"); sb.append(getLineSeparator()); } for (int column = 0; column < GameMatrix.SIZE; column++) { byte val = matrix.get(row, column); String str; if (val == GameMatrix.UNSET) { str = getUnknownCellContentCharacter(); } else { str = Integer.toString(val); } if (column != 0) { sb.append(TABLE_CELL_SEPARATOR); } sb.append(" "); sb.append(str); sb.append(" "); } sb.append("\\\\"); sb.append(getLineSeparator()); sb.append("\\hline"); sb.append(getLineSeparator()); } sb.append("\\end{tabular}"); sb.append(getLineSeparator()); sb.append("\\end{center}"); sb.append(getLineSeparator()); sb.append("\\vspace{25 mm}"); sb.append(getLineSeparator()); return sb.toString(); } }
LatexTableFormatter extends AbstractTextFormatter { @Override public String format(final GameMatrix matrix) { StringBuilder sb = new StringBuilder(); sb.append("\\begin{center}"); sb.append("\\huge"); sb.append(getLineSeparator()); sb.append("\\begin{tabular}{"); for (int i = 0; i < GameMatrix.SIZE; i++) { if (i % GameMatrix.BLOCK_SIZE == 0 && i != 0) { sb.append("|"); } sb.append("|C{1.1em}"); } sb.append("|"); sb.append("}"); sb.append(getLineSeparator()); for (int row = 0; row < GameMatrix.SIZE; row++) { if (row % GameMatrix.BLOCK_SIZE == 0) { sb.append("\\hline"); sb.append(getLineSeparator()); } for (int column = 0; column < GameMatrix.SIZE; column++) { byte val = matrix.get(row, column); String str; if (val == GameMatrix.UNSET) { str = getUnknownCellContentCharacter(); } else { str = Integer.toString(val); } if (column != 0) { sb.append(TABLE_CELL_SEPARATOR); } sb.append(" "); sb.append(str); sb.append(" "); } sb.append("\\\\"); sb.append(getLineSeparator()); sb.append("\\hline"); sb.append(getLineSeparator()); } sb.append("\\end{tabular}"); sb.append(getLineSeparator()); sb.append("\\end{center}"); sb.append(getLineSeparator()); sb.append("\\vspace{25 mm}"); sb.append(getLineSeparator()); return sb.toString(); } LatexTableFormatter(); }
LatexTableFormatter extends AbstractTextFormatter { @Override public String format(final GameMatrix matrix) { StringBuilder sb = new StringBuilder(); sb.append("\\begin{center}"); sb.append("\\huge"); sb.append(getLineSeparator()); sb.append("\\begin{tabular}{"); for (int i = 0; i < GameMatrix.SIZE; i++) { if (i % GameMatrix.BLOCK_SIZE == 0 && i != 0) { sb.append("|"); } sb.append("|C{1.1em}"); } sb.append("|"); sb.append("}"); sb.append(getLineSeparator()); for (int row = 0; row < GameMatrix.SIZE; row++) { if (row % GameMatrix.BLOCK_SIZE == 0) { sb.append("\\hline"); sb.append(getLineSeparator()); } for (int column = 0; column < GameMatrix.SIZE; column++) { byte val = matrix.get(row, column); String str; if (val == GameMatrix.UNSET) { str = getUnknownCellContentCharacter(); } else { str = Integer.toString(val); } if (column != 0) { sb.append(TABLE_CELL_SEPARATOR); } sb.append(" "); sb.append(str); sb.append(" "); } sb.append("\\\\"); sb.append(getLineSeparator()); sb.append("\\hline"); sb.append(getLineSeparator()); } sb.append("\\end{tabular}"); sb.append(getLineSeparator()); sb.append("\\end{center}"); sb.append(getLineSeparator()); sb.append("\\vspace{25 mm}"); sb.append(getLineSeparator()); return sb.toString(); } LatexTableFormatter(); @Override String format(final GameMatrix matrix); @Override String documentStart(); @Override String documentEnd(); }
LatexTableFormatter extends AbstractTextFormatter { @Override public String format(final GameMatrix matrix) { StringBuilder sb = new StringBuilder(); sb.append("\\begin{center}"); sb.append("\\huge"); sb.append(getLineSeparator()); sb.append("\\begin{tabular}{"); for (int i = 0; i < GameMatrix.SIZE; i++) { if (i % GameMatrix.BLOCK_SIZE == 0 && i != 0) { sb.append("|"); } sb.append("|C{1.1em}"); } sb.append("|"); sb.append("}"); sb.append(getLineSeparator()); for (int row = 0; row < GameMatrix.SIZE; row++) { if (row % GameMatrix.BLOCK_SIZE == 0) { sb.append("\\hline"); sb.append(getLineSeparator()); } for (int column = 0; column < GameMatrix.SIZE; column++) { byte val = matrix.get(row, column); String str; if (val == GameMatrix.UNSET) { str = getUnknownCellContentCharacter(); } else { str = Integer.toString(val); } if (column != 0) { sb.append(TABLE_CELL_SEPARATOR); } sb.append(" "); sb.append(str); sb.append(" "); } sb.append("\\\\"); sb.append(getLineSeparator()); sb.append("\\hline"); sb.append(getLineSeparator()); } sb.append("\\end{tabular}"); sb.append(getLineSeparator()); sb.append("\\end{center}"); sb.append(getLineSeparator()); sb.append("\\vspace{25 mm}"); sb.append(getLineSeparator()); return sb.toString(); } LatexTableFormatter(); @Override String format(final GameMatrix matrix); @Override String documentStart(); @Override String documentEnd();  }