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.swing.ui.GuiTools;
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.KanjiStrokeWithControlsPanel;

public class KanjiStrokeWithControlsPanelStartForTesting {

    public static void main(String[] args) {
        GuiTools.setNiceLayoutManager();

        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);

            KanjiStrokeWithControlsPanel kanjiStrokeWithControlsPanel =
                    new KanjiStrokeWithControlsPanel(hanKanjiStrokes);
            kanjiStrokeWithControlsPanel.setPreferredSize(new Dimension(750, 800));
            kanjiStrokeWithControlsPanel.setBorderWidth(2);
            kanjiStrokeWithControlsPanel.setActualStrokeNumber(5);

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

}
