Skip to content

Commit

Permalink
- add documentation
Browse files Browse the repository at this point in the history
- fix minor bugs while compressing, filePath and compressionChoice is not disable.
- add interface on InformationUI
  • Loading branch information
IRedDragonICY committed Dec 31, 2023
1 parent 29e928f commit 09ef107
Show file tree
Hide file tree
Showing 15 changed files with 137 additions and 41 deletions.
1 change: 1 addition & 0 deletions .idea/gradle.xml

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

120 changes: 102 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,102 @@
# CompactJV
<p align="center">
<img src="src/main/resources/com/example/compactjv/app.png" width="128" height="128" alt="CompactJV logo">
<h1 align="center">CompactJV</h1>


<p align="center">
<img src="https://img.shields.io/badge/CompactJV-v1.0.0-blue.svg?style=for-the-badge" alt="CompactJV version">
<img src="https://img.shields.io/badge/Java-v21-blue.svg?style=for-the-badge&logo=openjdk&logoColor=white" alt="Java version">
<img src="https://img.shields.io/badge/Windows-0078D6?style=for-the-badge&logo=windows&logoColor=white" alt="Windows">
<img src="https://img.shields.io/badge/Gradle-v7.2-blue.svg?style=for-the-badge&logo=gradle&logoColor=white" alt="Gradle version">
<img src="https://img.shields.io/badge/WIX-v3-blue.svg?style=for-the-badge&logo=wix&logoColor=white" alt="WIX version">
<img src="https://img.shields.io/badge/License-MIT-yellow.svg?style=for-the-badge" alt="License">
<img src="https://img.shields.io/badge/Contributions-Welcome-green.svg?style=for-the-badge" alt="Contributions">

____
</p>


**CompactJV** is a powerful compression tool developed using Java. It leverages the capabilities of Compact.exe from the
Windows SDK to compress files such as games or applications. Designed with Windows operating system users in mind,
CompactJV delivers high-performance file compression with the ease of use.

## Table of Contents

