Development of a JavaFX-Based Flowchart Decision Facilitator Project
VerifiedAdded on  2021/04/16
|11
|2112
|36
Project
AI Summary
This document details a student's project involving the creation of a Flowchart Decision Facilitator using JavaFX. The project encompasses several key components, including the development of classes such as Node, FlowChart, Decision, ActionNode, ConsoleUI, and GUI, all implemented using object-oriented programming principles in Java. The application allows users to create, visualize, and execute flowcharts, incorporating action and decision nodes. The GUI facilitates user interaction through features such as adding nodes, creating connections, and running the flowchart logic. The project also includes comprehensive testing, code snippets, and a reflective commentary discussing the development process, challenges, and achievements. The student successfully created a functional application that meets its objectives and requirements, enabling users to design and execute flowcharts effectively. The project references Jackson's work on digital illustration and object-oriented programming to support the design and implementation of the application.

Information Technology
[Student University]
[Student Name]
[Student University]
[Student Name]
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser

Testing Identifiers
Identifier Name of test Expected result
getScreenY invalidIdentifier 1
getChildren() validSyntax 1
rectangle validIdentifier 1
Testing Output
Before completion
After completion
Identifier Name of test Expected result
getScreenY invalidIdentifier 1
getChildren() validSyntax 1
rectangle validIdentifier 1
Testing Output
Before completion
After completion

