Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
ddeb1b60b8
5 changed files with 49 additions and 104 deletions
|
@ -1,14 +1,11 @@
|
|||
/**
|
||||
* @(#) App.java 0,1 2020/04/07
|
||||
* @(#) Application.java 0,2 2020/04/30
|
||||
* <p>
|
||||
* Copyright (c) 2020 Aberystwyth University.
|
||||
* All rights reserved.
|
||||
*/
|
||||
package uk.ac.aber.cs22120.group20.javafx;
|
||||
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.stage.FileChooser;
|
||||
import javafx.stage.Stage;
|
||||
import uk.ac.aber.cs22120.group20.json.DictionaryEntry;
|
||||
|
@ -16,9 +13,7 @@ import uk.ac.aber.cs22120.group20.json.JsonProcessing;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
* A class that launches the Welsh Vocabulary tutor Application.
|
||||
|
@ -31,89 +26,50 @@ import java.util.Scanner;
|
|||
* @author Oscar Pocock [osp1]
|
||||
* @author Waylen Watts [ncw]
|
||||
* @author Luke Wybar [law39]
|
||||
*
|
||||
* @version 0.1 Initial development
|
||||
*/
|
||||
public class Application extends javafx.application.Application {
|
||||
|
||||
|
||||
private JsonProcessing jsonProcessing = new JsonProcessing();
|
||||
private Scanner scanner = new Scanner(System.in);
|
||||
|
||||
// Dictionary containing all the words.
|
||||
public static LinkedList<DictionaryEntry> dictionary = new LinkedList<>();
|
||||
public static LinkedList<DictionaryEntry> practiseList = new LinkedList<>();
|
||||
|
||||
// Practice list containing all the practice words.
|
||||
public static LinkedList<DictionaryEntry> practiceList = new LinkedList<>();
|
||||
|
||||
// Json processor to import and export the json dictionary file.
|
||||
private JsonProcessing jsonProcessing = new JsonProcessing();
|
||||
|
||||
/**
|
||||
*
|
||||
* @param stage
|
||||
* @throws IOException
|
||||
*/
|
||||
@Override
|
||||
public void start(Stage stage) throws IOException {
|
||||
Scene scene;
|
||||
File jsonFileLocation = null;
|
||||
|
||||
while(jsonFileLocation ==null) {
|
||||
FileChooser fileChooser = new FileChooser();
|
||||
fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("Json Files", "*.json"));
|
||||
fileChooser.setTitle("Open Json File");
|
||||
jsonFileLocation = fileChooser.showOpenDialog(stage);
|
||||
}
|
||||
|
||||
final File jsonFileFinalLocation = jsonFileLocation;
|
||||
dictionary = jsonProcessing.readInJson(jsonFileFinalLocation);
|
||||
for (DictionaryEntry entry : dictionary) {
|
||||
if (entry.isPracticeWord()) {
|
||||
practiseList.add(entry);
|
||||
}
|
||||
}
|
||||
// dictionary.add(new DictionaryEntry("abbey", "abaty", "nm", false));
|
||||
// dictionary.add(new DictionaryEntry("believe", "credu", "verb", true));
|
||||
// dictionary.add(new DictionaryEntry("concert", "cyngerdd", "nm", false));
|
||||
// dictionary.add(new DictionaryEntry("disease", "clefyd", "nm", true));
|
||||
// dictionary.add(new DictionaryEntry("extremely", "dros ben", "other", false));
|
||||
// dictionary.add(new DictionaryEntry("flu", "ffliw", "nm", false));
|
||||
new ScreenSwitch(stage);
|
||||
// scene = new Scene(loadFXML("dictionary"));
|
||||
// stage.setScene(scene);
|
||||
// stage.setOnCloseRequest(e -> {
|
||||
// jsonProcessing.writeOutJson(jsonFileLocation, dictionary);
|
||||
// Platform.exit();
|
||||
// System.exit(0);
|
||||
// });
|
||||
// stage.show();
|
||||
// ScreenSwitch.setScene(scene);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Please now use ScreenSwitch swap method with SceneEnum
|
||||
* @param fxml
|
||||
* @throws IOException
|
||||
* @see ScreenSwitch
|
||||
* @see ScreenSwitch.SceneEnum
|
||||
*/
|
||||
static void setRoot(String fxml) throws IOException {
|
||||
ScreenSwitch.swap(ScreenSwitch.SceneEnum.dictionaryScene);
|
||||
}
|
||||
|
||||
// /**
|
||||
// *
|
||||
// * @param fxml
|
||||
// * @return
|
||||
// * @throws IOException
|
||||
// */
|
||||
// private static Parent loadFXML(String fxml) throws IOException {
|
||||
//// FXMLLoader fxmlLoader = new FXMLLoader(Application.class.getResource(fxml + ".fxml"));
|
||||
// FXMLLoader fxmlLoader = new FXMLLoader(new URL("file:src/main/resources/uk/ac/aber/cs22120/group20/" + fxml + ".fxml"));
|
||||
// return fxmlLoader.load();
|
||||
// }
|
||||
|
||||
/**
|
||||
*
|
||||
* @param args
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
launch();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param stage
|
||||
* @throws IOException
|
||||
*/
|
||||
@Override
|
||||
public void start(Stage stage) throws IOException {
|
||||
|
||||
// Prompts the user to load their dictionary json file.
|
||||
File jsonFileLocation = null;
|
||||
while (jsonFileLocation == null) {
|
||||
FileChooser fileChooser = new FileChooser();
|
||||
fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("Json Files", "*.json"));
|
||||
fileChooser.setTitle("Open Json File");
|
||||
jsonFileLocation = fileChooser.showOpenDialog(stage);
|
||||
}
|
||||
final File jsonFileFinalLocation = jsonFileLocation;
|
||||
dictionary = jsonProcessing.readInJson(jsonFileFinalLocation);
|
||||
|
||||
// Adds all words that are practice words to the practice list.
|
||||
for (DictionaryEntry entry : dictionary) {
|
||||
if (entry.isPracticeWord()) {
|
||||
practiceList.add(entry);
|
||||
}
|
||||
}
|
||||
new ScreenSwitch(stage);
|
||||
}
|
||||
}
|
|
@ -12,7 +12,6 @@ import javafx.collections.ObservableList;
|
|||
import javafx.collections.transformation.FilteredList;
|
||||
import javafx.collections.transformation.SortedList;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.control.TableColumn;
|
||||
import javafx.scene.control.TableRow;
|
||||
import javafx.scene.control.TableView;
|
||||
|
@ -21,13 +20,9 @@ import javafx.scene.image.Image;
|
|||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.stage.Stage;
|
||||
import uk.ac.aber.cs22120.group20.javafx.Application;
|
||||
import uk.ac.aber.cs22120.group20.json.DictionaryEntry;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
/**
|
||||
* A class that handles the keyboard and mouse input and interaction for the 'Dictionary Page' which is
|
||||
|
@ -160,16 +155,16 @@ public class DictionaryController extends SharedCodeController {
|
|||
if (row.getItem().isPracticeWord()) {
|
||||
Application.dictionary.get(list.indexOf(row.getItem())).setPracticeWord(false);
|
||||
ArrayList<DictionaryEntry> toRemove = new ArrayList<DictionaryEntry>();
|
||||
for (DictionaryEntry entry : Application.practiseList) {
|
||||
for (DictionaryEntry entry : Application.practiceList) {
|
||||
if (entry.equals(row.getItem())) {
|
||||
toRemove.add(entry);
|
||||
}
|
||||
}
|
||||
Application.practiseList.removeAll(toRemove);
|
||||
Application.practiceList.removeAll(toRemove);
|
||||
// row.getItem().setPracticeWord(false);
|
||||
} else if (!row.getItem().isPracticeWord()) {
|
||||
Application.dictionary.get(list.indexOf(row.getItem())).setPracticeWord(true);
|
||||
Application.practiseList.add(row.getItem());
|
||||
Application.practiceList.add(row.getItem());
|
||||
// row.getItem().setPracticeWord(true);
|
||||
}
|
||||
table.getSelectionModel().clearSelection();
|
||||
|
|
|
@ -45,10 +45,10 @@ public class FlashcardController extends SharedCodeController {
|
|||
@FXML
|
||||
private Text wordType;
|
||||
@FXML
|
||||
private Rectangle flashcard;
|
||||
@FXML
|
||||
private Text testWord;
|
||||
|
||||
@FXML
|
||||
private ImageView flashcard;
|
||||
@FXML
|
||||
private ImageView leftArrow;
|
||||
@FXML
|
||||
|
@ -76,9 +76,9 @@ public class FlashcardController extends SharedCodeController {
|
|||
|
||||
updateCounter();
|
||||
card = flashcard;
|
||||
|
||||
leftArrow.setImage(new Image(getClass().getResourceAsStream("/assets/icons/black_icons/50px/left-50.png")));
|
||||
rightArrow.setImage(new Image(getClass().getResourceAsStream("/assets/icons/black_icons/50px/right-50.png")));
|
||||
flashcard.setImage(new Image("file:src/main/resources/assets/flashcard/Flashcard.png"));
|
||||
leftArrow.setImage(new Image("file:src/main/resources/assets/icons/black_icons/50px/left-50.png"));
|
||||
rightArrow.setImage(new Image("file:src/main/resources/assets/icons/black_icons/50px/right-50.png"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -12,19 +12,14 @@ import javafx.collections.ObservableList;
|
|||
import javafx.collections.transformation.FilteredList;
|
||||
import javafx.collections.transformation.SortedList;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.stage.Stage;
|
||||
import uk.ac.aber.cs22120.group20.javafx.Application;
|
||||
import uk.ac.aber.cs22120.group20.json.DictionaryEntry;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
/**
|
||||
* A class that handles the keyboard and mouse input and interaction for the 'Dictionary Page' which is
|
||||
|
@ -83,7 +78,7 @@ public class PracticeListController extends SharedCodeController{
|
|||
langSort.setImage(new Image("file:src/main/resources/assets/icons/black_icons/50px/sort-lang-50.png"));
|
||||
|
||||
// list.addAll(Application.dictionary);
|
||||
list.addAll(Application.practiseList);
|
||||
list.addAll(Application.practiceList);
|
||||
// for (DictionaryEntry entry : Application.dictionary) {
|
||||
// if (entry.isPracticeWord())
|
||||
// list.add(entry);
|
||||
|
@ -150,13 +145,13 @@ public class PracticeListController extends SharedCodeController{
|
|||
}
|
||||
|
||||
ArrayList<DictionaryEntry> toRemove = new ArrayList<DictionaryEntry>();
|
||||
for (DictionaryEntry entry : Application.practiseList) {
|
||||
for (DictionaryEntry entry : Application.practiceList) {
|
||||
if (entry.equals(row.getItem())) {
|
||||
toRemove.add(entry);
|
||||
list.remove(row.getItem());
|
||||
}
|
||||
}
|
||||
Application.practiseList.removeAll(toRemove);
|
||||
Application.practiceList.removeAll(toRemove);
|
||||
table.getSelectionModel().clearSelection();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?import javafx.geometry.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.text.*?>
|
||||
|
@ -124,11 +124,10 @@
|
|||
<Insets top="25" right="25" bottom="10" left="25"/>
|
||||
</padding>
|
||||
<children>
|
||||
<StackPane alignment="CENTER" onMouseClicked="#handleFlashcardClick" VBox.vgrow="NEVER" minWidth="350">
|
||||
<StackPane alignment="CENTER" onMouseClicked="#handleFlashcardClick" minWidth="500">
|
||||
<children>
|
||||
<Rectangle fx:id="flashcard" width="550" height="360" fill="white" arcHeight="80" arcWidth="80"
|
||||
stroke="black"/>
|
||||
<Text textAlignment="CENTER" fx:id="testWord">
|
||||
<ImageView fx:id="flashcard" fitWidth="500" fitHeight="360"></ImageView>
|
||||
<Text textAlignment="CENTER" fx:id="testWord">
|
||||
<font>
|
||||
<Font size="55"/>
|
||||
</font>
|
||||
|
|
Reference in a new issue