Search in sources :

Example 1 with FinderInitializeException

use of exceptions.FinderInitializeException in project solution-finder by knewjade.

the class PathEntryPoint method createPathCore.

private PathCore createPathCore(Field field, int maxClearLine, int maxDepth, List<String> patterns, MinoFactory minoFactory, ColorConverter colorConverter, SizedBit sizedBit, SolutionFilter solutionFilter, boolean isUsingHold, BasicSolutions basicSolutions, int threadCount) throws FinderInitializeException, FinderExecuteException {
    assert 1 <= threadCount;
    List<InOutPairField> inOutPairFields = InOutPairField.createInOutPairFields(sizedBit, field);
    TaskResultHelper taskResultHelper = createTaskResultHelper(maxClearLine);
    PerfectPackSearcher searcher = new PerfectPackSearcher(inOutPairFields, basicSolutions, sizedBit, solutionFilter, taskResultHelper, threadCount != 1);
    FumenParser fumenParser = createFumenParser(settings.isTetfuSplit(), minoFactory, colorConverter);
    ThreadLocal<BuildUpStream> threadLocalBuildUpStream = createBuildUpStreamThreadLocal(settings.getDropType(), maxClearLine);
    try {
        return new PathCore(patterns, searcher, maxDepth, isUsingHold, fumenParser, threadLocalBuildUpStream);
    } catch (SyntaxException e) {
        output("Pattern syntax error");
        output(e.getMessage());
        throw new FinderInitializeException("Pattern syntax error", e);
    }
}
Also used : FinderInitializeException(exceptions.FinderInitializeException) InOutPairField(searcher.pack.InOutPairField) SyntaxException(common.SyntaxException) PerfectPackSearcher(searcher.pack.task.PerfectPackSearcher) TaskResultHelper(searcher.pack.task.TaskResultHelper) BuildUpStream(common.buildup.BuildUpStream)

Example 2 with FinderInitializeException

use of exceptions.FinderInitializeException in project solution-finder by knewjade.

the class FigUtilEntryPoint method createPng.

private FigWriter createPng(MinoFactory minoFactory, ColorConverter colorConverter, FrameType frameType, List<TetfuPage> usingTetfuPages) throws FinderException {
    // 日付から新しいディレクトリ名を生成
    Date date = new Date();
    SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd_HHmmss");
    String dateDirName = format.format(date);
    // 出力先の親ディレクトリを取得
    File originOutputFile = new File(settings.getOutputFilePath());
    File parentDirectory = originOutputFile.getParentFile();
    // 出力先ディレクトリを作成
    String baseName = getCanonicalPath(parentDirectory) + File.separatorChar + dateDirName;
    File outputDirectoryFile = new File(baseName);
    for (int suffix = 0; outputDirectoryFile.exists(); suffix++) {
        outputDirectoryFile = new File(baseName + "_" + suffix);
    }
    // ファイル名の取得
    String outputFileName = getRemoveExtensionFromPath(originOutputFile.getName());
    if (outputFileName.isEmpty())
        outputFileName = "fig";
    // 出力先ディレクトリがない場合は作成
    if (!outputDirectoryFile.exists()) {
        boolean mkdirsSuccess = outputDirectoryFile.mkdirs();
        if (!mkdirsSuccess) {
            throw new FinderInitializeException("Failed to make output directory: OutputFilePath=" + originOutputFile.getName());
        }
    }
    output("  .... Output to " + getCanonicalPath(outputDirectoryFile));
    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");
    }
    String path = String.format("%s" + File.separatorChar + "%s", getCanonicalPath(outputDirectoryFile), outputFileName);
    int nextBoxCount = settings.getNextBoxCount();
    return new PngWriter(minoFactory, colorConverter, figGenerator, bag, nextBoxCount, path, startPageIndex);
}
Also used : TetfuPage(common.tetfu.TetfuPage) FinderInitializeException(exceptions.FinderInitializeException) Bag(util.fig.Bag) Date(java.util.Date) EntryPoint(entry.EntryPoint) PngWriter(util.fig.output.PngWriter) FieldOnlyFigGenerator(util.fig.generator.FieldOnlyFigGenerator) NoHoldFigGenerator(util.fig.generator.NoHoldFigGenerator) AllFigGenerator(util.fig.generator.AllFigGenerator) FigGenerator(util.fig.generator.FigGenerator) SimpleDateFormat(java.text.SimpleDateFormat) File(java.io.File)

Example 3 with FinderInitializeException

use of exceptions.FinderInitializeException 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)

Example 4 with FinderInitializeException

use of exceptions.FinderInitializeException in project solution-finder by knewjade.

the class Verify method patterns.

public static PatternGenerator patterns(List<String> patterns, int depth) throws FinderInitializeException {
    PatternGenerator generator = patterns(patterns);
    int piecesDepth = generator.getDepth();
    if (piecesDepth < depth)
        throw new FinderInitializeException(String.format("Should specify equal to or more than %d pieces: CurrentPieces=%d", depth, piecesDepth));
    return generator;
}
Also used : PatternGenerator(common.pattern.PatternGenerator) LoadedPatternGenerator(common.pattern.LoadedPatternGenerator) FinderInitializeException(exceptions.FinderInitializeException)

Aggregations

FinderInitializeException (exceptions.FinderInitializeException)4 TetfuPage (common.tetfu.TetfuPage)2 EntryPoint (entry.EntryPoint)2 File (java.io.File)2 Bag (util.fig.Bag)2 AllFigGenerator (util.fig.generator.AllFigGenerator)2 FieldOnlyFigGenerator (util.fig.generator.FieldOnlyFigGenerator)2 FigGenerator (util.fig.generator.FigGenerator)2 NoHoldFigGenerator (util.fig.generator.NoHoldFigGenerator)2 SyntaxException (common.SyntaxException)1 BuildUpStream (common.buildup.BuildUpStream)1 LoadedPatternGenerator (common.pattern.LoadedPatternGenerator)1 PatternGenerator (common.pattern.PatternGenerator)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 InOutPairField (searcher.pack.InOutPairField)1 PerfectPackSearcher (searcher.pack.task.PerfectPackSearcher)1 TaskResultHelper (searcher.pack.task.TaskResultHelper)1 GifWriter (util.fig.output.GifWriter)1 PngWriter (util.fig.output.PngWriter)1