Code snippet
The below codes are the codes of each class that was created
Node
view.arrowClicked(event -> {
if (shapeList.size() >= 2){
view.setEffect("arrowOn");
view.changeWorkspaceBackgroud("rgba(212, 232, 251, 0.51)");
view.setHelptext("Click on the first shape for starting point...");
final Delta startEnd = new Delta();
shapeList.forEach(shape -> {
shape.setOnMouseClicked(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
//point A, primary click on mouse:
if (!event.isShiftDown()) {
startEnd.startX = shape.getTranslateX() +
(shape.getLayoutBounds().getWidth() / 2);
startEnd.startY = shape.getTranslateY() +
(shape.getLayoutBounds().getHeight() / 2);
shapeArray[0] = shape;
view.setHelptext("Hold shift and click on the second shape for end point.");
}
//point B, SHIFT + primary click on mouse:
if (event.isShiftDown()) {
startEnd.endX = shape.getTranslateX() +
(shape.getLayoutBounds().getWidth() / 2);
startEnd.endY = shape.getTranslateY() +
(shape.getLayoutBounds().getHeight() / 2);
shapeArray[1] = shape;
}
//create line:
if (shapeArray[0] != null && shapeArray[1] != null) {
FlowLine createLine2 = new FlowLine(shapeArray[0], shapeArray[1]);
The below codes are the codes of each class that was created
Node
view.arrowClicked(event -> {
if (shapeList.size() >= 2){
view.setEffect("arrowOn");
view.changeWorkspaceBackgroud("rgba(212, 232, 251, 0.51)");
view.setHelptext("Click on the first shape for starting point...");
final Delta startEnd = new Delta();
shapeList.forEach(shape -> {
shape.setOnMouseClicked(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
//point A, primary click on mouse:
if (!event.isShiftDown()) {
startEnd.startX = shape.getTranslateX() +
(shape.getLayoutBounds().getWidth() / 2);
startEnd.startY = shape.getTranslateY() +
(shape.getLayoutBounds().getHeight() / 2);
shapeArray[0] = shape;
view.setHelptext("Hold shift and click on the second shape for end point.");
}
//point B, SHIFT + primary click on mouse:
if (event.isShiftDown()) {
startEnd.endX = shape.getTranslateX() +
(shape.getLayoutBounds().getWidth() / 2);
startEnd.endY = shape.getTranslateY() +
(shape.getLayoutBounds().getHeight() / 2);
shapeArray[1] = shape;
}
//create line:
if (shapeArray[0] != null && shapeArray[1] != null) {
FlowLine createLine2 = new FlowLine(shapeArray[0], shapeArray[1]);
⊘ This is a preview!⊘
Do you want full access?
Subscribe today to unlock all pages.

Trusted by 1+ million students worldwide

view.addToWorkspace(createLine2);
arrowList.add(createLine2);
createLine2.toBack();
shapeArray[0] = null;
shapeArray[1] = null;
view.setEffect("arrowOff");
view.changeWorkspaceBackgroud("null");
view.setHelptext("");
//clear listeners from all shapes when done(adds the original rightclick
listener):
rightClickListener();
}
}
});
});
}
else{
//helptext shows for 2seconds.
view.setHelptext("Requires at least two shapes.");
Timeline timeline = new Timeline(new KeyFrame(
Duration.millis(2000),
ae -> view.setHelptext("")));
timeline.play();
}
});
public double getDisplayX() {
String text = "";
TextInputDialog dialog = new TextInputDialog();
dialog.setTitle("");
dialog.setHeaderText("Create text");
dialog.setContentText("Please enter your text:");
Optional<String> result = dialog.showAndWait();
if (result.isPresent()){
text = result.get();
}
else {
text = "cancel";
arrowList.add(createLine2);
createLine2.toBack();
shapeArray[0] = null;
shapeArray[1] = null;
view.setEffect("arrowOff");
view.changeWorkspaceBackgroud("null");
view.setHelptext("");
//clear listeners from all shapes when done(adds the original rightclick
listener):
rightClickListener();
}
}
});
});
}
else{
//helptext shows for 2seconds.
view.setHelptext("Requires at least two shapes.");
Timeline timeline = new Timeline(new KeyFrame(
Duration.millis(2000),
ae -> view.setHelptext("")));
timeline.play();
}
});
public double getDisplayX() {
String text = "";
TextInputDialog dialog = new TextInputDialog();
dialog.setTitle("");
dialog.setHeaderText("Create text");
dialog.setContentText("Please enter your text:");
Optional<String> result = dialog.showAndWait();
if (result.isPresent()){
text = result.get();
}
else {
text = "cancel";
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser

}
return text;
return 0;
}
FlowChart
public void setStartNode(Node startNode) {
String label = getLabel(); //gets label from superclass:
Text diamondText = new Text(label);
diamondText.setTextAlignment(TextAlignment.CENTER);
if (!label.equals("cancel")) {
double diamondwidth = diamondText.getLayoutBounds().getWidth() + 17;
if (diamondwidth < 35){
diamondwidth = 40;
}
Rectangle diamond = new Rectangle(diamondwidth, diamondwidth);
diamond.setFill(getColor());
diamond.setStroke(Color.BLACK);
diamond.setRotate(45);
setGlow(this);
this.getChildren().addAll(diamond, diamondText);
this.setMinWidth(diamondwidth+30);
this.setMinHeight(diamondwidth+30);
}
}
Gui
private void performAddNodeDialog(MouseEvent me) {
Stage popupStage = new Stage();
popupStage.setX(me.getScreenX());
popupStage.setY(me.getScreenY());
popupStage.initModality(Modality.APPLICATION_MODAL);
popupStage.setTitle("Add Node");
VBox root = new VBox();
HBox hbox = new HBox();
Button addActionButton = new Button("Add Action");
Button addDecisionButton = new Button("Add Decision");
Button cancelButton = new Button("Cancel");
hbox.getChildren().add(addActionButton);
hbox.getChildren().add(addDecisionButton);
hbox.getChildren().add(cancelButton);
TextArea textArea = new TextArea();
textArea.setPromptText("Enter Name");
return text;
return 0;
}
FlowChart
public void setStartNode(Node startNode) {
String label = getLabel(); //gets label from superclass:
Text diamondText = new Text(label);
diamondText.setTextAlignment(TextAlignment.CENTER);
if (!label.equals("cancel")) {
double diamondwidth = diamondText.getLayoutBounds().getWidth() + 17;
if (diamondwidth < 35){
diamondwidth = 40;
}
Rectangle diamond = new Rectangle(diamondwidth, diamondwidth);
diamond.setFill(getColor());
diamond.setStroke(Color.BLACK);
diamond.setRotate(45);
setGlow(this);
this.getChildren().addAll(diamond, diamondText);
this.setMinWidth(diamondwidth+30);
this.setMinHeight(diamondwidth+30);
}
}
Gui
private void performAddNodeDialog(MouseEvent me) {
Stage popupStage = new Stage();
popupStage.setX(me.getScreenX());
popupStage.setY(me.getScreenY());
popupStage.initModality(Modality.APPLICATION_MODAL);
popupStage.setTitle("Add Node");
VBox root = new VBox();
HBox hbox = new HBox();
Button addActionButton = new Button("Add Action");
Button addDecisionButton = new Button("Add Decision");
Button cancelButton = new Button("Cancel");
hbox.getChildren().add(addActionButton);
hbox.getChildren().add(addDecisionButton);
hbox.getChildren().add(cancelButton);
TextArea textArea = new TextArea();
textArea.setPromptText("Enter Name");

double displayX = me.getSceneX() / displayArea.getWidth();
double displayY = me.getSceneY() / displayArea.getHeight();
cancelButton.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
popupStage.close();
}
});
addActionButton.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
ActionNode node = flowChart.addAction(textArea.getText(),
displayX, displayY);
if (flowChart.getNbrNodes() == 1) {
flowChart.setStartNode(node);
runButton.setDisable(false);
}
popupStage.close();
}
});
addDecisionButton.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
DecisionNode node = flowChart.addDecision(textArea.getText(),
displayX, displayY);
if (flowChart.getNbrNodes() == 1) {
flowChart.setStartNode(node);
runButton.setDisable(false);
}
popupStage.close();
}
});
root.getChildren().add(hbox);
root.getChildren().add(textArea);
Scene popupScene = new Scene(root);
popupStage.setScene(popupScene);
popupStage.showAndWait();
}
Decision
public void setNext(Node node, boolean choice) {
double displayY = me.getSceneY() / displayArea.getHeight();
cancelButton.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
popupStage.close();
}
});
addActionButton.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
ActionNode node = flowChart.addAction(textArea.getText(),
displayX, displayY);
if (flowChart.getNbrNodes() == 1) {
flowChart.setStartNode(node);
runButton.setDisable(false);
}
popupStage.close();
}
});
addDecisionButton.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
DecisionNode node = flowChart.addDecision(textArea.getText(),
displayX, displayY);
if (flowChart.getNbrNodes() == 1) {
flowChart.setStartNode(node);
runButton.setDisable(false);
}
popupStage.close();
}
});
root.getChildren().add(hbox);
root.getChildren().add(textArea);
Scene popupScene = new Scene(root);
popupStage.setScene(popupScene);
popupStage.showAndWait();
}
Decision
public void setNext(Node node, boolean choice) {
⊘ This is a preview!⊘
Do you want full access?
Subscribe today to unlock all pages.

Trusted by 1+ million students worldwide

public FlowEllipse() {
String label = getLabel(); //gets label from superclass:
Text ellipseText = new Text(label);
ellipseText.setTextAlignment(TextAlignment.CENTER);
if (!label.equals("cancel")) {
double ellipseWidth = ellipseText.getLayoutBounds().getWidth() + 7;
if (ellipseWidth < 26){
ellipseWidth = 30;
}
Ellipse ellipse = new Ellipse(ellipseWidth, 23);
ellipse.setFill(getColor());
ellipse.setStroke(Color.BLACK);
setGlow(this);
this.getChildren().addAll(ellipse, ellipseText);
}
}
}
Action Node
public void setNext(Node nextNode) {
String textLabel = getText();
if (!textLabel.equals("cancel")) {
Text text = new Text(textLabel);
this.getChildren().add(text);
}
String label = getLabel(); //gets label from superclass:
Text rectText = new Text(label);
rectText.setTextAlignment(TextAlignment.CENTER);
if (!label.equals("cancel")) {
double rectWidth = rectText.getLayoutBounds().getWidth() + 40;
if (rectWidth < 60){
rectWidth = 60;
}
GUI rectangle = new GUI(rectWidth, 43);
rectangle.setFill(getColor());
rectangle.setStroke(Color.BLACK);
setGlow(this);
this.getChildren().addAll(rectangle, rectText);
}
}
String label = getLabel(); //gets label from superclass:
Text ellipseText = new Text(label);
ellipseText.setTextAlignment(TextAlignment.CENTER);
if (!label.equals("cancel")) {
double ellipseWidth = ellipseText.getLayoutBounds().getWidth() + 7;
if (ellipseWidth < 26){
ellipseWidth = 30;
}
Ellipse ellipse = new Ellipse(ellipseWidth, 23);
ellipse.setFill(getColor());
ellipse.setStroke(Color.BLACK);
setGlow(this);
this.getChildren().addAll(ellipse, ellipseText);
}
}
}
Action Node
public void setNext(Node nextNode) {
String textLabel = getText();
if (!textLabel.equals("cancel")) {
Text text = new Text(textLabel);
this.getChildren().add(text);
}
String label = getLabel(); //gets label from superclass:
Text rectText = new Text(label);
rectText.setTextAlignment(TextAlignment.CENTER);
if (!label.equals("cancel")) {
double rectWidth = rectText.getLayoutBounds().getWidth() + 40;
if (rectWidth < 60){
rectWidth = 60;
}
GUI rectangle = new GUI(rectWidth, 43);
rectangle.setFill(getColor());
rectangle.setStroke(Color.BLACK);
setGlow(this);
this.getChildren().addAll(rectangle, rectText);
}
}
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser

