Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,8 @@

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
replay_pid*
replay_pid*

## Build folders
.out/
.target/
9 changes: 9 additions & 0 deletions .idea/artifacts/sav_jar.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/libraries/grahamedgecombe_jterminal.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 0 additions & 8 deletions .idea/modules.xml

This file was deleted.

11 changes: 0 additions & 11 deletions .idea/sorting-algorithm-visualisation.iml

This file was deleted.

8 changes: 8 additions & 0 deletions .idea/sorting-algorithm-visualization.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,16 @@
# Visualization of different sorting algorithms

## How to build Maven?

1. Main menu (alt + \)
2. Build -> build artifacts -> sav:jar -> build

## How to run?

open terminal in a folder with `.jar` file
``` bash
java -jar sav.jar
```
=======


42 changes: 42 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>sorting.algorithm.visualization</groupId>
<artifactId>sav</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>22</maven.compiler.source>
<maven.compiler.target>22</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>io.github.shuoros</groupId>
<artifactId>JTerminal</artifactId>
<version>1.0.2</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
</project>
7 changes: 7 additions & 0 deletions src/main/java/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import ui.TestUI;

public class Main {
public static void main(String[] args) {
TestUI.start();
}
}
26 changes: 26 additions & 0 deletions src/main/java/ui/TestUI.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package ui;

import algorithms.BubbleSort;

import java.util.ArrayList;
import java.util.List;

public class TestUI {
public static void start() {

ArrayList<Integer> list = new ArrayList<>(List.of(
10, 17, 9, 19, 15, 7, 6, 4, 7, 6,
6, 20, 17, 6, 5, 8, 8, 5, 17, 18,
16, 17, 10, 1, 18, 4, 6, 20, 9, 14,
7, 4, 15, 7, 6, 2, 15, 15, 3, 1, 9,
2, 19, 8, 16, 14, 19, 5, 20, 9
));
BubbleSort bubbleSort = new BubbleSort(list);

bubbleSort.sort();

Utils.printArray(list);
}


}
38 changes: 38 additions & 0 deletions src/main/java/ui/Utils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package ui;

import io.github.shuoros.jterminal.JTerminal;

import java.util.ArrayList;

public abstract class Utils {
// change to ### view
public static void printArray(ArrayList<Integer> arrayList) {
try {
Thread.sleep(10);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
JTerminal.clear();
int line = findMax(arrayList);
StringBuilder sb = new StringBuilder();
while (line >= 0) {
for (var element : arrayList) {
if (element > line) JTerminal.print("#");
else JTerminal.print(" ");
}
JTerminal.println("");
line--;
}

}

private static int findMax(ArrayList<Integer> array) {
int max = 0;
for (var element : array) {
if (element > max) max = element;
}
return max;
}

// fillArrayRandomlyMethod (between 1 and 100 for example)
}
3 changes: 3 additions & 0 deletions src/main/resources/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Manifest-Version: 1.0
Main-Class: Main

24 changes: 0 additions & 24 deletions src/ui/TestUI.java

This file was deleted.

18 changes: 0 additions & 18 deletions src/ui/Utils.java

This file was deleted.