-
Notifications
You must be signed in to change notification settings - Fork 580
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #93 from LHeng1/branch-ui-compare
Add basic UI for compare function
- Loading branch information
Showing
3 changed files
with
126 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package seedu.address.ui; | ||
|
||
import java.io.IOException; | ||
|
||
import javafx.fxml.FXML; | ||
import javafx.fxml.FXMLLoader; | ||
import javafx.scene.Scene; | ||
import javafx.scene.control.Label; | ||
import javafx.scene.shape.Rectangle; | ||
import javafx.stage.Stage; | ||
import seedu.address.MainApp; | ||
import seedu.address.model.person.Gpa; | ||
import seedu.address.model.person.Person; | ||
|
||
/** | ||
* The Compare Pop-up Window. Provides a separate JavaFX stage when a "compare" command is inputted. | ||
* This window is used to display and compare the details of two applicants, | ||
* including student number, name, and their relevant achievements. | ||
*/ | ||
public class CompareWindow extends Stage { | ||
@FXML | ||
private Label person1StuNum; | ||
@FXML | ||
private Label person2StuNum; | ||
@FXML | ||
private Label person1Name; | ||
@FXML | ||
private Label person1Gpa; | ||
@FXML | ||
private Label person2Name; | ||
@FXML | ||
private Label person2Gpa; | ||
@FXML | ||
private Label nameLabel; | ||
@FXML | ||
private Label gpaLabel; | ||
@FXML | ||
private Rectangle gpa1Highlight; | ||
@FXML | ||
private Rectangle gpa2Highlight; | ||
|
||
/** | ||
* Creates a new instance of the CompareWindow with information about two persons to be compared. | ||
* | ||
* @param person1 The first person for comparison. | ||
* @param person2 The second person for comparison. | ||
*/ | ||
public CompareWindow(Person person1, Person person2) { | ||
FXMLLoader fxmlLoader = new FXMLLoader(MainApp.class.getResource("/view/CompareWindow.fxml")); | ||
fxmlLoader.setController(this); | ||
try { | ||
fxmlLoader.load(); | ||
} catch (IOException e) { | ||
throw new RuntimeException(e); | ||
} | ||
|
||
setTitle("Comparison Result"); | ||
|
||
Gpa gpa1 = person1.getGpa(); | ||
Gpa gpa2 = person2.getGpa(); | ||
|
||
person1StuNum.setText(person1.getStudentNumber().toString()); | ||
person1Name.setText(person1.getName().toString()); | ||
person1Gpa.setText(gpa1.toString()); | ||
|
||
person2StuNum.setText(person2.getStudentNumber().toString()); | ||
person2Name.setText(person2.getName().toString()); | ||
person2Gpa.setText(gpa2.toString()); | ||
|
||
if (gpa1.compareTo(gpa2) > 0) { | ||
gpa1Highlight.setOpacity(0.33); | ||
} else if (gpa1.compareTo(gpa2) < 0) { | ||
gpa2Highlight.setOpacity(0.33); | ||
} | ||
|
||
Scene scene = new Scene(fxmlLoader.getRoot()); | ||
setWidth(900); | ||
setHeight(600); | ||
setScene(scene); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<?import javafx.geometry.Insets?> | ||
<?import javafx.scene.control.Label?> | ||
<?import javafx.scene.layout.ColumnConstraints?> | ||
<?import javafx.scene.layout.GridPane?> | ||
<?import javafx.scene.layout.RowConstraints?> | ||
<?import javafx.scene.shape.Rectangle?> | ||
|
||
<GridPane alignment="CENTER" gridLinesVisible="true" hgap="10.0" style="-fx-background-color: #616B6f;" vgap="10" xmlns="http://javafx.com/javafx/20.0.1" xmlns:fx="http://javafx.com/fxml/1"> | ||
<padding> | ||
<Insets bottom="100.0" left="100.0" right="100.0" top="100.0" /> | ||
</padding> | ||
<Label fx:id="person1Name" alignment="CENTER" contentDisplay="CENTER" prefHeight="17.0" prefWidth="80.0" textAlignment="CENTER" textFill="WHITE" GridPane.rowIndex="1" /> | ||
<Label fx:id="nameLabel" alignment="CENTER" prefWidth="40.0" text="Name" textAlignment="CENTER" textFill="WHITE" GridPane.columnIndex="1" GridPane.halignment="CENTER" GridPane.rowIndex="1" /> | ||
<Label fx:id="person2Name" alignment="CENTER" contentDisplay="CENTER" prefHeight="17.0" prefWidth="81.0" textAlignment="CENTER" textFill="WHITE" GridPane.columnIndex="2" GridPane.rowIndex="1" /> | ||
<Label fx:id="person1Gpa" alignment="CENTER" contentDisplay="CENTER" prefHeight="17.0" prefWidth="79.0" textAlignment="CENTER" textFill="WHITE" GridPane.rowIndex="2" /> | ||
<Label fx:id="gpaLabel" text="GPA" textFill="WHITE" GridPane.columnIndex="1" GridPane.halignment="CENTER" GridPane.rowIndex="2" /> | ||
<Label fx:id="person2Gpa" alignment="CENTER" contentDisplay="CENTER" prefHeight="17.0" prefWidth="79.0" textAlignment="CENTER" textFill="WHITE" GridPane.columnIndex="2" GridPane.rowIndex="2" /> | ||
<Label fx:id="stuNumLabel" alignment="CENTER" contentDisplay="CENTER" prefHeight="17.0" prefWidth="101.0" text="Student No." textAlignment="CENTER" textFill="WHITE" GridPane.columnIndex="1" /> | ||
<Label fx:id="interviewScoreLabel" alignment="CENTER" contentDisplay="CENTER" prefHeight="17.0" prefWidth="105.0" text="Interview Score" textAlignment="CENTER" textFill="WHITE" GridPane.columnIndex="1" GridPane.rowIndex="3" /> | ||
<Label fx:id="moduleGradeLabel" alignment="CENTER" contentDisplay="CENTER" prefHeight="17.0" prefWidth="105.0" text="Module Grade" textAlignment="CENTER" textFill="WHITE" GridPane.columnIndex="1" GridPane.rowIndex="4" /> | ||
<Label fx:id="ccaNumberLabel" alignment="CENTER" contentDisplay="CENTER" prefHeight="17.0" prefWidth="105.0" text="CCA Number" textAlignment="CENTER" textFill="WHITE" GridPane.columnIndex="1" GridPane.rowIndex="5" /> | ||
<Rectangle fx:id="gpa1Highlight" arcHeight="5.0" arcWidth="5.0" fill="#ffe100" height="25.0" opacity="0.0" stroke="WHITE" strokeType="INSIDE" width="80.0" GridPane.rowIndex="2" /> | ||
<Rectangle fx:id="gpa2Highlight" arcHeight="5.0" arcWidth="5.0" fill="#ffe100" height="25.0" opacity="0.0" stroke="WHITE" strokeType="INSIDE" width="80.0" GridPane.columnIndex="2" GridPane.rowIndex="2" /> | ||
<Label fx:id="person1StuNum" alignment="CENTER" prefHeight="17.0" prefWidth="79.0" textAlignment="CENTER" textFill="WHITE" /> | ||
<Label fx:id="person2StuNum" alignment="CENTER" prefHeight="17.0" prefWidth="79.0" textAlignment="CENTER" textFill="WHITE" GridPane.columnIndex="2" /> | ||
<columnConstraints> | ||
<ColumnConstraints prefWidth="80.0" /> | ||
<ColumnConstraints prefWidth="100.0" /> | ||
<ColumnConstraints prefWidth="80.0" /> | ||
</columnConstraints> | ||
<rowConstraints> | ||
<RowConstraints prefHeight="25.0" /> | ||
<RowConstraints maxHeight="66.00002034505209" minHeight="15.333333333333343" prefHeight="25.0" /> | ||
<RowConstraints maxHeight="66.00002034505209" minHeight="10.666656494140625" prefHeight="25.0" /> | ||
<RowConstraints maxHeight="66.00002034505209" minHeight="15.333333333333343" prefHeight="25.0" /> | ||
<RowConstraints maxHeight="66.00002034505209" minHeight="15.333333333333343" prefHeight="25.0" /> | ||
<RowConstraints maxHeight="66.00002034505209" minHeight="15.333333333333343" prefHeight="25.0" /> | ||
<RowConstraints maxHeight="60.0" minHeight="9.33331298828125" prefHeight="50.0" /> | ||
</rowConstraints> | ||
</GridPane> |