package de.duehl.vocabulary.japanese.logic.symbol.kanji.strokes.test;

import java.awt.Dimension;
import java.util.List;

import javax.swing.JFrame;
import javax.swing.SwingUtilities;

import de.duehl.vocabulary.japanese.logic.symbol.kanji.strokes.own.KanjiStrokesDataStructureGenerator;
import de.duehl.vocabulary.japanese.logic.symbol.kanji.strokes.own.data.KanjiStrokePath;
import de.duehl.vocabulary.japanese.logic.symbol.kanji.strokes.own.data.KanjiStrokes;
import de.duehl.vocabulary.japanese.ui.dialog.kanji.stroke.KanjiStrokePanel;

public class KanjiStrokePanelStartForTesting {

    public static void main(String[] args) {
        KanjiStrokesDataStructureGenerator generator = new KanjiStrokesDataStructureGenerator();
        generator.generate();

        KanjiStrokes kanjiStrokes = new KanjiStrokes(generator.getKanjiStrokesByCodePoint());

        String kanji = "漢";
        if (!kanjiStrokes.knowsPathesForKanji(kanji)) {
            System.out.println("Zum Kanji " + kanji + " sind keine Striche hinterlegt.");
        }
        else {
            List<KanjiStrokePath> hanKanjiStrokes = kanjiStrokes.getPathesByKanji(kanji);
            KanjiStrokePanel kanjiStrokePanel = new KanjiStrokePanel(hanKanjiStrokes);
            kanjiStrokePanel.setPreferredSize(new Dimension(109, 109));
            kanjiStrokePanel.setBorderWidth(0);
            kanjiStrokePanel.setActualStrokeNumber(5);

            SwingUtilities.invokeLater(() -> {
                JFrame frame = new JFrame(kanji);
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                frame.setContentPane(kanjiStrokePanel);
                frame.pack();
                frame.setLocationByPlatform(true);
                frame.setVisible(true);
            });
        }
    }

}
