Skip to content

Commit

Permalink
Add reactive score component
Browse files Browse the repository at this point in the history
  • Loading branch information
jingting1412 committed Oct 28, 2023
1 parent 658c420 commit 41686a8
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 3 deletions.
29 changes: 26 additions & 3 deletions src/main/java/seedu/staffsnap/ui/ApplicantCard.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ public ApplicantCard(Applicant applicant, int displayedIndex) {
displayApplicantInterviews();
displayApplicantScore();
}


private void displayApplicantId(int displayedIndex) {
id.setText(displayedIndex + ". ");
}
Expand Down Expand Up @@ -173,11 +175,32 @@ private void displayApplicantScore() {
ratingLabel.getStyleClass().add("overall_rating_label");

Label scoreLabel = new Label();
scoreLabel.setText(applicant.getScore().hasRating()
? applicant.getScore().toString()
: "-");
String labelText = applicant.getScore().hasRating() ? applicant.getScore().toString() : "N.A.";
scoreLabel.setText(labelText);
scoreLabel.getStyleClass().add("score_label");

Color[] colours = { Color.TRANSPARENT, Color.web("#1a8cff"), Color.web("#3333cc"),
Color.web("#7a00cc"), Color.web("#cc0099"), Color.web("#ff0066"),
Color.web("#ff6600"), Color.web("#ffcc00"), Color.web("#ccff33"),
Color.web("#66ff33"), Color.web("#00ffcc")};

for (int i = 0; i < 10; i++) {
Arc arc = new Arc(0, 0, 43, 43,
90 + i * 36, -30);
arc.setType(ArcType.ROUND);
arc.setFill(Color.GREY);
stackedArcs.getChildren().add(arc);
}

double applicantRating = labelText.equals("N.A.") ? 0 : Double.parseDouble(labelText);
double ratingArcLength = -360 * (applicantRating / 10);
Arc ratingArc = new Arc(0, 0, 43, 43, 90, ratingArcLength);
Color arcColour = colours[(int) Math.floor(applicantRating)];
ratingArc.setFill(arcColour);
ratingArc.setType(ArcType.ROUND);

stackedArcs.getChildren().add(ratingArc);


overallRating.getChildren().addAll(stackedArcs, innerCircle, scoreLabel);
}
Expand Down
18 changes: 18 additions & 0 deletions src/test/java/seedu/staffsnap/ui/ApplicantCardTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package seedu.staffsnap.ui;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static seedu.staffsnap.testutil.Assert.assertThrows;

import java.net.URL;
import java.nio.file.Path;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;

import javafx.fxml.FXML;
import seedu.staffsnap.MainApp;

public class ApplicantCardTest {

}

0 comments on commit 41686a8

Please sign in to comment.