-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c821909
commit 75c6012
Showing
37 changed files
with
1,256 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Manifest-Version: 1.0 | ||
Main-Class: app.Main | ||
|
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,91 @@ | ||
package app; | ||
|
||
import app.about.AboutWindow; | ||
import app.gsheetedit.GradeSheetEditor; | ||
import app.license.LicenseWindow; | ||
import javafx.animation.FadeTransition; | ||
import javafx.application.Platform; | ||
import javafx.event.ActionEvent; | ||
import javafx.fxml.FXML; | ||
import javafx.scene.control.Alert; | ||
import javafx.scene.control.ButtonBar; | ||
import javafx.scene.control.ButtonType; | ||
import javafx.scene.image.ImageView; | ||
import javafx.util.Duration; | ||
import java.util.Optional; | ||
|
||
public class Controller extends ControllerAnimation | ||
{ | ||
@FXML | ||
public void quitMenuBtnAction (ActionEvent event) | ||
{ | ||
Alert alert = new Alert(Alert.AlertType.CONFIRMATION); | ||
alert.setTitle("Confirmation"); | ||
alert.setHeaderText("Are you sure to quit?"); | ||
alert.setContentText(null); | ||
|
||
alert.getDialogPane().setGraphic(new ImageView(new resources().questionIcon)); | ||
|
||
alert.initOwner(calculateButton.getScene().getWindow()); | ||
ButtonType yesButton = new ButtonType("Yes", ButtonBar.ButtonData.YES); | ||
ButtonType noButton = new ButtonType("No", ButtonBar.ButtonData.NO); | ||
alert.getButtonTypes().setAll(yesButton, noButton); | ||
Optional<ButtonType> alertStatus = alert.showAndWait(); | ||
if (alertStatus.isPresent() && alertStatus.get() == yesButton) { | ||
System.out.println("Quit"); | ||
Platform.exit(); | ||
} | ||
event.consume(); | ||
} | ||
|
||
@FXML | ||
public void calculateBtnAction (ActionEvent event) | ||
{ | ||
calculator cgpa = new calculator ( | ||
theoryBox.getText().strip(), | ||
labBox.getText().strip(), | ||
theoryCheckBox.isSelected(), | ||
labCheckBox.isSelected() | ||
); | ||
|
||
String result = String.valueOf(cgpa.getCGPA()); | ||
mainLabel.setText("Your cgpa is: " + result); | ||
|
||
// Main Label Fade In | ||
{ | ||
FadeTransition fadeIn = new FadeTransition(); | ||
fadeIn.setDuration(Duration.seconds(1)); | ||
fadeIn.setNode(mainLabel); | ||
fadeIn.setFromValue(0.0); | ||
fadeIn.setToValue(1.0); | ||
fadeIn.setCycleCount(1); | ||
fadeIn.setAutoReverse(false); | ||
fadeIn.playFromStart(); | ||
} | ||
event.consume(); | ||
} | ||
|
||
@FXML | ||
public void editSheetBtnAction (ActionEvent event) | ||
{ | ||
GradeSheetEditor x = new GradeSheetEditor(); | ||
x.showWindow(); | ||
event.consume(); | ||
} | ||
|
||
@FXML | ||
public void licenseMenuBtnAction (ActionEvent event) | ||
{ | ||
LicenseWindow licenseWindow = new LicenseWindow(); | ||
licenseWindow.showWindow(); | ||
event.consume(); | ||
} | ||
|
||
@FXML | ||
public void aboutMenuBtnAction (ActionEvent event) | ||
{ | ||
AboutWindow aboutWindow = new AboutWindow(); | ||
aboutWindow.showWindow(); | ||
event.consume(); | ||
} | ||
} |
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,137 @@ | ||
package app; | ||
|
||
import javafx.animation.FadeTransition; | ||
import javafx.animation.PathTransition; | ||
import javafx.animation.RotateTransition; | ||
import javafx.fxml.Initializable; | ||
import javafx.scene.shape.Line; | ||
import javafx.util.Duration; | ||
import java.net.URL; | ||
import java.util.ResourceBundle; | ||
|
||
|
||
class ControllerAnimation extends ControllerSceneObjectVars implements Initializable | ||
{ | ||
@Override | ||
public void initialize(URL url, ResourceBundle resourceBundle) | ||
{ | ||
// Making check boxes selected | ||
theoryCheckBox.setSelected(true); | ||
labCheckBox.setSelected(true); | ||
|
||
//Circle Image and Calculate Button Animation | ||
{ | ||
// Circle Image Rotation Part 1 | ||
{ | ||
RotateTransition rt = new RotateTransition(); | ||
rt.setNode(circleImage); | ||
rt.setDuration(Duration.seconds(1)); | ||
rt.setFromAngle(360); | ||
rt.setToAngle(0); | ||
rt.setAutoReverse(true); | ||
rt.setCycleCount(3); | ||
rt.play(); | ||
} | ||
|
||
// Calculate Button Rotation | ||
{ | ||
RotateTransition rt = new RotateTransition(); | ||
rt.setNode(calculateButton); | ||
rt.setDuration(Duration.seconds(2)); | ||
rt.setFromAngle(0); | ||
rt.setToAngle(360); | ||
rt.setAutoReverse(true); | ||
rt.setCycleCount(3); | ||
rt.play(); | ||
} | ||
|
||
// Circle Image Rotation Part 2 | ||
{ | ||
RotateTransition rt = new RotateTransition(); | ||
rt.setNode(circleImage); | ||
rt.setDuration(Duration.seconds(2)); | ||
rt.setFromAngle(360); | ||
rt.setToAngle(0); | ||
rt.setAutoReverse(false); | ||
rt.setCycleCount(2); | ||
rt.play(); | ||
} | ||
} | ||
|
||
// Main Label Slide and Fade In Animation | ||
{ | ||
// Fade In | ||
{ | ||
FadeTransition fadeIn = new FadeTransition(); | ||
fadeIn.setDuration(Duration.seconds(3)); | ||
fadeIn.setNode(mainLabel); | ||
fadeIn.setFromValue(0.0); | ||
fadeIn.setToValue(1.0); | ||
fadeIn.setCycleCount(1); | ||
fadeIn.setAutoReverse(false); | ||
fadeIn.playFromStart(); | ||
} | ||
// Slide | ||
{ | ||
Line line = new Line(); | ||
line.setStartX(-150); | ||
line.setStartY(30); | ||
line.setEndX(235); | ||
line.setEndY(30); | ||
PathTransition scaleIn2 = new PathTransition(); | ||
scaleIn2.setNode(mainLabel); | ||
scaleIn2.setDuration(Duration.seconds(3)); | ||
scaleIn2.setPath(line); | ||
scaleIn2.play(); | ||
} | ||
} | ||
|
||
// Theory Box Fade In Animation | ||
{ | ||
FadeTransition fadeIn = new FadeTransition(); | ||
fadeIn.setDuration(Duration.seconds(2)); | ||
fadeIn.setNode(theoryBox); | ||
fadeIn.setFromValue(0.0); | ||
fadeIn.setToValue(1.0); | ||
fadeIn.setCycleCount(1); | ||
fadeIn.setAutoReverse(false); | ||
fadeIn.playFromStart(); | ||
} | ||
|
||
// Lab Box Fade In Animation | ||
{ | ||
FadeTransition fadeIn = new FadeTransition(); | ||
fadeIn.setDuration(Duration.seconds(2)); | ||
fadeIn.setNode(labBox); | ||
fadeIn.setFromValue(0.0); | ||
fadeIn.setToValue(1.0); | ||
fadeIn.setCycleCount(1); | ||
fadeIn.setAutoReverse(false); | ||
fadeIn.playFromStart(); | ||
} | ||
|
||
// Theory CheckBox Fade In Animation | ||
{ | ||
FadeTransition fadeIn = new FadeTransition(); | ||
fadeIn.setDuration(Duration.seconds(1)); | ||
fadeIn.setNode(theoryCheckBox); | ||
fadeIn.setFromValue(0.0); | ||
fadeIn.setToValue(1.0); | ||
fadeIn.setCycleCount(3); | ||
fadeIn.setAutoReverse(true); | ||
fadeIn.playFromStart(); | ||
} | ||
|
||
// Lab CheckBox Fade In Animation | ||
{ | ||
FadeTransition fadeIn = new FadeTransition(); | ||
fadeIn.setDuration(Duration.seconds(1)); | ||
fadeIn.setNode(labCheckBox); | ||
fadeIn.setFromValue(0.0); | ||
fadeIn.setToValue(1.0); | ||
fadeIn.setCycleCount(3); | ||
fadeIn.setAutoReverse(true); | ||
fadeIn.playFromStart(); | ||
} | ||
} | ||
} |
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,36 @@ | ||
package app; | ||
|
||
import javafx.fxml.FXML; | ||
import javafx.scene.control.*; | ||
import javafx.scene.image.ImageView; | ||
import javafx.scene.layout.AnchorPane; | ||
|
||
class ControllerSceneObjectVars | ||
{ | ||
// Layouts | ||
@FXML protected AnchorPane mainForm; | ||
|
||
// Labels | ||
@FXML protected Label mainLabel; | ||
|
||
// Buttons | ||
@FXML protected Button calculateButton; | ||
|
||
// MenuItems | ||
@FXML protected MenuItem quitMenuBtn; | ||
@FXML protected MenuItem editSheetBtn; | ||
@FXML protected MenuItem licenseMenuBtn; | ||
@FXML protected MenuItem aboutMenuBtn; | ||
|
||
// TextFields | ||
@FXML protected TextField theoryBox; | ||
@FXML protected TextField labBox; | ||
|
||
// CheckBoxes | ||
@FXML protected CheckBox theoryCheckBox; | ||
@FXML protected CheckBox labCheckBox; | ||
|
||
// ImageViews | ||
@FXML protected ImageView circleImage; | ||
|
||
} |
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,35 @@ | ||
package app; | ||
|
||
public class ExtraWork | ||
{ | ||
public String appRootPath() | ||
{ | ||
String AppPath = System.getProperty("java.class.path"); | ||
StringBuilder x = new StringBuilder(); | ||
|
||
if (AppPath.contains(".jar;")) { | ||
AppPath = ""; | ||
} | ||
else if (AppPath.contains(".jar")) { | ||
if (this.isWindows()) { | ||
String[] tmp = AppPath.split("\\s*\\\\s*"); | ||
for (int i = 0; i < tmp.length-1; i++) | ||
x.append(tmp[i]).append("\\"); | ||
} else { | ||
String[] tmp = AppPath.split("\\s*/\\s*"); | ||
for (int i = 0; i < tmp.length-1; i++) | ||
x.append(tmp[i]).append("/"); | ||
} | ||
AppPath = x.toString(); | ||
} else { | ||
AppPath = ""; | ||
} | ||
return AppPath; | ||
} | ||
|
||
private boolean isWindows() | ||
{ | ||
String osName = System.getProperty("os.name"); | ||
return osName.contains("Windows"); | ||
} | ||
} |
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,77 @@ | ||
package app; | ||
|
||
import javafx.application.Application; | ||
import javafx.fxml.FXMLLoader; | ||
import javafx.scene.Parent; | ||
import javafx.scene.Scene; | ||
import javafx.scene.input.KeyCode; | ||
import javafx.scene.input.KeyEvent; | ||
import javafx.stage.Stage; | ||
|
||
public class Main extends Application | ||
{ | ||
private static Controller controller; | ||
|
||
@Override | ||
public void start(Stage primaryStage) throws Exception | ||
{ | ||
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("MainWindow.fxml")); | ||
Parent root = fxmlLoader.load(); | ||
controller = fxmlLoader.getController(); | ||
Scene scene = new Scene(root); | ||
scene.setOnKeyPressed(Main::handle); | ||
scene.getStylesheets().clear(); | ||
scene.getStylesheets().add(getClass().getResource("MainWindow.css").toExternalForm()); | ||
primaryStage.setTitle("CGPA Calculator"); | ||
primaryStage.setScene(scene); | ||
primaryStage.setResizable(false); | ||
primaryStage.setScene(scene); | ||
primaryStage.getIcons().add(new resources().icon); | ||
primaryStage.show(); | ||
} | ||
|
||
private static void handle(KeyEvent event) { | ||
// Shortcut Handling | ||
Object keyCode = event.getCode(); | ||
|
||
// Calculate Button Shortcut | ||
if (keyCode == KeyCode.C) { | ||
System.out.println("Shortcut key C is pressed"); | ||
controller.calculateButton.fire(); | ||
event.consume(); | ||
} | ||
|
||
// Edit Sheet Button Shortcut | ||
else if (keyCode == KeyCode.G) { | ||
System.out.println("Shortcut key G is pressed"); | ||
controller.editSheetBtn.fire(); | ||
event.consume(); | ||
} | ||
|
||
// Quit Button Shortcut | ||
else if (keyCode == KeyCode.Q) { | ||
System.out.println("Shortcut key Q is pressed"); | ||
controller.quitMenuBtn.fire(); | ||
event.consume(); | ||
} | ||
|
||
// License Button Shortcut | ||
else if (keyCode == KeyCode.L) { | ||
System.out.println("Shortcut key L is pressed"); | ||
controller.licenseMenuBtn.fire(); | ||
event.consume(); | ||
} | ||
|
||
// About Button Shortcut | ||
else if (keyCode == KeyCode.A) { | ||
System.out.println("Shortcut key A is pressed"); | ||
controller.aboutMenuBtn.fire(); | ||
event.consume(); | ||
} | ||
} | ||
|
||
public static void main(String[] args) | ||
{ | ||
launch(args); | ||
} | ||
} |
Oops, something went wrong.