Main Class
private static FlowChart flowChart = new FlowChart();
private static boolean running = false;
private static Scanner scanner = new Scanner(System.in);
public static void main(String[] args) {
String option = "M";
while (!option.startsWith("Q")) {
if (option.startsWith("M")) {
showMenu();
} //Options available in set up mode
if (!running) {
if (option.startsWith("R")) {
flowChart.start();
running = true;
} else if (option.startsWith("L")) {
listNodes();
} else if (option.startsWith("A")) {
addNode(true);
} else if (option.startsWith("D")) {
addNode(false);
} else if (option.startsWith("C") && flowChart.getNbrNodes() >= 2) {
addConnection();
} else if (option.startsWith("S")) {
Node node = getNode("Enter index of start node");
flowChart.setStartNode(node);
}
} else { //Otions available in run mode
Node currentNode = flowChart.getCurrentNode();
if (option.startsWith("C")
&& currentNode instanceof ActionNode) {
flowChart.advance(true);
} else if (option.startsWith("Y")
&& currentNode instanceof DecisionNode) {
flowChart.advance(true);
} else if (option.startsWith("N")
&& currentNode instanceof DecisionNode) {
flowChart.advance(false);
} else if (option.startsWith("S")) {
running = false;
}
}
if (running) {
private static FlowChart flowChart = new FlowChart();
private static boolean running = false;
private static Scanner scanner = new Scanner(System.in);
public static void main(String[] args) {
String option = "M";
while (!option.startsWith("Q")) {
if (option.startsWith("M")) {
showMenu();
} //Options available in set up mode
if (!running) {
if (option.startsWith("R")) {
flowChart.start();
running = true;
} else if (option.startsWith("L")) {
listNodes();
} else if (option.startsWith("A")) {
addNode(true);
} else if (option.startsWith("D")) {
addNode(false);
} else if (option.startsWith("C") && flowChart.getNbrNodes() >= 2) {
addConnection();
} else if (option.startsWith("S")) {
Node node = getNode("Enter index of start node");
flowChart.setStartNode(node);
}
} else { //Otions available in run mode
Node currentNode = flowChart.getCurrentNode();
if (option.startsWith("C")
&& currentNode instanceof ActionNode) {
flowChart.advance(true);
} else if (option.startsWith("Y")
&& currentNode instanceof DecisionNode) {
flowChart.advance(true);
} else if (option.startsWith("N")
&& currentNode instanceof DecisionNode) {
flowChart.advance(false);
} else if (option.startsWith("S")) {
running = false;
}
}
if (running) {

Node currentNode = flowChart.getCurrentNode();
if (currentNode != null) {
System.out.println("Current Node is " + currentNode.getTitle());
}
}
System.out.print("Enter first character of your choice (type M to see menu)> ");
option = scanner.nextLine();
}
}
Node
public String getTitle() {
//Own commands depending on witch shape is clicked:
switch (shape){
case "rectOn":
menuRectangle.setEffect(shapeShadow);
break;
case "rectOff":
menuRectangle.setEffect(null);
break;
case "ellipseOn":
menuEllipse.setEffect(shapeShadow);
break;
case "ellipseOff":
menuEllipse.setEffect(null);
break;
case "diamondOn":
menuDiamond.setEffect(shapeShadow);
break;
case "diamondOff":
menuDiamond.setEffect(null);
break;
case "textOn":
textStack.setEffect(shapeShadow);
break;
case "textOff":
textStack.setEffect(null);
break;
case "arrowOn":
arrowStack.setEffect(shapeShadow);
break;
case "arrowOff":
arrowStack.setEffect(null);
break;
}
return null;
if (currentNode != null) {
System.out.println("Current Node is " + currentNode.getTitle());
}
}
System.out.print("Enter first character of your choice (type M to see menu)> ");
option = scanner.nextLine();
}
}
Node
public String getTitle() {
//Own commands depending on witch shape is clicked:
switch (shape){
case "rectOn":
menuRectangle.setEffect(shapeShadow);
break;
case "rectOff":
menuRectangle.setEffect(null);
break;
case "ellipseOn":
menuEllipse.setEffect(shapeShadow);
break;
case "ellipseOff":
menuEllipse.setEffect(null);
break;
case "diamondOn":
menuDiamond.setEffect(shapeShadow);
break;
case "diamondOff":
menuDiamond.setEffect(null);
break;
case "textOn":
textStack.setEffect(shapeShadow);
break;
case "textOff":
textStack.setEffect(null);
break;
case "arrowOn":
arrowStack.setEffect(shapeShadow);
break;
case "arrowOff":
arrowStack.setEffect(null);
break;
}
return null;
⊘ This is a preview!⊘
Do you want full access?
Subscribe today to unlock all pages.

Trusted by 1+ million students worldwide

}
Reflective Commentary
It was a very great experience using the javafx flowchart decision facilitator. At first, I could not
imagine that the javafx will effectively construct and develop an efficient flowchart facilitator as
this.
I developed the classes, methods and constructor since I was using an object oriented
programming language java in the whole process of developing the software.
Some of the classes that I created includes the following: the node, flowchart, decision,
actionNode, ConsoleUI and the GUI.
I employed the use of methods and constructor in order to avoid the repetition of codes and also
to make it possible to tract bugs incase of system runtime error.
I developed this program in reference to the article guide hereunder. The program now is able to
create the flowchart decision system fully.
Reflecting into my main aim of creating the system which in this case is creating an application
which can permit the user to develop, create an also run the flowchart which has the action nodes
that represent actions that have to be perfomed, I can state that the system meets the objective
and the set requirements.
It is possible through the application to run the file of the application, and perform the following
tasks; the program is able to draw flowcharts and determine the actions that are supposed to be
perfomed in each and every decision area. The application is also able to check the decision that
has to be followed by the use of the decision node.
Reference
Reflective Commentary
It was a very great experience using the javafx flowchart decision facilitator. At first, I could not
imagine that the javafx will effectively construct and develop an efficient flowchart facilitator as
this.
I developed the classes, methods and constructor since I was using an object oriented
programming language java in the whole process of developing the software.
Some of the classes that I created includes the following: the node, flowchart, decision,
actionNode, ConsoleUI and the GUI.
I employed the use of methods and constructor in order to avoid the repetition of codes and also
to make it possible to tract bugs incase of system runtime error.
I developed this program in reference to the article guide hereunder. The program now is able to
create the flowchart decision system fully.
Reflecting into my main aim of creating the system which in this case is creating an application
which can permit the user to develop, create an also run the flowchart which has the action nodes
that represent actions that have to be perfomed, I can state that the system meets the objective
and the set requirements.
It is possible through the application to run the file of the application, and perform the following
tasks; the program is able to draw flowcharts and determine the actions that are supposed to be
perfomed in each and every decision area. The application is also able to check the decision that
has to be followed by the use of the decision node.
Reference
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser

Jackson, W. (2015). The Automation of Digital Illustration: Programming. In Digital Illustration
Fundamentals (pp. 149-158). Apress, Berkeley, CA.
Jackson, W. (2016). Objects and Object-Oriented Programming: OOP Primer. In JSON Quick Syntax
Reference(pp. 31-50). Apress, Berkeley, CA.
Fundamentals (pp. 149-158). Apress, Berkeley, CA.
Jackson, W. (2016). Objects and Object-Oriented Programming: OOP Primer. In JSON Quick Syntax
Reference(pp. 31-50). Apress, Berkeley, CA.
1 out of 11

Your All-in-One AI-Powered Toolkit for Academic Success.
 +13062052269
info@desklib.com
Available 24*7 on WhatsApp / Email
Unlock your academic potential
Copyright © 2020–2025 A2Z Services. All Rights Reserved. Developed and managed by ZUCOL.