Integrated dictionary screen with the menu.c

This commit is contained in:
top19 2020-04-29 17:19:42 +01:00
parent 86f62e76cd
commit e69991a4ac
2 changed files with 219 additions and 66 deletions

View file

@ -19,6 +19,7 @@ import javafx.scene.control.TableView;
import javafx.scene.control.TextField; import javafx.scene.control.TextField;
import javafx.scene.image.Image; import javafx.scene.image.Image;
import javafx.scene.image.ImageView; import javafx.scene.image.ImageView;
import javafx.scene.paint.Color;
import javafx.stage.Stage; import javafx.stage.Stage;
import uk.ac.aber.cs22120.group20.javafx.Application; import uk.ac.aber.cs22120.group20.javafx.Application;
import uk.ac.aber.cs22120.group20.json.DictionaryEntry; import uk.ac.aber.cs22120.group20.json.DictionaryEntry;
@ -45,12 +46,14 @@ import java.util.ResourceBundle;
* @see Application * @see Application
*/ */
//public class DictionaryController implements Initializable { //public class DictionaryController implements Initializable {
public class DictionaryController { public class DictionaryController extends SharedCodeController {
public static Stage primaryStage = null; public static Stage primaryStage = null;
@FXML @FXML
private ImageView alphaSort; private ImageView alphaSort;
@FXML @FXML
private ImageView langSort;
@FXML
private TextField searchBox; private TextField searchBox;
@FXML @FXML
private TableView<DictionaryEntry> table; private TableView<DictionaryEntry> table;
@ -135,6 +138,13 @@ public class DictionaryController {
* @see DictionaryEntry * @see DictionaryEntry
*/ */
public void initialize() { public void initialize() {
setup();
currentPageIcon.setImage(new Image(getClass().getResourceAsStream("/assets/icons/white_icons/50px/read-50.png")));
currentPageText.setText("Dictionary");
dictionaryIcon.setImage(new Image(getClass().getResourceAsStream("/assets/icons/black_icons/50px/read-50.png")));
dictionaryText.setFill(Color.BLACK);
list.addAll(Application.dictionary); list.addAll(Application.dictionary);
table.setRowFactory(tv -> { table.setRowFactory(tv -> {

View file

@ -12,69 +12,212 @@
<?import javafx.scene.layout.VBox?> <?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?> <?import javafx.scene.text.Font?>
<VBox alignment="CENTER" prefHeight="512.0" prefWidth="432.0" spacing="20.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="uk.ac.aber.cs22120.group20.javafx.DictionaryController"> <?import javafx.scene.layout.*?>
<children>
<HBox alignment="CENTER_LEFT" prefHeight="11.0" prefWidth="392.0" VBox.vgrow="NEVER"> <?import javafx.scene.shape.Rectangle?>
<children> <?import javafx.scene.image.ImageView?>
<Label minWidth="-Infinity" text="Search:"> <?import javafx.scene.text.Text?>
<font> <?import javafx.scene.text.Font?>
<Font name="System Bold" size="13.0" /> <BorderPane xmlns="http://javafx.com/javafx"
</font></Label> xmlns:fx="http://javafx.com/fxml"
<TextField fx:id="searchBox" prefHeight="26.0" prefWidth="519.0" HBox.hgrow="ALWAYS" /> fx:controller="uk.ac.aber.cs22120.group20.javafx.DictionaryController"
</children> fx:id="container"
</HBox> stylesheets=""
<HBox alignment="BOTTOM_CENTER" fillHeight="false" prefHeight="14.0" prefWidth="392.0" VBox.vgrow="NEVER"> minWidth="450"
<children> minHeight="550"
<HBox alignment="BOTTOM_CENTER" prefHeight="100.0" prefWidth="200.0" HBox.hgrow="ALWAYS"> >
<children>
<Label minWidth="-Infinity" text="English">
<font> <left>
<Font name="System Bold" size="13.0" />
</font></Label> <StackPane fx:id="outerBar">
</children> <Rectangle fx:id="sideBar" fill="dimgray" height="${outerBar.height}" width="50"></Rectangle>
<VBox spacing="300">
<VBox alignment="TOP_CENTER" maxHeight="${outerBar.height}">
<StackPane onMouseClicked="#dictionaryIconClick">
<Rectangle fill="white" height="60" width="${sideBar.width}"></Rectangle>
<HBox alignment="CENTER_RIGHT">
<Text fx:id="dictionaryText" fill="white">
<font>
<Font name="System Bold" size="25"></Font>
</font>
</Text>
<ImageView fx:id="dictionaryIcon"></ImageView>
</HBox>
</StackPane>
<StackPane onMouseClicked="#practiceListIconClick">
<Rectangle fill="dimgray" height="60" width="${sideBar.width}"></Rectangle>
<HBox alignment="CENTER_RIGHT">
<Text fx:id="practiceListTest" fill="white">
<font>
<Font name="System Bold" size="25"></Font>
</font>
</Text>
<ImageView fx:id="practiceListIcon"></ImageView>
</HBox>
</StackPane>
<StackPane onMouseClicked="#flashcardIconClick">
<Rectangle fill="dimgray" height="60" width="${sideBar.width}"></Rectangle>
<HBox alignment="CENTER_RIGHT">
<Text fx:id="flashcardsText" fill="white">
<font>
<Font name="System Bold" size="25"></Font>
</font>
</Text>
<ImageView fx:id="flashcardIcon"></ImageView>
</HBox>
</StackPane>
<StackPane onMouseClicked="#studyIconClick">
<Rectangle fill="dimgray" height="60" width="${sideBar.width}"></Rectangle>
<HBox alignment="CENTER_RIGHT">
<Text fx:id="studyText" fill="white">
<font>
<Font name="System Bold" size="25"></Font>
</font>
</Text>
<ImageView fx:id="studyIcon"></ImageView>
</HBox>
</StackPane>
</VBox>
<StackPane alignment="BOTTOM_CENTER" onMouseClicked="#addWordIconClick">
<Rectangle fill="dimgray" height="60" width="${sideBar.width}"></Rectangle>
<HBox alignment="CENTER_RIGHT">
<Text fx:id="addDefinitionText" fill="white">
<font>
<Font name="System Bold" size="25"></Font>
</font>
</Text>
<ImageView fx:id="addDefinitionIcon"></ImageView>
</HBox>
</StackPane>
</VBox>
</StackPane>
</left>
<top>
<StackPane fx:id="topBar">
<Rectangle fx:id="parentRectangle" fill="dimgray" width="${topBar.width}" height="50"></Rectangle>
<HBox alignment="CENTER_LEFT" prefWidth="${topBar.width}" spacing="7">
<StackPane onMouseClicked="#expandMenuClick">
<Rectangle fill="dimgray" width="55" height="50"></Rectangle>
<ImageView fx:id="expandMenuIcon"></ImageView>
</StackPane>
<ImageView fx:id="currentPageIcon"></ImageView>
<Text fx:id="currentPageText" fill="white">
<font>
<Font name="System Bold" size="25"></Font>
</font>
</Text>
</HBox> </HBox>
<HBox alignment="BOTTOM_CENTER" prefHeight="100.0" prefWidth="200.0">
<children> </StackPane>
<ImageView fx:id="alphaSort" fitHeight="20.0" fitWidth="20.0" onMouseClicked="#switchAlphaSort" pickOnBounds="true" preserveRatio="true"> </top>
<image>
<Image url="@../../../../../assets/icons/black_icons/50px/sort-alpha-up-50.png" /> <center>
</image>
<HBox.margin> <VBox alignment="CENTER" prefHeight="512.0" prefWidth="432.0" spacing="20.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1">
<Insets right="5.0" /> <children>
</HBox.margin> <HBox alignment="CENTER_LEFT" prefHeight="11.0" prefWidth="392.0" VBox.vgrow="NEVER">
</ImageView> <children>
<ImageView fitHeight="20.0" fitWidth="20.0" onMouseClicked="#switchLangSort" pickOnBounds="true" preserveRatio="true"> <Label minWidth="-Infinity" text="Search:">
<image> <font>
<Image url="@../../../../../assets/icons/black_icons/50px/sort-lang-50.png" /> <Font name="System Bold" size="13.0" />
</image> </font></Label>
<HBox.margin> <TextField fx:id="searchBox" prefHeight="26.0" prefWidth="519.0" HBox.hgrow="ALWAYS" />
<Insets left="5.0" /> </children>
</HBox.margin> </HBox>
</ImageView> <HBox alignment="BOTTOM_CENTER" fillHeight="false" prefHeight="14.0" prefWidth="392.0" VBox.vgrow="NEVER">
</children> <children>
</HBox> <HBox alignment="BOTTOM_CENTER" prefHeight="100.0" prefWidth="200.0" HBox.hgrow="ALWAYS">
<HBox alignment="BOTTOM_CENTER" prefHeight="100.0" prefWidth="200.0" HBox.hgrow="ALWAYS"> <children>
<children> <Label minWidth="-Infinity" text="English">
<Label minWidth="-Infinity" text="Welsh"> <font>
<font> <Font name="System Bold" size="13.0" />
<Font name="System Bold" size="13.0" /> </font></Label>
</font></Label> </children>
</children> </HBox>
</HBox> <HBox alignment="BOTTOM_CENTER" prefHeight="100.0" prefWidth="200.0">
</children> <children>
</HBox> <ImageView fx:id="alphaSort" fitHeight="20.0" fitWidth="20.0" onMouseClicked="#switchAlphaSort" pickOnBounds="true" preserveRatio="true">
<TableView fx:id="table" VBox.vgrow="ALWAYS"> <HBox.margin>
<columns> <Insets right="5.0" />
<TableColumn fx:id="english" prefWidth="196.0" text="English" /> </HBox.margin>
<TableColumn fx:id="welsh" prefWidth="195.0" text="Welsh" /> </ImageView>
</columns> <ImageView fx:id="langSort" fitHeight="20.0" fitWidth="20.0" onMouseClicked="#switchLangSort" pickOnBounds="true" preserveRatio="true">
<columnResizePolicy>
<TableView fx:constant="CONSTRAINED_RESIZE_POLICY" /> <HBox.margin>
</columnResizePolicy> <Insets left="5.0" />
</TableView> </HBox.margin>
<Button fx:id="primaryButton" onAction="#switchToPracticeList" text="Switch to Practice List" /> </ImageView>
</children> </children>
<padding> </HBox>
<Insets bottom="20.0" left="20.0" right="20.0" top="20.0" /> <HBox alignment="BOTTOM_CENTER" prefHeight="100.0" prefWidth="200.0" HBox.hgrow="ALWAYS">
</padding> <children>
</VBox> <Label minWidth="-Infinity" text="Welsh">
<font>
<Font name="System Bold" size="13.0" />
</font></Label>
</children>
</HBox>
</children>
</HBox>
<TableView fx:id="table" VBox.vgrow="ALWAYS">
<columns>
<TableColumn fx:id="english" prefWidth="196.0" text="English" />
<TableColumn fx:id="welsh" prefWidth="195.0" text="Welsh" />
</columns>
<columnResizePolicy>
<TableView fx:constant="CONSTRAINED_RESIZE_POLICY" />
</columnResizePolicy>
</TableView>
<Button fx:id="primaryButton" onAction="#switchToPracticeList" text="Switch to Practice List" />
</children>
<padding>
<Insets bottom="20.0" left="20.0" right="20.0" top="20.0" />
</padding>
</VBox>
</center>
</BorderPane>