-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
alex
committed
Mar 6, 2022
0 parents
commit 0646fbe
Showing
7 changed files
with
153 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.idea/* | ||
target/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Java 2D | ||
|
||
Это пример использования библиотеки JWM. | ||
Репозиторий этой библиотеки [здесь](https://github.com/HumbleUI/JWM). | ||
|
||
Она использует Skija библиотеку для 2D рисования, её репозиторий | ||
[здесь](https://github.com/JetBrains/skija). | ||
|
||
Главный класс - это `app.Application`. Он рисует панели, каждая из которых | ||
определена в отдельном классе. | ||
|
||
|
||
Чтобы запустить javaDoc, нужно указать кодировку | ||
|
||
`-encoding UTF-8 -charset UTF-8 -docencoding UTF-8` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?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>org.example</groupId> | ||
<artifactId>JavaGeometry2D_0</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
|
||
<properties> | ||
<maven.compiler.source>17</maven.compiler.source> | ||
<maven.compiler.target>17</maven.compiler.target> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.github.humbleui</groupId> | ||
<artifactId>jwm</artifactId> | ||
<version>0.4.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.github.humbleui.skija</groupId> | ||
<artifactId>skija-windows</artifactId> | ||
<version>0.96.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.fasterxml.jackson.core</groupId> | ||
<artifactId>jackson-databind</artifactId> | ||
<version>2.13.1</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>4.13.2</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import app.Application; | ||
import io.github.humbleui.jwm.App; | ||
|
||
/** | ||
* Главный класс приложения | ||
*/ | ||
public class Main { | ||
/** | ||
* Главный метод приложения | ||
* | ||
* @param args аргументы командной строки | ||
*/ | ||
public static void main(String[] args) { | ||
App.start(Application::new); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package app; | ||
|
||
import io.github.humbleui.jwm.*; | ||
|
||
import java.util.function.Consumer; | ||
|
||
/** | ||
* Класс окна приложения | ||
*/ | ||
public class Application implements Consumer<Event> { | ||
/** | ||
* окно приложения | ||
*/ | ||
private final Window window; | ||
|
||
/** | ||
* Конструктор окна приложения | ||
*/ | ||
public Application() { | ||
// создаём окно | ||
window = App.makeWindow(); | ||
// задаём обработчиком событий текущий объект | ||
window.setEventListener(this); | ||
// делаем окно видимым | ||
window.setVisible(true); | ||
} | ||
|
||
/** | ||
* Обработчик событий | ||
* | ||
* @param e событие | ||
*/ | ||
@Override | ||
public void accept(Event e) { | ||
// если событие - это закрытие окна | ||
if (e instanceof EventWindowClose) { | ||
// завершаем работу приложения | ||
App.terminate(); | ||
} else if (e instanceof EventWindowCloseRequest) { | ||
window.close(); | ||
} | ||
} | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import org.junit.Test; | ||
|
||
/** | ||
* Класс тестирования | ||
*/ | ||
public class UnitTest { | ||
|
||
/** | ||
* Первый тест | ||
*/ | ||
@Test | ||
public void firstTest() { | ||
// сумма изначально равна 0 | ||
int sum = 0; | ||
// суммируем числа от 0 до 9 | ||
for (int i = 0; i < 10; i++) { | ||
sum += i; | ||
} | ||
// проверяем, равна ли сумма 45 | ||
assert sum == 45; | ||
} | ||
|
||
/** | ||
* Второй тест | ||
*/ | ||
@Test | ||
public void secondTest() { | ||
// сумма изначально равна 0 | ||
int sum = 0; | ||
// суммируем числа от 0 до 19 | ||
for (int i = 0; i < 20; i++) { | ||
sum += i; | ||
} | ||
// проверяем, равна ли сумма 190 | ||
assert sum == 190; | ||
} | ||
} |