How 11fenil11/gui-based-algorithm-calculator works
1. This repository is a small Java desktop application: a Swing-based “algorithm calculator” for demonstrating and running six sorting algorithms on integer arrays.
2. The architecture is intentionally simple and mostly single-process. There is no server, database, or network layer. The whole app runs locally in the JVM and uses Swing/AWT for the UI.
3. The two main source classes are:
- Frame.java: the main navigation/UI frame.
- Sortingss.java: the sorting-oriented second frame and/or the sorting logic behind it.
The package name is algo_Calc, which also appears under bin/ as the compiled output.
4. UI flow is a two-screen desktop workflow:
- Main frame: presents six buttons, one per sorting algorithm.
- Secondary frame: accepts input, shows sorted output, and provides an “Open Code” action.
Clicking an algorithm button hides the current frame and shows the next one, carrying a key/selection value that identifies the chosen algorithm.
5. The primary data flow is user input → parsing → sorting → formatted output:
- The user enters an integer array in a text area.
- The app interprets that input according to the selected algorithm screen.
- The chosen algorithm is executed.
- The sorted array is rendered back into an output text area.
6. The repository supports these six algorithms:
- Bubble sort
- Insertion sort
- Merge sort
- Quick sort
- Heap sort
- Selection sort
Each algorithm is exposed as a separate UI choice, but they appear to share the same interaction pattern and output surface.
7. Exception handling is part of the input boundary. Since the app expects integer arrays from free-form text input, input validation/parsing errors are an important edge case in the UI-to-algorithm transition.
8. The “Open Code” feature is a separate desktop boundary from the sorting engine. It uses ProcessBuilder to launch the associated .txt file for the selected algorithm in an external editor, likely Notepad on Windows. That means the app depends on the host operating system’s file-opening behavior.
9. The algorithm source references are stored as plain text files at the repo root:
- bubble.txt
- insertion.txt
- merge.txt
- quicksort.txt
- maxheap.txt
- selection.txt
These are not runtime data files for computation; they are documentation/code-view assets used by the Open Code action.
10. The UI technology stack is standard Java Swing plus AWT event handling:
- JFrame, JButton, JTextArea, JLabel, JTextField
- ActionListener / ActionEvent
- EventQueue
This strongly suggests a traditional event-driven desktop application rather than a layered web or service architecture.
11. The repository structure reflects an Eclipse-managed Java project:
- .project and .settings indicate Eclipse metadata.
- bin/ holds compiled classes.
- src/ holds the editable source.
- Images/ contains screenshots used in the README, not runtime logic.
12. The most important architectural boundary is between “algorithm selection/UI state” and “sorting execution.” The selected button determines which algorithm path the second frame uses, but the interaction remains a single user-driven loop inside the desktop app.
13. For an architecture diagram, the key components are:
- User
- Main menu frame
- Sorting/input frame
- Sorting logic for six algorithms
- External text-file/code viewer launched by ProcessBuilder
- Local .txt algorithm reference files
The arrows should show user-driven navigation and one-way file launching, not persistent data exchange.
Main entry points: Sortingss.java Sort engine · Frame.java Main frame · bubble.txt Text refs
Components 16
Source code
Editable Java Swing application code.
- Main frame · Main navigation window with six algorithm buttons.
src/algo_Calc/Frame.java - Sort screen · Secondary screen that accepts input, runs the chosen sort, and shows results.
src/algo_Calc/Sortingss.java - Selection key · Carries the chosen algorithm from the menu frame into the sorting screen.
src/algo_Calc/Frame.java - Input parser · Converts free-form text into an integer array and handles parse errors.
src/algo_Calc/Sortingss.java - Sort engine · Routes the selected input through the chosen sorting routine.
src/algo_Calc/Sortingss.java - Bubble sort · Supported sorting option.
src/algo_Calc/Sortingss.java - Insertion sort · Supported sorting option.
src/algo_Calc/Sortingss.java - Merge sort · Supported sorting option.
src/algo_Calc/Sortingss.java - Quick sort · Supported sorting option.
src/algo_Calc/Sortingss.java - Heap sort · Supported sorting option.
src/algo_Calc/Sortingss.java - Selection sort · Supported sorting option.
src/algo_Calc/Sortingss.java - Output area · Displays the sorted array back to the user.
src/algo_Calc/Sortingss.java - Open Code · Launches the algorithm's reference file in the host editor.
src/algo_Calc/Sortingss.java
Algorithm refs
Plain-text code/reference files opened from the app.
- Text refs · Algorithm reference files opened by the app.
bubble.txt
Other components
- User · Chooses a sorting algorithm, enters integer arrays, and triggers output or code viewing.
- External editor · System default text editor or Notepad-like application launched outside the JVM.
Connections 16
- User → Main frame: select algorithm · User clicks one of six sorting buttons.
- Main frame → Selection key: set choice · Main menu stores the selected algorithm key.
- Selection key → Sort screen: open screen · Selection is passed into the sorting frame.
- User → Sort screen: enter input · User provides an integer array on the secondary screen.
- Sort screen → Input parser: parse text · Input text is interpreted as integers.
- Input parser → Sort engine: validated array · Parsed integers flow into the selected sort routine.
- Sort engine → Bubble sort: dispatch · Runs bubble sort when selected.
- Sort engine → Insertion sort: dispatch · Runs insertion sort when selected.
- Sort engine → Merge sort: dispatch · Runs merge sort when selected.
- Sort engine → Quick sort: dispatch · Runs quick sort when selected.
- Sort engine → Heap sort: dispatch · Runs heap sort when selected.
- Sort engine → Selection sort: dispatch · Runs selection sort when selected.
- Sort engine → Output area: render · Sorted values are formatted into the output text area.
- User → Open Code: open code · User requests the algorithm source/reference view.
- Open Code → Text refs: choose file · Launcher targets the matching text file for the selected algorithm.
- Open Code → External editor: spawn process · ProcessBuilder starts the external editor or file association.