|
1 | | -# 2D Array Operations (Java GUI) |
| 1 | +# 2D Array Operations |
2 | 2 |
|
3 | | -A lightweight Java AWT/Swing desktop app to create and explore two‑dimensional integer arrays. It provides interactive menus to generate arrays, compute statistics, search values, and perform matrix operations with a visual grid display. |
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | + |
4 | 7 |
|
5 | | -## Features |
6 | | -- Create a random 2D array with custom rows/cols and value range |
7 | | -- Statistics: minimum, maximum, average, standard deviation |
8 | | -- Operations: search for a value, add, subtract, and multiply arrays |
9 | | -- Visual output: draws arrays in a grid with labels and results |
10 | | -- Resizable window; redraws on resize |
| 8 | +A Java AWT/Swing desktop application for creating, visualizing, and manipulating two-dimensional integer arrays with comprehensive statistical analysis and matrix operations. |
11 | 9 |
|
12 | | -## How It Works |
13 | | -- UI shell: `Array2DOperations` (Frame with menus, drawing surface) |
14 | | -- Core logic: `TwoDArray` (array creation, stats, search, math) |
15 | | -- Rendering: values and outlines drawn using `Graphics` |
16 | | -- Input: dialogs (`JOptionPane`) prompt for sizes, ranges, and search keys |
| 10 | +## ✨ Features |
17 | 11 |
|
18 | | -## Requirements |
19 | | -- JDK 8+ (AWT/Swing included) |
20 | | -- Windows/macOS/Linux |
| 12 | +- **Array Generation**: Create random 2D arrays with custom dimensions and value ranges |
| 13 | +- **Visual Display**: Interactive grid rendering with automatic resize support |
| 14 | +- **Statistical Analysis**: Calculate min, max, average, and standard deviation |
| 15 | +- **Search Operations**: Find values and display their coordinates |
| 16 | +- **Matrix Mathematics**: Add, subtract, and multiply arrays |
| 17 | +- **Menu-Driven Interface**: Intuitive menu system for all operations |
| 18 | +- **Real-Time Updates**: Automatic repainting on window resize |
| 19 | + |
| 20 | +## 🚀 Quick Start |
| 21 | + |
| 22 | +### Using Maven (Recommended) |
21 | 23 |
|
22 | | -## Quick Start (Windows PowerShell) |
23 | 24 | ```powershell |
24 | | -cd "g:\My Drive\GITHUB\java\java_array_2d_operations_gh" |
| 25 | +# Build the project |
| 26 | +mvn clean package |
| 27 | +
|
| 28 | +# Run the application |
| 29 | +java -jar target/array-2d-operations-1.0.0.jar |
| 30 | +``` |
| 31 | + |
| 32 | +### Without Maven |
25 | 33 |
|
| 34 | +```powershell |
26 | 35 | # Compile |
27 | 36 | javac Array2DOperations.java TwoDArray.java |
28 | 37 |
|
29 | | -# Run (opens a desktop window) |
| 38 | +# Run |
30 | 39 | java Array2DOperations |
31 | 40 | ``` |
32 | 41 |
|
33 | | -## Usage Guide |
34 | | -- File → About: Shows a summary of features |
35 | | -- Two Dimensional Array → Create New Array: Configure rows, columns, and value range, then generate |
36 | | -- Statistics → (Min/Max/Avg/Std Dev): Computes and displays results below the grid |
37 | | -- Operations → Array Search: Prompts for a key and shows location if found |
38 | | -- Operations → Array Add/Subtract: Prompts for a second array and displays result |
39 | | -- Operations → Array Multiply: Prompts for a second array and displays `A × B` |
40 | | - |
41 | | -Notes: |
42 | | -- Matrix multiply requires compatible sizes: `A[rows × k] × B[k × cols]` |
43 | | -- Values are integers; average and standard deviation are rounded for display |
44 | | - |
45 | | -## Project Structure |
46 | | -- `Array2DOperations.java`: Window, menus, event handling, painting |
47 | | -- `TwoDArray.java`: Creation, statistics, search, add/subtract/multiply helpers |
48 | | - |
49 | | -## Common Questions |
50 | | -- Window doesn’t update after resize? The app listens to resize events and repaints automatically. |
51 | | -- Where are inputs entered? Via dialogs (rows, columns, low/high values, search keys). |
52 | | -- Why is multiply disabled sometimes? If dimensions are incompatible, an error is thrown to prevent invalid math. |
53 | | - |
54 | | -## Next Steps |
55 | | -- Add input validation loops (reject invalid/empty values) |
56 | | -- Export arrays/results to CSV |
57 | | -- Color-code cells by magnitude or highlight search hits |
58 | | -- Keyboard shortcuts for frequent actions |
59 | | - |
60 | | -## License |
61 | | -This example is provided as-is for educational and demonstration purposes. |
| 42 | +## 📖 Usage Guide |
| 43 | + |
| 44 | +### Menu Options |
| 45 | + |
| 46 | +#### File Menu |
| 47 | +- **About**: Display feature summary and application info |
| 48 | + |
| 49 | +#### Two Dimensional Array Menu |
| 50 | +- **Create New Array**: Configure rows, columns, and value range to generate random array |
| 51 | + |
| 52 | +#### Statistics Menu |
| 53 | +- **Minimum**: Find and display smallest value |
| 54 | +- **Maximum**: Find and display largest value |
| 55 | +- **Average**: Calculate mean value |
| 56 | +- **Standard Deviation**: Compute statistical deviation |
| 57 | + |
| 58 | +#### Operations Menu |
| 59 | +- **Array Search**: Find specific value and show its location |
| 60 | +- **Array Add**: Add two arrays element-wise |
| 61 | +- **Array Subtract**: Subtract second array from first |
| 62 | +- **Array Multiply**: Perform matrix multiplication (requires compatible dimensions) |
| 63 | + |
| 64 | +## 🔢 Matrix Operations |
| 65 | + |
| 66 | +### Addition & Subtraction |
| 67 | +- Arrays must have same dimensions |
| 68 | +- Element-wise operations |
| 69 | + |
| 70 | +### Multiplication |
| 71 | +- Requires compatible sizes: `A[m × k] × B[k × n] = C[m × n]` |
| 72 | +- Standard matrix multiplication algorithm |
| 73 | + |
| 74 | +## 🏗️ Architecture |
| 75 | + |
| 76 | +### Components |
| 77 | +- **Array2DOperations.java**: Main window, menu system, event handling, rendering |
| 78 | +- **TwoDArray.java**: Core logic for array operations, statistics, and matrix math |
| 79 | + |
| 80 | +### Key Features |
| 81 | +- Dialog-based input using `JOptionPane` |
| 82 | +- Custom rendering with Java Graphics API |
| 83 | +- Event-driven architecture |
| 84 | +- Thread-safe operations |
| 85 | + |
| 86 | +## 📋 Requirements |
| 87 | + |
| 88 | +- **JDK 21** (Temurin recommended) |
| 89 | +- **Maven 3.9+** |
| 90 | +- Cross-platform: Windows, macOS, Linux |
| 91 | + |
| 92 | +## 🏗️ Building from Source |
| 93 | + |
| 94 | +```powershell |
| 95 | +# Clone the repository |
| 96 | +git clone https://github.com/maxwell-hauser/java_array_2d_operations.git |
| 97 | +cd java_array_2d_operations |
| 98 | +
|
| 99 | +# Build with Maven |
| 100 | +mvn clean install |
| 101 | +
|
| 102 | +# Run tests |
| 103 | +mvn test |
| 104 | +``` |
| 105 | + |
| 106 | +## 💡 Tips |
| 107 | + |
| 108 | +- **Dimensions**: Choose array sizes that fit comfortably in your window |
| 109 | +- **Value Range**: Select appropriate min/max values for better visualization |
| 110 | +- **Matrix Multiplication**: Ensure middle dimensions match (k in A[m×k] and B[k×n]) |
| 111 | +- **Resize**: Window automatically redraws arrays when resized |
| 112 | + |
| 113 | +## 🚀 Future Enhancements |
| 114 | + |
| 115 | +- Enhanced input validation with retry loops |
| 116 | +- Export arrays and results to CSV |
| 117 | +- Color-coded cells based on value magnitude |
| 118 | +- Search result highlighting in grid |
| 119 | +- Keyboard shortcuts for frequent operations |
| 120 | +- Additional statistical measures (median, mode) |
| 121 | + |
| 122 | +## 📄 License |
| 123 | + |
| 124 | +This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. |
| 125 | + |
| 126 | +## 👤 Author |
| 127 | + |
| 128 | +**Maxwell Hauser** |
| 129 | + |
| 130 | +## 🤝 Contributing |
| 131 | + |
| 132 | +Contributions, issues, and feature requests are welcome! Feel free to check the [issues page](https://github.com/maxwell-hauser/java_array_2d_operations/issues). |
0 commit comments