Search in sources :

Example 1 with GifWriter

use of util.fig.output.GifWriter in project solution-finder by knewjade.

the class FigUtilEntryPoint method createGif.

private FigWriter createGif(MinoFactory minoFactory, ColorConverter colorConverter, FrameType frameType, File originalOutputFile, List<TetfuPage> usingTetfuPages) throws FinderException {
    String outputFilePath = getRemoveExtensionFromPath(getCanonicalPath(originalOutputFile));
    if (outputFilePath.isEmpty())
        outputFilePath = "fig";
    outputFilePath += ".gif";
    File outputFile = new File(outputFilePath);
    if (outputFile.isDirectory())
        throw new FinderInitializeException("Cannot specify directory as output file path: Output=" + settings.getOutputFilePath());
    if (outputFile.exists() && !outputFile.canWrite())
        throw new FinderInitializeException("Cannot write output file: Output=" + settings.getOutputFilePath());
    output("  .... Output to " + getCanonicalPath(outputFile));
    Quiz quiz = parseQuiz();
    // generatorの準備
    boolean usingHold = settings.isUsingHold();
    FigGenerator figGenerator = createFigGenerator(frameType, usingHold, minoFactory, colorConverter);
    // Bagの作成
    List<TetfuPage> tetfuPages = settings.getTetfuPages();
    int startPageIndex = settings.getStartPageIndex();
    int endPage = settings.getEndPage();
    Bag bag = createBag(colorConverter, startPageIndex, tetfuPages, quiz, usingTetfuPages);
    // もし開始ページ以降にQuizが含まれるときは無視することを警告
    if (tetfuPages.subList(startPageIndex + 1, endPage).stream().map(TetfuPage::getComment).anyMatch(s -> s.startsWith("#Q="))) {
        output("#### WARNING: Contains Quiz in tetfu after start page. ignored");
    }
    int nextBoxCount = settings.getNextBoxCount();
    int delay = settings.getDelay();
    boolean isInfiniteLoop = settings.getInfiniteLoop();
    return new GifWriter(minoFactory, colorConverter, figGenerator, bag, nextBoxCount, delay, outputFile, isInfiniteLoop);
}
Also used : TetfuPage(common.tetfu.TetfuPage) FinderInitializeException(exceptions.FinderInitializeException) FieldOnlyFigGenerator(util.fig.generator.FieldOnlyFigGenerator) NoHoldFigGenerator(util.fig.generator.NoHoldFigGenerator) AllFigGenerator(util.fig.generator.AllFigGenerator) FigGenerator(util.fig.generator.FigGenerator) GifWriter(util.fig.output.GifWriter) Bag(util.fig.Bag) File(java.io.File) EntryPoint(entry.EntryPoint)

Aggregations

TetfuPage (common.tetfu.TetfuPage)1 EntryPoint (entry.EntryPoint)1 FinderInitializeException (exceptions.FinderInitializeException)1 File (java.io.File)1 Bag (util.fig.Bag)1 AllFigGenerator (util.fig.generator.AllFigGenerator)1 FieldOnlyFigGenerator (util.fig.generator.FieldOnlyFigGenerator)1 FigGenerator (util.fig.generator.FigGenerator)1 NoHoldFigGenerator (util.fig.generator.NoHoldFigGenerator)1 GifWriter (util.fig.output.GifWriter)1