Search in sources :

Example 1 with HTMLColumn

use of output.HTMLColumn in project solution-finder by knewjade.

the class LinkPathOutput method outputOperationsToSimpleHTML.

private void outputOperationsToSimpleHTML(Field field, MyFile file, List<PathPair> pathPairs, SizedBit sizedBit) throws FinderExecuteException {
    // Get height
    int maxClearLine = sizedBit.getHeight();
    // テト譜用のフィールド作成
    ColoredField initField = ColoredFieldFactory.createField(24);
    for (int y = 0; y < maxClearLine; y++) for (int x = 0; x < 10; x++) if (!field.isEmpty(x, y))
        initField.setColorType(ColorType.Gray, x, y);
    // 並び替える
    Comparator<PathPair> comparator = new PathPairComparator();
    pathPairs.sort(comparator);
    // HTMLの生成  // true: ライン消去あり, false: ライン消去なし
    HTMLBuilder<HTMLColumn> htmlBuilder = new HTMLBuilder<>("Path Result");
    htmlBuilder.addHeader(String.format("<div>%dパターン</div>", pathPairs.size()));
    pathPairs.parallelStream().forEach(pathPair -> {
        PathHTMLColumn htmlColumn = getHTMLColumn(pathPair);
        Pair<String, Integer> linkAndPriority = createALink(pathPair);
        String line = String.format("<div>%s</div>", linkAndPriority.getKey());
        htmlBuilder.addColumn(htmlColumn, line, -linkAndPriority.getValue());
    });
    // 出力
    try (BufferedWriter writer = file.newBufferedWriter()) {
        List<HTMLColumn> priorityList = Arrays.asList(PathHTMLColumn.NotDeletedLine, PathHTMLColumn.DeletedLine);
        for (String line : htmlBuilder.toList(priorityList, false)) writer.write(line);
        writer.flush();
    } catch (Exception e) {
        throw new FinderExecuteException("Failed to output file", e);
    }
}
Also used : ColoredField(common.tetfu.field.ColoredField) HTMLBuilder(output.HTMLBuilder) FinderExecuteException(exceptions.FinderExecuteException) FinderInitializeException(exceptions.FinderInitializeException) BufferedWriter(java.io.BufferedWriter) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) HTMLColumn(output.HTMLColumn) FinderExecuteException(exceptions.FinderExecuteException)

Aggregations

ColoredField (common.tetfu.field.ColoredField)1 FinderExecuteException (exceptions.FinderExecuteException)1 FinderInitializeException (exceptions.FinderInitializeException)1 BufferedWriter (java.io.BufferedWriter)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 HTMLBuilder (output.HTMLBuilder)1 HTMLColumn (output.HTMLColumn)1