- [Demo](#demo)
- [How It Works](#how-it-works)
- [Usage](#usage)
- [Getting Started](#getting-started)
- [Prerequisites](#prerequisites)
- [Installation](#installation)
- [Contributing](#contributing)
- [License](#license)
- [Development Team](#development-team)
- [Acknowledgements](#acknowledgements)

## Demo

<p align="center">
<img src="documentation/demo/demo1.png" width="200" alt="Demo 1">
<img src="documentation/demo/demo2.png" width="200" alt="Demo 2">
<img src="documentation/demo/demo3.png" width="200" alt="Demo 3">
<img src="documentation/demo/demo4.png" width="200" alt="Demo 4">
</p>

[//]: # (https://github.com/IRedDragonICY/CompactJV)
![Java](https://img.shields.io/badge/java-%23ED8B00.svg?style=for-the-badge&logo=openjdk&logoColor=white)
![Windows](https://img.shields.io/badge/Windows-0078D6?style=for-the-badge&logo=windows&logoColor=white)
[![Visitor](http://hits.dwyl.com/IRedDragonICY/CompactJV.svg)](http://hits.dwyl.com/IRedDragonICY/CompactJV)
## Getting Started

CompactJV is a compression tool using Compact.exe from Windows SDK to Files like games of application. This tool is developed using Java language and is intended to be used on Windows operating system.
To get CompactJV running on your local machine for development and testing, follow the instructions below.

## Getting Started
## How It Works

CompactJV uses the Compact.exe tool from the Windows SDK to compress files. It supports several compression algorithms,
including XPRESS4K, XPRESS8K, XPRESS16K, XPRESS, and LZX.

Here's a brief overview of how each algorithm works:

1. **XPRESS4K**: This is a fast compression algorithm that provides a reasonable compression ratio. The '4K' in its name
refers to the size of the sliding window used during compression.

2. **XPRESS8K and XPRESS16K**: These are variations of the XPRESS4K algorithm. They use larger sliding windows of 8K and
16K, respectively. This allows them to achieve better compression ratios, but at the cost of slower performance.

3. **XPRESS**: This algorithm provides a balance between performance and compression ratio. It's more efficient than
XPRESS4K, XPRESS8K, and XPRESS16K, but not as powerful as LZX.

4. **LZX**: This is a very high-performance compression algorithm. It provides excellent compression ratios, but it's
also quite slow compared to the other algorithms.

When you choose to compress a file with CompactJV, the program uses one of these algorithms to reduce the file's size.
The specific algorithm used depends on the options you select.

These instructions will guide you on how to get a copy of the project up and running on your local machine for development and testing purposes.
## Usage

Here's how to use CompactJV:

1. Select the file you want to compress.
2. Choose the compression algorithm you want to use.
3. Click the 'Compress' button.

CompactJV will then compress the file using the selected algorithm. The compressed file will be saved in the same
location as the original file.

Remember: the more powerful the compression algorithm, the longer it will take to compress the file. If speed is a
concern, you may want to use a faster algorithm like XPRESS4K or XPRESS. If you're more concerned about reducing the
file's size as much as possible, you may want to use a more powerful algorithm like LZX.

### Prerequisites

Ensure that you have the following installed on your machine:
Please make sure you have the following software installed:

- [Java Development Kit (JDK 17)](https://www.oracle.com/java/technologies/downloads/#java17)
- [Java Development Kit (JDK 21)](https://www.oracle.com/java/technologies/downloads/#java21)
- Gradle
- [WIX v3](https://wixtoolset.org/docs/wix3/)
- [WIX v3](https://wixtoolset.org/docs/wix3/)
- [IntelliJ IDEA](https://www.jetbrains.com/idea/download/?section=windows) (optional)

### Installation

To get a local copy up and running, follow these steps:
1. Ensure that you have the required tools installed.
Follow these steps to get a local copy of CompactJV:

1. Ensure the required tools are installed.
2. Clone the CompactJV repository to your local machine.

```bash
Expand All @@ -32,22 +105,33 @@ To get a local copy up and running, follow these steps:

3. Navigate to the project directory.

4. Run the following command to build the project:
4. Run this command to build the project:

```bash
./gradlew jpackage
```

This will compile the project and package it into a distributable format.
This command compiles the project and packages it into a distributable format.

## Contributing

We welcome contributions from all developers. Feel free to fork the project, make your changes, and submit a pull request.
We welcome contributions from developers. Feel free to fork the project, make your changes, and submit a pull request.

## License

This project is licensed under the MIT License. For more information, see the `LICENSE` file in the project repository.
This project is licensed under the MIT License. For more information, please refer to the `LICENSE` file in the project
repository.

## Development Team

This project is brought to you by a team of dedicated developers from Universitas Ahmad Dahlan:

1. **Muhammad Farid Hendianto (Ndik)** - _Student ID: 2200018401_
2. **Reyhanssan Islamey (Justin)** - _Student ID: 2200018411_
3. **Rendie Abdi Saputra (Ryu)** - _Student ID: 2200018094_
4. **Fadhil Raifan Andika** - _Student ID: 2200018458_

## Acknowledgements

- **Faisal Fajri Rahani S.Si., M.Cs.**, for his guidance and support.
We would like to express our gratitude to **Faisal Fajri Rahani S.Si., M.Cs.**, for his exemplary guidance and
unwavering support throughout the development of this project.
Binary file added documentation/class diagram.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added documentation/demo/demo1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added documentation/demo/demo2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added documentation/demo/demo3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added documentation/demo/demo4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
Binary file added src/main/Design/design3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 15 additions & 12 deletions src/main/java/com/example/compactjv/UI/ButtonHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,26 @@

public class ButtonHandler extends Controller {


public ButtonHandler() {
super();
setupCompressionButton();
setupDecompressionButton();
}

private void setupCompressionButton() {
compressButton.setOnAction(event -> handleCompressionOrDecompression(true));
compressButton.setDisable(true);
setButtonState(true);
}

private void setupDecompressionButton() {
decompressButton.setOnAction(event -> handleCompressionOrDecompression(false));
decompressButton.setDisable(true);
setButtonState(true);
}

private void handleCompressionOrDecompression(boolean isCompression) {
String filePath = compact.getFilePath();
updateSizeOnDiskLabel("Loading...");
disableButtons();
setButtonState(true);
Runnable task = createCompressionOrDecompressionTask(isCompression, filePath);
Future<?> future = executorServiceManager.submitTask(task);
new LoadingBarUI(future, filePath, isCompression);
Expand All @@ -36,6 +36,7 @@ private void handleCompressionOrDecompression(boolean isCompression) {
private Runnable createCompressionOrDecompressionTask(boolean isCompression, String filePath) {
return () -> {
progressBar.setVisible(true);
setUIState(true);
if (isCompression) {
String algorithm = compressionAlgorithmChoiceBox.getValue();
compact.compress(filePath, algorithm);
Expand All @@ -45,32 +46,34 @@ private Runnable createCompressionOrDecompressionTask(boolean isCompression, Str
updateAfterTaskCompletion();
};
}

private void updateAfterTaskCompletion() {
Size size = compact.calculateFolderSize(compact.getFilePath());
boolean isCompressed = compact.isCompressed(compact.getFilePath());
updateUIAfterFolderPreparation(isCompressed, size);
enableButtons();
setButtonState(false);
}

private void updateSizeOnDiskLabel(String text) {
sizeOnDiskLabel.setText(text);
}

private void disableButtons() {
compressButton.setDisable(true);
decompressButton.setDisable(true);
private void setButtonState(boolean state) {
compressButton.setDisable(state);
decompressButton.setDisable(state);
}

private void enableButtons() {
compressButton.setDisable(false);
decompressButton.setDisable(false);
private void setUIState(boolean state) {
filePathField.setDisable(state);
compressionAlgorithmChoiceBox.setDisable(state);
}

private void updateUIAfterFolderPreparation(boolean isCompressed, Size size) {
Platform.runLater(() -> {
updateButtonVisibilityAndText(isCompressed);
currentSizeLabel.setText(size.getSizeFormatted());
setUIState(false);
sizeOnDiskLabel.setText(isCompressed ? size.getSizeOnDiskFormatted() : "??");
compressionAlgorithmChoiceBox.setDisable(false);
});
}

Expand Down
9 changes: 6 additions & 3 deletions src/main/java/com/example/compactjv/UI/ButtonUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ private void setupInformationButton() {
dialog.initOwner(primaryStage);
dialog.initStyle(StageStyle.TRANSPARENT);
dialog.setWidth(400);
dialog.setHeight(400);
dialog.setHeight(420);

GridPane content = new GridPane();
content.setPadding(new Insets(20));
Expand Down Expand Up @@ -72,8 +72,11 @@ private void setupInformationButton() {
"""
Developed by:
1. Muhammad Farid Hendianto (Ndik) {2200018401}
2. Reyhanssan Islamey (Justin) {2200018411}
3. Rendie Abdi Saputra (Ryu) {2200018094}"""
2. Reyhanssan Islamey (Justin) {2200018411}
3. Rendie Abdi Saputra (Ryu) {2200018094}
4. Fadhil Raifan Andika {2200018458}
"""
);
developers.setFill(Color.WHITE);

Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/example/compactjv/UI/CPUInformationUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@

import java.util.concurrent.TimeUnit;

public class CPUInformationUI extends Controller {

public class CPUInformationUI extends Controller implements InformationUI {

public CPUInformationUI() {
super();
setupCPUUsageLabel();
setupUsageLabel();
}

private void setupCPUUsageLabel() {
@Override
public void setupUsageLabel() {
Runnable task = () -> {
String cpuUsage = File.getCPUUsage();
Platform.runLater(() -> cpuUsageLabel.setText(cpuUsage + "%"));
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/example/compactjv/UI/InformationUI.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.example.compactjv.UI;

public interface InformationUI {
void setupUsageLabel();
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@

import java.util.concurrent.TimeUnit;

public class MemoryInformationUI extends Controller {

public class MemoryInformationUI extends Controller implements InformationUI {

public MemoryInformationUI() {
super();
setupMemoryUsageLabel();
setupUsageLabel();
}

private void setupMemoryUsageLabel() {
@Override
public void setupUsageLabel() {
Runnable task = () -> {
String memoryUsage = File.getMemoryUsage();
Platform.runLater(() -> memoryUsageLabel.setText(memoryUsage + "%"));
Expand Down

0 comments on commit 09ef107

Please sign in to comment.