Repository navigation
Expand file tree
/
Copy pathMainController.java
More file actions
1001 lines (851 loc) · 44 KB
/
Copy pathMainController.java
File metadata and controls
1001 lines (851 loc) · 44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package com.simulator;
import javafx.animation.*;
import javafx.application.Platform;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.control.Alert;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.effect.DropShadow;
import javafx.scene.input.KeyEvent;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
import javafx.util.Duration;
import javafx.fxml.Initializable;
import com.simulator.TooltipService;
import com.simulator.TooltipService.AlgorithmInfo;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.stage.Modality;
import javafx.scene.Scene;
import javafx.scene.control.ScrollPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;
import org.kordamp.ikonli.javafx.FontIcon;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
public class MainController implements Initializable {
@FXML private Button themeToggleButton;
@FXML private Label statusLabel;
@FXML private VBox sortingCard;
@FXML private VBox searchCard;
@FXML private VBox stackCard;
@FXML private VBox linkedListCard;
@FXML private VBox arrayCard;
@FXML private VBox analysisCard;
@FXML private VBox graphCard;
@FXML private Button sortingButton;
@FXML private Button searchButton;
@FXML private Button stackButton;
@FXML private Button linkedListButton;
@FXML private Button arrayButton;
@FXML private Button analysisButton;
@FXML private Button graphButton;
private NavigationService navigationService;
private AnimationService animationService;
private TooltipService tooltipService;
@Override
public void initialize(URL location, ResourceBundle resources) {
System.out.println("MainController initialized");
// Initialize services with error handling
try {
navigationService = new NavigationService();
animationService = AnimationService.getInstance();
tooltipService = TooltipService.getInstance(); // NEW: Initialize tooltip service
} catch (Exception e) {
System.err.println("Error initializing services: " + e.getMessage());
}
// Register scene with theme manager
Platform.runLater(() -> {
if (statusLabel != null && statusLabel.getScene() != null) {
try {
ThemeManager.getInstance().registerScene(statusLabel.getScene());
setupKeyboardShortcuts();
} catch (Exception e) {
System.out.println("Scene registration not available: " + e.getMessage());
}
}
});
// Set initial emoji theme
updateThemeEmoji();
updateStatusLabel("Algorithm Simulator ready - Click any card to explore algorithms");
// Setup click handlers and hover tooltips
setupClickHandlers();
setupHoverTooltips(); // NEW: Setup hover tooltips
// Start welcome animation
playWelcomeAnimation();
}
/**
* NEW: Setup hover tooltips for algorithm cards
*/
private void setupHoverTooltips() {
// Sorting Algorithms Tooltip
if (sortingCard != null) {
AlgorithmInfo sortingInfo = new AlgorithmInfo(
"Sorting Algorithms",
"Fundamental algorithms that arrange elements in a specific order. Essential for optimizing search operations and data organization.",
"• Database indexing and queries\n• E-commerce product listings\n• Scientific data analysis\n• File system organization",
"O(n log n) to O(n²)",
"O(1) to O(n)",
"fas-sort-amount-up"
);
setupCardTooltip(sortingCard, sortingInfo);
}
// Search Algorithms Tooltip
if (searchCard != null) {
AlgorithmInfo searchInfo = new AlgorithmInfo(
"Search Algorithms",
"Efficient methods to locate specific elements within data structures. Critical for information retrieval systems.",
"• Web search engines\n• Database queries\n• Autocomplete systems\n• Navigation applications",
"O(log n) to O(n)",
"O(1) to O(n)",
"fas-search"
);
setupCardTooltip(searchCard, searchInfo);
}
// Stack Operations Tooltip
if (stackCard != null) {
AlgorithmInfo stackInfo = new AlgorithmInfo(
"Stack Operations",
"Last-In-First-Out (LIFO) data structure operations. Fundamental for memory management and expression evaluation.",
"• Function call management\n• Undo operations in applications\n• Expression parsing\n• Browser history",
"O(1) for all operations",
"O(n)",
"fas-layer-group"
);
setupCardTooltip(stackCard, stackInfo);
}
// Linked Lists Tooltip
if (linkedListCard != null) {
AlgorithmInfo linkedListInfo = new AlgorithmInfo(
"Linked Lists",
"Dynamic data structures with elements connected through pointers. Excellent for dynamic memory allocation.",
"• Music playlists\n• Image viewers\n• Undo/Redo functionality\n• Dynamic memory management",
"O(1) to O(n)",
"O(n)",
"fas-link"
);
setupCardTooltip(linkedListCard, linkedListInfo);
}
// Array Operations Tooltip
if (arrayCard != null) {
AlgorithmInfo arrayInfo = new AlgorithmInfo(
"Array Operations",
"Fundamental operations on contiguous memory structures. Building blocks for more complex data structures.",
"• Matrix operations\n• Image processing\n• Game development\n• Scientific computing",
"O(1) to O(n)",
"O(1) to O(n)",
"fas-th-list"
);
setupCardTooltip(arrayCard, arrayInfo);
}
// Graph Algorithms Tooltip
if (graphCard != null) {
AlgorithmInfo graphInfo = new AlgorithmInfo(
"Graph Algorithms",
"Algorithms for traversing and analyzing graph structures. Essential for network analysis and pathfinding.",
"• Social network analysis\n• GPS navigation systems\n• Network routing\n• Recommendation systems",
"O(V + E) to O(V²)",
"O(V) to O(V + E)",
"fas-project-diagram"
);
setupCardTooltip(graphCard, graphInfo);
}
// Performance Analysis Tooltip
if (analysisCard != null) {
AlgorithmInfo analysisInfo = new AlgorithmInfo(
"Performance Analysis",
"Mathematical analysis of algorithm efficiency using Big-O notation. Critical for choosing optimal solutions.",
"• Algorithm optimization\n• System performance tuning\n• Resource allocation\n• Scalability planning",
"Varies by algorithm",
"Varies by algorithm",
"fas-chart-line"
);
setupCardTooltip(analysisCard, analysisInfo);
}
}
/**
* ENTERPRISE: Professional tooltip setup with debouncing
*/
private void setupCardTooltip(VBox card, AlgorithmInfo info) {
// SIMPLIFIED: Just mouse enter and exit - service handles debouncing
card.setOnMouseEntered(e -> {
System.out.println("🖱️ Mouse entered: " + info.getTitle());
tooltipService.showAlgorithmTooltip(card, info);
updateStatusLabel("📖 Learning about " + info.getTitle() + "...");
});
card.setOnMouseExited(e -> {
System.out.println("🖱️ Mouse exited: " + info.getTitle());
tooltipService.hideCurrentTooltip();
updateStatusLabel("Algorithm Simulator ready - Click any card to explore algorithms");
});
// REMOVED: Mouse moved handler - no longer needed due to professional debouncing
}
public void cleanup() {
System.out.println("🧹 Starting MainController cleanup...");
try {
// Hide any open tooltips and shutdown tooltip service
if (tooltipService != null) {
tooltipService.hideCurrentTooltip();
System.out.println("✅ Tooltip service cleaned up");
}
// Close all navigation windows
if (navigationService != null) {
navigationService.closeAllWindows();
System.out.println("✅ Navigation service cleaned up");
}
// Unregister scene from theme manager
if (statusLabel != null && statusLabel.getScene() != null) {
ThemeManager.getInstance().unregisterScene(statusLabel.getScene());
System.out.println("✅ Scene unregistered from ThemeManager");
}
// Stop any running animations
if (animationService != null) {
// Animation service cleanup if needed
System.out.println("✅ Animation service cleaned up");
}
System.out.println("🎉 MainController cleanup completed successfully");
} catch (Exception e) {
System.err.println("❌ Error during MainController cleanup: " + e.getMessage());
e.printStackTrace();
}
}
private void setupKeyboardShortcuts() {
if (statusLabel != null && statusLabel.getScene() != null) {
statusLabel.getScene().setOnKeyPressed(this::handleKeyboardShortcuts);
System.out.println("✅ Keyboard shortcuts registered successfully");
}
}
private void updateThemeEmoji() {
if (themeToggleButton != null) {
try {
boolean isDarkMode = ThemeManager.getInstance().isDarkMode();
if (isDarkMode) {
themeToggleButton.setText("🌙");
themeToggleButton.setStyle(
"-fx-font-size: 22px; " +
"-fx-font-weight: bold; " +
"-fx-text-fill: #a78bfa; " +
"-fx-background-color: rgba(167,139,250,0.1); " +
"-fx-border-color: rgba(167,139,250,0.3); " +
"-fx-border-width: 1px; " +
"-fx-border-radius: 10px; " +
"-fx-background-radius: 10px; " +
"-fx-padding: 8px; " +
"-fx-cursor: hand; " +
"-fx-pref-width: 50px; " +
"-fx-pref-height: 50px; " +
"-fx-effect: dropshadow(gaussian, rgba(167,139,250,0.5), 8, 0, 0, 3);"
);
System.out.println("🌙 Dark Mode - Moon emoji displayed");
} else {
themeToggleButton.setText("💡");
themeToggleButton.setStyle(
"-fx-font-size: 22px; " +
"-fx-font-weight: bold; " +
"-fx-text-fill: #f59e0b; " +
"-fx-background-color: rgba(245,158,11,0.1); " +
"-fx-border-color: rgba(245,158,11,0.3); " +
"-fx-border-width: 1px; " +
"-fx-border-radius: 10px; " +
"-fx-background-radius: 10px; " +
"-fx-padding: 8px; " +
"-fx-cursor: hand; " +
"-fx-pref-width: 50px; " +
"-fx-pref-height: 50px; " +
"-fx-effect: dropshadow(gaussian, rgba(245,158,11,0.5), 8, 0, 0, 3);"
);
System.out.println("💡 Light Mode - Light bulb emoji displayed");
}
} catch (Exception e) {
System.err.println("❌ Error updating theme emoji: " + e.getMessage());
themeToggleButton.setText("🎨");
themeToggleButton.setStyle("-fx-font-size: 20px; -fx-cursor: hand;");
}
}
}
private void setupClickHandlers() {
// Card click handlers
if (sortingCard != null) {
sortingCard.setOnMouseClicked(this::openSortingModule);
}
if (searchCard != null) {
searchCard.setOnMouseClicked(this::openSearchModule);
}
if (stackCard != null) {
stackCard.setOnMouseClicked(this::openStackModule);
}
if (linkedListCard != null) {
linkedListCard.setOnMouseClicked(this::openLinkedListModule);
}
if (arrayCard != null) {
arrayCard.setOnMouseClicked(this::openArrayModule);
}
if (analysisCard != null) {
analysisCard.setOnMouseClicked(this::openAnalysisModule);
}
if (graphCard != null) {
graphCard.setOnMouseClicked(this::openGraphModule);
}
// Button click handlers
if (sortingButton != null) {
sortingButton.setOnAction(e -> openSortingModule(null));
}
if (searchButton != null) {
searchButton.setOnAction(e -> openSearchModule(null));
}
if (stackButton != null) {
stackButton.setOnAction(e -> openStackModule(null));
}
if (linkedListButton != null) {
linkedListButton.setOnAction(e -> openLinkedListModule(null));
}
if (arrayButton != null) {
arrayButton.setOnAction(e -> openArrayModule(null));
}
if (analysisButton != null) {
analysisButton.setOnAction(e -> openAnalysisModule(null));
}
if (graphButton != null) {
graphButton.setOnAction(e -> openGraphModule(null));
}
}
private void playWelcomeAnimation() {
if (statusLabel != null && animationService != null) {
try {
FadeTransition fadeIn = animationService.createFadeAnimation(statusLabel, 0.0, 1.0, 1000);
fadeIn.play();
} catch (Exception e) {
System.out.println("Animation service error: " + e.getMessage());
}
}
}
@FXML
private void toggleTheme() {
System.out.println("🎯 Theme toggle clicked - Current mode: " +
(ThemeManager.getInstance().isDarkMode() ? "Dark" : "Light"));
try {
if (themeToggleButton != null) {
ScaleTransition scaleOut = new ScaleTransition(Duration.millis(100), themeToggleButton);
scaleOut.setToX(1.3);
scaleOut.setToY(1.3);
scaleOut.setAutoReverse(true);
scaleOut.setCycleCount(2);
scaleOut.play();
if (animationService != null) {
try {
animationService.playButtonHoverAnimation(themeToggleButton, true);
} catch (Exception e) {
System.out.println("Animation service not available: " + e.getMessage());
}
}
}
ThemeManager.getInstance().toggleTheme();
updateThemeEmoji();
updateStatusLabel("🎨 Theme switched to " +
(ThemeManager.getInstance().isDarkMode() ? "Dark" : "Light") + " mode");
} catch (Exception e) {
System.err.println("Error toggling theme: " + e.getMessage());
e.printStackTrace();
}
}
@FXML
private void showSettings() {
System.out.println("Settings button clicked");
Alert settingsDialog = new Alert(Alert.AlertType.INFORMATION);
settingsDialog.setTitle("Settings");
settingsDialog.setHeaderText("Algorithm Simulator Settings");
settingsDialog.setContentText(
"🎨 Theme Settings:\n" +
"• Current Theme: " + ThemeManager.getInstance().getCurrentTheme() + "\n" +
"• Dark Mode: " + (ThemeManager.getInstance().isDarkMode() ? "Enabled" : "Disabled") + "\n\n" +
"🚀 Performance Settings:\n" +
"• Animation Speed: " + String.format("%.1fx", AnimationService.getInstance().getAnimationSpeed()) + "\n" +
"• Hardware Acceleration: Enabled\n\n" +
"📊 Statistics:\n" +
"• Open Windows: " + navigationService.getOpenWindowCount() + "\n" +
"• Memory Usage: Optimized\n\n" +
"💡 Tip: Use Ctrl+T to quickly toggle themes!"
);
settingsDialog.showAndWait();
updateStatusLabel("Settings accessed - Customize your experience");
}
@FXML
private void showAbout() {
System.out.println("About button clicked");
try {
// Create custom stage for about dialog
Stage aboutStage = new Stage();
aboutStage.initOwner(statusLabel.getScene().getWindow());
aboutStage.initModality(Modality.APPLICATION_MODAL);
aboutStage.setTitle("About Algorithm Simulator");
aboutStage.setResizable(true);
// Create main container
VBox mainContainer = new VBox();
mainContainer.setSpacing(0);
mainContainer.getStyleClass().addAll("main-layout", "about-dialog");
// Header section
HBox header = new HBox();
header.setAlignment(javafx.geometry.Pos.CENTER);
header.setSpacing(15);
header.getStyleClass().add("about-header");
header.setPadding(new javafx.geometry.Insets(25, 30, 20, 30));
// App icon
FontIcon appIcon = new FontIcon("fas-laptop-code");
appIcon.setIconSize(48);
appIcon.getStyleClass().add("about-icon");
// Title section
VBox titleSection = new VBox();
titleSection.setAlignment(javafx.geometry.Pos.CENTER_LEFT);
titleSection.setSpacing(5);
Label appTitle = new Label("Algorithm Simulator");
appTitle.getStyleClass().add("about-title");
appTitle.setWrapText(true);
Label appVersion = new Label("Professional Edition v2.0");
appVersion.getStyleClass().add("about-version");
appVersion.setWrapText(true);
Label authorLabel = new Label("by Ankit Raj");
authorLabel.getStyleClass().add("about-author");
authorLabel.setWrapText(true);
// 🎯 ENHANCED: Increase font size and make bold
appTitle.setStyle("-fx-font-size: 36px; -fx-font-weight: bold;");
appVersion.setStyle("-fx-font-size: 18px; -fx-font-weight: semi-bold;");
authorLabel.setStyle("-fx-font-size: 16px; -fx-font-style: italic; -fx-font-weight: normal;");
// 🎯 ENHANCED: Apply theme-aware drop shadow
boolean isDarkMode = ThemeManager.getInstance().isDarkMode();
// Create drop shadow effect with theme-aware colors
DropShadow titleShadow = new DropShadow();
titleShadow.setRadius(8.0);
titleShadow.setOffsetX(4.0);
titleShadow.setOffsetY(4.0);
DropShadow versionShadow = new DropShadow();
versionShadow.setRadius(6.0);
versionShadow.setOffsetX(3.0);
versionShadow.setOffsetY(3.0);
if (isDarkMode) {
// Dark mode: Golden/yellowish shadow
titleShadow.setColor(Color.web("rgba(255, 215, 0, 0.8)")); // Rich gold
versionShadow.setColor(Color.web("rgba(255, 223, 0, 0.6)")); // Lighter gold
} else {
// Light mode: Black shadow
titleShadow.setColor(Color.web("rgba(0, 0, 0, 0.7)")); // Deep black
versionShadow.setColor(Color.web("rgba(0, 0, 0, 0.5)")); // Lighter black
}
// Apply shadow effects
appTitle.setEffect(titleShadow);
appVersion.setEffect(versionShadow);
// 🎯 APPLY THEME-AWARE TEXT COLORS TO HEADER LABELS
applyThemeTextColors(appTitle, appVersion, authorLabel);
titleSection.getChildren().addAll(appTitle, appVersion, authorLabel);
header.getChildren().addAll(appIcon, titleSection);
// Content area with scroll
ScrollPane scrollPane = new ScrollPane();
scrollPane.setFitToWidth(true);
scrollPane.setFitToHeight(true);
scrollPane.getStyleClass().add("about-scroll");
scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
scrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED);
// Content container
VBox contentContainer = new VBox();
contentContainer.setSpacing(20);
contentContainer.setPadding(new javafx.geometry.Insets(20, 35, 30, 35));
contentContainer.getStyleClass().add("about-content");
// Create content sections
contentContainer.getChildren().addAll(
createAboutSection("🎯 COMPREHENSIVE INTERACTIVE ALGORITHM VISUALIZATION PLATFORM",
"A professional-grade educational tool designed for computer science students, educators, and developers."),
createFeatureSection("🚀 CORE ALGORITHM MODULES", new String[]{
"• Sorting Algorithms (9): Bubble, Selection, Insertion, Merge, Quick, Heap, Shell, Radix, Counting",
"• Search Algorithms (3): Linear, Binary, Interpolation with real-time visualization",
"• Data Structures: Professional Stack & LinkedList implementations",
"• Graph Algorithms (8): BFS, DFS, Dijkstra, A*, Shortest Path, Topological Sort, Cycle Detection",
"• Algorithm Analysis: Comprehensive performance comparison with complexity curves"
}),
createFeatureSection("📚 INTERACTIVE CODE REPOSITORIES", new String[]{
"• Stack Operations: 16+ complete code examples with applications",
"• LinkedList Collection: 25+ examples (Singly, Doubly, Circular implementations)",
"• Advanced Operations: Merge, reverse, cycle detection, sorting algorithms",
"• Copy-to-clipboard functionality with syntax highlighting",
"• Searchable code categories with expand/collapse navigation"
}),
createFeatureSection("🎨 ADVANCED VISUALIZATION FEATURES", new String[]{
"• Real-time Algorithm Animation with speed control (0.1x - 5x)",
"• Interactive Graph Canvas with drag-and-drop vertex positioning",
"• Professional 3D-style elements with shadows and depth effects",
"• Smart Color Coding: Comparison (Orange), Success (Green), Operations (Red)",
"• Multi-window support with up to 10 concurrent algorithm windows"
}),
createFeatureSection("🔬 EDUCATIONAL & ANALYSIS TOOLS", new String[]{
"• Algorithm Performance Comparison with mathematical complexity curves",
"• Side-by-side analysis supporting 6 simultaneous complexity visualizations",
"• Detailed pseudocode with complete Java implementations",
"• Smart algorithm recommendations based on use cases",
"• Comprehensive Big-O notation analysis for all complexity classes"
}),
createFeatureSection("💻 PROFESSIONAL TECHNOLOGY STACK", new String[]{
"• JavaFX 21+ with Modern FXML Architecture",
"• AtlantaFX Professional Theme Engine (6 themes: Primer, Nord, Cupertino)",
"• Enterprise-level Service Layer (Navigation, Theme, Animation services)",
"• Advanced Tooltip System with interaction-aware cancellation",
"• Repository Pattern with JSON-based algorithm data management",
"• Maven build system with modular architecture"
}),
createFeatureSection("🎮 USER EXPERIENCE EXCELLENCE", new String[]{
"• Live Dark/Light theme switching across all windows",
"• Professional keyboard shortcuts (Ctrl+T, Ctrl+W, F11, etc.)",
"• Smart input validation with real-time error handling",
"• Responsive design supporting multiple screen sizes",
"• Automatic window cascading and intelligent positioning"
}),
createFeatureSection("🎯 TARGET AUDIENCE", new String[]{
"👨🎓 Computer Science Students (Undergraduate/Graduate)",
"👩🏫 Educators and Computer Science Professors",
"👨💻 Professional Developers and Software Engineers",
"📝 Technical Interview Candidates",
"🏆 Competitive Programming Enthusiasts"
}),
createFeatureSection("🌟 UNIQUE VALUE PROPOSITION", new String[]{
"✅ 6 Major Algorithm Domains with 35+ Specific Implementations",
"✅ Complete Code Repository (100+ Examples) with Professional Documentation",
"✅ Interactive Experimentation Platform, Not Just Visualization",
"✅ Enterprise-Grade Architecture with Modern Design Patterns",
"✅ Cross-Platform Compatibility (Windows, macOS, Linux)"
}),
createAboutSection("🚀 ALGORITHM SIMULATOR - WHERE THEORY MEETS INTERACTIVE PRACTICE",
"Built for the next generation of computer scientists and algorithm enthusiasts!")
);
scrollPane.setContent(contentContainer);
// Button area
HBox buttonArea = new HBox();
buttonArea.setAlignment(javafx.geometry.Pos.CENTER);
buttonArea.setPadding(new javafx.geometry.Insets(20, 30, 25, 30));
buttonArea.getStyleClass().add("about-buttons");
Button closeButton = new Button("Close");
closeButton.getStyleClass().addAll("category-button", "primary-button");
closeButton.setPrefWidth(120);
closeButton.setOnAction(e -> aboutStage.close());
closeButton.setDefaultButton(true);
buttonArea.getChildren().add(closeButton);
// Assemble dialog
mainContainer.getChildren().addAll(header, scrollPane, buttonArea);
VBox.setVgrow(scrollPane, javafx.scene.layout.Priority.ALWAYS);
// Create scene
Scene aboutScene = new Scene(mainContainer, 900, 700); // Increased width to 900px
// Apply current theme
try {
aboutScene.getStylesheets().addAll(statusLabel.getScene().getStylesheets());
ThemeManager.getInstance().registerScene(aboutScene);
String themeClass = ThemeManager.getInstance().isDarkMode() ? "dark-theme" : "light-theme";
String removeClass = ThemeManager.getInstance().isDarkMode() ? "light-theme" : "dark-theme";
mainContainer.getStyleClass().removeAll(removeClass);
mainContainer.getStyleClass().add(themeClass);
} catch (Exception e) {
System.out.println("ℹ️ Could not apply theme to about dialog");
}
aboutStage.setScene(aboutScene);
// Set minimum size and center on parent
aboutStage.setMinWidth(800);
aboutStage.setMinHeight(600);
// Center on parent window
if (statusLabel.getScene() != null && statusLabel.getScene().getWindow() instanceof Stage) {
Stage parentStage = (Stage) statusLabel.getScene().getWindow();
aboutStage.setX(parentStage.getX() + (parentStage.getWidth() - 900) / 2);
aboutStage.setY(parentStage.getY() + (parentStage.getHeight() - 700) / 2);
}
// Cleanup on close
aboutStage.setOnCloseRequest(e -> {
ThemeManager.getInstance().unregisterScene(aboutScene);
});
aboutStage.showAndWait();
updateStatusLabel("About Algorithm Simulator - Professional Edition v2.0 | 35+ Algorithms | 6 Domains | 100+ Code Examples");
} catch (Exception e) {
System.err.println("❌ Error showing about dialog: " + e.getMessage());
e.printStackTrace();
// Fallback to simple alert
Alert fallbackAlert = new Alert(Alert.AlertType.INFORMATION);
fallbackAlert.setTitle("About Algorithm Simulator");
fallbackAlert.setHeaderText("Algorithm Simulator - Professional Edition v2.0");
fallbackAlert.setContentText("Comprehensive Interactive Algorithm Visualization Platform\n\n" +
"Features 35+ algorithms across 6 major domains with professional visualizations and code examples.");
fallbackAlert.showAndWait();
}
}
// Helper method to create content sections
private VBox createAboutSection(String title, String description) {
VBox section = new VBox();
section.setSpacing(10);
section.getStyleClass().add("about-section");
Label titleLabel = new Label(title);
titleLabel.getStyleClass().add("section-header");
titleLabel.setWrapText(true);
Label descLabel = new Label(description);
descLabel.getStyleClass().add("section-description");
descLabel.setWrapText(true);
// 🎯 APPLY THEME-AWARE TEXT COLORS
applyThemeTextColors(titleLabel, descLabel);
section.getChildren().addAll(titleLabel, descLabel);
return section;
}
// Helper method to create feature sections
private VBox createFeatureSection(String title, String[] features) {
VBox section = new VBox();
section.setSpacing(8);
section.getStyleClass().add("feature-section");
Label titleLabel = new Label(title);
titleLabel.getStyleClass().add("section-header");
titleLabel.setWrapText(true);
VBox featureList = new VBox();
featureList.setSpacing(4);
featureList.getStyleClass().add("feature-list");
for (String feature : features) {
Label featureLabel = new Label(feature);
featureLabel.getStyleClass().add("feature-item");
featureLabel.setWrapText(true);
featureList.getChildren().add(featureLabel);
// 🎯 APPLY THEME-AWARE TEXT COLOR
applyThemeTextColors(featureLabel);
}
// 🎯 APPLY THEME-AWARE TEXT COLOR TO TITLE
applyThemeTextColors(titleLabel);
section.getChildren().addAll(titleLabel, featureList);
return section;
}
// 🎯 ENHANCED: Helper method to apply theme-aware text colors with size handling
private void applyThemeTextColors(Label... labels) {
try {
boolean isDarkMode = ThemeManager.getInstance().isDarkMode();
for (Label label : labels) {
String baseStyle = "";
// Determine base styling based on style class
if (label.getStyleClass().contains("about-title")) {
baseStyle = "-fx-font-size: 36px; -fx-font-weight: bold;";
} else if (label.getStyleClass().contains("about-version")) {
baseStyle = "-fx-font-size: 18px; -fx-font-weight: semi-bold;";
} else if (label.getStyleClass().contains("section-header")) {
baseStyle = "-fx-font-size: 16px; -fx-font-weight: bold;";
} else if (label.getStyleClass().contains("about-author")) { // ✅ NEW
baseStyle = "-fx-font-size: 16px; -fx-font-style: italic; -fx-font-weight: normal;";
} else if (label.getStyleClass().contains("feature-item") ||
label.getStyleClass().contains("section-description")) {
baseStyle = "-fx-font-size: 13px;";
}
if (isDarkMode) {
// Dark mode: White text
label.setStyle(baseStyle + "; -fx-text-fill: #ffffff; -fx-opacity: 0.98;");
} else {
// Light mode: Dark text
label.setStyle(baseStyle + "; -fx-text-fill: #1a1a1a; -fx-opacity: 0.95;");
}
}
System.out.println("✅ Applied " + (isDarkMode ? "dark" : "light") + " theme colors to " + labels.length + " labels");
} catch (Exception e) {
System.out.println("ℹ️ Could not apply theme text colors: " + e.getMessage());
e.printStackTrace();
}
}
// ===== MODULE NAVIGATION METHODS ===== //
@FXML
private void openSortingModule(MouseEvent event) {
TooltipService.getInstance().cancelTooltipOnInteraction();
System.out.println("🔄 Opening Sorting Algorithms module");
if (event != null) playCardClickAnimation(event);
if (navigationService != null) {
navigationService.openModule("/fxml/SortingView.fxml", "Sorting Algorithms - Interactive Visualization", 1400, 900);
}
updateStatusLabel("🔄 Sorting Algorithms - Bubble, Selection, Insertion, Merge, Quick Sort");
}
@FXML
private void openSearchModule(MouseEvent event) {
TooltipService.getInstance().cancelTooltipOnInteraction();
System.out.println("🔍 Opening Search Algorithms module");
if (event != null) playCardClickAnimation(event);
if (navigationService != null) {
navigationService.openModule("/fxml/SearchingView.fxml", "Search Algorithms - Linear & Binary Search", 1300, 800);
}
updateStatusLabel("🔍 Search Algorithms - Linear, Binary, and Interpolation Search");
}
@FXML
private void openStackModule(MouseEvent event) {
TooltipService.getInstance().cancelTooltipOnInteraction();
System.out.println("📚 Opening Stack Operations module");
if (event != null) playCardClickAnimation(event);
if (navigationService != null) {
navigationService.openModule("/fxml/StackView.fxml", "Stack Operations - LIFO Data Structure", 1100, 700);
}
updateStatusLabel("📚 Stack Operations - Push, Pop, Peek with Visual Animations");
}
@FXML
private void openLinkedListModule(MouseEvent event) {
TooltipService.getInstance().cancelTooltipOnInteraction();
System.out.println("🔗 Opening Linked List Operations module");
if (event != null) playCardClickAnimation(event);
if (navigationService != null) {
navigationService.openModule("/fxml/LinkedListView.fxml", "Linked List Operations - Dynamic Data Structure", 1300, 800);
}
updateStatusLabel("🔗 Linked List - Insert, Delete, Search with Visual Connections");
}
@FXML
private void openGraphModule(MouseEvent event) {
TooltipService.getInstance().cancelTooltipOnInteraction();
System.out.println("🌐 Opening Graph Algorithms module");
if (event != null) playCardClickAnimation(event);
if (navigationService != null) {
navigationService.openModule("/fxml/GraphView.fxml", "Graph Algorithms - BFS & DFS Visualization", 1400, 900);
}
updateStatusLabel("🌐 Graph Algorithms - BFS, DFS, Shortest Path with Interactive Visualization");
}
@FXML
private void openArrayModule(MouseEvent event) {
TooltipService.getInstance().cancelTooltipOnInteraction();
System.out.println("📊 Opening Array Operations module");
if (event != null) playCardClickAnimation(event);
if (navigationService != null) {
navigationService.openModule("/fxml/ArrayView.fxml", "Array Operations - Dynamic Array Management", 1200, 700);
}
updateStatusLabel("📊 Array Operations - Insert, Delete, Update with Visual Feedback");
}
@FXML
private void openAnalysisModule(MouseEvent event) {
TooltipService.getInstance().cancelTooltipOnInteraction();
System.out.println("📈 Opening Performance Analysis module");
if (event != null) playCardClickAnimation(event);
if (navigationService != null) {
navigationService.openModule("/fxml/AnalysisView.fxml", "Performance Analysis - Algorithm Complexity", 1400, 850);
}
updateStatusLabel("📈 Performance Analysis - Time & Space Complexity Visualization");
}
private void playCardClickAnimation(MouseEvent event) {
if (event.getSource() instanceof javafx.scene.Node && animationService != null) {
javafx.scene.Node card = (javafx.scene.Node) event.getSource();
try {
animationService.playCardClickAnimation(card);
} catch (Exception e) {
System.out.println("Card animation error: " + e.getMessage());
}
}
}
private void updateStatusLabel(String message) {
if (statusLabel != null && message != null) {
Platform.runLater(() -> {
if (animationService != null) {
try {
FadeTransition fadeOut = animationService.createFadeAnimation(statusLabel, 1.0, 0.3, 200);
fadeOut.setOnFinished(e -> {
statusLabel.setText(message);
FadeTransition fadeIn = animationService.createFadeAnimation(statusLabel, 0.3, 1.0, 200);
fadeIn.play();
});
fadeOut.play();
} catch (Exception e) {
statusLabel.setText(message);
}
} else {
statusLabel.setText(message);
}
});
}
}
public void handleKeyboardShortcuts(KeyEvent event) {
if (event.isControlDown()) {
switch (event.getCode()) {
case T:
System.out.println("⌨️ Ctrl+T pressed - Toggling theme");
toggleTheme();
event.consume();
break;
case Q:
System.out.println("⌨️ Ctrl+Q pressed - Exiting application");
Platform.exit();
event.consume();
break;
case H:
System.out.println("⌨️ Ctrl+H pressed - Showing about");
showAbout();
event.consume();
break;
case S:
System.out.println("⌨️ Ctrl+S pressed - Showing settings");
showSettings();
event.consume();
break;
default:
break;
}
}
switch (event.getCode()) {
case F1:
showAbout();
event.consume();
break;
case F2:
showSettings();
event.consume();
break;
case ESCAPE:
break;
}
}
/**
* 📧 ACTION: Show feedback dialog
*/
@FXML
private void showFeedback() {
System.out.println("Feedback button clicked");
try {
// Create custom stage for feedback dialog
Stage feedbackStage = new Stage();
feedbackStage.initOwner(statusLabel.getScene().getWindow());
feedbackStage.initModality(Modality.APPLICATION_MODAL);
feedbackStage.setTitle("Send Feedback - Algorithm Simulator");
feedbackStage.setResizable(true);
// Load FXML
FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/FeedbackView.fxml"));
Parent root = loader.load();
// Get controller and set stage reference
FeedbackController controller = loader.getController();
controller.setDialogStage(feedbackStage);
// Create scene
Scene feedbackScene = new Scene(root, 600, 750);
// Apply current theme
try {
feedbackScene.getStylesheets().addAll(statusLabel.getScene().getStylesheets());
ThemeManager.getInstance().registerScene(feedbackScene);
String themeClass = ThemeManager.getInstance().isDarkMode() ? "dark-theme" : "light-theme";
root.getStyleClass().add(themeClass);
} catch (Exception e) {
System.out.println("ℹ️ Could not apply theme to feedback dialog");
}
feedbackStage.setScene(feedbackScene);
// Set minimum size and center on parent
feedbackStage.setMinWidth(500);
feedbackStage.setMinHeight(600);
// Center on parent window
if (statusLabel.getScene() != null && statusLabel.getScene().getWindow() instanceof Stage) {
Stage parentStage = (Stage) statusLabel.getScene().getWindow();
feedbackStage.setX(parentStage.getX() + (parentStage.getWidth() - 600) / 2);
feedbackStage.setY(parentStage.getY() + (parentStage.getHeight() - 750) / 2);
}
// Cleanup on close
feedbackStage.setOnCloseRequest(e -> {
ThemeManager.getInstance().unregisterScene(feedbackScene);
});
feedbackStage.showAndWait();
updateStatusLabel("Feedback system ready - Thank you for helping us improve!");
} catch (Exception e) {
System.err.println("❌ Error showing feedback dialog: " + e.getMessage());
e.printStackTrace();
showAlert("Error", "Could not open feedback form: " + e.getMessage());
}
}
// Helper method for alerts
private void showAlert(String title, String message) {
Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setTitle(title);
alert.setHeaderText(null);
alert.setContentText(message);
alert.showAndWait();
}