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
1 change: 0 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ dependencies {
implementation group: "org.apache.commons", name: "commons-math3", version: "3.6.1"

implementation group: "com.google.inject", name: "guice", version: guiceVersion
implementation group: "org.tinfour", name: "TinfourCore", version: "2.1.8"
implementation "com.fasterxml.jackson.module:jackson-module-kotlin:$jacksonVersion"
implementation "org.apache.commons:commons-collections4:4.4"

Expand Down
9 changes: 9 additions & 0 deletions common-utils/src/main/kotlin/ru/nucodelabs/util/Point.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package ru.nucodelabs.util

data class Point(
val x: Double,
val y: Double,
val z: Double
)

fun Point(x: Double, y: Double) = Point(x, y, .0)
25 changes: 12 additions & 13 deletions kfx-utils/build.gradle
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

plugins {
id 'org.jetbrains.kotlin.jvm' version '2.2.0'
id 'java-library'
id 'org.openjfx.javafxplugin' version '0.1.0'
id "org.jetbrains.kotlin.jvm" version "2.2.0"
id "java-library"
id "org.openjfx.javafxplugin" version "0.1.0"
}

version = rootProject.version

tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
options.encoding = "UTF-8"
}

javafx {
version = rootProject['javafx']['version']
modules = ['javafx.controls', 'javafx.fxml', 'javafx.graphics', 'javafx.swing']
version = rootProject["javafx"]["version"]
modules = ["javafx.controls", "javafx.fxml", "javafx.graphics", "javafx.swing"]
}

repositories {
// Use Maven Central for resolving dependencies.
mavenCentral()
}

Expand All @@ -39,14 +38,14 @@ compileKotlin {
}

dependencies {
implementation platform('org.jetbrains.kotlin:kotlin-bom')
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
implementation platform("org.jetbrains.kotlin:kotlin-bom")
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"

testImplementation 'org.jetbrains.kotlin:kotlin-test'
testImplementation 'org.jetbrains.kotlin:kotlin-test-junit'
testImplementation "org.jetbrains.kotlin:kotlin-test"
testImplementation "org.jetbrains.kotlin:kotlin-test-junit"
testImplementation "org.openjfx:javafx:${javafx.version}"

api "org.openjfx:javafx:${javafx.version}"
api group: 'com.google.inject', name: 'guice', version: rootProject.guiceVersion
api 'no.tornado:tornadofx:1.7.20'
api group: "com.google.inject", name: "guice", version: rootProject.guiceVersion
api "no.tornado:tornadofx:1.7.20"
}
44 changes: 23 additions & 21 deletions src/main/java/ru/nucodelabs/gem/config/AppModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@
import ru.nucodelabs.geo.target.RelativeErrorAwareTargetFunction;
import ru.nucodelabs.geo.target.impl.SquareDiffTargetFunction;

import java.io.FileInputStream;
import java.io.IOException;
import java.math.RoundingMode;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
Expand Down Expand Up @@ -69,8 +69,8 @@ private Locale currentLocale() {

@Provides
@Singleton
private ResourceBundle uiProperties() {
return ResourceBundle.getBundle("ui", currentLocale());
private ResourceBundle uiProperties(Locale currentLocale) {
return ResourceBundle.getBundle("ui", currentLocale);
}

@Provides
Expand Down Expand Up @@ -149,6 +149,7 @@ private Preferences preferences() {

@Provides
@Named(Name.PRECISE_FORMAT)
@Singleton
DecimalFormat preciseFormat() {
DecimalFormat decimalFormat = new DecimalFormat();
decimalFormat.setRoundingMode(RoundingMode.HALF_UP);
Expand All @@ -162,6 +163,7 @@ DecimalFormat preciseFormat() {
}

@Provides
@Singleton
private DecimalFormat decimalFormat() {
DecimalFormat decimalFormat = new DecimalFormat();
decimalFormat.setRoundingMode(RoundingMode.HALF_UP);
Expand All @@ -176,6 +178,7 @@ private DecimalFormat decimalFormat() {
}

@Provides
@Singleton
private StringConverter<Double> doubleStringConverter(DecimalFormat decimalFormat) {
return new StringConverter<>() {
@Override
Expand All @@ -199,6 +202,7 @@ public Double fromString(String string) {
}

@Provides
@Singleton
StringConverter<Number> numberStringConverter(StringConverter<Double> doubleStringConverter) {
return new StringConverter<>() {
@Override
Expand All @@ -216,44 +220,42 @@ public Number fromString(String string) {
@Provides
@Singleton
@Named(Name.DEFAULT_CLR)
ClrInfo clrInfo() throws IOException {
LoadedClr colormapFile() throws IOException {
// Firstly lookup next to executable
var externalFile = Paths.get("colormap/default.clr").toFile();
if (!externalFile.exists()) {
var externalFile = Paths.get("colormap/default.clr");
if (Files.notExists(externalFile)) {
// Load default from resources if no external .clr file found
var defaultResourceStream = Objects.requireNonNull(
this.getClass().getClassLoader().getResourceAsStream("colormap/default.clr"),
"Resource colormap/default.clr is null"
"Resource colormap/default.clr must not be null"
);
log.info("Loading default .clr file from resources");
try (defaultResourceStream) {
log.info("Loading default .clr file from resources");
return new ClrInfo(
return new LoadedClr(
"Default",
new String(defaultResourceStream.readAllBytes(), StandardCharsets.UTF_8)
);
}
}
try (var externalFileStream = new FileInputStream(externalFile)) {
log.info("Loading external .clr file");
return new ClrInfo(
externalFile.getAbsolutePath(),
new String(externalFileStream.readAllBytes(), StandardCharsets.UTF_8)
);
}
log.info("Loading external .clr file");
return new LoadedClr(
externalFile.toAbsolutePath().toString(),
Files.readString(externalFile, StandardCharsets.UTF_8)
);
}

@Provides
@Singleton
@Named(Name.CLR_SOURCE)
String clrSource(@Named(Name.DEFAULT_CLR) ClrInfo clrInfo) {
return clrInfo.source();
String clrSource(@Named(Name.DEFAULT_CLR) LoadedClr loadedClr) {
return loadedClr.source();
}

@Provides
@Named(Name.DEFAULT_CLR)
@Singleton
ClrParser clrParser(@Named(Name.DEFAULT_CLR) ClrInfo clrInfo) {
return new ClrParser(clrInfo.content());
ClrParser clrParser(@Named(Name.DEFAULT_CLR) LoadedClr loadedClr) {
return new ClrParser(loadedClr.content());
}

@Provides
Expand Down Expand Up @@ -283,6 +285,6 @@ RelativeErrorAwareTargetFunction targetFunction() {
return new SquareDiffTargetFunction();
}

private record ClrInfo(String source, String content) {
private record LoadedClr(String source, String content) {
}
}
5 changes: 4 additions & 1 deletion src/main/java/ru/nucodelabs/gem/config/ChartsModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@

import com.google.inject.AbstractModule;
import com.google.inject.Provides;
import com.google.inject.Singleton;
import ru.nucodelabs.geo.forward.ForwardSolver;
import ru.nucodelabs.geo.ves.calc.graph.MathVesNativeMisfitsFunction;
import ru.nucodelabs.geo.ves.calc.graph.MisfitsFunction;

public class ChartsModule extends AbstractModule {

@Provides
@Singleton
MisfitsFunction misfitValuesFactory(ForwardSolver forwardSolver) {
return MisfitsFunction.createDefault(forwardSolver);
return new MathVesNativeMisfitsFunction(forwardSolver);
}
}
Loading
Loading