diff --git a/src/main/java/tui/Main.java b/src/main/java/tui/Main.java index d3d662b..45ee85c 100644 --- a/src/main/java/tui/Main.java +++ b/src/main/java/tui/Main.java @@ -1,10 +1,7 @@ package tui; -import java.util.Scanner; - public class Main { - public static void main(String[]args){ - TUI tui = new TUI(); + new TUI(); } } diff --git a/src/main/java/tui/TUI.java b/src/main/java/tui/TUI.java index a74ab4b..d23d052 100644 --- a/src/main/java/tui/TUI.java +++ b/src/main/java/tui/TUI.java @@ -5,45 +5,97 @@ import facade.WordCloudManager; import java.util.Scanner; public class TUI { - boolean isRunning; + private boolean isRunning; + private Scanner scan; + private int option; + private WordCloudManager wcm; + private boolean fMenu; public TUI(){ + wcm = new WordCloudManager(); isRunning = true; + fMenu = true; + scan = new Scanner(System.in); tui(); + } public void tui() { - Scanner scan = new Scanner(System.in); - WordCloudManager wcm = new WordCloudManager(); -// while(isRunning) { - System.out.println("Welcome to Word Cloud.\nMenu:\n\n(0) Load File from main path\n(1) Load File with Gui" + - "\n(2) Save File\n(3) Show Picture\n(4) Exit"); - int option = scan.nextInt(); + + + while(isRunning) { + System.out.println("Welcome to Word Cloud.\nType number in the following Menu to access your targeted Option.\nMenu:\n\n(0) Load File\n(1) URL Path" + + "\n(2) Exit"); + option = Integer.parseInt(scan.nextLine()); switch (option) { - case (0): - //Load File Path - break; - case (1): + case(0): //Load File GUI if(wcm.loadFileGUI()) { System.out.println("File loaded successful!\n"); + fileMenu(); } else { System.out.println("File cannot be loaded!\n"); } break; - case (2): - //Save Picture + case(1): + //URL Input break; - case (3): - //Show Picture - break; - case (4): + case(2): //Exit isRunning = false; System.out.println("Close Program!"); break; } -// } + } scan.close(); } + + public void fileMenu() { + while(fMenu) { + System.out.println("(0) Load Stopwords\n(1) Add to Stopwords\n(2) Set Max Words in HTML\n" + + "(3) Stemming? (only German available)\n(4) Create WordCloud\n(5) Exit FileMenu"); + option = Integer.parseInt(scan.nextLine()); + switch(option) { + case (0): + // Load stopwords file + if(wcm.loadFileGUI()) { + System.out.println("File loaded successful!\n"); + wcm.setStopWords(); + } else { + System.out.println("File cannot be loaded!\n"); + } + break; + case(1): + // Add more stopwords + System.out.println("Type your stopword:\n"); + String input = scan.nextLine(); + wcm.addToStopWords(input); + break; + case(2): + // Set number of max words + int number = Integer.parseInt(scan.nextLine()); + wcm.maxWordsInList(number); + wcm.cutWordsList(); + break; + case(3): + // Set Stemming + System.out.println("Set Stemming: Input 'yes' or 'no'"); + String stemmingOption = scan.nextLine(); + wcm.stemming(stemmingOption); + break; + case(4): + //Create WordCloud + wcm.tokenizingText(); + wcm.createWordCloud(); + fMenu = false; + System.out.println("HTML File created!"); + break; + case(5): + //Exit filemenu + fMenu = false; + System.out.println("Close Program!"); + break; + } + } + } }