2021-08-22
This commit is contained in:
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -7,6 +7,6 @@
|
|||||||
|
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
@@ -10,5 +10,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
// https://mvnrepository.com/artifact/org.apache.commons/commons-imaging
|
||||||
|
implementation("org.apache.commons:commons-imaging:1.0-alpha2")
|
||||||
|
|
||||||
}
|
}
|
||||||
43
imaging/src/main/java/kr/pe/elex/examples/CommonsSample.java
Normal file
43
imaging/src/main/java/kr/pe/elex/examples/CommonsSample.java
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
* Examples for Java
|
||||||
|
*
|
||||||
|
* Copyright (c) 2021. Elex. All Rights Reserved.
|
||||||
|
* https://www.elex-project.com/
|
||||||
|
*/
|
||||||
|
|
||||||
|
package kr.pe.elex.examples;
|
||||||
|
|
||||||
|
import org.apache.commons.imaging.*;
|
||||||
|
import org.apache.commons.imaging.formats.png.PngConstants;
|
||||||
|
import org.apache.commons.imaging.formats.tiff.constants.TiffConstants;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class CommonsSample {
|
||||||
|
public static void main(String... args) throws ImageWriteException, IOException, ImageReadException {
|
||||||
|
readPNG();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void readPNG() throws IOException, ImageReadException, ImageWriteException {
|
||||||
|
BufferedImage imageSource = Imaging.getBufferedImage(Objects
|
||||||
|
.requireNonNull(Sample.class.getResourceAsStream("/java.png")));
|
||||||
|
Image scaledImage = imageSource.getScaledInstance(16, 16, Image.SCALE_SMOOTH);
|
||||||
|
|
||||||
|
BufferedImage newImage = new BufferedImage(16, 16, BufferedImage.TYPE_INT_RGB);
|
||||||
|
Graphics2D g = newImage.createGraphics();
|
||||||
|
g.drawImage(scaledImage, 0, 0, null);
|
||||||
|
|
||||||
|
final Map<String, Object> params = new HashMap<>();
|
||||||
|
params.put(ImagingConstants.PARAM_KEY_COMPRESSION,
|
||||||
|
TiffConstants.TIFF_COMPRESSION_UNCOMPRESSED);
|
||||||
|
|
||||||
|
Imaging.writeImage(newImage, new File("out/test-out.ico"), ImageFormats.TIFF, params);
|
||||||
|
//PngConstants.
|
||||||
|
}
|
||||||
|
}
|
||||||
57
imaging/src/main/java/kr/pe/elex/examples/Sample.java
Normal file
57
imaging/src/main/java/kr/pe/elex/examples/Sample.java
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
/*
|
||||||
|
* Examples for Java
|
||||||
|
*
|
||||||
|
* Copyright (c) 2021. Elex. All Rights Reserved.
|
||||||
|
* https://www.elex-project.com/
|
||||||
|
*/
|
||||||
|
|
||||||
|
package kr.pe.elex.examples;
|
||||||
|
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class Sample {
|
||||||
|
public static void main(String... args) throws IOException {
|
||||||
|
formats();
|
||||||
|
//readPNG();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void readPNG() throws IOException {
|
||||||
|
BufferedImage imageSource = ImageIO.read(Objects
|
||||||
|
.requireNonNull(Sample.class.getResourceAsStream("/java.png")));
|
||||||
|
Image scaledImage = imageSource.getScaledInstance(100, 100, Image.SCALE_SMOOTH);
|
||||||
|
|
||||||
|
BufferedImage newImage = new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB);
|
||||||
|
Graphics2D g = newImage.createGraphics();
|
||||||
|
boolean r = g.drawImage(scaledImage, 0, 0, null);
|
||||||
|
|
||||||
|
System.out.println("? " + r);
|
||||||
|
ImageIO.write(newImage, "JPG", new File("out/test-out.jpg"));
|
||||||
|
//ImageIO.write(imageSource, "JPG", new File("test-src-out.jpg"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BufferedImage convert(final Image image, final int imageTYpe) {
|
||||||
|
final BufferedImage newImage = new BufferedImage(image.getWidth(null), image.getHeight(null),
|
||||||
|
imageTYpe);
|
||||||
|
|
||||||
|
final Graphics2D g = newImage.createGraphics();
|
||||||
|
g.drawImage(image, 0, 0, null);
|
||||||
|
g.dispose();
|
||||||
|
return newImage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void formats(){
|
||||||
|
System.out.println("Writer");
|
||||||
|
for (String item : ImageIO.getWriterFormatNames()) {
|
||||||
|
System.out.println(item);
|
||||||
|
}
|
||||||
|
System.out.println("Reader");
|
||||||
|
for (String item : ImageIO.getReaderFormatNames()) {
|
||||||
|
System.out.println(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
imaging/src/main/resources/java.png
Normal file
BIN
imaging/src/main/resources/java.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 68 KiB |
@@ -1,25 +0,0 @@
|
|||||||
/*
|
|
||||||
* Examples for Java
|
|
||||||
*
|
|
||||||
* Copyright (c) 2021. Elex. All Rights Reserved.
|
|
||||||
* https://www.elex-project.com/
|
|
||||||
*/
|
|
||||||
|
|
||||||
plugins {
|
|
||||||
id("elex-java")
|
|
||||||
id("application")
|
|
||||||
id("org.openjfx.javafxplugin") version "0.0.10"
|
|
||||||
id("org.beryx.jlink") version "2.23.1"
|
|
||||||
}
|
|
||||||
application {
|
|
||||||
mainClass.set("kr.pe.elex.examples.FxmlApplication")
|
|
||||||
mainModule.set("kr.pe.elex.examples")
|
|
||||||
}
|
|
||||||
javafx {
|
|
||||||
version = "11.0.2"
|
|
||||||
modules = listOf("javafx.controls", "javafx.fxml")
|
|
||||||
}
|
|
||||||
dependencies {
|
|
||||||
//implementation("org.openjfx:javafx-controls:11.0.2")
|
|
||||||
//implementation("org.openjfx:javafx-fxml:11.0.2")
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!--
|
|
||||||
~ Examples for Java
|
|
||||||
~
|
|
||||||
~ Copyright (c) 2021. Elex. All Rights Reserved.
|
|
||||||
~ https://www.elex-project.com/
|
|
||||||
-->
|
|
||||||
|
|
||||||
<configuration>
|
|
||||||
|
|
||||||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
|
|
||||||
<encoder>
|
|
||||||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
|
|
||||||
</encoder>
|
|
||||||
</appender>
|
|
||||||
|
|
||||||
<root level="TRACE">
|
|
||||||
<appender-ref ref="CONSOLE" />
|
|
||||||
</root>
|
|
||||||
</configuration>
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
/*
|
|
||||||
* Examples for Java
|
|
||||||
*
|
|
||||||
* Copyright (c) 2021. Elex. All Rights Reserved.
|
|
||||||
* https://www.elex-project.com/
|
|
||||||
*/
|
|
||||||
|
|
||||||
package kr.pe.elex.examples;
|
|
||||||
|
|
||||||
import javafx.application.Application;
|
|
||||||
import javafx.fxml.FXMLLoader;
|
|
||||||
import javafx.scene.Parent;
|
|
||||||
import javafx.scene.Scene;
|
|
||||||
import javafx.scene.layout.GridPane;
|
|
||||||
import javafx.stage.Stage;
|
|
||||||
|
|
||||||
public class FxmlApplication extends Application {
|
|
||||||
public static void main(String... args) {
|
|
||||||
launch(args);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void start(Stage primaryStage) throws Exception {
|
|
||||||
primaryStage.setTitle("Hello!");
|
|
||||||
primaryStage.setWidth(800);
|
|
||||||
primaryStage.setHeight(600);
|
|
||||||
//GridPane root = new GridPane();
|
|
||||||
Parent root = FXMLLoader.load(getClass().getResource ("/fxml/root.fxml"));
|
|
||||||
Scene scene = new Scene(root);
|
|
||||||
primaryStage.setScene(scene);
|
|
||||||
primaryStage.show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
module kr.pe.elex.examples {
|
|
||||||
requires javafx.graphics;
|
|
||||||
requires javafx.fxml;
|
|
||||||
|
|
||||||
exports kr.pe.elex.examples;
|
|
||||||
}
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
|
|
||||||
<?import javafx.scene.control.*?>
|
|
||||||
<?import javafx.scene.layout.*?>
|
|
||||||
|
|
||||||
<!--
|
|
||||||
~ Examples for Java
|
|
||||||
~
|
|
||||||
~ Copyright (c) 2021. Elex. All Rights Reserved.
|
|
||||||
~ https://www.elex-project.com/
|
|
||||||
-->
|
|
||||||
|
|
||||||
<BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/11.0.2" xmlns:fx="http://javafx.com/fxml/1">
|
|
||||||
<center>
|
|
||||||
<Button mnemonicParsing="false" text="Button" BorderPane.alignment="CENTER" />
|
|
||||||
</center>
|
|
||||||
<bottom>
|
|
||||||
|
|
||||||
</bottom>
|
|
||||||
<top>
|
|
||||||
<MenuBar BorderPane.alignment="CENTER">
|
|
||||||
<menus>
|
|
||||||
<Menu mnemonicParsing="false" text="File">
|
|
||||||
<items>
|
|
||||||
<MenuItem mnemonicParsing="false" text="Close" />
|
|
||||||
</items>
|
|
||||||
</Menu>
|
|
||||||
<Menu mnemonicParsing="false" text="Edit">
|
|
||||||
<items>
|
|
||||||
<MenuItem mnemonicParsing="false" text="Delete" />
|
|
||||||
</items>
|
|
||||||
</Menu>
|
|
||||||
<Menu mnemonicParsing="false" text="Help">
|
|
||||||
<items>
|
|
||||||
<MenuItem mnemonicParsing="false" text="About" />
|
|
||||||
</items>
|
|
||||||
</Menu>
|
|
||||||
</menus>
|
|
||||||
</MenuBar>
|
|
||||||
</top>
|
|
||||||
</BorderPane>
|
|
||||||
@@ -13,6 +13,7 @@ include(
|
|||||||
"web-socket-servlet", "web-socket-client",
|
"web-socket-servlet", "web-socket-client",
|
||||||
"thread", "hibernate", "jdbc-sqlite",
|
"thread", "hibernate", "jdbc-sqlite",
|
||||||
"xml", "jackson", "jsoup", "markdown", "network", "httpd",
|
"xml", "jackson", "jsoup", "markdown", "network", "httpd",
|
||||||
"swing", "java-fx", "properties",
|
"properties",
|
||||||
"mustache", "thymeleaf", "locale", "quartz", "sysinfo"
|
"mustache", "thymeleaf", "locale", "quartz", "sysinfo",
|
||||||
|
"imaging"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!--
|
|
||||||
~ Examples for Java
|
|
||||||
~
|
|
||||||
~ Copyright (c) 2021. Elex. All Rights Reserved.
|
|
||||||
~ https://www.elex-project.com/
|
|
||||||
-->
|
|
||||||
|
|
||||||
<configuration>
|
|
||||||
|
|
||||||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
|
|
||||||
<encoder>
|
|
||||||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
|
|
||||||
</encoder>
|
|
||||||
</appender>
|
|
||||||
|
|
||||||
<root level="TRACE">
|
|
||||||
<appender-ref ref="CONSOLE" />
|
|
||||||
</root>
|
|
||||||
</configuration>
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
/*
|
|
||||||
* Examples for Java
|
|
||||||
*
|
|
||||||
* Copyright (c) 2021. Elex. All Rights Reserved.
|
|
||||||
* https://www.elex-project.com/
|
|
||||||
*/
|
|
||||||
|
|
||||||
package kr.pe.elex.examples;
|
|
||||||
|
|
||||||
import com.sun.net.httpserver.HttpExchange;
|
|
||||||
import com.sun.net.httpserver.HttpHandler;
|
|
||||||
import com.sun.net.httpserver.HttpServer;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.net.InetSocketAddress;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.util.concurrent.ExecutorService;
|
|
||||||
import java.util.concurrent.Executors;
|
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
public class HttpD {
|
|
||||||
public static void main(String... args) throws IOException {
|
|
||||||
final ExecutorService threadPool = Executors.newCachedThreadPool();
|
|
||||||
HttpServer httpServer = HttpServer.create(new InetSocketAddress(18080), 0);
|
|
||||||
httpServer.setExecutor(threadPool);
|
|
||||||
|
|
||||||
httpServer.createContext("/", new HttpHandler() {
|
|
||||||
@Override
|
|
||||||
public void handle(final HttpExchange httpExchange) {
|
|
||||||
try {
|
|
||||||
httpExchange.getResponseHeaders().add("X-Datetime", LocalDateTime.now().toString());
|
|
||||||
String message = "<html><body><h1>Hello, world!</h1></body></html>";
|
|
||||||
//message += httpExchange.getRequestMethod();
|
|
||||||
//BufferedReader reader = new BufferedReader(new InputStreamReader(httpExchange.getRequestBody()));
|
|
||||||
//message += reader.readLine();
|
|
||||||
httpExchange.sendResponseHeaders(200, message.getBytes().length);
|
|
||||||
OutputStream os = httpExchange.getResponseBody();
|
|
||||||
os.write(message.getBytes());
|
|
||||||
os.flush();
|
|
||||||
os.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
httpServer.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user