diff --git a/build.gradle b/build.gradle
index 51dfef12..422753c1 100644
--- a/build.gradle
+++ b/build.gradle
@@ -208,8 +208,12 @@ compileJava {
run {
jvmArgs '-Dprism.maxvram=2G'
jvmArgs '-Djavafx.animation.fullspeed=true'
- jvmArgs '--enable-native-access=javafx.graphics'
- jvmArgs '--enable-native-access=javafx.media'
+ jvmArgs '--sun-misc-unsafe-memory-access=warn'
+ jvmArgs '--enable-native-access=javafx.graphics,javafx.media'
+ jvmArgs '--illegal-native-access=warn'
+ jvmArgs '-XX:+UseCompactObjectHeaders'
+ jvmArgs '-XX:+UseShenandoahGC'
+ jvmArgs '-XX:ShenandoahGCMode=generational'
}
tasks.named('test', Test) {
@@ -377,7 +381,12 @@ jlink {
} else {
jvmArgs += ["-Dtrinity.app.dir={{BIN_DIR}}"]
}
- jvmArgs += ['--enable-native-access=javafx.graphics', '--enable-native-access=javafx.media']
+ jvmArgs += ['--sun-misc-unsafe-memory-access=warn']
+ jvmArgs += ['--enable-native-access=javafx.graphics,javafx.media']
+ jvmArgs += ['--illegal-native-access=warn']
+ jvmArgs += ['-XX:+UseCompactObjectHeaders']
+ jvmArgs += ['-XX:+UseShenandoahGC']
+ jvmArgs += ['-XX:ShenandoahGCMode=generational']
//jvmArgs += ["--add-exports external.module.name/external.package.name=$sModuleName", ...]
}
//forceMerge('javafx')
@@ -391,7 +400,12 @@ jlink {
jvmArgs = ['-Dprism.maxvram=2G', '-Djavafx.animation.fullspeed=true']
jvmArgs += ["-Dlogback.configurationFile=\$APPDIR${fileSep}logback.xml"]
jvmArgs += ["-Dtrinity.app.dir=\$APPDIR"]
- jvmArgs += ['--enable-native-access=javafx.graphics', '--enable-native-access=javafx.media']
+ jvmArgs += ['--sun-misc-unsafe-memory-access=warn']
+ jvmArgs += ['--enable-native-access=javafx.graphics,javafx.media']
+ jvmArgs += ['--illegal-native-access=warn']
+ jvmArgs += ['-XX:+UseCompactObjectHeaders']
+ jvmArgs += ['-XX:+UseShenandoahGC']
+ jvmArgs += ['-XX:ShenandoahGCMode=generational']
jvmArgs += ['--module-path', '.']
if (currentOS.windows) {
skipInstaller = true
diff --git a/nbactions-4kMemory.xml b/nbactions-4kMemory.xml
index f8fe5684..5d5836f5 100644
--- a/nbactions-4kMemory.xml
+++ b/nbactions-4kMemory.xml
@@ -7,7 +7,7 @@
process-classes
- org.codehaus.mojo:exec-maven-plugin:3.5.0:exec
+ org.codehaus.mojo:exec-maven-plugin:3.6.2:exec
-Dprism.maxvram=2G
@@ -23,7 +23,7 @@
process-classes
- org.codehaus.mojo:exec-maven-plugin:3.5.0:exec
+ org.codehaus.mojo:exec-maven-plugin:3.6.2:exec
-Dprism.maxvram=2G -agentlib:jdwp=transport=dt_socket,server=n,address=${jpda.address}
@@ -40,7 +40,7 @@
process-classes
- org.codehaus.mojo:exec-maven-plugin:3.5.0:exec
+ org.codehaus.mojo:exec-maven-plugin:3.6.2:exec
-Dprism.maxvram=2G
diff --git a/nbactions-DalleWalle.xml b/nbactions-DalleWalle.xml
index 62f8e2a3..9254f57e 100644
--- a/nbactions-DalleWalle.xml
+++ b/nbactions-DalleWalle.xml
@@ -7,7 +7,7 @@
process-classes
- org.codehaus.mojo:exec-maven-plugin:3.5.0:exec
+ org.codehaus.mojo:exec-maven-plugin:3.6.2:exec
-Dprism.maxvram=2G
@@ -24,7 +24,7 @@
process-classes
- org.codehaus.mojo:exec-maven-plugin:3.5.0:exec
+ org.codehaus.mojo:exec-maven-plugin:3.6.2:exec
-Dprism.maxvram=2G -agentlib:jdwp=transport=dt_socket,server=n,address=${jpda.address}
@@ -43,7 +43,7 @@
process-classes
- org.codehaus.mojo:exec-maven-plugin:3.5.0:exec
+ org.codehaus.mojo:exec-maven-plugin:3.6.2:exec
-Dprism.maxvram=2G
diff --git a/nbactions-OutRun.xml b/nbactions-OutRun.xml
index 0a6e575d..4048f61d 100644
--- a/nbactions-OutRun.xml
+++ b/nbactions-OutRun.xml
@@ -7,7 +7,7 @@
process-classes
- org.codehaus.mojo:exec-maven-plugin:3.5.0:exec
+ org.codehaus.mojo:exec-maven-plugin:3.6.2:exec
-Dprism.maxvram=2G
@@ -25,7 +25,7 @@
process-classes
- org.codehaus.mojo:exec-maven-plugin:3.5.0:exec
+ org.codehaus.mojo:exec-maven-plugin:3.6.2:exec
-Dprism.maxvram=2G -agentlib:jdwp=transport=dt_socket,server=n,address=${jpda.address}
@@ -44,7 +44,7 @@
process-classes
- org.codehaus.mojo:exec-maven-plugin:3.5.0:exec
+ org.codehaus.mojo:exec-maven-plugin:3.6.2:exec
-Dprism.maxvram=2G
diff --git a/nbactions-Synthwav.xml b/nbactions-Synthwav.xml
index cff04e59..965cd268 100644
--- a/nbactions-Synthwav.xml
+++ b/nbactions-Synthwav.xml
@@ -7,7 +7,7 @@
process-classes
- org.codehaus.mojo:exec-maven-plugin:3.5.0:exec
+ org.codehaus.mojo:exec-maven-plugin:3.6.2:exec
-Dprism.maxvram=2G
@@ -24,7 +24,7 @@
process-classes
- org.codehaus.mojo:exec-maven-plugin:3.5.0:exec
+ org.codehaus.mojo:exec-maven-plugin:3.6.2:exec
-Dprism.maxvram=2G -agentlib:jdwp=transport=dt_socket,server=n,address=${jpda.address}
@@ -42,7 +42,7 @@
process-classes
- org.codehaus.mojo:exec-maven-plugin:3.5.0:exec
+ org.codehaus.mojo:exec-maven-plugin:3.6.2:exec
-Dprism.maxvram=2G
diff --git a/nbactions-VRAMDebug.xml b/nbactions-VRAMDebug.xml
index b4891843..0238bd7d 100644
--- a/nbactions-VRAMDebug.xml
+++ b/nbactions-VRAMDebug.xml
@@ -7,7 +7,7 @@
process-classes
- org.codehaus.mojo:exec-maven-plugin:3.5.0:exec
+ org.codehaus.mojo:exec-maven-plugin:3.6.2:exec
-Dprism.maxvram=2G
@@ -23,7 +23,7 @@
process-classes
- org.codehaus.mojo:exec-maven-plugin:3.5.0:exec
+ org.codehaus.mojo:exec-maven-plugin:3.6.2:exec
-Dprism.maxvram=2G -Dprism.poolstats=true -agentlib:jdwp=transport=dt_socket,server=n,address=${jpda.address}
@@ -40,7 +40,7 @@
process-classes
- org.codehaus.mojo:exec-maven-plugin:3.5.0:exec
+ org.codehaus.mojo:exec-maven-plugin:3.6.2:exec
-Dprism.maxvram=2G
diff --git a/nbactions-ZeroMQ.xml b/nbactions-ZeroMQ.xml
index 586a9ff9..d3539dee 100644
--- a/nbactions-ZeroMQ.xml
+++ b/nbactions-ZeroMQ.xml
@@ -7,7 +7,7 @@
process-classes
- org.codehaus.mojo:exec-maven-plugin:3.5.0:exec
+ org.codehaus.mojo:exec-maven-plugin:3.6.2:exec
-Dprism.maxvram=2G
@@ -24,7 +24,7 @@
process-classes
- org.codehaus.mojo:exec-maven-plugin:3.5.0:exec
+ org.codehaus.mojo:exec-maven-plugin:3.6.2:exec
-Dprism.maxvram=2G -agentlib:jdwp=transport=dt_socket,server=n,address=${jpda.address}
@@ -42,7 +42,7 @@
process-classes
- org.codehaus.mojo:exec-maven-plugin:3.5.0:exec
+ org.codehaus.mojo:exec-maven-plugin:3.6.2:exec
-Dprism.maxvram=2G
diff --git a/nbactions-http.xml b/nbactions-http.xml
index 76fc3a04..d55e5aaa 100644
--- a/nbactions-http.xml
+++ b/nbactions-http.xml
@@ -7,7 +7,7 @@
process-classes
- org.codehaus.mojo:exec-maven-plugin:3.5.0:exec
+ org.codehaus.mojo:exec-maven-plugin:3.6.2:exec
-Dprism.maxvram=2G
@@ -24,7 +24,7 @@
process-classes
- org.codehaus.mojo:exec-maven-plugin:3.5.0:exec
+ org.codehaus.mojo:exec-maven-plugin:3.6.2:exec
-Dprism.maxvram=2G -agentlib:jdwp=transport=dt_socket,server=n,address=${jpda.address}
@@ -42,7 +42,7 @@
process-classes
- org.codehaus.mojo:exec-maven-plugin:3.5.0:exec
+ org.codehaus.mojo:exec-maven-plugin:3.6.2:exec
-Dprism.maxvram=2G
diff --git a/src/main/java/edu/jhuapl/trinity/AppAsyncManager.java b/src/main/java/edu/jhuapl/trinity/AppAsyncManager.java
index f617912a..ab19bb95 100644
--- a/src/main/java/edu/jhuapl/trinity/AppAsyncManager.java
+++ b/src/main/java/edu/jhuapl/trinity/AppAsyncManager.java
@@ -228,10 +228,10 @@ protected Void call() throws Exception {
//example: 200x100+800+800
String[] tokens = geometryParamString.split("\\+");
String[] sizeTokens = tokens[0].split("x");
- ((Stage) scene.getWindow()).setWidth(Double.parseDouble(sizeTokens[0]));
- ((Stage) scene.getWindow()).setHeight(Double.parseDouble(sizeTokens[1]));
- ((Stage) scene.getWindow()).setX(Double.parseDouble(tokens[1]));
- ((Stage) scene.getWindow()).setY(Double.parseDouble(tokens[2]));
+ scene.getWindow().setWidth(Double.parseDouble(sizeTokens[0]));
+ scene.getWindow().setHeight(Double.parseDouble(sizeTokens[1]));
+ scene.getWindow().setX(Double.parseDouble(tokens[1]));
+ scene.getWindow().setY(Double.parseDouble(tokens[2]));
});
} catch (NumberFormatException ex) {
LOG.info("Exception thrown parsing: {}. Setting to Maximized.", geometryParamString);
@@ -764,7 +764,7 @@ protected Void call() throws Exception {
if (null != e.object)
visible = (boolean) e.object;
projectorPane.setVisible(visible);
- if (visible && projectorPane.firstTime == true) {
+ if (visible && projectorPane.firstTime) {
projectorPane.firstTime = false;
projectorPane.scanAndAnimate();
}
diff --git a/src/main/java/edu/jhuapl/trinity/data/FilterSet.java b/src/main/java/edu/jhuapl/trinity/data/FilterSet.java
index c575884a..c5d4b04b 100644
--- a/src/main/java/edu/jhuapl/trinity/data/FilterSet.java
+++ b/src/main/java/edu/jhuapl/trinity/data/FilterSet.java
@@ -9,7 +9,6 @@ public enum Inclusion {
INNER, OUTER, BOUNDARIES
}
- ;
public Inclusion inclusion;
public Number minimum = -1;
public Number maximum = 1;
diff --git a/src/main/java/edu/jhuapl/trinity/data/audio/EndianDataInputStream.java b/src/main/java/edu/jhuapl/trinity/data/audio/EndianDataInputStream.java
index 19ba9d9b..501808a9 100644
--- a/src/main/java/edu/jhuapl/trinity/data/audio/EndianDataInputStream.java
+++ b/src/main/java/edu/jhuapl/trinity/data/audio/EndianDataInputStream.java
@@ -2,6 +2,7 @@
import java.io.DataInputStream;
import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
public class EndianDataInputStream extends DataInputStream {
public EndianDataInputStream(InputStream in) {
@@ -11,7 +12,7 @@ public EndianDataInputStream(InputStream in) {
public String read4ByteString() throws Exception {
byte[] bytes = new byte[4];
readFully(bytes);
- return new String(bytes, "US-ASCII");
+ return new String(bytes, StandardCharsets.US_ASCII);
}
public short readShortLittleEndian() throws Exception {
diff --git a/src/main/java/edu/jhuapl/trinity/data/audio/FourierTransform.java b/src/main/java/edu/jhuapl/trinity/data/audio/FourierTransform.java
index 1f93004e..f0e79e9b 100644
--- a/src/main/java/edu/jhuapl/trinity/data/audio/FourierTransform.java
+++ b/src/main/java/edu/jhuapl/trinity/data/audio/FourierTransform.java
@@ -193,7 +193,7 @@ protected void fillSpectrum() {
}
if (whichAverage == LINAVG) {
- int avgWidth = (int) spectrum.length / averages.length;
+ int avgWidth = spectrum.length / averages.length;
for (int i = 0; i < averages.length; i++) {
float avg = 0;
int j;
@@ -419,7 +419,7 @@ public float indexToFreq(int i) {
public float getAverageCenterFrequency(int i) {
if (whichAverage == LINAVG) {
// an average represents a certain number of bands in the spectrum
- int avgWidth = (int) spectrum.length / averages.length;
+ int avgWidth = spectrum.length / averages.length;
// the "center" bin of the average, this is fudgy.
int centerBinIndex = i * avgWidth + avgWidth / 2;
return indexToFreq(centerBinIndex);
diff --git a/src/main/java/edu/jhuapl/trinity/data/messages/llm/Prompts.java b/src/main/java/edu/jhuapl/trinity/data/messages/llm/Prompts.java
index 342d8cd3..6ef4021f 100644
--- a/src/main/java/edu/jhuapl/trinity/data/messages/llm/Prompts.java
+++ b/src/main/java/edu/jhuapl/trinity/data/messages/llm/Prompts.java
@@ -88,7 +88,7 @@ public static String loadAutochooseCaptionPrompt() throws IOException {
}
public static String insertAutochooseChoices(String captionPrompt, List choices) {
- StringBuilder choicesCSV = new StringBuilder("");
+ StringBuilder choicesCSV = new StringBuilder();
for (int i = 0; i < choices.size(); i++) {
choicesCSV.append(choices.get(i));
if (i < choices.size() - 1)
diff --git a/src/main/java/edu/jhuapl/trinity/data/messages/xai/GaussianMixture.java b/src/main/java/edu/jhuapl/trinity/data/messages/xai/GaussianMixture.java
index 4084cfc0..982f9677 100644
--- a/src/main/java/edu/jhuapl/trinity/data/messages/xai/GaussianMixture.java
+++ b/src/main/java/edu/jhuapl/trinity/data/messages/xai/GaussianMixture.java
@@ -17,7 +17,6 @@ public static enum COVARIANCE_MODE {
DIAGONAL, FULL
}
- ;
public static final String TYPESTRING = "gaussian_mixture";
//
/*
diff --git a/src/main/java/edu/jhuapl/trinity/data/messages/xai/UmapConfig.java b/src/main/java/edu/jhuapl/trinity/data/messages/xai/UmapConfig.java
index 4a19ab4f..6a17cbc5 100644
--- a/src/main/java/edu/jhuapl/trinity/data/messages/xai/UmapConfig.java
+++ b/src/main/java/edu/jhuapl/trinity/data/messages/xai/UmapConfig.java
@@ -72,7 +72,7 @@ public static String configToFilename(UmapConfig uc) {
NumberFormat format = new DecimalFormat("0.00");
StringBuilder sb = new StringBuilder("UmapConfig-");
// sb.append(targetWeightSlider.getValue()).append("-");
- sb.append((String) uc.getMetric()).append("-");
+ sb.append(uc.getMetric()).append("-");
sb.append("R").append(format.format(uc.getRepulsionStrength())).append("-");
sb.append("MD").append(format.format(uc.getMinDist())).append("-");
sb.append("S").append(format.format(uc.getSpread())).append("-");
diff --git a/src/main/java/edu/jhuapl/trinity/javafx/components/ExportMicroToolbar.java b/src/main/java/edu/jhuapl/trinity/javafx/components/ExportMicroToolbar.java
index cb62f47f..71681ed9 100644
--- a/src/main/java/edu/jhuapl/trinity/javafx/components/ExportMicroToolbar.java
+++ b/src/main/java/edu/jhuapl/trinity/javafx/components/ExportMicroToolbar.java
@@ -15,9 +15,9 @@
import javafx.geometry.Bounds;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
-import javafx.scene.Scene;
import javafx.scene.Node;
import javafx.scene.Parent;
+import javafx.scene.Scene;
import javafx.scene.SnapshotParameters;
import javafx.scene.control.CheckMenuItem;
import javafx.scene.control.ContentDisplay;
@@ -500,7 +500,7 @@ private WritableImage snapshot(Node target, int scale, boolean transparent) {
} else if (target.getParent() != null) {
target.getParent().applyCss();
if (target.getParent() instanceof Parent) {
- ((Parent) target.getParent()).layout();
+ target.getParent().layout();
}
}
diff --git a/src/main/java/edu/jhuapl/trinity/javafx/components/LockState.java b/src/main/java/edu/jhuapl/trinity/javafx/components/LockState.java
index 47a2c9c4..b26ae3c5 100644
--- a/src/main/java/edu/jhuapl/trinity/javafx/components/LockState.java
+++ b/src/main/java/edu/jhuapl/trinity/javafx/components/LockState.java
@@ -17,5 +17,5 @@
package edu.jhuapl.trinity.javafx.components;
public enum LockState {
- UNLOCKED, X_LOCKED, Y_LOCKED;
+ UNLOCKED, X_LOCKED, Y_LOCKED
}
diff --git a/src/main/java/edu/jhuapl/trinity/javafx/components/MatrixHeatmapView.java b/src/main/java/edu/jhuapl/trinity/javafx/components/MatrixHeatmapView.java
index cff4f686..17cebca1 100644
--- a/src/main/java/edu/jhuapl/trinity/javafx/components/MatrixHeatmapView.java
+++ b/src/main/java/edu/jhuapl/trinity/javafx/components/MatrixHeatmapView.java
@@ -55,16 +55,7 @@ public enum PaletteKind {
/**
* Simple click payload.
*/
- public static final class MatrixClick {
- public final int row;
- public final int col;
- public final double value;
-
- public MatrixClick(int row, int col, double value) {
- this.row = row;
- this.col = col;
- this.value = value;
- }
+ public record MatrixClick(int row, int col, double value) {
}
// -------------------- State --------------------
diff --git a/src/main/java/edu/jhuapl/trinity/javafx/components/PairwiseJpdfView.java b/src/main/java/edu/jhuapl/trinity/javafx/components/PairwiseJpdfView.java
index 25bd6fed..415c6fa8 100644
--- a/src/main/java/edu/jhuapl/trinity/javafx/components/PairwiseJpdfView.java
+++ b/src/main/java/edu/jhuapl/trinity/javafx/components/PairwiseJpdfView.java
@@ -148,10 +148,10 @@ public PairwiseJpdfView(JpdfBatchEngine engine, DensityCache cache, PairwiseJpdf
try {
FileChooser fc = new FileChooser();
fc.getExtensionFilters().add(new FileChooser.ExtensionFilter("PNG Image", "*.png"));
- fc.setInitialFileName(safeFilename(req.item.xLabel + "_" + req.item.yLabel) + ".png");
+ fc.setInitialFileName(safeFilename(req.item().xLabel + "_" + req.item().yLabel) + ".png");
File f = fc.showSaveDialog(getScene() != null ? getScene().getWindow() : null);
if (f == null) return;
- WritableImage img = req.image;
+ WritableImage img = req.image();
ImageIO.write(SwingFXUtils.fromFXImage(img, null), "png", f);
toast("Saved " + f.getName(), false);
} catch (Exception ex) {
@@ -413,10 +413,10 @@ private MenuButton buildAppearanceMenu() {
normalizeAllBtn.setOnAction(e -> {
PairGridPane.Range r = gridPane.computeGlobalRange();
if (r != null) {
- vminField.setText(String.format("%.6g", r.vmin));
- vmaxField.setText(String.format("%.6g", r.vmax));
+ vminField.setText(String.format("%.6g", r.vmin()));
+ vmaxField.setText(String.format("%.6g", r.vmax()));
rangeFixedBtn.setSelected(true);
- gridPane.setRangeModeFixed(r.vmin, r.vmax);
+ gridPane.setRangeModeFixed(r.vmin(), r.vmax());
}
});
@@ -491,20 +491,20 @@ public void runWithRecipe(JpdfRecipe recipe) {
final boolean doIncrementalSort = incrementalSortCheck.isSelected();
final java.util.function.Consumer onResult = job -> {
- if (job == null || job.density == null) return;
+ if (job == null || job.density() == null) return;
- String xLbl = (job.i >= 0) ? ("Comp " + job.i) : "X";
- String yLbl = (job.j >= 0) ? ("Comp " + job.j) : "Y";
+ String xLbl = (job.i() >= 0) ? ("Comp " + job.i()) : "X";
+ String yLbl = (job.j() >= 0) ? ("Comp " + job.j()) : "Y";
PairGridPane.PairItem.Builder b = PairGridPane.PairItem
.newBuilder(xLbl, yLbl)
- .indices(job.i >= 0 ? job.i : null, job.j >= 0 ? job.j : null)
- .from(job.density, false, true)
+ .indices(job.i() >= 0 ? job.i() : null, job.j() >= 0 ? job.j() : null)
+ .from(job.density(), false, true)
.palette(HeatmapThumbnailView.PaletteKind.SEQUENTIAL)
.autoRange(true)
.showLegend(false);
- if (job.rank != null) b.score(job.rank.score);
+ if (job.rank() != null) b.score(job.rank().score());
PairGridPane.PairItem item = b.build();
gridPane.addItemStreaming(item, flushN, flushMs, doIncrementalSort);
@@ -529,7 +529,7 @@ protected Void call() {
}
} catch (Throwable t) {
final String msg = "Batch failed: " + t.getClass().getSimpleName()
- + " - " + String.valueOf(t.getMessage());
+ + " - " + t.getMessage();
Platform.runLater(() -> {
setControlsDisabled(false);
setProgressText("");
@@ -544,11 +544,11 @@ protected Void call() {
Platform.runLater(() -> {
gridPane.sortByScoreDescending();
- int total = Math.max(finalBatch.submittedPairs, finalCompleted);
+ int total = Math.max(finalBatch.submittedPairs(), finalCompleted);
setProgressText("Loaded " + finalCompleted + " / " + total);
setControlsDisabled(false);
toast("Batch complete: " + finalCompleted
- + " surfaces; cacheHits=" + finalBatch.cacheHits
+ + " surfaces; cacheHits=" + finalBatch.cacheHits()
+ "; wall=" + wall + " ms.", false);
});
return null;
diff --git a/src/main/java/edu/jhuapl/trinity/javafx/components/PairwiseMatrixView.java b/src/main/java/edu/jhuapl/trinity/javafx/components/PairwiseMatrixView.java
index edc15a91..02f3307f 100644
--- a/src/main/java/edu/jhuapl/trinity/javafx/components/PairwiseMatrixView.java
+++ b/src/main/java/edu/jhuapl/trinity/javafx/components/PairwiseMatrixView.java
@@ -132,17 +132,17 @@ public PairwiseMatrixView(PairwiseMatrixConfigPanel configPanel, DensityCache ca
toast("Cohort A is empty and no synthetic cohorts were provided.", true);
return;
}
- renderPdfForCellUsingEngine(click.row, click.col, effective);
+ renderPdfForCellUsingEngine(click.row(), click.col(), effective);
} else {
if (cohortA == null || cohortA.isEmpty() || cohortB == null || cohortB.isEmpty()) {
toast("Cohorts A/B are empty and no synthetic cohorts were provided.", true);
return;
}
- renderDeltaPdfForCellUsingEngine(click.row, click.col, effective);
+ renderDeltaPdfForCellUsingEngine(click.row(), click.col(), effective);
}
}
} catch (Throwable t) {
- toast("Cell render failed: " + t.getClass().getSimpleName() + ": " + String.valueOf(t.getMessage()), true);
+ toast("Cell render failed: " + t.getClass().getSimpleName() + ": " + t.getMessage(), true);
}
// still notify any external listener you set via setOnCellClick(...)
@@ -371,7 +371,7 @@ cohortA, cohortB, recipe, nonNull(req.divergenceMetric, DivergenceMetric.JS), ca
Platform.runLater(() -> {
setControlsDisabled(false);
setProgressText("");
- toast("Matrix run failed: " + t.getClass().getSimpleName() + " - " + String.valueOf(t.getMessage()), true);
+ toast("Matrix run failed: " + t.getClass().getSimpleName() + " - " + t.getMessage(), true);
});
}
}, "PairwiseMatrixView-Worker").start();
@@ -412,13 +412,13 @@ public void renderPdfForCellUsingEngine(int i, int j, Request req) {
policy,
useCache,
(pair) -> {
- GridDensityResult gdr = pair.density;
+ GridDensityResult gdr = pair.density();
List> zGrid = gdr.pdfAsListGrid();
getScene().getRoot().fireEvent(new HypersurfaceGridEvent(
HypersurfaceGridEvent.RENDER_PDF,
zGrid,
- gdr.getxCenters(),
- gdr.getyCenters(),
+ gdr.xCenters(),
+ gdr.yCenters(),
"Comp " + Math.min(i, j) + " | Comp " + Math.max(i, j) + " (PDF)"
));
}
@@ -459,18 +459,18 @@ private void renderDeltaPdfForCellUsingEngine(int i, int j, Request req) {
JpdfBatchEngine.BatchResult batchB =
JpdfBatchEngine.runWhitelistPairs(cohortB, recipe, policy, useCache);
- if (batchA.jobs.isEmpty() || batchB.jobs.isEmpty()
- || batchA.jobs.get(0).density == null || batchB.jobs.get(0).density == null) {
+ if (batchA.jobs().isEmpty() || batchB.jobs().isEmpty()
+ || batchA.jobs().get(0).density() == null || batchB.jobs().get(0).density() == null) {
toast("Could not compute ΔPDF for (" + i + "," + j + ").", true);
return;
}
- GridDensityResult a = batchA.jobs.get(0).density;
- GridDensityResult b = batchB.jobs.get(0).density;
+ GridDensityResult a = batchA.jobs().get(0).density();
+ GridDensityResult b = batchB.jobs().get(0).density();
// (4) Align grids if necessary; then out = A.pdf - B.pdf
- double[] ax = a.getxCenters(), ay = a.getyCenters();
- double[] bx = b.getxCenters(), by = b.getyCenters();
+ double[] ax = a.xCenters(), ay = a.yCenters();
+ double[] bx = b.xCenters(), by = b.yCenters();
List> out;
if (sameCenters(ax, bx) && sameCenters(ay, by)) {
@@ -573,7 +573,7 @@ private MenuButton buildActionsMenu() {
dlg.showAndWait().ifPresent(res -> {
switch (res.kind()) {
case SIMILARITY_MATRIX, DIVERGENCE_MATRIX -> loadSyntheticMatrix(res.matrix());
- case COHORTS -> setCohorts(res.cohorts().cohortA, "A", res.cohorts().cohortB, "B");
+ case COHORTS -> setCohorts(res.cohorts().cohortA(), "A", res.cohorts().cohortB(), "B");
}
});
});
@@ -655,36 +655,36 @@ private void triggerGraphBuild(MatrixToGraphAdapter.MatrixKind kind) {
* Load a synthetic matrix (similarity or divergence) into the heatmap and stash fallback cohorts if provided.
*/
public void loadSyntheticMatrix(SyntheticMatrix sm) {
- if (sm == null || sm.matrix == null || sm.matrix.length == 0) {
+ if (sm == null || sm.matrix() == null || sm.matrix().length == 0) {
toast("Synthetic matrix is empty.", true);
heatmap.setMatrix((double[][]) null);
return;
}
// Map factory kind to adapter kind
- this.currentMatrixKind = (sm.kind == MatrixToGraphAdapter.MatrixKind.DIVERGENCE)
+ this.currentMatrixKind = (sm.kind() == MatrixToGraphAdapter.MatrixKind.DIVERGENCE)
? MatrixToGraphAdapter.MatrixKind.DIVERGENCE
: MatrixToGraphAdapter.MatrixKind.SIMILARITY;
// Render the matrix
- heatmap.setMatrix(sm.matrix);
- if (sm.labels != null && !sm.labels.isEmpty()) {
- heatmap.setRowLabels(sm.labels);
- heatmap.setColLabels(sm.labels);
+ heatmap.setMatrix(sm.matrix());
+ if (sm.labels() != null && !sm.labels().isEmpty()) {
+ heatmap.setRowLabels(sm.labels());
+ heatmap.setColLabels(sm.labels());
} else {
// fallback label set
- List labels = new java.util.ArrayList<>(sm.matrix.length);
- for (int i = 0; i < sm.matrix.length; i++) labels.add("F" + i);
+ List labels = new java.util.ArrayList<>(sm.matrix().length);
+ for (int i = 0; i < sm.matrix().length; i++) labels.add("F" + i);
heatmap.setRowLabels(labels);
heatmap.setColLabels(labels);
}
// Palette + range defaults based on kind
- applyHeatmapDefaultsFor(this.currentMatrixKind, sm.matrix);
+ applyHeatmapDefaultsFor(this.currentMatrixKind, sm.matrix());
// Stash possible underlying vectors as *fallback* cohorts
- this.fallbackCohortA = sm.cohortA != null ? new ArrayList<>(sm.cohortA) : null;
- this.fallbackCohortB = sm.cohortB != null ? new ArrayList<>(sm.cohortB) : null;
+ this.fallbackCohortA = sm.cohortA() != null ? new ArrayList<>(sm.cohortA()) : null;
+ this.fallbackCohortB = sm.cohortB() != null ? new ArrayList<>(sm.cohortB()) : null;
// If user hasn't loaded cohorts yet, adopt the fallbacks now (keeps UX simple)
if ((cohortA == null || cohortA.isEmpty()) && fallbackCohortA != null) {
@@ -694,8 +694,8 @@ public void loadSyntheticMatrix(SyntheticMatrix sm) {
setCohortB(fallbackCohortB, "B");
}
- String title = (sm.title != null && !sm.title.isBlank()) ? sm.title : "Synthetic";
- toast(title + " — N=" + sm.matrix.length + " loaded.", false);
+ String title = (sm.title() != null && !sm.title().isBlank()) ? sm.title() : "Synthetic";
+ toast(title + " — N=" + sm.matrix().length + " loaded.", false);
}
/**
diff --git a/src/main/java/edu/jhuapl/trinity/javafx/components/dialogs/SyntheticDataDialog.java b/src/main/java/edu/jhuapl/trinity/javafx/components/dialogs/SyntheticDataDialog.java
index f4d5316d..9677e97e 100644
--- a/src/main/java/edu/jhuapl/trinity/javafx/components/dialogs/SyntheticDataDialog.java
+++ b/src/main/java/edu/jhuapl/trinity/javafx/components/dialogs/SyntheticDataDialog.java
@@ -225,7 +225,7 @@ public SyntheticDataDialog() {
};
} catch (Throwable t) {
Alert a = new Alert(Alert.AlertType.ERROR,
- "Build failed: " + t.getClass().getSimpleName() + " – " + String.valueOf(t.getMessage()),
+ "Build failed: " + t.getClass().getSimpleName() + " – " + t.getMessage(),
ButtonType.OK);
a.showAndWait();
return null;
@@ -320,7 +320,7 @@ private Result buildSimilarity() {
if (simAttachCohorts.isSelected()) {
int N = ival(simCohN, 400);
- int D = sm.matrix.length; // match feature dimension to matrix size
+ int D = sm.matrix().length; // match feature dimension to matrix size
double mu = dval(simCohMu, 0.0);
double sigma = dval(simCohSigma, 1.0);
double min = dval(simCohMin, -2.0);
@@ -329,7 +329,7 @@ private Result buildSimilarity() {
long seedB = lval(simCohSeedB, 101L);
Cohorts c = SyntheticMatrixFactory.makeCohorts_GaussianVsUniform(N, D, mu, sigma, min, max, seedA, seedB);
- sm = sm.withCohorts(c.cohortA, c.cohortB).withTitle(" + Cohorts(Gauss μ=" + mu + ",σ=" + sigma + " vs Uniform[" + min + "," + max + "], N=" + N + ")");
+ sm = sm.withCohorts(c.cohortA(), c.cohortB()).withTitle(" + Cohorts(Gauss μ=" + mu + ",σ=" + sigma + " vs Uniform[" + min + "," + max + "], N=" + N + ")");
}
return Result.similarity(sm);
@@ -397,7 +397,7 @@ private Result buildDivergence() {
long seedB = lval(divCohSeedB, 101L);
Cohorts c = SyntheticMatrixFactory.makeCohorts_GaussianVsUniform(N, D, mu, sigma, min, max, seedA, seedB);
- sm = sm.withCohorts(c.cohortA, c.cohortB).withTitle(" + Cohorts(Gauss μ=" + mu + ",σ=" + sigma + " vs Uniform[" + min + "," + max + "], N=" + N + ", D=" + D + ")");
+ sm = sm.withCohorts(c.cohortA(), c.cohortB()).withTitle(" + Cohorts(Gauss μ=" + mu + ",σ=" + sigma + " vs Uniform[" + min + "," + max + "], N=" + N + ", D=" + D + ")");
}
return Result.divergence(sm);
diff --git a/src/main/java/edu/jhuapl/trinity/javafx/components/hyperdrive/BatchRequestManager.java b/src/main/java/edu/jhuapl/trinity/javafx/components/hyperdrive/BatchRequestManager.java
index 6abffcb6..337d3c14 100644
--- a/src/main/java/edu/jhuapl/trinity/javafx/components/hyperdrive/BatchRequestManager.java
+++ b/src/main/java/edu/jhuapl/trinity/javafx/components/hyperdrive/BatchRequestManager.java
@@ -56,17 +56,17 @@ public class BatchRequestManager {
public interface BatchResult {
- int getBatchNumber();
+ int batchNumber();
- int getRequestId();
+ int requestId();
- T getBatch();
+ T batch();
- Status getStatus();
+ Status status();
- int getRetryCount();
+ int retryCount();
- Exception getException();
+ Exception exception();
enum Status {
SUCCESS, FAILURE, TIMEOUT
@@ -331,51 +331,10 @@ public void setTotalBatches(int totalBatches) {
this.totalBatches = totalBatches;
}
- private static class BatchResultImpl implements BatchResult {
-
- private final int requestId;
- private final int batchNumber;
- private final T batch;
- private final Status status;
- private final int retryCount;
- private final Exception ex;
-
- BatchResultImpl(int requestId, int batchNumber, T batch, Status status, int retryCount, Exception ex) {
- this.requestId = requestId;
- this.batchNumber = batchNumber;
- this.batch = batch;
- this.status = status;
- this.retryCount = retryCount;
- this.ex = ex;
- }
-
- @Override
- public int getRequestId() {
- return requestId;
- }
-
- @Override
- public int getBatchNumber() {
- return batchNumber;
- }
-
- @Override
- public T getBatch() {
- return batch;
- }
-
- @Override
- public Status getStatus() {
- return status;
- }
-
- @Override
- public int getRetryCount() {
- return retryCount;
- }
-
+ private record BatchResultImpl(int requestId, int batchNumber, T batch, Status status, int retryCount, Exception ex) implements BatchResult {
+ // Java records don't like deeply mutable values like this on interfaces
@Override
- public Exception getException() {
+ public Exception exception() {
return ex;
}
}
diff --git a/src/main/java/edu/jhuapl/trinity/javafx/components/hyperdrive/LoadTextTask.java b/src/main/java/edu/jhuapl/trinity/javafx/components/hyperdrive/LoadTextTask.java
index 69289afe..eb6bb767 100644
--- a/src/main/java/edu/jhuapl/trinity/javafx/components/hyperdrive/LoadTextTask.java
+++ b/src/main/java/edu/jhuapl/trinity/javafx/components/hyperdrive/LoadTextTask.java
@@ -35,7 +35,7 @@ protected void processTask() throws Exception {
AtomicInteger atomicCount = new AtomicInteger(0);
if (null != progressIndicator) {
progressIndicator.setFadeTimeMS(250);
- progressIndicator.setLabelLater("Loading " + atomicCount.toString() + " files...");
+ progressIndicator.setLabelLater("Loading " + atomicCount + " files...");
progressIndicator.spin(true);
progressIndicator.fadeBusy(false);
}
@@ -71,7 +71,7 @@ protected void processTask() throws Exception {
}).toList();
Utils.logTotalTime(startTime);
- LOG.info("loaded {} ASCII/PDF files.", String.valueOf(textFilesList.size()));
+ LOG.info("loaded {} ASCII/PDF files.", textFilesList.size());
Platform.runLater(() -> {
scene.getRoot().fireEvent(
new HyperdriveEvent(HyperdriveEvent.NEW_BATCH_TEXTLOAD, newItems, textFilesList));
diff --git a/src/main/java/edu/jhuapl/trinity/javafx/components/panes/HyperdrivePane.java b/src/main/java/edu/jhuapl/trinity/javafx/components/panes/HyperdrivePane.java
index 51bd2d81..36dc2826 100644
--- a/src/main/java/edu/jhuapl/trinity/javafx/components/panes/HyperdrivePane.java
+++ b/src/main/java/edu/jhuapl/trinity/javafx/components/panes/HyperdrivePane.java
@@ -1170,7 +1170,7 @@ public HyperdrivePane(Scene scene, Pane parent) {
List inputFiles = (List) event.object;
int request = (int) event.object2;
outstandingRequests.put(request, REQUEST_STATUS.FAILED);
- long totalRequests = outstandingRequests.entrySet().size();
+ long totalRequests = outstandingRequests.size();
long remainingRequests = outstandingRequests.entrySet().stream()
.filter(t -> t.getValue() == REQUEST_STATUS.REQUESTED).count();
textEmbeddingRequestIndicator.setTopLabelLater("Received "
diff --git a/src/main/java/edu/jhuapl/trinity/javafx/components/panes/HypersurfaceControlsPane.java b/src/main/java/edu/jhuapl/trinity/javafx/components/panes/HypersurfaceControlsPane.java
index 60f8ccbf..9f1345a2 100644
--- a/src/main/java/edu/jhuapl/trinity/javafx/components/panes/HypersurfaceControlsPane.java
+++ b/src/main/java/edu/jhuapl/trinity/javafx/components/panes/HypersurfaceControlsPane.java
@@ -94,25 +94,25 @@ public HypersurfaceControlsPane(Scene scene, Pane parent, Hypersurface3DPane tar
// --- GUI sync from model → controls
scene.addEventHandler(HypersurfaceEvent.SET_XWIDTH_GUI, e -> {
- if (xWidthSpinner != null && !xWidthSpinner.getValue().equals((Integer) e.object)) {
+ if (xWidthSpinner != null && !xWidthSpinner.getValue().equals(e.object)) {
xWidthSpinner.getValueFactory().setValue((Integer) e.object);
}
e.consume();
});
scene.addEventHandler(HypersurfaceEvent.SET_ZWIDTH_GUI, e -> {
- if (zWidthSpinner != null && !zWidthSpinner.getValue().equals((Integer) e.object)) {
+ if (zWidthSpinner != null && !zWidthSpinner.getValue().equals(e.object)) {
zWidthSpinner.getValueFactory().setValue((Integer) e.object);
}
e.consume();
});
scene.addEventHandler(HypersurfaceEvent.SET_YSCALE_GUI, e -> {
- if (yScaleSpinner != null && !yScaleSpinner.getValue().equals((Double) e.object)) {
+ if (yScaleSpinner != null && !yScaleSpinner.getValue().equals(e.object)) {
yScaleSpinner.getValueFactory().setValue((Double) e.object);
}
e.consume();
});
scene.addEventHandler(HypersurfaceEvent.SET_SURFSCALE_GUI, e -> {
- if (surfScaleSpinner != null && !surfScaleSpinner.getValue().equals((Double) e.object)) {
+ if (surfScaleSpinner != null && !surfScaleSpinner.getValue().equals(e.object)) {
surfScaleSpinner.getValueFactory().setValue((Double) e.object);
}
e.consume();
diff --git a/src/main/java/edu/jhuapl/trinity/javafx/components/panes/PairwiseJpdfPane.java b/src/main/java/edu/jhuapl/trinity/javafx/components/panes/PairwiseJpdfPane.java
index be629b77..1bd7ac8c 100644
--- a/src/main/java/edu/jhuapl/trinity/javafx/components/panes/PairwiseJpdfPane.java
+++ b/src/main/java/edu/jhuapl/trinity/javafx/components/panes/PairwiseJpdfPane.java
@@ -55,8 +55,8 @@ public PairwiseJpdfPane(
scene.getRoot().fireEvent(new HypersurfaceGridEvent(
HypersurfaceGridEvent.RENDER_PDF,
gridList,
- res.getxCenters(),
- res.getyCenters(),
+ res.xCenters(),
+ res.yCenters(),
item.xLabel + " | " + item.yLabel + " (PDF)"
));
view.toast("Opened PDF in 3D.", false);
diff --git a/src/main/java/edu/jhuapl/trinity/javafx/components/panes/PairwiseMatrixPane.java b/src/main/java/edu/jhuapl/trinity/javafx/components/panes/PairwiseMatrixPane.java
index 243e483a..c32c0729 100644
--- a/src/main/java/edu/jhuapl/trinity/javafx/components/panes/PairwiseMatrixPane.java
+++ b/src/main/java/edu/jhuapl/trinity/javafx/components/panes/PairwiseMatrixPane.java
@@ -62,8 +62,8 @@ public PairwiseMatrixPane(
if (click == null) return;
// Use the latest request the user executed (or rebuild one)
var req = view.getLastRequestOrBuild();
- view.renderPdfForCellUsingEngine(click.row, click.col, req);
- String msg = "Cell (" + click.row + "," + click.col + ") = " + click.value;
+ view.renderPdfForCellUsingEngine(click.row(), click.col(), req);
+ String msg = "Cell (" + click.row() + "," + click.col() + ") = " + click.value();
toast(msg, false);
});
// Forward view toasts to the command terminal
diff --git a/src/main/java/edu/jhuapl/trinity/javafx/components/panes/StatPdfCdfPane.java b/src/main/java/edu/jhuapl/trinity/javafx/components/panes/StatPdfCdfPane.java
index 78034651..e56fd8ad 100644
--- a/src/main/java/edu/jhuapl/trinity/javafx/components/panes/StatPdfCdfPane.java
+++ b/src/main/java/edu/jhuapl/trinity/javafx/components/panes/StatPdfCdfPane.java
@@ -107,8 +107,8 @@ private void onComputeSurface(GridDensityResult result) {
? edu.jhuapl.trinity.javafx.events.HypersurfaceGridEvent.RENDER_CDF
: edu.jhuapl.trinity.javafx.events.HypersurfaceGridEvent.RENDER_PDF,
grid,
- result.getxCenters(),
- result.getyCenters(),
+ result.xCenters(),
+ result.yCenters(),
label
)
);
diff --git a/src/main/java/edu/jhuapl/trinity/javafx/components/panes/WaveformCanvasOverlayPane.java b/src/main/java/edu/jhuapl/trinity/javafx/components/panes/WaveformCanvasOverlayPane.java
index 41bb9ae7..b7598d4d 100644
--- a/src/main/java/edu/jhuapl/trinity/javafx/components/panes/WaveformCanvasOverlayPane.java
+++ b/src/main/java/edu/jhuapl/trinity/javafx/components/panes/WaveformCanvasOverlayPane.java
@@ -323,7 +323,7 @@ protected Task createTask() {
protected Boolean call() {
try {
if (audioFile != null) {
- LOG.info("Attempting to load {}", audioFile.toURI().toString());
+ LOG.info("Attempting to load {}", audioFile.toURI());
Media m = new Media(audioFile.toURI().toString());
setMedia(m);
//@DEBUG SMP System.out.println("Setting up media player...");
@@ -352,7 +352,7 @@ protected Boolean call() {
/**
* Calculate and initialize {@link WaveformVisualizationService#audioAmplitudes} and
- * {@link WaveformVisualization#waveformData}
+ * {@link WaveformVisualizationService#waveformData}
* @throws IOException if encountered IO error
* @throws UnsupportedAudioFileException if encountered invalid audio file
*/
@@ -431,7 +431,7 @@ private void calcAudioAmplitudes() throws Exception, IOException, UnsupportedAud
}
/**
- * Calculate and initialize {@link WaveformVisualization#waveformData}
+ * Calculate and initialize {@link WaveformVisualizationService#waveformData}
*/
public void processAudioAmplitudes() {
// The width of the resulting waveform panel
diff --git a/src/main/java/edu/jhuapl/trinity/javafx/components/radial/RadialEntity.java b/src/main/java/edu/jhuapl/trinity/javafx/components/radial/RadialEntity.java
index ae50027f..491f735e 100644
--- a/src/main/java/edu/jhuapl/trinity/javafx/components/radial/RadialEntity.java
+++ b/src/main/java/edu/jhuapl/trinity/javafx/components/radial/RadialEntity.java
@@ -301,8 +301,7 @@ private void handleRadialEntityEvent(RadialEntityEvent event) {
subItems.forEach(item -> {
item.getItems().forEach((t) -> {
Node node = t.getGraphic();
- if (node instanceof ImageView) {
- ImageView iv = (ImageView) node;
+ if (node instanceof ImageView iv) {
iv.setFitWidth(event.newValue);
}
});
@@ -409,8 +408,7 @@ public void resizeItemsToFit() {
double pixelsPerItem = (getRadius() * scaling) / items.size();
items.stream().forEach(item -> {
Node node = item.getGraphic();
- if (node instanceof ImageView) {
- ImageView iv = (ImageView) node;
+ if (node instanceof ImageView iv) {
iv.setPreserveRatio(true);
iv.setFitWidth(pixelsPerItem);
}
@@ -419,8 +417,7 @@ public void resizeItemsToFit() {
public void setCenterFitWidth(double fitWidth) {
Node centerNode = getCenterGraphic();
- if (centerNode instanceof ImageView) {
- ImageView civ = (ImageView) centerNode;
+ if (centerNode instanceof ImageView civ) {
civ.setFitWidth(fitWidth);
civ.setTranslateX(-fitWidth / 2.0);
civ.setTranslateY(-fitWidth / 2.0);
diff --git a/src/main/java/edu/jhuapl/trinity/javafx/components/timeline/MissionTimerX.java b/src/main/java/edu/jhuapl/trinity/javafx/components/timeline/MissionTimerX.java
index a615a544..fd5cdc34 100644
--- a/src/main/java/edu/jhuapl/trinity/javafx/components/timeline/MissionTimerX.java
+++ b/src/main/java/edu/jhuapl/trinity/javafx/components/timeline/MissionTimerX.java
@@ -78,8 +78,8 @@ public class MissionTimerX extends Region {
private double outerCircleDiameterAspect = 1.84; //this.outerCircleDiameter = 1.84 * width;
private double middleCircleDiameterAspect = 1.75; //this.middleCircleDiameter = 1.75 * width;
private double innerCircleDiameterAspect = 1.66; //this.innerCircleDiameter = 1.66 * width;
- private static final long REALTIME_REDRAW = 1_000_000l;
- private static final long REALTIME_TIMER = 1_000_000_000l;
+ private static final long REALTIME_REDRAW = 1_000_000L;
+ private static final long REALTIME_TIMER = 1_000_000_000L;
public int timeDialator = 2; //@TODO SMP... I am not sure yet why I need this hack
private LocalDateTime currentPropagationTime;
private String stringCurrentPropRate;
@@ -216,9 +216,9 @@ public void handle(final long now) {
lastRedrawCall = now;
}
if (now > lastTimerCall + timerStepSize) {
- long timeSpan = Math.abs((getStartTime() + duration) < 0 ? getStartTime() + duration : (duration + getStartTime()));
+ long timeSpan = Math.abs(getStartTime() + duration);
days = (int) TimeUnit.SECONDS.toDays(timeSpan);
- hours = TimeUnit.SECONDS.toHours(timeSpan) - (days * 24);
+ hours = TimeUnit.SECONDS.toHours(timeSpan) - (days * 24L);
minutes = TimeUnit.SECONDS.toMinutes(timeSpan) - (TimeUnit.SECONDS.toHours(timeSpan) * 60);
seconds = TimeUnit.SECONDS.toSeconds(timeSpan) - (TimeUnit.SECONDS.toMinutes(timeSpan) * 60);
if (internalClock)
@@ -883,9 +883,9 @@ public void setStartTime(final long startTime) {
if (null == this.startTime) {
stop();
_startTime = startTime;
- long timeSpan = Math.abs((getStartTime() + duration) < 0 ? getStartTime() + duration : (duration + getStartTime()));
+ long timeSpan = Math.abs(getStartTime() + duration);
days = (int) TimeUnit.SECONDS.toDays(timeSpan);
- hours = TimeUnit.SECONDS.toHours(timeSpan) - (days * 24);
+ hours = TimeUnit.SECONDS.toHours(timeSpan) - (days * 24L);
minutes = TimeUnit.SECONDS.toMinutes(timeSpan) - (TimeUnit.SECONDS.toHours(timeSpan) * 60);
seconds = TimeUnit.SECONDS.toSeconds(timeSpan) - (TimeUnit.SECONDS.toMinutes(timeSpan) * 60);
redraw();
diff --git a/src/main/java/edu/jhuapl/trinity/javafx/components/timeline/MissionTimerXBuilder.java b/src/main/java/edu/jhuapl/trinity/javafx/components/timeline/MissionTimerXBuilder.java
index d73226cf..1cdbfa0b 100644
--- a/src/main/java/edu/jhuapl/trinity/javafx/components/timeline/MissionTimerXBuilder.java
+++ b/src/main/java/edu/jhuapl/trinity/javafx/components/timeline/MissionTimerXBuilder.java
@@ -259,10 +259,10 @@ public final MissionTimerX build() {
}
}
- if (properties.keySet().contains("itemArray")) {
+ if (properties.containsKey("itemArray")) {
timer.getItems().addAll(((ObjectProperty- ) properties.get("itemArray")).get());
}
- if (properties.keySet().contains("itemList")) {
+ if (properties.containsKey("itemList")) {
timer.getItems().addAll(((ObjectProperty
>) properties.get("itemList")).get());
}
diff --git a/src/main/java/edu/jhuapl/trinity/javafx/components/timeline/TimelineAnimation.java b/src/main/java/edu/jhuapl/trinity/javafx/components/timeline/TimelineAnimation.java
index 2d8cfc2b..cd8e584e 100644
--- a/src/main/java/edu/jhuapl/trinity/javafx/components/timeline/TimelineAnimation.java
+++ b/src/main/java/edu/jhuapl/trinity/javafx/components/timeline/TimelineAnimation.java
@@ -83,7 +83,7 @@ public void start() {
// RESTART THE Animation at time 0
public void restartProp() {
- stepsFromStart = (long) 0;
+ stepsFromStart = 0;
}
// INCREASE PROPAGATION RATE.
diff --git a/src/main/java/edu/jhuapl/trinity/javafx/controllers/ConfigurationController.java b/src/main/java/edu/jhuapl/trinity/javafx/controllers/ConfigurationController.java
index bc27c7e8..e2c23317 100644
--- a/src/main/java/edu/jhuapl/trinity/javafx/controllers/ConfigurationController.java
+++ b/src/main/java/edu/jhuapl/trinity/javafx/controllers/ConfigurationController.java
@@ -584,7 +584,7 @@ private void setupDataBoundsSpinners() {
point3DSizeSpinner.valueProperty().addListener(e -> {
scene.getRoot().fireEvent(
new HyperspaceEvent(HyperspaceEvent.POINT3D_SIZE_GUI,
- (Double) point3DSizeSpinner.getValue()));
+ point3DSizeSpinner.getValue()));
});
pointScaleSpinner.setValueFactory(
@@ -594,7 +594,7 @@ private void setupDataBoundsSpinners() {
pointScaleSpinner.valueProperty().addListener(e -> {
scene.getRoot().fireEvent(
new HyperspaceEvent(HyperspaceEvent.POINT_SCALE_GUI,
- (Double) pointScaleSpinner.getValue()));
+ pointScaleSpinner.getValue()));
});
scatterBuffScalingSpinner.setValueFactory(
@@ -604,7 +604,7 @@ private void setupDataBoundsSpinners() {
scatterBuffScalingSpinner.valueProperty().addListener(e -> {
scene.getRoot().fireEvent(
new HyperspaceEvent(HyperspaceEvent.SCATTERBUFF_SCALING_GUI,
- (Double) scatterBuffScalingSpinner.getValue()));
+ scatterBuffScalingSpinner.getValue()));
});
}
@@ -932,7 +932,7 @@ private void setupShadowCubeControls() {
domainMinimumSpinner.valueProperty().addListener(e -> {
scene.getRoot().fireEvent(
new ShadowEvent(ShadowEvent.SET_DOMAIN_MINIMUM,
- (double) domainMinimumSpinner.getValue()));
+ domainMinimumSpinner.getValue()));
});
domainMinimumSpinner.disableProperty().bind(
overrideDomainTransformCheckBox.selectedProperty().not());
@@ -944,7 +944,7 @@ private void setupShadowCubeControls() {
domainMaximumSpinner.valueProperty().addListener(e -> {
scene.getRoot().fireEvent(
new ShadowEvent(ShadowEvent.SET_DOMAIN_MAXIMUM,
- (double) domainMaximumSpinner.getValue()));
+ domainMaximumSpinner.getValue()));
});
domainMaximumSpinner.disableProperty().bind(
overrideDomainTransformCheckBox.selectedProperty().not());
@@ -958,7 +958,7 @@ private void setupShadowCubeControls() {
pointScalingSpinner.valueProperty().addListener(e -> {
scene.getRoot().fireEvent(
new ShadowEvent(ShadowEvent.SET_POINT_SCALING,
- (double) pointScalingSpinner.getValue()));
+ pointScalingSpinner.getValue()));
});
}
diff --git a/src/main/java/edu/jhuapl/trinity/javafx/controllers/DataController.java b/src/main/java/edu/jhuapl/trinity/javafx/controllers/DataController.java
index 30d23711..e97d8386 100644
--- a/src/main/java/edu/jhuapl/trinity/javafx/controllers/DataController.java
+++ b/src/main/java/edu/jhuapl/trinity/javafx/controllers/DataController.java
@@ -128,7 +128,7 @@ public void initialize(URL url, ResourceBundle rb) {
trajectorySizeSpinner.valueProperty().addListener(e -> {
scene.getRoot().fireEvent(
new TrajectoryEvent(TrajectoryEvent.TRAJECTORY_TAIL_SIZE,
- (int) trajectorySizeSpinner.getValue()));
+ trajectorySizeSpinner.getValue()));
});
trajectorySizeSpinner.disableProperty().bind(
showStateTrajectoryCheckBox.selectedProperty().not());
@@ -141,7 +141,7 @@ public void initialize(URL url, ResourceBundle rb) {
projectionQueueSizeSpinner.valueProperty().addListener(e -> {
scene.getRoot().fireEvent(
new ManifoldEvent(ManifoldEvent.SET_PROJECTIONQUEUE_SIZE,
- (int) projectionQueueSizeSpinner.getValue()));
+ projectionQueueSizeSpinner.getValue()));
});
restProgressIndicator.visibleProperty().bind(restInjectToggleButton.selectedProperty());
diff --git a/src/main/java/edu/jhuapl/trinity/javafx/controllers/ManifoldControlController.java b/src/main/java/edu/jhuapl/trinity/javafx/controllers/ManifoldControlController.java
index 7a3870c7..6d3d885c 100644
--- a/src/main/java/edu/jhuapl/trinity/javafx/controllers/ManifoldControlController.java
+++ b/src/main/java/edu/jhuapl/trinity/javafx/controllers/ManifoldControlController.java
@@ -400,7 +400,7 @@ private void setupHullControls() {
manualSpinner.valueProperty().addListener(e -> {
scene.getRoot().fireEvent(
new ManifoldEvent(ManifoldEvent.SET_DISTANCE_TOLERANCE,
- (Double) manualSpinner.getValue()));
+ manualSpinner.getValue()));
});
manualSpinner.disableProperty().bind(automaticCheckBox.selectedProperty());
@@ -624,7 +624,7 @@ public UmapConfig getCurrentUmapConfig() {
uc.setNumberNearestNeighbours((int) nearestNeighborsSpinner.getValue());
uc.setNegativeSampleRate((int) negativeSampleRateSpinner.getValue());
uc.setLocalConnectivity((int) localConnectivitySpinner.getValue());
- uc.setThreshold((double) thresholdSpinner.getValue());
+ uc.setThreshold(thresholdSpinner.getValue());
uc.setMetric((String) metricChoiceBox.getValue());
uc.setVerbose(verboseCheckBox.isSelected());
return uc;
@@ -722,7 +722,7 @@ public void project() {
umap.setNumberNearestNeighbours((int) nearestNeighborsSpinner.getValue());
umap.setNegativeSampleRate((int) negativeSampleRateSpinner.getValue());
umap.setLocalConnectivity((int) localConnectivitySpinner.getValue());
- umap.setThreshold((double) thresholdSpinner.getValue());
+ umap.setThreshold(thresholdSpinner.getValue());
umap.setMetric((String) metricChoiceBox.getValue());
umap.setVerbose(verboseCheckBox.isSelected());
ManifoldEvent.POINT_SOURCE pointSource = useHypersurfaceButton.isSelected() ?
@@ -740,7 +740,7 @@ public void generate() {
scene.getRoot().fireEvent(new ManifoldEvent(
ManifoldEvent.GENERATE_PROJECTION_MANIFOLD,
useVisibleRadioButton.isSelected(),
- (String) labelChoiceBox.getValue(), tolerance
+ labelChoiceBox.getValue(), tolerance
));
}
diff --git a/src/main/java/edu/jhuapl/trinity/javafx/controllers/PairwiseJpdfPanePopoutController.java b/src/main/java/edu/jhuapl/trinity/javafx/controllers/PairwiseJpdfPanePopoutController.java
index 1fae3689..4e19b10c 100644
--- a/src/main/java/edu/jhuapl/trinity/javafx/controllers/PairwiseJpdfPanePopoutController.java
+++ b/src/main/java/edu/jhuapl/trinity/javafx/controllers/PairwiseJpdfPanePopoutController.java
@@ -90,8 +90,8 @@ private void buildStageAndWire() {
appScene.getRoot().fireEvent(new HypersurfaceGridEvent(
HypersurfaceGridEvent.RENDER_PDF,
gridList,
- res.getxCenters(),
- res.getyCenters(),
+ res.xCenters(),
+ res.yCenters(),
item.xLabel + " | " + item.yLabel + " (PDF)"
));
// Optionally, show a toast:
diff --git a/src/main/java/edu/jhuapl/trinity/javafx/controllers/StatPdfCdfPopoutController.java b/src/main/java/edu/jhuapl/trinity/javafx/controllers/StatPdfCdfPopoutController.java
index d358d38c..49c7c962 100644
--- a/src/main/java/edu/jhuapl/trinity/javafx/controllers/StatPdfCdfPopoutController.java
+++ b/src/main/java/edu/jhuapl/trinity/javafx/controllers/StatPdfCdfPopoutController.java
@@ -196,8 +196,8 @@ private void forwardSurfaceToMainScene(GridDensityResult result) {
new HypersurfaceGridEvent(
useCDF ? HypersurfaceGridEvent.RENDER_CDF : HypersurfaceGridEvent.RENDER_PDF,
grid,
- result.getxCenters(),
- result.getyCenters(),
+ result.xCenters(),
+ result.yCenters(),
label
)
);
diff --git a/src/main/java/edu/jhuapl/trinity/javafx/handlers/ExpandTouchGestureHandler.java b/src/main/java/edu/jhuapl/trinity/javafx/handlers/ExpandTouchGestureHandler.java
index 62b6a248..39ebf53d 100644
--- a/src/main/java/edu/jhuapl/trinity/javafx/handlers/ExpandTouchGestureHandler.java
+++ b/src/main/java/edu/jhuapl/trinity/javafx/handlers/ExpandTouchGestureHandler.java
@@ -56,7 +56,6 @@ public void handle(long now) {
}
}
- ;
};
animationTimer.start();
}
@@ -73,7 +72,7 @@ public void handle(TouchEvent event) {
if (event.getEventType() == TouchEvent.TOUCH_MOVED) {
isDirty = true;
event.getTouchPoints().parallelStream().forEach(t -> {
- activeTouchPoints.put((Integer) t.getId(), t);
+ activeTouchPoints.put(t.getId(), t);
});
} else if (event.getEventType() == TouchEvent.TOUCH_PRESSED) {
isDirty = true;
diff --git a/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/DirectedScatterMesh.java b/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/DirectedScatterMesh.java
index a9c77a78..a06bfece 100644
--- a/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/DirectedScatterMesh.java
+++ b/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/DirectedScatterMesh.java
@@ -59,7 +59,7 @@ public class DirectedScatterMesh extends Group implements TextureMode {
private final static double DEFAULT_HEIGHT = 0.1d;
private final static int DEFAULT_LEVEL = 0;
private final static boolean DEFAULT_JOIN_SEGMENTS = true;
- private ObservableList meshes = FXCollections.observableArrayList();
+ private ObservableList meshes = FXCollections.observableArrayList();
public boolean renderOnChange = true;
public DirectedScatterMesh() {
diff --git a/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/DirectedTetrahedraMesh.java b/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/DirectedTetrahedraMesh.java
index ea2aef92..4f879e6e 100644
--- a/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/DirectedTetrahedraMesh.java
+++ b/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/DirectedTetrahedraMesh.java
@@ -377,7 +377,7 @@ public Point3D unTransform(Point3D p) {
private final HashMap map = new HashMap<>();
private int getMiddle(int v1, Point3D p1, int v2, Point3D p2) {
- String key = "" + Math.min(v1, v2) + "_" + Math.max(v1, v2);
+ String key = Math.min(v1, v2) + "_" + Math.max(v1, v2);
if (map.get(key) != null) {
return map.get(key);
}
@@ -389,7 +389,7 @@ private int getMiddle(int v1, Point3D p1, int v2, Point3D p2) {
}
private int getMiddle(int v1, Point2D p1, int v2, Point2D p2) {
- String key = "" + Math.min(v1, v2) + "_" + Math.max(v1, v2);
+ String key = Math.min(v1, v2) + "_" + Math.max(v1, v2);
if (map.get(key) != null) {
return map.get(key);
}
diff --git a/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/HyperSurfacePlotMesh.java b/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/HyperSurfacePlotMesh.java
index 258087c7..79856ea3 100644
--- a/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/HyperSurfacePlotMesh.java
+++ b/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/HyperSurfacePlotMesh.java
@@ -433,9 +433,9 @@ private TriangleMesh createSmoothMesh(Function vertFunction, int
int p00, p01, p10, p11;
// Create points
for (int z = 0; z <= divisionsZ; z++) {
- dz = (float) (((float) z / (float) divisionsZ) * rangeZ);
+ dz = ((float) z / (float) divisionsZ) * rangeZ;
for (int x = 0; x <= divisionsX; x++) {
- dx = (float) (((float) x / (float) divisionsX) * rangeX);
+ dx = ((float) x / (float) divisionsX) * rangeX;
pointY = (float) yScale * vertFunction.apply(new Vert3D(dx, dz, x, z)).floatValue();
listVertices.add(new Point3D(dx, pointY, dz));
}
diff --git a/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/Hyperspace3DPane.java b/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/Hyperspace3DPane.java
index 385de331..0ff852ae 100644
--- a/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/Hyperspace3DPane.java
+++ b/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/Hyperspace3DPane.java
@@ -1248,15 +1248,15 @@ private void updateLabels() {
if (xFactorIndex < featureLabels.size())
xLabel.setText(featureLabels.get(xFactorIndex));
else
- xLabel.setText("Factor X(" + String.valueOf(xFactorIndex) + ")");
+ xLabel.setText("Factor X(" + xFactorIndex + ")");
if (yFactorIndex < featureLabels.size())
yLabel.setText(featureLabels.get(yFactorIndex));
else
- yLabel.setText("Factor Y(" + String.valueOf(yFactorIndex) + ")");
+ yLabel.setText("Factor Y(" + yFactorIndex + ")");
if (zFactorIndex < featureLabels.size())
zLabel.setText(featureLabels.get(zFactorIndex));
else
- zLabel.setText("Factor Z(" + String.valueOf(zFactorIndex) + ")");
+ zLabel.setText("Factor Z(" + zFactorIndex + ")");
shape3DToLabel.forEach((node, label) -> {
javafx.geometry.Point3D coordinates = node.localToScene(javafx.geometry.Point3D.ZERO, true);
//@DEBUG SMP useful debugging print
diff --git a/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/Hypersurface3DPane.java b/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/Hypersurface3DPane.java
index 01992eaf..2c53526c 100644
--- a/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/Hypersurface3DPane.java
+++ b/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/Hypersurface3DPane.java
@@ -1033,7 +1033,7 @@ public void updateTheMesh() {
}
public void updatePaintMesh() {
- diffusePaintImage = new WritableImage((int) xWidth, (int) zWidth);
+ diffusePaintImage = new WritableImage(xWidth, zWidth);
if (null == paintTriangleMesh) {
paintTriangleMesh = new TriangleMesh();
paintMeshView = new MeshView(paintTriangleMesh);
@@ -1065,10 +1065,10 @@ public void updatePaintMesh() {
int numDivX = subDivX + 1;
int numVerts = (subDivZ + 1) * numDivX;
float currZ, currX;
- float texCoords[] = new float[numVerts * texCoordSize];
+ float[] texCoords = new float[numVerts * texCoordSize];
int faceCount = subDivX * subDivZ * 2;
final int faceSize = 6;
- int faces[] = new int[faceCount * faceSize];
+ int[] faces = new int[faceCount * faceSize];
int index, p00, p01, p10, p11, tc00, tc01, tc10, tc11;
for (int z = 0; z < subDivZ; z++) {
@@ -1267,8 +1267,8 @@ private Number vertToHeight(Vert3D p) {
// Convert to grid space: index + in-cell fraction.
// If p.getX()/getY() are already grid-space, this still works.
// If they are world-space, the /surfScale fixes it.
- double gx = p.xIndex + frac(p.getX() / Math.max(1.0, (double) surfScale));
- double gy = p.yIndex + frac(p.getY() / Math.max(1.0, (double) surfScale));
+ double gx = p.xIndex + frac(p.getX() / Math.max(1.0, surfScale));
+ double gy = p.yIndex + frac(p.getY() / Math.max(1.0, surfScale));
return SurfaceUtils.sample(dataGrid, gx, gy, interpMode);
}
case NEAREST:
@@ -1601,7 +1601,7 @@ private void wireEventHandlers() {
// Publish for analysis panels/plots (reuses your existing pattern)
scene.getRoot().fireEvent(new FactorAnalysisEvent(
FactorAnalysisEvent.ANALYSIS_DATA_VECTOR,
- "Graph Similarity Row (hover): " + String.valueOf(gNode),
+ "Graph Similarity Row (hover): " + gNode,
row
));
@@ -1615,7 +1615,7 @@ private void wireEventHandlers() {
Double[] row = buildSimilarityRowFromGraph(gNode);
scene.getRoot().fireEvent(new FactorAnalysisEvent(
FactorAnalysisEvent.ANALYSIS_DATA_VECTOR,
- "Graph Similarity Row (click): " + String.valueOf(gNode),
+ "Graph Similarity Row (click): " + gNode,
row
));
highlightSurfaceRowIfPossible(gNode);
diff --git a/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/Manifold3D.java b/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/Manifold3D.java
index e1b4b9af..1e85a832 100644
--- a/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/Manifold3D.java
+++ b/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/Manifold3D.java
@@ -450,7 +450,6 @@ public void handle(long now) {
}
}
- ;
};
tessellationTimer.start();
}
diff --git a/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/Projections3DPane.java b/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/Projections3DPane.java
index 95bcf43e..4599b3bc 100644
--- a/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/Projections3DPane.java
+++ b/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/Projections3DPane.java
@@ -1737,15 +1737,15 @@ private void updateFloatingNodes() {
if (xFactorIndex < featureLabels.size())
xLabel.setText(featureLabels.get(xFactorIndex));
else
- xLabel.setText("Factor X(" + String.valueOf(xFactorIndex) + ")");
+ xLabel.setText("Factor X(" + xFactorIndex + ")");
if (yFactorIndex < featureLabels.size())
yLabel.setText(featureLabels.get(yFactorIndex));
else
- yLabel.setText("Factor Y(" + String.valueOf(yFactorIndex) + ")");
+ yLabel.setText("Factor Y(" + yFactorIndex + ")");
if (zFactorIndex < featureLabels.size())
zLabel.setText(featureLabels.get(zFactorIndex));
else
- zLabel.setText("Factor Z(" + String.valueOf(zFactorIndex) + ")");
+ zLabel.setText("Factor Z(" + zFactorIndex + ")");
shape3DToLabel.forEach((node, label) -> {
javafx.geometry.Point3D coordinates = node.localToScene(javafx.geometry.Point3D.ZERO, true);
//@DEBUG SMP useful debugging print
diff --git a/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/ProjectorNodeGroup.java b/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/ProjectorNodeGroup.java
index 20d571d4..70b4c281 100644
--- a/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/ProjectorNodeGroup.java
+++ b/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/ProjectorNodeGroup.java
@@ -84,7 +84,7 @@ public ProjectorNode addNodeToScene(ProjectorNode projectorNode, String rowLabel
//this logic should alternate row placement in the 3D scene such that
//0 is equitorial, negative goes Y up and positive goes Y down...
int r = rows.isEmpty() ? 0 : rows.size() / 2 + 1;
- if (positiveRow == false)
+ if (!positiveRow)
r *= -1;
ProjectorRow newRow = new ProjectorRow(rowLabel, r, originRadius);
diff --git a/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/RetroWavePane.java b/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/RetroWavePane.java
index 9db620b3..c99373a2 100644
--- a/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/RetroWavePane.java
+++ b/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/RetroWavePane.java
@@ -577,24 +577,18 @@ private void moonShot(double milliseconds, boolean rightNow) {
new Font("Consolas", 50), Color.GREEN));
resetView(1000, false);
});
- timeline.getKeyFrames().addAll(new KeyFrame[]{
- new KeyFrame(Duration.millis(milliseconds * 0.333), new KeyValue[]{
- new KeyValue(cameraTransform.rx.angleProperty(), 0, Interpolator.EASE_IN),
+ timeline.getKeyFrames().addAll(new KeyFrame(Duration.millis(milliseconds * 0.333), new KeyValue(cameraTransform.rx.angleProperty(), 0, Interpolator.EASE_IN),
new KeyValue(cameraTransform.ry.angleProperty(), 0, Interpolator.EASE_IN),
new KeyValue(cameraTransform.rz.angleProperty(), 0, Interpolator.EASE_IN),
new KeyValue(camera.translateXProperty(), 0, Interpolator.EASE_IN),
new KeyValue(camera.translateYProperty(), 0, Interpolator.EASE_IN),
- new KeyValue(camera.translateZProperty(), 0, Interpolator.EASE_IN)
- })
- , new KeyFrame(Duration.millis(milliseconds), new KeyValue[]{
- new KeyValue(cameraTransform.ry.angleProperty(), 180, Interpolator.EASE_OUT),
- new KeyValue(camera.translateYProperty(), -sunTranslateY / 3.0, Interpolator.EASE_OUT),
- new KeyValue(camera.translateZProperty(), -1200, Interpolator.EASE_OUT)
- })
+ new KeyValue(camera.translateZProperty(), 0, Interpolator.EASE_IN))
+ , new KeyFrame(Duration.millis(milliseconds), new KeyValue(cameraTransform.ry.angleProperty(), 180, Interpolator.EASE_OUT),
+ new KeyValue(camera.translateYProperty(), -sunTranslateY / 3.0, Interpolator.EASE_OUT),
+ new KeyValue(camera.translateZProperty(), -1200, Interpolator.EASE_OUT))
, new KeyFrame(Duration.millis(milliseconds * 1.25), kv -> {
- creditsTimeline.playFromStart();
- })
- });
+ creditsTimeline.playFromStart();
+ }));
timeline.playFromStart();
} else {
dataXForm.reset();
diff --git a/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/ShadowCubeWorld.java b/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/ShadowCubeWorld.java
index 7709c13f..5e64c0d1 100644
--- a/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/ShadowCubeWorld.java
+++ b/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/ShadowCubeWorld.java
@@ -373,16 +373,14 @@ public void setScene(Scene scene) {
public Timeline animateOut(double milliseconds, double distance) {
Timeline timeline = new Timeline();
- timeline.getKeyFrames().addAll(new KeyFrame[]{
- new KeyFrame(Duration.millis(milliseconds), new KeyValue[]{// Frame End
+ timeline.getKeyFrames().addAll(new KeyFrame(Duration.millis(milliseconds), // Frame End
new KeyValue(x1AxisRectangle.translateZProperty(), -distance, Interpolator.EASE_OUT),
new KeyValue(x2AxisRectangle.translateZProperty(), distance, Interpolator.EASE_OUT),
new KeyValue(y1AxisRectangle.translateXProperty(), -distance, Interpolator.EASE_OUT),
new KeyValue(y2AxisRectangle.translateXProperty(), distance, Interpolator.EASE_OUT),
new KeyValue(z1AxisRectangle.translateYProperty(), distance, Interpolator.EASE_OUT),
- new KeyValue(z2AxisRectangle.translateYProperty(), -distance, Interpolator.EASE_OUT)
- }),
- new KeyFrame(Duration.millis(milliseconds * 1.5), new KeyValue[]{// Frame End
+ new KeyValue(z2AxisRectangle.translateYProperty(), -distance, Interpolator.EASE_OUT)),
+ new KeyFrame(Duration.millis(milliseconds * 1.5), // Frame End
new KeyValue(xy1GridLinesGroup.translateZProperty(), -distance, Interpolator.EASE_OUT),
new KeyValue(xx1GridLinesGroup.translateZProperty(), -distance, Interpolator.EASE_OUT),
new KeyValue(xy2GridLinesGroup.translateZProperty(), distance, Interpolator.EASE_OUT),
@@ -396,25 +394,21 @@ public Timeline animateOut(double milliseconds, double distance) {
new KeyValue(zy1GridLinesGroup.translateYProperty(), distance, Interpolator.EASE_OUT),
new KeyValue(zx1GridLinesGroup.translateYProperty(), distance, Interpolator.EASE_OUT),
new KeyValue(zy2GridLinesGroup.translateYProperty(), -distance, Interpolator.EASE_OUT),
- new KeyValue(zx2GridLinesGroup.translateYProperty(), -distance, Interpolator.EASE_OUT)
- })
- });
+ new KeyValue(zx2GridLinesGroup.translateYProperty(), -distance, Interpolator.EASE_OUT)));
timeline.playFromStart();
return timeline;
}
public Timeline animateIn(long milliseconds, double size) {
Timeline timeline = new Timeline();
- timeline.getKeyFrames().addAll(new KeyFrame[]{
- new KeyFrame(Duration.millis(milliseconds * 1.5), new KeyValue[]{// Frame End
+ timeline.getKeyFrames().addAll(new KeyFrame(Duration.millis(milliseconds * 1.5), // Frame End
new KeyValue(x1AxisRectangle.translateZProperty(), -size / 2.0, Interpolator.EASE_OUT),
new KeyValue(x2AxisRectangle.translateZProperty(), size / 2.0, Interpolator.EASE_OUT),
new KeyValue(y1AxisRectangle.translateXProperty(), -size, Interpolator.EASE_OUT),
new KeyValue(y2AxisRectangle.translateXProperty(), 0, Interpolator.EASE_OUT),
new KeyValue(z1AxisRectangle.translateYProperty(), 0, Interpolator.EASE_OUT),
- new KeyValue(z2AxisRectangle.translateYProperty(), -size, Interpolator.EASE_OUT)
- }),
- new KeyFrame(Duration.millis(milliseconds), new KeyValue[]{// Frame End
+ new KeyValue(z2AxisRectangle.translateYProperty(), -size, Interpolator.EASE_OUT)),
+ new KeyFrame(Duration.millis(milliseconds), // Frame End
new KeyValue(xy1GridLinesGroup.translateZProperty(), 0, Interpolator.EASE_OUT),
new KeyValue(xx1GridLinesGroup.translateZProperty(), 0, Interpolator.EASE_OUT),
new KeyValue(xy2GridLinesGroup.translateZProperty(), 0, Interpolator.EASE_OUT),
@@ -428,9 +422,7 @@ public Timeline animateIn(long milliseconds, double size) {
new KeyValue(zy1GridLinesGroup.translateYProperty(), 0, Interpolator.EASE_OUT),
new KeyValue(zx1GridLinesGroup.translateYProperty(), 0, Interpolator.EASE_OUT),
new KeyValue(zy2GridLinesGroup.translateYProperty(), 0, Interpolator.EASE_OUT),
- new KeyValue(zx2GridLinesGroup.translateYProperty(), 0, Interpolator.EASE_OUT)
- })
- });
+ new KeyValue(zx2GridLinesGroup.translateYProperty(), 0, Interpolator.EASE_OUT)));
timeline.playFromStart();
return timeline;
}
@@ -781,8 +773,7 @@ private void copyCanvas(ShadowPane src, ShadowPane dst) {
}
private void mouseDrawHandler(MouseEvent me) {
- if (me.getSource() instanceof ShadowPane) {
- ShadowPane shadowPane = (ShadowPane) me.getSource();
+ if (me.getSource() instanceof ShadowPane shadowPane) {
if (me.isControlDown()) {
Platform.runLater(() -> {
diff --git a/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/animated/AnimatedBox.java b/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/animated/AnimatedBox.java
index 86748a18..4dd5fadb 100644
--- a/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/animated/AnimatedBox.java
+++ b/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/animated/AnimatedBox.java
@@ -83,7 +83,7 @@ private TriangleMesh createMesh(float w, float h, float d) {
float hh = h / 2f;
float hd = d / 2f;
- float points[] = {
+ float[] points = {
-hw, -hh, -hd,
hw, -hh, -hd,
hw, hh, -hd,
@@ -93,14 +93,14 @@ private TriangleMesh createMesh(float w, float h, float d) {
hw, hh, hd,
-hw, hh, hd};
- float texCoords[] = {0, 0, 1, 0, 1, 1, 0, 1};
+ float[] texCoords = {0, 0, 1, 0, 1, 1, 0, 1};
// Specifies hard edges.
- int faceSmoothingGroups[] = {
+ int[] faceSmoothingGroups = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
- int faces[] = {
+ int[] faces = {
0, 0, 2, 2, 1, 1,
2, 2, 0, 0, 3, 3,
1, 0, 6, 2, 5, 1,
diff --git a/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/animated/BillboardNode.java b/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/animated/BillboardNode.java
index d454a300..ce658269 100644
--- a/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/animated/BillboardNode.java
+++ b/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/animated/BillboardNode.java
@@ -57,7 +57,7 @@ public abstract class BillboardNode extends Group {
public enum BillboardMode {
SPHERICAL,
- CYLINDRICAL;
+ CYLINDRICAL
}
protected abstract T getBillboardNode();
diff --git a/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/animated/Opticon.java b/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/animated/Opticon.java
index b7cdb98f..edd46be1 100644
--- a/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/animated/Opticon.java
+++ b/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/animated/Opticon.java
@@ -257,13 +257,10 @@ public void fireData(Group parent, Point3D destination, double milliseconds, Col
dataSphere.setMaterial(new PhongMaterial(dataColor));
Timeline timeline = new Timeline();
- timeline.getKeyFrames().addAll(new KeyFrame[]{
- new KeyFrame(Duration.millis(milliseconds), new KeyValue[]{// Frame End
- new KeyValue(dataSphere.translateXProperty(), sceneToLocalPoint.getX(), Interpolator.EASE_OUT),
- new KeyValue(dataSphere.translateYProperty(), sceneToLocalPoint.getY(), Interpolator.EASE_OUT),
- new KeyValue(dataSphere.translateZProperty(), sceneToLocalPoint.getZ(), Interpolator.EASE_OUT),
- })
- });
+ timeline.getKeyFrames().addAll(new KeyFrame(Duration.millis(milliseconds), // Frame End
+ new KeyValue(dataSphere.translateXProperty(), sceneToLocalPoint.getX(), Interpolator.EASE_OUT),
+ new KeyValue(dataSphere.translateYProperty(), sceneToLocalPoint.getY(), Interpolator.EASE_OUT),
+ new KeyValue(dataSphere.translateZProperty(), sceneToLocalPoint.getZ(), Interpolator.EASE_OUT)));
timeline.setOnFinished(e -> {
parent.getChildren().remove(dataSphere);
});
diff --git a/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/animated/TessellationMesh.java b/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/animated/TessellationMesh.java
index 9a07e52d..786ebb21 100644
--- a/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/animated/TessellationMesh.java
+++ b/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/animated/TessellationMesh.java
@@ -112,7 +112,6 @@ public void handle(long now) {
updateMaterial(image);
}
- ;
};
matrixTimer.start();
}
@@ -161,7 +160,6 @@ public void handle(long now) {
}
}
- ;
};
tessellationTimer.start();
}
@@ -178,10 +176,10 @@ public void tessellateImage(Image image, float scale, float maxH, int pskip) {
int numVerts = (subDivZ + 1) * numDivX;
final int texCoordSize = 2;
float currZ, currX;
- float texCoords[] = new float[numVerts * texCoordSize];
+ float[] texCoords = new float[numVerts * texCoordSize];
int faceCount = subDivX * subDivZ * 2;
final int faceSize = 6; //should always be 6 for a triangle mesh
- int faces[] = new int[faceCount * faceSize];
+ int[] faces = new int[faceCount * faceSize];
int index, p00, p01, p10, p11, tc00, tc01, tc10, tc11;
double yValue;
for (int z = 0; z < subDivZ; z++) {
@@ -190,7 +188,7 @@ public void tessellateImage(Image image, float scale, float maxH, int pskip) {
for (int x = 0; x < subDivX; x++) {
currX = (float) x / subDivX;
// color value for pixel at point
- rgb = ((int) image.getPixelReader().getArgb(x * pskip, z * pskip));
+ rgb = image.getPixelReader().getArgb(x * pskip, z * pskip);
r = (rgb >> 16) & 0xFF;
g = (rgb >> 8) & 0xFF;
b = rgb & 0xFF;
diff --git a/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/animated/TessellationTube.java b/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/animated/TessellationTube.java
index 8bda9e6b..2484bfda 100644
--- a/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/animated/TessellationTube.java
+++ b/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/animated/TessellationTube.java
@@ -68,8 +68,8 @@ public TriangleMesh buildWarp(List> dataGrid, double radius, double
int numVerts = (rowHeight + 1) * numDivX;
final int faceSize = 6; //should always be 6 for a triangle mesh
int faceCount = rowHeight * columnWidth * faceGroupSize;
- int faces[] = new int[faceCount * faceSize];
- float texCoords[] = new float[numVerts * texCoordSize];
+ int[] faces = new int[faceCount * faceSize];
+ float[] texCoords = new float[numVerts * texCoordSize];
float tIndex, tSize;
int index, p00, p01, p10, p11, tc00, tc01, tc10, tc11;
diff --git a/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/projectiles/Plane.java b/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/projectiles/Plane.java
index 4541479b..a6cf3f5c 100644
--- a/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/projectiles/Plane.java
+++ b/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/projectiles/Plane.java
@@ -267,8 +267,8 @@ public String toString() {
* @return The smallest magnitude distance from the plane to the point. Positive values indicate the point is on the
* positive side of the plane (where the normal points), and negative values indicate the opposite side.
*/
- public static final double distanceToPlane(final Vector3D planeNormal, final Point3D planePoint, final double x,
- final double y, final double z) {
+ public static double distanceToPlane(final Vector3D planeNormal, final Point3D planePoint, final double x,
+ final double y, final double z) {
return ((planeNormal.x * (x - planePoint.x)) + (planeNormal.y * (y - planePoint.y)) + (planeNormal.z * (z - planePoint.z)));
}
diff --git a/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/tasks/ExMaxClusterTask.java b/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/tasks/ExMaxClusterTask.java
index c3f28d78..50b4a577 100644
--- a/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/tasks/ExMaxClusterTask.java
+++ b/src/main/java/edu/jhuapl/trinity/javafx/javafx3d/tasks/ExMaxClusterTask.java
@@ -59,7 +59,7 @@ protected void processTask() throws Exception {
ArrayList clusters = new ArrayList<>();
int i = 0;
for (GaussianMixtureComponent c : gmm.components) {
- LOG.info("After GMM Fit Centroid {}: {}", i, Arrays.toString(c.distribution.mu));
+ LOG.info("After GMM Fit Centroid {}: {}", i, Arrays.toString(c.distribution().mu));
clusters.add(new Cluster(observations[0].length));
i++;
}
diff --git a/src/main/java/edu/jhuapl/trinity/messages/ChatCompletionCallback.java b/src/main/java/edu/jhuapl/trinity/messages/ChatCompletionCallback.java
index a3010d2a..53464700 100644
--- a/src/main/java/edu/jhuapl/trinity/messages/ChatCompletionCallback.java
+++ b/src/main/java/edu/jhuapl/trinity/messages/ChatCompletionCallback.java
@@ -16,8 +16,6 @@ public class ChatCompletionCallback extends RestConsumer {
public enum STATUS {REQUESTED, SUCCEEDED, FAILED}
- ;
-
public ChatCompletionCallback(Scene scene, int inputID, int requestNumber) {
super(scene);
this.requestNumber = requestNumber;
diff --git a/src/main/java/edu/jhuapl/trinity/messages/EmbeddingsImageLandmarkCallback.java b/src/main/java/edu/jhuapl/trinity/messages/EmbeddingsImageLandmarkCallback.java
index dd49a628..38ee9c88 100644
--- a/src/main/java/edu/jhuapl/trinity/messages/EmbeddingsImageLandmarkCallback.java
+++ b/src/main/java/edu/jhuapl/trinity/messages/EmbeddingsImageLandmarkCallback.java
@@ -18,8 +18,6 @@ public class EmbeddingsImageLandmarkCallback extends RestConsumer {
public enum STATUS {REQUESTED, SUCCEEDED, FAILED}
- ;
-
public EmbeddingsImageLandmarkCallback(Scene scene, List inputIDs, int requestNumber) {
super(scene);
this.inputIDs = inputIDs;
diff --git a/src/main/java/edu/jhuapl/trinity/messages/EmbeddingsTextCallback.java b/src/main/java/edu/jhuapl/trinity/messages/EmbeddingsTextCallback.java
index d7ca1ea2..29321190 100644
--- a/src/main/java/edu/jhuapl/trinity/messages/EmbeddingsTextCallback.java
+++ b/src/main/java/edu/jhuapl/trinity/messages/EmbeddingsTextCallback.java
@@ -18,8 +18,6 @@ public class EmbeddingsTextCallback extends RestConsumer {
public enum STATUS {REQUESTED, SUCCEEDED, FAILED}
- ;
-
public EmbeddingsTextCallback(Scene scene, List inputIDs, int requestNumber) {
super(scene);
this.inputIDs = inputIDs;
diff --git a/src/main/java/edu/jhuapl/trinity/messages/EmbeddingsTextLandmarkCallback.java b/src/main/java/edu/jhuapl/trinity/messages/EmbeddingsTextLandmarkCallback.java
index 27678928..224ea327 100644
--- a/src/main/java/edu/jhuapl/trinity/messages/EmbeddingsTextLandmarkCallback.java
+++ b/src/main/java/edu/jhuapl/trinity/messages/EmbeddingsTextLandmarkCallback.java
@@ -18,8 +18,6 @@ public class EmbeddingsTextLandmarkCallback extends RestConsumer {
public enum STATUS {REQUESTED, SUCCEEDED, FAILED}
- ;
-
public EmbeddingsTextLandmarkCallback(Scene scene, List inputIDs, int requestNumber) {
super(scene);
this.inputIDs = inputIDs;
diff --git a/src/main/java/edu/jhuapl/trinity/messages/EmbeddingsTextQueryCallback.java b/src/main/java/edu/jhuapl/trinity/messages/EmbeddingsTextQueryCallback.java
index a1df041c..c2f3a271 100644
--- a/src/main/java/edu/jhuapl/trinity/messages/EmbeddingsTextQueryCallback.java
+++ b/src/main/java/edu/jhuapl/trinity/messages/EmbeddingsTextQueryCallback.java
@@ -19,8 +19,6 @@ public class EmbeddingsTextQueryCallback extends RestConsumer {
public enum STATUS {REQUESTED, SUCCEEDED, FAILED}
- ;
-
public EmbeddingsTextQueryCallback(Scene scene, List inputIDs, int requestNumber) {
super(scene);
this.inputIDs = inputIDs;
diff --git a/src/main/java/edu/jhuapl/trinity/messages/MessageProcessor.java b/src/main/java/edu/jhuapl/trinity/messages/MessageProcessor.java
index 0dff1068..188c9bff 100644
--- a/src/main/java/edu/jhuapl/trinity/messages/MessageProcessor.java
+++ b/src/main/java/edu/jhuapl/trinity/messages/MessageProcessor.java
@@ -1,6 +1,5 @@
package edu.jhuapl.trinity.messages;
-import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import edu.jhuapl.trinity.data.FactorAnalysisState;
@@ -54,7 +53,7 @@ public MessageProcessor(Scene scene) {
// mapper.registerModule(new JavaTimeModule());
}
- public void process(String message) throws JsonProcessingException, IOException {
+ public void process(String message) throws IOException {
if (CommandRequest.isCommandRequest(message)) {
CommandRequest command = mapper.readValue(message, CommandRequest.class);
CommandTask commandTask = new CommandTask(command, scene);
diff --git a/src/main/java/edu/jhuapl/trinity/messages/ZeroMQSubscriberConfig.java b/src/main/java/edu/jhuapl/trinity/messages/ZeroMQSubscriberConfig.java
index bcadc360..5dd46695 100644
--- a/src/main/java/edu/jhuapl/trinity/messages/ZeroMQSubscriberConfig.java
+++ b/src/main/java/edu/jhuapl/trinity/messages/ZeroMQSubscriberConfig.java
@@ -7,8 +7,6 @@ public class ZeroMQSubscriberConfig {
public static enum CONNECTION {SUBSCRIBER, PULL}
- ;
-
public static final String DEFAULT_NAME = "ZeroMQ";
public static final String DEFAULT_DESCRIPTION = "Default";
public static final String DEFAULT_HOST = "tcp://localhost:5563";
diff --git a/src/main/java/edu/jhuapl/trinity/utils/AnalysisUtils.java b/src/main/java/edu/jhuapl/trinity/utils/AnalysisUtils.java
index 8e3606f7..e7ef3a04 100644
--- a/src/main/java/edu/jhuapl/trinity/utils/AnalysisUtils.java
+++ b/src/main/java/edu/jhuapl/trinity/utils/AnalysisUtils.java
@@ -35,19 +35,12 @@ public enum AnalysisUtils {
public static enum ANALYSIS_METHOD {PCA, SVD, KPCA}
- ;
-
public static enum SOURCE {HYPERSPACE, HYPERSURFACE}
- ;
-
public static enum KERNEL {Gaussian, Laplacian, Linear, Pearson, Polynomial}
- ;
-
public static enum RANGE {MINIMUM, MAXIMUM}
- ;
public static double EPISILON = 0.0000000001;
public static void clearAnalysisConfig() {
@@ -219,12 +212,12 @@ public static Double[][] boxDoubleArrays(double[][] arrays) {
// A function to randomly select k items from
// stream[0..n-1].
- public static double[][] selectKItems(double stream[][], int n, int k) {
+ public static double[][] selectKItems(double[][] stream, int n, int k) {
int i; // index for elements in stream[]
// reservoir[] is the output array. Initialize it
// with first k elements from stream[]
- double reservoir[][] = new double[k][stream[0].length];
+ double[][] reservoir = new double[k][stream[0].length];
for (i = 0; i < k; i++)
reservoir[i] = stream[i];
diff --git a/src/main/java/edu/jhuapl/trinity/utils/ConcaveUtils.java b/src/main/java/edu/jhuapl/trinity/utils/ConcaveUtils.java
index 405315b4..00408d6a 100644
--- a/src/main/java/edu/jhuapl/trinity/utils/ConcaveUtils.java
+++ b/src/main/java/edu/jhuapl/trinity/utils/ConcaveUtils.java
@@ -90,7 +90,7 @@ Calculate distance between point A and component B(OH)
public double calcPCDistance(double[] pointA, int idxComponentB) {
double dist = -1;
- int getRecord[] = (int[]) cvxList.get(idxComponentB);
+ int[] getRecord = cvxList.get(idxComponentB);
switch (NO_OF_DIM) {
case 2: ////////////////////////////////////////////////////////////////////// 2-Dimensional
@@ -115,7 +115,7 @@ public double calcPCDistance(double[] pointA, int idxComponentB) {
} else {
//t=sa.x*sb.y-sb.x*sa.y+sb.x*pa.y-pa.x*sb.y+pa.x*sa.y-sa.x*pa.y;
t = x1 * y2 - x2 * y1 + x2 * y0 - x0 * y2 + x0 * y1 - x1 * y0;
- dist = (double) Math.abs(t) / (double) Math.sqrt(c);
+ dist = Math.abs(t) / Math.sqrt(c);
}
return dist;
//break;
@@ -184,7 +184,7 @@ public void flagVertexPoints(Point3d[] points) {
orgData[pointIndex][2] = points[pointIndex].z;
}
//for every point which is a convex hull face mark that with a 1 (true)
- int getRecord[];
+ int[] getRecord;
for (int i = 0; i < cvxList.size(); i++) {
getRecord = cvxList.get(i);
for (int j = 0; j < getRecord.length; j++) {
@@ -206,7 +206,7 @@ public void findConcave() {
// Step. 0 Calculate average of edges of each component
double avgEdgeLength = 0;
int cCnt = 0;
- int getRecord[] = (int[]) cvxList.get(i);
+ int[] getRecord = cvxList.get(i);
int[] indices;
CombinationGenerator cg = new CombinationGenerator(getRecord.length, 2);
@@ -219,7 +219,7 @@ public void findConcave() {
cCnt++;
}
- avgEdgeLength /= (double) cCnt;
+ avgEdgeLength /= cCnt;
// End of Step. 0
// Step. 1 Find nearest inner point of each component
@@ -237,7 +237,7 @@ public void findConcave() {
double tmpLength = calcEDistance(orgData[j], orgData[getRecord[x] - 1]);
tmpAverage += tmpLength;
}
- tmpAverage /= (double) NO_OF_DIM;
+ tmpAverage /= NO_OF_DIM;
arrLength.add(tmpAverage);
arrIdx.add(j);
@@ -251,7 +251,7 @@ public void findConcave() {
double shortestLength = 999999;
int nearestPoint = 0;
for (int k = 0; k < arrLength.size(); k++) {
- double currLength = (double) arrLength.get(k);
+ double currLength = arrLength.get(k);
if (currLength < shortestLength) {
// check if current point is close to neighbor compoinnt OH 20110111
{ ////////////////////////////////////////////////////////////////////////////
@@ -260,7 +260,7 @@ public void findConcave() {
double minDistance = 999999;
for (int m = 0; m < NO_OF_DIM; m++) {
- double tmpDistance = calcEDistance(orgData[(int) arrIdx.get(k)], orgData[getRecord[m] - 1]);
+ double tmpDistance = calcEDistance(orgData[arrIdx.get(k)], orgData[getRecord[m] - 1]);
if (tmpDistance < minDistance) {
minDistance = tmpDistance;
idxNearEdgePoint = getRecord[m];
@@ -289,13 +289,13 @@ public void findConcave() {
int closerToNeighbor = 0;
for (int r = 0; r < linkComponent.size(); r++) {
int idxLinkComponent = Integer.parseInt(linkComponent.get(r));
- if (calcPCDistance(orgData[(int) arrIdx.get(k)], idxLinkComponent) < calcPCDistance(orgData[(int) arrIdx.get(k)], i)) {
+ if (calcPCDistance(orgData[arrIdx.get(k)], idxLinkComponent) < calcPCDistance(orgData[arrIdx.get(k)], i)) {
closerToNeighbor = 1;
}
}
if (closerToNeighbor == 0) {
- nearestPoint = (int) arrIdx.get(k);
+ nearestPoint = arrIdx.get(k);
shortestLength = currLength;
}
} ////////////////////////////////////////////////////////////////////////////
@@ -322,7 +322,7 @@ public void findConcave() {
// step. 3 Compare the ratio of decision distance with threshold N.
// if the ratio bigger than N, nearest inner point is inserted to concave list.
- double diggRatio = (double) avgEdgeLength / (double) minLength;
+ double diggRatio = avgEdgeLength / minLength;
if (diggRatio < 0)
LOG.info("Negative diggRatio!");
if (minLength > 0 && diggRatio > N) {
@@ -333,7 +333,7 @@ public void findConcave() {
cg = new CombinationGenerator(NO_OF_DIM, NO_OF_DIM - 1);
while (cg.hasMore()) {
indices = cg.getNext();
- int newRecord[] = new int[NO_OF_DIM];
+ int[] newRecord = new int[NO_OF_DIM];
for (int q = 0; q < NO_OF_DIM - 1; q++) {
newRecord[q] = getRecord[indices[q]];
diff --git a/src/main/java/edu/jhuapl/trinity/utils/Configuration.java b/src/main/java/edu/jhuapl/trinity/utils/Configuration.java
index f1d3f6a0..e975950f 100644
--- a/src/main/java/edu/jhuapl/trinity/utils/Configuration.java
+++ b/src/main/java/edu/jhuapl/trinity/utils/Configuration.java
@@ -6,7 +6,6 @@
import org.slf4j.LoggerFactory;
import java.io.FileInputStream;
-import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
@@ -27,7 +26,7 @@ public Configuration() {
}
- public Configuration(String filename) throws FileNotFoundException, IOException {
+ public Configuration(String filename) throws IOException {
Properties madProps = new Properties();
madProps.load(new FileInputStream(filename));
configProps = madProps;
diff --git a/src/main/java/edu/jhuapl/trinity/utils/DataUtils.java b/src/main/java/edu/jhuapl/trinity/utils/DataUtils.java
index 5f50b3db..7af30c9c 100644
--- a/src/main/java/edu/jhuapl/trinity/utils/DataUtils.java
+++ b/src/main/java/edu/jhuapl/trinity/utils/DataUtils.java
@@ -158,7 +158,7 @@ public static List convertSemanticReconstruction(SemanticReconstr
ArrayList[] timesTouples = new ArrayList[eventsSet.size()];
timesTouples = reconstruction.getAttrs().getEvents().values().toArray(timesTouples);
- String[] eventLabels = new String[eventsMap.keySet().size()];
+ String[] eventLabels = new String[eventsMap.size()];
eventLabels = eventsMap.keySet().toArray(eventLabels);
double framerate = reconstruction.getAttrs().getFramerate();
diff --git a/src/main/java/edu/jhuapl/trinity/utils/DoubleConverter.java b/src/main/java/edu/jhuapl/trinity/utils/DoubleConverter.java
index 9b685e12..2881a6c3 100644
--- a/src/main/java/edu/jhuapl/trinity/utils/DoubleConverter.java
+++ b/src/main/java/edu/jhuapl/trinity/utils/DoubleConverter.java
@@ -39,5 +39,4 @@ public Double fromString(String string) {
}
}
- ;
}
diff --git a/src/main/java/edu/jhuapl/trinity/utils/JavaFX3DUtils.java b/src/main/java/edu/jhuapl/trinity/utils/JavaFX3DUtils.java
index 9728370b..3189e49b 100644
--- a/src/main/java/edu/jhuapl/trinity/utils/JavaFX3DUtils.java
+++ b/src/main/java/edu/jhuapl/trinity/utils/JavaFX3DUtils.java
@@ -413,11 +413,8 @@ public static Affine lookAt(Node node,
public static void zoomTransition(double milliseconds, Camera camera, double distance) {
Timeline timeline = new Timeline();
- timeline.getKeyFrames().addAll(new KeyFrame[]{
- new KeyFrame(Duration.millis(milliseconds), new KeyValue[]{// Frame End
- new KeyValue(camera.translateZProperty(), distance, Interpolator.EASE_OUT),
- })
- });
+ timeline.getKeyFrames().addAll(new KeyFrame(Duration.millis(milliseconds), // Frame End
+ new KeyValue(camera.translateZProperty(), distance, Interpolator.EASE_OUT)));
timeline.playFromStart();
}
@@ -425,16 +422,13 @@ public static void zoomTransition(double milliseconds, Camera camera, double dis
public static Timeline transitionCameraTo(double milliseconds, Camera camera, CameraTransformer transformer,
double tx, double ty, double tz, double rx, double ry, double rz) {
Timeline timeline = new Timeline();
- timeline.getKeyFrames().addAll(new KeyFrame[]{
- new KeyFrame(Duration.millis(milliseconds), new KeyValue[]{// Frame End
- new KeyValue(transformer.rx.angleProperty(), rx, Interpolator.EASE_BOTH),
- new KeyValue(transformer.ry.angleProperty(), ry, Interpolator.EASE_BOTH),
- new KeyValue(transformer.rz.angleProperty(), rz, Interpolator.EASE_BOTH),
- new KeyValue(camera.translateXProperty(), tx, Interpolator.EASE_BOTH),
- new KeyValue(camera.translateYProperty(), ty, Interpolator.EASE_BOTH),
- new KeyValue(camera.translateZProperty(), tz, Interpolator.EASE_BOTH)
- })
- });
+ timeline.getKeyFrames().addAll(new KeyFrame(Duration.millis(milliseconds), // Frame End
+ new KeyValue(transformer.rx.angleProperty(), rx, Interpolator.EASE_BOTH),
+ new KeyValue(transformer.ry.angleProperty(), ry, Interpolator.EASE_BOTH),
+ new KeyValue(transformer.rz.angleProperty(), rz, Interpolator.EASE_BOTH),
+ new KeyValue(camera.translateXProperty(), tx, Interpolator.EASE_BOTH),
+ new KeyValue(camera.translateYProperty(), ty, Interpolator.EASE_BOTH),
+ new KeyValue(camera.translateZProperty(), tz, Interpolator.EASE_BOTH)));
timeline.playFromStart();
return timeline;
}
@@ -507,10 +501,10 @@ public static TriangleMesh createHeightMap(Image image, int pskip, float maxH, f
final int faceSize = 6;
int numDivX = subDivX + 1;
int numVerts = (subDivZ + 1) * numDivX;
- float points[] = new float[numVerts * pointSize];
- float texCoords[] = new float[numVerts * texCoordSize];
+ float[] points = new float[numVerts * pointSize];
+ float[] texCoords = new float[numVerts * texCoordSize];
int faceCount = subDivX * subDivZ * 2;
- int faces[] = new int[faceCount * faceSize];
+ int[] faces = new int[faceCount * faceSize];
float currZ, currX;
double fz, fx;
int index, rgb, r, g, b;
@@ -525,7 +519,7 @@ public static TriangleMesh createHeightMap(Image image, int pskip, float maxH, f
points[index] = (float) fx * scale; // x
// color value for pixel at point
- rgb = ((int) image.getPixelReader().getArgb(x * pskip, z * pskip));
+ rgb = image.getPixelReader().getArgb(x * pskip, z * pskip);
r = (rgb >> 16) & 0xFF;
g = (rgb >> 8) & 0xFF;
b = rgb & 0xFF;
diff --git a/src/main/java/edu/jhuapl/trinity/utils/ResourceUtils.java b/src/main/java/edu/jhuapl/trinity/utils/ResourceUtils.java
index 1625947d..c04fdf9c 100644
--- a/src/main/java/edu/jhuapl/trinity/utils/ResourceUtils.java
+++ b/src/main/java/edu/jhuapl/trinity/utils/ResourceUtils.java
@@ -79,14 +79,12 @@
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLDecoder;
import java.nio.IntBuffer;
-import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
@@ -115,7 +113,7 @@ public static List getClasspathEntriesByPath(String path) throws NullPoi
InputStream is = ResourceUtils.class.getClassLoader().getResourceAsStream(path);
StringBuilder sb = new StringBuilder();
byte[] buffer = is.readAllBytes();
- sb.append(new String(buffer, Charset.defaultCharset()));
+ sb.append(new String(buffer, StandardCharsets.UTF_8));
return Arrays
.asList(sb.toString().split("\n")) // Convert StringBuilder to individual lines
@@ -140,7 +138,7 @@ public static List getClasspathEntriesByPath(String path) throws NullPoi
public static String[] getResourceListing(Class clazz, String path) throws URISyntaxException, IOException {
URL dirURL = clazz.getClassLoader().getResource(path);
if (dirURL != null && dirURL.getProtocol().equals("file")) {
- LOG.info("dirURL {}", dirURL.toString());
+ LOG.info("dirURL {}", dirURL);
/* A file path: easy enough */
return new File(dirURL.toURI()).list();
}
@@ -159,7 +157,7 @@ public static String[] getResourceListing(Class clazz, String path) throws URISy
if (dirURL.getProtocol().equals("jar")) {
/* A JAR path */
String jarPath = dirURL.getPath().substring(5, dirURL.getPath().indexOf("!")); //strip out only the JAR file
- JarFile jar = new JarFile(URLDecoder.decode(jarPath, "UTF-8"));
+ JarFile jar = new JarFile(URLDecoder.decode(jarPath, StandardCharsets.UTF_8));
Enumeration entries = jar.entries(); //gives ALL entries in jar
Set result = new HashSet<>(); //avoid duplicates in case it is a subdirectory
while (entries.hasMoreElements()) {
@@ -180,7 +178,7 @@ public static String[] getResourceListing(Class clazz, String path) throws URISy
throw new UnsupportedOperationException("Cannot list files for URL " + dirURL);
}
- public static List getFilenamesForDirnameFromCP(String directoryName) throws URISyntaxException, UnsupportedEncodingException, IOException {
+ public static List getFilenamesForDirnameFromCP(String directoryName) throws URISyntaxException, IOException {
List filenames = new ArrayList<>();
URL url = ResourceUtils.class.getResource(directoryName);
@@ -200,7 +198,7 @@ public static List getFilenamesForDirnameFromCP(String directoryName) th
String dirname = directoryName + "/";
String path = url.getPath();
String jarPath = path.substring(5, path.indexOf("!"));
- try (JarFile jar = new JarFile(URLDecoder.decode(jarPath, StandardCharsets.UTF_8.name()))) {
+ try (JarFile jar = new JarFile(URLDecoder.decode(jarPath, StandardCharsets.UTF_8))) {
Enumeration entries = jar.entries();
while (entries.hasMoreElements()) {
JarEntry entry = entries.nextElement();
@@ -218,7 +216,7 @@ public static List getFilenamesForDirnameFromCP(String directoryName) th
public static File saveImageFile(Image image) throws IOException {
- File newFile = new File("imagery/Trinity-scan-" + UUID.randomUUID().toString() + ".png");
+ File newFile = new File("imagery/Trinity-scan-" + UUID.randomUUID() + ".png");
BufferedImage buff = SwingFXUtils.fromFXImage(image, null);
ImageIO.write(buff, "PNG", newFile);
return newFile;
@@ -368,7 +366,7 @@ public static boolean asciiBytesCheck(File f) {
size = 1000;
data = new byte[size];
in.read(data);
- String s = new String(data, "ISO-8859-1");
+ String s = new String(data, StandardCharsets.ISO_8859_1);
String s2 = s.replaceAll(
"[a-zA-Z0-9ßöäü\\.\\*!\"§\\$\\%&/()=\\?@~'#:,;\\" +
"+><\\|\\[\\]\\{\\}\\^°²³\\\\ \\n\\r\\t_\\-`´âêîô" +
@@ -767,4 +765,4 @@ public static byte[] byteMe(Image me) throws IOException {
public static String imageToBase64(Image image) throws IOException {
return Base64.getEncoder().encodeToString(imageToBytes(image));
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/edu/jhuapl/trinity/utils/Utils.java b/src/main/java/edu/jhuapl/trinity/utils/Utils.java
index e8abca7d..f44a617f 100644
--- a/src/main/java/edu/jhuapl/trinity/utils/Utils.java
+++ b/src/main/java/edu/jhuapl/trinity/utils/Utils.java
@@ -7,7 +7,6 @@
import java.io.File;
import java.io.FileInputStream;
-import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -89,7 +88,7 @@ public static double[] linspace(double min, double max, int points) {
return d;
}
- public static Properties readProps(String propsPath, Properties defaults) throws FileNotFoundException, IOException {
+ public static Properties readProps(String propsPath, Properties defaults) throws IOException {
Properties newProps = new Properties();
if (null != defaults)
newProps = new Properties(defaults);
@@ -99,7 +98,7 @@ public static Properties readProps(String propsPath, Properties defaults) throws
return newProps;
}
- public static Properties readProps(File file, Properties defaults) throws FileNotFoundException, IOException {
+ public static Properties readProps(File file, Properties defaults) throws IOException {
Properties newProps = new Properties();
if (null != defaults)
newProps = new Properties(defaults);
@@ -109,7 +108,7 @@ public static Properties readProps(File file, Properties defaults) throws FileNo
return newProps;
}
- public static void writeProps(String propsPath, Properties madProps, String comments) throws FileNotFoundException, IOException {
+ public static void writeProps(String propsPath, Properties madProps, String comments) throws IOException {
try (OutputStream os = new FileOutputStream(new File(propsPath))) {
madProps.store(os, comments);
}
diff --git a/src/main/java/edu/jhuapl/trinity/utils/clustering/GaussianMixture.java b/src/main/java/edu/jhuapl/trinity/utils/clustering/GaussianMixture.java
index 20476931..b2bc5c1f 100644
--- a/src/main/java/edu/jhuapl/trinity/utils/clustering/GaussianMixture.java
+++ b/src/main/java/edu/jhuapl/trinity/utils/clustering/GaussianMixture.java
@@ -99,7 +99,7 @@ public static GaussianMixture fit(double[][] x, GaussianMixtureComponent[] compo
GaussianMixtureComponent c = components[i];
for (int j = 0; j < n; j++) {
- posteriori[i][j] = c.priori * c.distribution.p(x[j]);
+ posteriori[i][j] = c.priori() * c.distribution().p(x[j]);
}
}
@@ -130,19 +130,19 @@ public static GaussianMixture fit(double[][] x, GaussianMixtureComponent[] compo
// Maximization step
double Z = 0.0;
for (int i = 0; i < k; i++) {
- components[i] = ((GaussianDistribution) components[i].distribution).maximization(x, posteriori[i]);
- Z += components[i].priori;
+ components[i] = components[i].distribution().maximization(x, posteriori[i]);
+ Z += components[i].priori();
}
for (int i = 0; i < k; i++) {
- components[i] = new GaussianMixtureComponent(components[i].priori / Z, components[i].distribution);
+ components[i] = new GaussianMixtureComponent(components[i].priori() / Z, components[i].distribution());
}
double loglikelihood = 0.0;
for (double[] xi : x) {
double p = 0.0;
for (GaussianMixtureComponent c : components) {
- p += c.priori * c.distribution.p(xi);
+ p += c.priori() * c.distribution().p(xi);
}
if (p > 0) loglikelihood += Math.log(p);
}
@@ -163,7 +163,7 @@ public static GaussianMixture fit(double[][] x, GaussianMixtureComponent[] compo
public int length() {
int f = components.length - 1; // independent priori parameters
for (GaussianMixtureComponent component : components) {
- f += component.distribution.length();
+ f += component.distribution().length();
}
return f;
@@ -173,7 +173,7 @@ public double p(double[] x) {
double p = 0.0;
for (GaussianMixtureComponent c : components) {
- p += c.priori * c.distribution.p(x);
+ p += c.priori() * c.distribution().p(x);
}
return p;
@@ -210,7 +210,7 @@ public double[] posteriori(double[] x) {
double[] prob = new double[k];
for (int i = 0; i < k; i++) {
GaussianMixtureComponent c = components[i];
- prob[i] = c.priori * c.distribution.p(x);
+ prob[i] = c.priori() * c.distribution().p(x);
}
double p = ClusterUtils.sum(prob);
@@ -221,16 +221,16 @@ public double[] posteriori(double[] x) {
}
public double[] mean() {
- double w = components[0].priori;
- double[] m = components[0].distribution.mean();
+ double w = components[0].priori();
+ double[] m = components[0].distribution().mean();
double[] mu = new double[m.length];
for (int i = 0; i < m.length; i++) {
mu[i] = w * m[i];
}
for (int k = 1; k < components.length; k++) {
- w = components[k].priori;
- m = components[k].distribution.mean();
+ w = components[k].priori();
+ m = components[k].distribution().mean();
for (int i = 0; i < m.length; i++) {
mu[i] += w * m[i];
}
@@ -240,8 +240,8 @@ public double[] mean() {
}
public RealMatrix cov() {
- double w = components[0].priori;
- RealMatrix v = components[0].distribution.cov();
+ double w = components[0].priori();
+ RealMatrix v = components[0].distribution().cov();
int m = v.getRowDimension();
int n = v.getColumnDimension();
@@ -254,8 +254,8 @@ public RealMatrix cov() {
}
for (int k = 1; k < components.length; k++) {
- w = components[k].priori;
- v = components[k].distribution.cov();
+ w = components[k].priori();
+ v = components[k].distribution().cov();
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
cov.addToEntry(i, j, w * w * v.getEntry(i, j));
@@ -271,7 +271,7 @@ public Pair maxPostProb(double[] x) {
double[] prob = new double[k];
for (int i = 0; i < k; i++) {
GaussianMixtureComponent c = components[i];
- prob[i] = c.priori * c.distribution.p(x);
+ prob[i] = c.priori() * c.distribution().p(x);
}
int maxIndex = ClusterUtils.whichMax(prob);
return new Pair<>(maxIndex, prob[maxIndex]);
diff --git a/src/main/java/edu/jhuapl/trinity/utils/clustering/GaussianMixtureComponent.java b/src/main/java/edu/jhuapl/trinity/utils/clustering/GaussianMixtureComponent.java
index 07c98092..400efe78 100644
--- a/src/main/java/edu/jhuapl/trinity/utils/clustering/GaussianMixtureComponent.java
+++ b/src/main/java/edu/jhuapl/trinity/utils/clustering/GaussianMixtureComponent.java
@@ -4,27 +4,9 @@
* the mixture distribution is defined by a distribution
* and its weight in the mixture.
*
+ * @param priori The priori probability of component.
+ * @param distribution The distribution of component.
* @author Sean Phillips
*/
-public class GaussianMixtureComponent {
- /**
- * The priori probability of component.
- */
- public final double priori;
-
- /**
- * The distribution of component.
- */
- public final GaussianDistribution distribution;
-
- /**
- * Constructor.
- *
- * @param priori the priori probability of component.
- * @param distribution the distribution of component.
- */
- public GaussianMixtureComponent(double priori, GaussianDistribution distribution) {
- this.priori = priori;
- this.distribution = distribution;
- }
+public record GaussianMixtureComponent(double priori, GaussianDistribution distribution) {
}
diff --git a/src/main/java/edu/jhuapl/trinity/utils/fun/CRTPower.java b/src/main/java/edu/jhuapl/trinity/utils/fun/CRTPower.java
index 9eb4ebaf..37735720 100644
--- a/src/main/java/edu/jhuapl/trinity/utils/fun/CRTPower.java
+++ b/src/main/java/edu/jhuapl/trinity/utils/fun/CRTPower.java
@@ -74,9 +74,7 @@ public void play(boolean powerOn) {
private void playScanlineFlash() {
Node parent = target.getParent();
- if (!(parent instanceof Pane)) return;
-
- Pane parentPane = (Pane) parent;
+ if (!(parent instanceof Pane parentPane)) return;
Rectangle scanline = new Rectangle();
scanline.setFill(Color.WHITE);
diff --git a/src/main/java/edu/jhuapl/trinity/utils/fun/DalleWalle.java b/src/main/java/edu/jhuapl/trinity/utils/fun/DalleWalle.java
index 6a9ea6c7..202892fd 100644
--- a/src/main/java/edu/jhuapl/trinity/utils/fun/DalleWalle.java
+++ b/src/main/java/edu/jhuapl/trinity/utils/fun/DalleWalle.java
@@ -388,7 +388,7 @@ public void watchDirectoryPath(java.nio.file.Path path) {
LOG.info("New file created: {}", newPath);
if (newPath.toString().endsWith("png") || newPath.toString().endsWith("PNG")) {
try {
- String filePath = path.toString() + "/" + newPath.toString();
+ String filePath = path + "/" + newPath;
File file = new File(filePath);
String fixedPath = file.getAbsolutePath();
int tempIndex = imageIndex;
diff --git a/src/main/java/edu/jhuapl/trinity/utils/metric/CorrelationMetric.java b/src/main/java/edu/jhuapl/trinity/utils/metric/CorrelationMetric.java
index 0691696a..5b310134 100644
--- a/src/main/java/edu/jhuapl/trinity/utils/metric/CorrelationMetric.java
+++ b/src/main/java/edu/jhuapl/trinity/utils/metric/CorrelationMetric.java
@@ -50,7 +50,7 @@ public double distance(final double[] x, final double[] y) {
} else if (dotProduct == 0.0) {
return 1;
} else {
- return (double) (1 - (dotProduct / Math.sqrt(normX * normY)));
+ return 1 - (dotProduct / Math.sqrt(normX * normY));
}
}
}
diff --git a/src/main/java/edu/jhuapl/trinity/utils/metric/CosineMetric.java b/src/main/java/edu/jhuapl/trinity/utils/metric/CosineMetric.java
index ac2ec461..7c471915 100644
--- a/src/main/java/edu/jhuapl/trinity/utils/metric/CosineMetric.java
+++ b/src/main/java/edu/jhuapl/trinity/utils/metric/CosineMetric.java
@@ -39,7 +39,7 @@ public double distance(final double[] x, final double[] y) {
} else if (normX == 0.0 || normY == 0.0) {
return 1;
} else {
- return (double) (1 - (result / Math.sqrt(normX * normY)));
+ return 1 - (result / Math.sqrt(normX * normY));
}
}
}
diff --git a/src/main/java/edu/jhuapl/trinity/utils/metric/EuclideanMetric.java b/src/main/java/edu/jhuapl/trinity/utils/metric/EuclideanMetric.java
index 95293074..ba93c3fc 100644
--- a/src/main/java/edu/jhuapl/trinity/utils/metric/EuclideanMetric.java
+++ b/src/main/java/edu/jhuapl/trinity/utils/metric/EuclideanMetric.java
@@ -29,6 +29,6 @@ public double distance(final double[] x, final double[] y) {
final double d = x[i] - y[i];
result += d * d;
}
- return (double) Math.sqrt(result);
+ return Math.sqrt(result);
}
}
diff --git a/src/main/java/edu/jhuapl/trinity/utils/metric/HaversineMetric.java b/src/main/java/edu/jhuapl/trinity/utils/metric/HaversineMetric.java
index b6f2b1c3..e5369499 100644
--- a/src/main/java/edu/jhuapl/trinity/utils/metric/HaversineMetric.java
+++ b/src/main/java/edu/jhuapl/trinity/utils/metric/HaversineMetric.java
@@ -29,6 +29,6 @@ public double distance(final double[] x, final double[] y) {
final double sinLat = Math.sin(0.5 * (x[0] - y[0]));
final double sinLong = Math.sin(0.5 * (x[1] - y[1]));
final double result = Math.sqrt(sinLat * sinLat + Math.cos(x[0]) * Math.cos(y[0]) * sinLong * sinLong);
- return (double) (2 * Math.asin(result));
+ return 2 * Math.asin(result);
}
}
diff --git a/src/main/java/edu/jhuapl/trinity/utils/metric/MahalanobisMetric.java b/src/main/java/edu/jhuapl/trinity/utils/metric/MahalanobisMetric.java
index db9c658e..924bc739 100644
--- a/src/main/java/edu/jhuapl/trinity/utils/metric/MahalanobisMetric.java
+++ b/src/main/java/edu/jhuapl/trinity/utils/metric/MahalanobisMetric.java
@@ -39,6 +39,6 @@ public double distance(final double[] x, final double[] y) {
}
result += tmp * diff[i];
}
- return (double) Math.sqrt(result);
+ return Math.sqrt(result);
}
}
diff --git a/src/main/java/edu/jhuapl/trinity/utils/metric/MinkowskiMetric.java b/src/main/java/edu/jhuapl/trinity/utils/metric/MinkowskiMetric.java
index 7d611c10..0a76ef28 100644
--- a/src/main/java/edu/jhuapl/trinity/utils/metric/MinkowskiMetric.java
+++ b/src/main/java/edu/jhuapl/trinity/utils/metric/MinkowskiMetric.java
@@ -28,6 +28,6 @@ public double distance(final double[] x, final double[] y) {
for (int i = 0; i < x.length; ++i) {
result += Math.pow(Math.abs(x[i] - y[i]), mPower);
}
- return (double) Math.pow(result, 1 / mPower);
+ return Math.pow(result, 1 / mPower);
}
}
diff --git a/src/main/java/edu/jhuapl/trinity/utils/metric/SokalSneathMetric.java b/src/main/java/edu/jhuapl/trinity/utils/metric/SokalSneathMetric.java
index e61d315d..866b1ec2 100644
--- a/src/main/java/edu/jhuapl/trinity/utils/metric/SokalSneathMetric.java
+++ b/src/main/java/edu/jhuapl/trinity/utils/metric/SokalSneathMetric.java
@@ -35,6 +35,6 @@ public double distance(final double[] x, final double[] y) {
++numNotEqual;
}
}
- return numNotEqual == 0 ? 0 : numNotEqual / (double) (0.5 * numTrueTrue + numNotEqual);
+ return numNotEqual == 0 ? 0 : numNotEqual / (0.5 * numTrueTrue + numNotEqual);
}
}
diff --git a/src/main/java/edu/jhuapl/trinity/utils/metric/StandardisedEuclideanMetric.java b/src/main/java/edu/jhuapl/trinity/utils/metric/StandardisedEuclideanMetric.java
index 3f688f18..60d7d7ab 100644
--- a/src/main/java/edu/jhuapl/trinity/utils/metric/StandardisedEuclideanMetric.java
+++ b/src/main/java/edu/jhuapl/trinity/utils/metric/StandardisedEuclideanMetric.java
@@ -29,6 +29,6 @@ public double distance(final double[] x, final double[] y) {
final double d = x[i] - y[i];
result += d * d / mSigma[i];
}
- return (double) Math.sqrt(result);
+ return Math.sqrt(result);
}
}
diff --git a/src/main/java/edu/jhuapl/trinity/utils/metric/WeightedMinkowskiMetric.java b/src/main/java/edu/jhuapl/trinity/utils/metric/WeightedMinkowskiMetric.java
index 98b17d43..c09b586d 100644
--- a/src/main/java/edu/jhuapl/trinity/utils/metric/WeightedMinkowskiMetric.java
+++ b/src/main/java/edu/jhuapl/trinity/utils/metric/WeightedMinkowskiMetric.java
@@ -28,6 +28,6 @@ public double distance(final double[] x, final double[] y) {
for (int i = 0; i < x.length; ++i) {
result += Math.pow(mWeights[i] * Math.abs(x[i] - y[i]), mPower);
}
- return (double) Math.pow(result, 1 / mPower);
+ return Math.pow(result, 1 / mPower);
}
}
diff --git a/src/main/java/edu/jhuapl/trinity/utils/statistics/ABComparisonEngine.java b/src/main/java/edu/jhuapl/trinity/utils/statistics/ABComparisonEngine.java
index 59edf55d..0915e8f0 100644
--- a/src/main/java/edu/jhuapl/trinity/utils/statistics/ABComparisonEngine.java
+++ b/src/main/java/edu/jhuapl/trinity/utils/statistics/ABComparisonEngine.java
@@ -2,7 +2,6 @@
import edu.jhuapl.trinity.data.messages.xai.FeatureVector;
-import java.io.Serial;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
@@ -34,50 +33,21 @@ public final class ABComparisonEngine {
/**
* Immutable result bundle for a single A/B compare on one (x,y) pair.
+ *
+ * @param a baseline A (may contain both PDF/CDF)
+ * @param b baseline B
+ * @param pdfDiff A.pdf - B.pdf (nullable if not requested)
+ * @param cdfDiff A.cdf - B.cdf (nullable if not requested)
+ * @param pdfProvA nullable when recipe does not request PDF
+ * @param pdfProvB nullable when recipe does not request PDF
+ * @param pdfProvDiff nullable when recipe does not request PDF
+ * @param cdfProvA nullable when recipe does not request CDF
+ * @param cdfProvB nullable when recipe does not request CDF
+ * @param cdfProvDiff nullable when recipe does not request CDF
*/
- public static final class AbResult implements Serializable {
- @Serial
- private static final long serialVersionUID = 1L;
-
- public final GridSpec grid;
-
- public final GridDensityResult a; // baseline A (may contain both PDF/CDF)
- public final GridDensityResult b; // baseline B
-
- public final List> pdfDiff; // A.pdf - B.pdf (nullable if not requested)
- public final List> cdfDiff; // A.cdf - B.cdf (nullable if not requested)
-
- public final JpdfProvenance pdfProvA; // nullable when recipe does not request PDF
- public final JpdfProvenance pdfProvB; // nullable when recipe does not request PDF
- public final JpdfProvenance pdfProvDiff; // nullable when recipe does not request PDF
-
- public final JpdfProvenance cdfProvA; // nullable when recipe does not request CDF
- public final JpdfProvenance cdfProvB; // nullable when recipe does not request CDF
- public final JpdfProvenance cdfProvDiff; // nullable when recipe does not request CDF
-
- public AbResult(GridSpec grid,
- GridDensityResult a,
- GridDensityResult b,
- List> pdfDiff,
- List> cdfDiff,
- JpdfProvenance pdfProvA,
- JpdfProvenance pdfProvB,
- JpdfProvenance pdfProvDiff,
- JpdfProvenance cdfProvA,
- JpdfProvenance cdfProvB,
- JpdfProvenance cdfProvDiff) {
- this.grid = grid;
- this.a = a;
- this.b = b;
- this.pdfDiff = pdfDiff;
- this.cdfDiff = cdfDiff;
- this.pdfProvA = pdfProvA;
- this.pdfProvB = pdfProvB;
- this.pdfProvDiff = pdfProvDiff;
- this.cdfProvA = cdfProvA;
- this.cdfProvB = cdfProvB;
- this.cdfProvDiff = cdfProvDiff;
- }
+ public record AbResult(GridSpec grid, GridDensityResult a, GridDensityResult b, List> pdfDiff, List> cdfDiff,
+ JpdfProvenance pdfProvA, JpdfProvenance pdfProvB, JpdfProvenance pdfProvDiff, JpdfProvenance cdfProvA, JpdfProvenance cdfProvB,
+ JpdfProvenance cdfProvDiff) implements Serializable {
}
private ABComparisonEngine() {
@@ -211,10 +181,10 @@ private static GridSpec buildAlignedGrid(List aVectors,
CanonicalGridPolicy.AxisRange ryA = policy.axisRange(aVectors, yAxis, "A");
CanonicalGridPolicy.AxisRange rxB = policy.axisRange(bVectors, xAxis, "B");
CanonicalGridPolicy.AxisRange ryB = policy.axisRange(bVectors, yAxis, "B");
- g.setMinX(Math.min(rxA.min, rxB.min));
- g.setMaxX(Math.max(rxA.max, rxB.max));
- g.setMinY(Math.min(ryA.min, ryB.min));
- g.setMaxY(Math.max(ryA.max, ryB.max));
+ g.setMinX(Math.min(rxA.min(), rxB.min()));
+ g.setMaxX(Math.max(rxA.max(), rxB.max()));
+ g.setMinY(Math.min(ryA.min(), ryB.min()));
+ g.setMaxY(Math.max(ryA.max(), ryB.max()));
}
case CANONICAL_BY_FEATURE -> {
// Use the named policy, but union A/B axis ranges to avoid clipping one cohort.
@@ -223,10 +193,10 @@ private static GridSpec buildAlignedGrid(List aVectors,
CanonicalGridPolicy.AxisRange ryA = policy.axisRange(aVectors, yAxis, "A");
CanonicalGridPolicy.AxisRange rxB = policy.axisRange(bVectors, xAxis, "B");
CanonicalGridPolicy.AxisRange ryB = policy.axisRange(bVectors, yAxis, "B");
- g.setMinX(Math.min(rxA.min, rxB.min));
- g.setMaxX(Math.max(rxA.max, rxB.max));
- g.setMinY(Math.min(ryA.min, ryB.min));
- g.setMaxY(Math.max(ryA.max, ryB.max));
+ g.setMinX(Math.min(rxA.min(), rxB.min()));
+ g.setMaxX(Math.max(rxA.max(), rxB.max()));
+ g.setMinY(Math.min(ryA.min(), ryB.min()));
+ g.setMaxY(Math.max(ryA.max(), ryB.max()));
}
}
return g;
diff --git a/src/main/java/edu/jhuapl/trinity/utils/statistics/CanonicalGridPolicy.java b/src/main/java/edu/jhuapl/trinity/utils/statistics/CanonicalGridPolicy.java
index 67434a04..5405d7d2 100644
--- a/src/main/java/edu/jhuapl/trinity/utils/statistics/CanonicalGridPolicy.java
+++ b/src/main/java/edu/jhuapl/trinity/utils/statistics/CanonicalGridPolicy.java
@@ -53,69 +53,27 @@ public enum Mode {
/**
* AxisKey identifies the semantic axis (ScalarType + metric/component/ref hints).
* This lets you set per-axis canonical overrides and cache computed ranges.
+ *
+ * @param metricName for METRIC_DISTANCE_TO_MEAN
+ * @param componentIndex for COMPONENT_AT_DIMENSION
+ * @param label optional display tag
*/
- public static final class AxisKey implements Serializable {
- @Serial
- private static final long serialVersionUID = 1L;
-
- public final StatisticEngine.ScalarType type;
- public final String metricName; // for METRIC_DISTANCE_TO_MEAN
- public final Integer componentIndex;// for COMPONENT_AT_DIMENSION
- public final String label; // optional display tag
-
- public AxisKey(StatisticEngine.ScalarType type, String metricName, Integer componentIndex, String label) {
- this.type = Objects.requireNonNull(type, "type");
- this.metricName = metricName;
- this.componentIndex = componentIndex;
- this.label = label;
+ public record AxisKey(StatisticEngine.ScalarType type, String metricName, Integer componentIndex, String label) implements Serializable {
+
+ public AxisKey {
+ Objects.requireNonNull(type);
}
public static AxisKey from(AxisParams a) {
return new AxisKey(a.getType(), a.getMetricName(), a.getComponentIndex(), a.getMetricName());
}
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (!(o instanceof AxisKey)) return false;
- AxisKey that = (AxisKey) o;
- return type == that.type &&
- Objects.equals(metricName, that.metricName) &&
- Objects.equals(componentIndex, that.componentIndex) &&
- Objects.equals(label, that.label);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(type, metricName, componentIndex, label);
- }
-
- @Override
- public String toString() {
- return "AxisKey{" +
- "type=" + type +
- ", metricName='" + metricName + '\'' +
- ", componentIndex=" + componentIndex +
- ", label='" + label + '\'' +
- '}';
- }
}
/**
* Per-axis explicit override (any field nullable = leave to policy).
*/
- public static final class AxisOverride implements Serializable {
- @Serial
- private static final long serialVersionUID = 1L;
- public final Double min;
- public final Double max;
- public final Integer bins;
-
- public AxisOverride(Double min, Double max, Integer bins) {
- this.min = min;
- this.max = max;
- this.bins = bins;
- }
+ public record AxisOverride(Double min, Double max, Integer bins) implements Serializable {
public AxisOverride withBins(Integer b) {
return new AxisOverride(min, max, b);
@@ -125,20 +83,8 @@ public AxisOverride withBins(Integer b) {
/**
* Simple holder for numeric range.
*/
- public static final class AxisRange implements Serializable {
- @Serial
- private static final long serialVersionUID = 1L;
- public final double min, max;
-
- public AxisRange(double min, double max) {
- this.min = min;
- this.max = max;
- }
+ public record AxisRange(double min, double max) implements Serializable {
- @Override
- public String toString() {
- return "[" + min + ", " + max + "]";
- }
}
// ---------- Policy fields ----------
diff --git a/src/main/java/edu/jhuapl/trinity/utils/statistics/DensityCache.java b/src/main/java/edu/jhuapl/trinity/utils/statistics/DensityCache.java
index bd030686..b6677b5d 100644
--- a/src/main/java/edu/jhuapl/trinity/utils/statistics/DensityCache.java
+++ b/src/main/java/edu/jhuapl/trinity/utils/statistics/DensityCache.java
@@ -89,19 +89,10 @@ public DensityCache build() {
/**
* Internal entry.
+ *
+ * @param provenance optional; may be null
*/
- private static final class Entry implements Serializable {
- @Serial
- private static final long serialVersionUID = 1L;
- final GridDensityResult result;
- final long createdAt;
- final JpdfProvenance provenance; // optional; may be null
-
- Entry(GridDensityResult r, long t, JpdfProvenance p) {
- this.result = r;
- this.createdAt = t;
- this.provenance = p;
- }
+ private record Entry(GridDensityResult result, long createdAt, JpdfProvenance provenance) implements Serializable {
}
private final int maxEntries;
@@ -374,10 +365,10 @@ private static String axisKey(AxisParams a) {
StringBuilder sb = new StringBuilder(64);
sb.append(a.getType());
if (a.getType() == StatisticEngine.ScalarType.METRIC_DISTANCE_TO_MEAN) {
- sb.append(":metric=").append(String.valueOf(a.getMetricName()));
+ sb.append(":metric=").append(a.getMetricName());
sb.append(":ref=").append(vecHash(a.getReferenceVec()));
} else if (a.getType() == StatisticEngine.ScalarType.COMPONENT_AT_DIMENSION) {
- sb.append(":comp=").append(String.valueOf(a.getComponentIndex()));
+ sb.append(":comp=").append(a.getComponentIndex());
}
String lbl = a.getMetricName();
if (lbl != null && !lbl.isBlank()) sb.append(":lbl=").append(lbl);
diff --git a/src/main/java/edu/jhuapl/trinity/utils/statistics/DivergenceComputer.java b/src/main/java/edu/jhuapl/trinity/utils/statistics/DivergenceComputer.java
index c5de2601..cb4d8ef2 100644
--- a/src/main/java/edu/jhuapl/trinity/utils/statistics/DivergenceComputer.java
+++ b/src/main/java/edu/jhuapl/trinity/utils/statistics/DivergenceComputer.java
@@ -2,7 +2,6 @@
import edu.jhuapl.trinity.data.messages.xai.FeatureVector;
-import java.io.Serial;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
@@ -60,78 +59,19 @@ public enum DivergenceMetric {
/**
* Output bundle for a single divergence computation.
+ *
+ * @param matrix Symmetric divergence matrix (F x F).
+ * @param quality Optional quality matrix (F x F), e.g., min(coverageA, coverageB) fraction in [0,1].
+ * @param metric Chosen divergence metric.
+ * @param componentIndices Selected component indices (length F).
+ * @param labels Human-friendly labels "Comp i", length F.
+ * @param binsX Binning used for X and Y (from recipe).
+ * @param boundsPolicy Bounds policy applied (from recipe).
+ * @param canonicalPolicyId Canonical policy id (when boundsPolicy == CANONICAL_BY_FEATURE).
+ * @param cacheEnabled Whether cache was allowed (recipe-level flag; not a guarantee of hits).
*/
- public static final class DivergenceResult implements Serializable {
- @Serial
- private static final long serialVersionUID = 1L;
-
- /**
- * Symmetric divergence matrix (F x F).
- */
- public final double[][] matrix;
-
- /**
- * Optional quality matrix (F x F), e.g., min(coverageA, coverageB) fraction in [0,1].
- */
- public final double[][] quality;
-
- /**
- * Chosen divergence metric.
- */
- public final DivergenceMetric metric;
-
- /**
- * Selected component indices (length F).
- */
- public final int[] componentIndices;
-
- /**
- * Human-friendly labels "Comp i", length F.
- */
- public final List labels;
-
- /**
- * Binning used for X and Y (from recipe).
- */
- public final int binsX;
- public final int binsY;
-
- /**
- * Bounds policy applied (from recipe).
- */
- public final JpdfRecipe.BoundsPolicy boundsPolicy;
-
- /**
- * Canonical policy id (when boundsPolicy == CANONICAL_BY_FEATURE).
- */
- public final String canonicalPolicyId;
-
- /**
- * Whether cache was allowed (recipe-level flag; not a guarantee of hits).
- */
- public final boolean cacheEnabled;
-
- public DivergenceResult(double[][] matrix,
- double[][] quality,
- DivergenceMetric metric,
- int[] componentIndices,
- List labels,
- int binsX,
- int binsY,
- JpdfRecipe.BoundsPolicy boundsPolicy,
- String canonicalPolicyId,
- boolean cacheEnabled) {
- this.matrix = matrix;
- this.quality = quality;
- this.metric = metric;
- this.componentIndices = componentIndices;
- this.labels = labels;
- this.binsX = binsX;
- this.binsY = binsY;
- this.boundsPolicy = boundsPolicy;
- this.canonicalPolicyId = canonicalPolicyId;
- this.cacheEnabled = cacheEnabled;
- }
+ public record DivergenceResult(double[][] matrix, double[][] quality, DivergenceMetric metric, int[] componentIndices, List labels, int binsX,
+ int binsY, JpdfRecipe.BoundsPolicy boundsPolicy, String canonicalPolicyId, boolean cacheEnabled) implements Serializable {
}
private DivergenceComputer() {
@@ -262,8 +202,8 @@ public static DivergenceResult computeForComponents(
);
// Convert PDFs to mass distributions (flatten)
- MassVec pa = toMass(ab.a);
- MassVec pb = toMass(ab.b);
+ MassVec pa = toMass(ab.a());
+ MassVec pb = toMass(ab.b());
// Normalize (guard if sums deviate from 1 by numeric noise)
normalizeInPlace(pa.values);
@@ -319,11 +259,11 @@ public static DivergenceResult computeForComponents(
* Flatten pdf grid to mass vector (z * dx * dy).
*/
private static MassVec toMass(GridDensityResult r) {
- double[][] pdf = r.getPdfZ();
+ double[][] pdf = r.pdfZ();
int by = pdf.length;
int bx = (by == 0) ? 0 : pdf[0].length;
double[] out = new double[bx * by];
- double w = r.getDx() * r.getDy();
+ double w = r.dx() * r.dy();
int k = 0;
for (int y = 0; y < by; y++) {
double[] row = pdf[y];
@@ -335,12 +275,7 @@ private static MassVec toMass(GridDensityResult r) {
return new MassVec(out);
}
- private static final class MassVec {
- final double[] values;
-
- MassVec(double[] v) {
- this.values = v;
- }
+ private record MassVec(double[] values) {
}
/**
diff --git a/src/main/java/edu/jhuapl/trinity/utils/statistics/FeatureSimilarityComputer.java b/src/main/java/edu/jhuapl/trinity/utils/statistics/FeatureSimilarityComputer.java
index bef0caf6..e60cde8c 100644
--- a/src/main/java/edu/jhuapl/trinity/utils/statistics/FeatureSimilarityComputer.java
+++ b/src/main/java/edu/jhuapl/trinity/utils/statistics/FeatureSimilarityComputer.java
@@ -2,7 +2,6 @@
import edu.jhuapl.trinity.data.messages.xai.FeatureVector;
-import java.io.Serial;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
@@ -46,75 +45,28 @@ public enum SimilarityMetric {
/**
* Result bundle for a single cohort.
+ *
+ * @param sim Similarity matrix, size N x N. May contain NaN where insufficient.
+ * @param sufficient True where the corresponding sim[i][j] passed the sufficiency guard.
+ * @param labels Display labels for each component (length N), e.g., "Comp 7".
+ * @param meta Metadata for auditing and UI badges.
*/
- public static final class Result implements Serializable {
- @Serial
- private static final long serialVersionUID = 1L;
-
- /**
- * Similarity matrix, size N x N. May contain NaN where insufficient.
- */
- public final double[][] sim;
-
- /**
- * True where the corresponding sim[i][j] passed the sufficiency guard.
- */
- public final boolean[][] sufficient;
-
- /**
- * Display labels for each component (length N), e.g., "Comp 7".
- */
- public final List labels;
-
- /**
- * Metadata for auditing and UI badges.
- */
- public final Meta meta;
-
- public Result(double[][] sim, boolean[][] sufficient, List labels, Meta meta) {
- this.sim = sim;
- this.sufficient = sufficient;
- this.labels = labels;
- this.meta = meta;
- }
+ public record Result(double[][] sim, boolean[][] sufficient, List labels, Meta meta) implements Serializable {
+
+
}
/**
* Metadata captured for the matrix computation.
+ *
+ * @param miBins for MI_LITE
+ * @param kendallMaxN for KENDALL sampling
+ * @param binsX for sufficiency guard
+ * @param binsY for sufficiency guard
*/
- public static final class Meta implements Serializable {
- @Serial
- private static final long serialVersionUID = 1L;
-
- public final int startIndex;
- public final int endIndex;
- public final long nSamples;
- public final SimilarityMetric metric;
- public final int miBins; // for MI_LITE
- public final int kendallMaxN; // for KENDALL sampling
- public final int binsX; // for sufficiency guard
- public final int binsY; // for sufficiency guard
- public final double minAvgCountPerCell;
-
- public Meta(int startIndex,
- int endIndex,
- long nSamples,
- SimilarityMetric metric,
- int miBins,
- int kendallMaxN,
- int binsX,
- int binsY,
- double minAvgCountPerCell) {
- this.startIndex = startIndex;
- this.endIndex = endIndex;
- this.nSamples = nSamples;
- this.metric = metric;
- this.miBins = miBins;
- this.kendallMaxN = kendallMaxN;
- this.binsX = binsX;
- this.binsY = binsY;
- this.minAvgCountPerCell = minAvgCountPerCell;
- }
+ public record Meta(int startIndex, int endIndex, long nSamples, SimilarityMetric metric, int miBins, int kendallMaxN, int binsX, int binsY,
+ double minAvgCountPerCell) implements Serializable {
+
}
private FeatureSimilarityComputer() {
diff --git a/src/main/java/edu/jhuapl/trinity/utils/statistics/GridDensityResult.java b/src/main/java/edu/jhuapl/trinity/utils/statistics/GridDensityResult.java
index d04a9fe1..0e1b6133 100644
--- a/src/main/java/edu/jhuapl/trinity/utils/statistics/GridDensityResult.java
+++ b/src/main/java/edu/jhuapl/trinity/utils/statistics/GridDensityResult.java
@@ -14,67 +14,16 @@
*
* Designed for use in Trinity’s 3D Hypersurface renderer.
*
+ * @param pdfZ size binsY x binsX (row-major: y, then x)
+ * @param cdfZ same shape, cumulative in +x and +y
+ * @param xEdges length binsX+1
+ * @param yEdges length binsY+1
+ * @param xCenters length binsX
+ * @param yCenters length binsY
* @author Sean Phillips
*/
-public final class GridDensityResult {
- private final double[][] pdfZ; // size binsY x binsX (row-major: y, then x)
- private final double[][] cdfZ; // same shape, cumulative in +x and +y
- private final double[] xEdges; // length binsX+1
- private final double[] yEdges; // length binsY+1
- private final double[] xCenters; // length binsX
- private final double[] yCenters; // length binsY
- private final double dx;
- private final double dy;
-
- public GridDensityResult(double[][] pdfZ,
- double[][] cdfZ,
- double[] xEdges,
- double[] yEdges,
- double[] xCenters,
- double[] yCenters,
- double dx,
- double dy) {
- this.pdfZ = pdfZ;
- this.cdfZ = cdfZ;
- this.xEdges = xEdges;
- this.yEdges = yEdges;
- this.xCenters = xCenters;
- this.yCenters = yCenters;
- this.dx = dx;
- this.dy = dy;
- }
-
- public double[][] getPdfZ() {
- return pdfZ;
- }
-
- public double[][] getCdfZ() {
- return cdfZ;
- }
-
- public double[] getxEdges() {
- return xEdges;
- }
-
- public double[] getyEdges() {
- return yEdges;
- }
-
- public double[] getxCenters() {
- return xCenters;
- }
-
- public double[] getyCenters() {
- return yCenters;
- }
-
- public double getDx() {
- return dx;
- }
-
- public double getDy() {
- return dy;
- }
+public record GridDensityResult(double[][] pdfZ, double[][] cdfZ, double[] xEdges, double[] yEdges, double[] xCenters, double[] yCenters, double dx,
+ double dy) {
/**
* Convert PDF grid to List> (row-major).
diff --git a/src/main/java/edu/jhuapl/trinity/utils/statistics/JpdfBatchEngine.java b/src/main/java/edu/jhuapl/trinity/utils/statistics/JpdfBatchEngine.java
index 6d75d01e..86b84ec8 100644
--- a/src/main/java/edu/jhuapl/trinity/utils/statistics/JpdfBatchEngine.java
+++ b/src/main/java/edu/jhuapl/trinity/utils/statistics/JpdfBatchEngine.java
@@ -2,7 +2,6 @@
import edu.jhuapl.trinity.data.messages.xai.FeatureVector;
-import java.io.Serial;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
@@ -43,81 +42,25 @@ public JpdfBatchEngine() {
/**
* Per-pair output bundle.
+ *
+ * @param i component index for X (or -1 if not component-mode)
+ * @param j component index for Y (or -1 if not component-mode)
+ * @param rank may be null in whitelist mode
+ * @param provenance may be null if cache doesn't store it
*/
- public static final class PairJobResult implements Serializable {
- @Serial
- private static final long serialVersionUID = 1L;
-
- public final int i; // component index for X (or -1 if not component-mode)
- public final int j; // component index for Y (or -1 if not component-mode)
- public final AxisParams xAxis;
- public final AxisParams yAxis;
- public final GridSpec grid;
- public final GridDensityResult density;
- public final PairScorer.PairScore rank; // may be null in whitelist mode
- public final boolean fromCache;
- public final long computeMillis;
- public final JpdfProvenance provenance; // may be null if cache doesn't store it
-
- public PairJobResult(int i,
- int j,
- AxisParams xAxis,
- AxisParams yAxis,
- GridSpec grid,
- GridDensityResult density,
- PairScorer.PairScore rank,
- boolean fromCache,
- long computeMillis,
- JpdfProvenance provenance) {
- this.i = i;
- this.j = j;
- this.xAxis = xAxis;
- this.yAxis = yAxis;
- this.grid = grid;
- this.density = density;
- this.rank = rank;
- this.fromCache = fromCache;
- this.computeMillis = computeMillis;
- this.provenance = provenance;
- }
+ public record PairJobResult(int i, int j, AxisParams xAxis, AxisParams yAxis, GridSpec grid, GridDensityResult density, PairScorer.PairScore rank,
+ boolean fromCache, long computeMillis, JpdfProvenance provenance) implements Serializable {
+
+
}
/**
* Batch summary + outputs.
*/
- public static final class BatchResult implements Serializable {
- @Serial
- private static final long serialVersionUID = 1L;
-
- public final String datasetFingerprint;
- public final String recipeName;
- public final String policyId;
- public final List jobs;
- public final long wallMillis;
- public final int submittedPairs;
- public final int computedPairs;
- public final int cacheHits;
- public final DensityCache.Stats cacheStatsSnapshot;
-
- public BatchResult(String datasetFingerprint,
- String recipeName,
- String policyId,
- List jobs,
- long wallMillis,
- int submittedPairs,
- int computedPairs,
- int cacheHits,
- DensityCache.Stats cacheStatsSnapshot) {
- this.datasetFingerprint = datasetFingerprint;
- this.recipeName = recipeName;
- this.policyId = policyId;
- this.jobs = jobs;
- this.wallMillis = wallMillis;
- this.submittedPairs = submittedPairs;
- this.computedPairs = computedPairs;
- this.cacheHits = cacheHits;
- this.cacheStatsSnapshot = cacheStatsSnapshot;
- }
+ public record BatchResult(String datasetFingerprint, String recipeName, String policyId, List jobs, long wallMillis, int submittedPairs,
+ int computedPairs, int cacheHits, DensityCache.Stats cacheStatsSnapshot) implements Serializable {
+
+
}
// =====================================================================================
@@ -181,7 +124,7 @@ public static BatchResult runComponentPairs(List vectors,
case THRESHOLD_BY_SCORE -> {
List out = new ArrayList<>();
for (PairScorer.PairScore ps : candidates) {
- if (ps.score >= recipe.getScoreThreshold() && ps.sufficient) {
+ if (ps.score() >= recipe.getScoreThreshold() && ps.sufficient()) {
out.add(ps);
}
}
@@ -203,11 +146,11 @@ public static BatchResult runComponentPairs(List vectors,
for (PairScorer.PairScore ps : selected) {
AxisParams x = new AxisParams();
x.setType(StatisticEngine.ScalarType.COMPONENT_AT_DIMENSION);
- x.setComponentIndex(ps.i);
+ x.setComponentIndex(ps.i());
AxisParams y = new AxisParams();
y.setType(StatisticEngine.ScalarType.COMPONENT_AT_DIMENSION);
- y.setComponentIndex(ps.j);
+ y.setComponentIndex(ps.j());
GridSpec grid = resolveGrid(vectors, x, y, recipe, canonicalPolicy, dsFp);
ecs.submit(new ComputeTask(vectors, x, y, grid, ps, recipe, cache, dsFp));
@@ -238,7 +181,7 @@ public static BatchResult runComponentPairs(List vectors,
pool.shutdown();
}
- out.sort(Comparator.comparingDouble(o -> o.rank != null ? -o.rank.score : 0.0));
+ out.sort(Comparator.comparingDouble(o -> o.rank != null ? -o.rank.score() : 0.0));
long wall = System.currentTimeMillis() - t0;
return new BatchResult(dsFp, recipe.getName(), canonicalPolicy.id(),
@@ -328,33 +271,8 @@ public static BatchResult runWhitelistPairs(List vectors,
// Worker
// =====================================================================================
- private static final class ComputeTask implements Callable {
- private final List vectors;
- private final AxisParams x;
- private final AxisParams y;
- private final GridSpec grid;
- private final PairScorer.PairScore rank;
- private final JpdfRecipe recipe;
- private final DensityCache cache;
- private final String datasetFp;
-
- ComputeTask(List vectors,
- AxisParams x,
- AxisParams y,
- GridSpec grid,
- PairScorer.PairScore rank,
- JpdfRecipe recipe,
- DensityCache cache,
- String datasetFp) {
- this.vectors = vectors;
- this.x = x;
- this.y = y;
- this.grid = grid;
- this.rank = rank;
- this.recipe = recipe;
- this.cache = cache;
- this.datasetFp = datasetFp;
- }
+ private record ComputeTask(List vectors, AxisParams x, AxisParams y, GridSpec grid, PairScorer.PairScore rank, JpdfRecipe recipe,
+ DensityCache cache, String datasetFp) implements Callable {
@Override
public PairJobResult call() {
diff --git a/src/main/java/edu/jhuapl/trinity/utils/statistics/JpdfProvenance.java b/src/main/java/edu/jhuapl/trinity/utils/statistics/JpdfProvenance.java
index abe614f3..dc8e7eb4 100644
--- a/src/main/java/edu/jhuapl/trinity/utils/statistics/JpdfProvenance.java
+++ b/src/main/java/edu/jhuapl/trinity/utils/statistics/JpdfProvenance.java
@@ -66,273 +66,62 @@ public enum BoundsPolicy {
/**
* Summary of a single axis' semantic definition.
+ *
+ * @param metricName for METRIC_DISTANCE_TO_MEAN
+ * @param componentIndex for COMPONENT_AT_DIMENSION
+ * @param referenceIndex when VECTOR_AT_INDEX
+ * @param label optional display label
*/
- public static final class AxisSummary implements Serializable {
- @Serial
- private static final long serialVersionUID = 1L;
+ public record AxisSummary(StatisticEngine.ScalarType scalarType, String metricName, Integer componentIndex, ReferenceKind referenceKind,
+ Integer referenceIndex, String label) implements Serializable {
public enum ReferenceKind {NONE, MEAN, VECTOR_AT_INDEX, CUSTOM}
- private final StatisticEngine.ScalarType scalarType;
- private final String metricName; // for METRIC_DISTANCE_TO_MEAN
- private final Integer componentIndex; // for COMPONENT_AT_DIMENSION
- private final ReferenceKind referenceKind;
- private final Integer referenceIndex; // when VECTOR_AT_INDEX
- private final String label; // optional display label
-
- public AxisSummary(StatisticEngine.ScalarType scalarType,
- String metricName,
- Integer componentIndex,
- ReferenceKind referenceKind,
- Integer referenceIndex,
- String label) {
- this.scalarType = Objects.requireNonNull(scalarType, "scalarType");
- this.metricName = metricName;
- this.componentIndex = componentIndex;
- this.referenceKind = referenceKind == null ? ReferenceKind.NONE : referenceKind;
- this.referenceIndex = referenceIndex;
- this.label = label;
+ public AxisSummary {
+ Objects.requireNonNull(scalarType);
+ referenceKind = referenceKind == null ? ReferenceKind.NONE : referenceKind;
}
- public StatisticEngine.ScalarType scalarType() {
- return scalarType;
- }
-
- public String metricName() {
- return metricName;
- }
-
- public Integer componentIndex() {
- return componentIndex;
- }
-
- public ReferenceKind referenceKind() {
- return referenceKind;
- }
-
- public Integer referenceIndex() {
- return referenceIndex;
- }
-
- public String label() {
- return label;
- }
-
- @Override
- public String toString() {
- return "AxisSummary{" +
- "scalarType=" + scalarType +
- ", metricName='" + metricName + '\'' +
- ", componentIndex=" + componentIndex +
- ", referenceKind=" + referenceKind +
- ", referenceIndex=" + referenceIndex +
- ", label='" + label + '\'' +
- '}';
- }
}
/**
* Canonical grid & bounds.
+ *
+ * @param canonicalPolicyId when CANONICAL_BY_FEATURE
*/
- public static final class GridSummary implements Serializable {
- @Serial
- private static final long serialVersionUID = 1L;
-
- private final int binsX, binsY;
- private final double minX, maxX, minY, maxY;
- private final double dx, dy;
- private final BoundsPolicy boundsPolicy;
- private final String canonicalPolicyId; // when CANONICAL_BY_FEATURE
-
- public GridSummary(int binsX, int binsY,
- double minX, double maxX, double minY, double maxY,
- double dx, double dy,
- BoundsPolicy boundsPolicy,
- String canonicalPolicyId) {
- this.binsX = binsX;
- this.binsY = binsY;
- this.minX = minX;
- this.maxX = maxX;
- this.minY = minY;
- this.maxY = maxY;
- this.dx = dx;
- this.dy = dy;
- this.boundsPolicy = boundsPolicy == null ? BoundsPolicy.DATA_MIN_MAX : boundsPolicy;
- this.canonicalPolicyId = canonicalPolicyId;
- }
-
- public int binsX() {
- return binsX;
- }
-
- public int binsY() {
- return binsY;
- }
-
- public double minX() {
- return minX;
- }
-
- public double maxX() {
- return maxX;
- }
-
- public double minY() {
- return minY;
- }
-
- public double maxY() {
- return maxY;
- }
-
- public double dx() {
- return dx;
- }
-
- public double dy() {
- return dy;
- }
+ public record GridSummary(int binsX, int binsY, double minX, double maxX, double minY, double maxY, double dx, double dy, BoundsPolicy boundsPolicy,
+ String canonicalPolicyId) implements Serializable {
- public BoundsPolicy boundsPolicy() {
- return boundsPolicy;
+ public GridSummary {
+ boundsPolicy = boundsPolicy == null ? BoundsPolicy.DATA_MIN_MAX : boundsPolicy;
}
- public String canonicalPolicyId() {
- return canonicalPolicyId;
- }
-
- @Override
- public String toString() {
- return "GridSummary{" +
- "binsX=" + binsX +
- ", binsY=" + binsY +
- ", minX=" + minX +
- ", maxX=" + maxX +
- ", minY=" + minY +
- ", maxY=" + maxY +
- ", dx=" + dx +
- ", dy=" + dy +
- ", boundsPolicy=" + boundsPolicy +
- ", canonicalPolicyId='" + canonicalPolicyId + '\'' +
- '}';
- }
}
/**
* Data/quality/selection details useful for auditing & UI badges.
+ *
+ * @param nSamples number of (x,y) pairs used
+ * @param minAvgCountPerCell guard from recipe
+ * @param sufficiencyPass N/(bx*by) >= minAvgCountPerCell
+ * @param selectionScore preselection score for this pair (nullable)
+ * @param selectionRank rank among candidates (nullable)
*/
- public static final class DataSummary implements Serializable {
- @Serial
- private static final long serialVersionUID = 1L;
-
- private final long nSamples; // number of (x,y) pairs used
- private final double minAvgCountPerCell; // guard from recipe
- private final boolean sufficiencyPass; // N/(bx*by) >= minAvgCountPerCell
- private final JpdfRecipe.ScoreMetric scoreMetric;
- private final Double selectionScore; // preselection score for this pair (nullable)
- private final Integer selectionRank; // rank among candidates (nullable)
-
- public DataSummary(long nSamples,
- double minAvgCountPerCell,
- boolean sufficiencyPass,
- JpdfRecipe.ScoreMetric scoreMetric,
- Double selectionScore,
- Integer selectionRank) {
- this.nSamples = nSamples;
- this.minAvgCountPerCell = minAvgCountPerCell;
- this.sufficiencyPass = sufficiencyPass;
- this.scoreMetric = scoreMetric;
- this.selectionScore = selectionScore;
- this.selectionRank = selectionRank;
- }
-
- public long nSamples() {
- return nSamples;
- }
-
- public double minAvgCountPerCell() {
- return minAvgCountPerCell;
- }
+ public record DataSummary(long nSamples, double minAvgCountPerCell, boolean sufficiencyPass, JpdfRecipe.ScoreMetric scoreMetric, Double selectionScore,
+ Integer selectionRank) implements Serializable {
- public boolean sufficiencyPass() {
- return sufficiencyPass;
- }
-
- public JpdfRecipe.ScoreMetric scoreMetric() {
- return scoreMetric;
- }
-
- public Double selectionScore() {
- return selectionScore;
- }
-
- public Integer selectionRank() {
- return selectionRank;
- }
-
- @Override
- public String toString() {
- return "DataSummary{" +
- "nSamples=" + nSamples +
- ", minAvgCountPerCell=" + minAvgCountPerCell +
- ", sufficiencyPass=" + sufficiencyPass +
- ", scoreMetric=" + scoreMetric +
- ", selectionScore=" + selectionScore +
- ", selectionRank=" + selectionRank +
- '}';
- }
}
/**
* Numeric hygiene checks for the produced surface.
+ *
+ * @param pdfMass sum(pdf)*dx*dy (≈1 for PDFs)
+ * @param cdfTerminal cdf[bY-1][bX-1] (≈1 for CDFs)
+ * @param cdfMonotoneXY true if monotone in +x and +y
+ * @param maxZ value range
*/
- public static final class NumericChecks implements Serializable {
- @Serial
- private static final long serialVersionUID = 1L;
-
- private final Double pdfMass; // sum(pdf)*dx*dy (≈1 for PDFs)
- private final Double cdfTerminal; // cdf[bY-1][bX-1] (≈1 for CDFs)
- private final Boolean cdfMonotoneXY; // true if monotone in +x and +y
- private final Double minZ, maxZ; // value range
-
- public NumericChecks(Double pdfMass, Double cdfTerminal, Boolean cdfMonotoneXY, Double minZ, Double maxZ) {
- this.pdfMass = pdfMass;
- this.cdfTerminal = cdfTerminal;
- this.cdfMonotoneXY = cdfMonotoneXY;
- this.minZ = minZ;
- this.maxZ = maxZ;
- }
-
- public Double pdfMass() {
- return pdfMass;
- }
-
- public Double cdfTerminal() {
- return cdfTerminal;
- }
+ public record NumericChecks(Double pdfMass, Double cdfTerminal, Boolean cdfMonotoneXY, Double minZ, Double maxZ) implements Serializable {
- public Boolean cdfMonotoneXY() {
- return cdfMonotoneXY;
- }
-
- public Double minZ() {
- return minZ;
- }
-
- public Double maxZ() {
- return maxZ;
- }
-
- @Override
- public String toString() {
- return "NumericChecks{" +
- "pdfMass=" + pdfMass +
- ", cdfTerminal=" + cdfTerminal +
- ", cdfMonotoneXY=" + cdfMonotoneXY +
- ", minZ=" + minZ +
- ", maxZ=" + maxZ +
- '}';
- }
}
// ---------- Immutable fields ----------
diff --git a/src/main/java/edu/jhuapl/trinity/utils/statistics/JpdfRecipe.java b/src/main/java/edu/jhuapl/trinity/utils/statistics/JpdfRecipe.java
index 9f20b402..40f5ba08 100644
--- a/src/main/java/edu/jhuapl/trinity/utils/statistics/JpdfRecipe.java
+++ b/src/main/java/edu/jhuapl/trinity/utils/statistics/JpdfRecipe.java
@@ -102,23 +102,10 @@ public enum BoundsPolicy {
* AxisPair wraps the axis definitions used by GridDensity3DEngine.
* In whitelist mode, each pair defines (X axis, Y axis) explicitly.
*/
- public static final class AxisPair implements Serializable {
- @Serial
- private static final long serialVersionUID = 1L;
- private final AxisParams xAxis;
- private final AxisParams yAxis;
-
- public AxisPair(AxisParams xAxis, AxisParams yAxis) {
- this.xAxis = Objects.requireNonNull(xAxis, "xAxis");
- this.yAxis = Objects.requireNonNull(yAxis, "yAxis");
- }
-
- public AxisParams xAxis() {
- return xAxis;
- }
-
- public AxisParams yAxis() {
- return yAxis;
+ public record AxisPair(AxisParams xAxis, AxisParams yAxis) implements Serializable {
+ public AxisPair {
+ Objects.requireNonNull(xAxis);
+ Objects.requireNonNull(yAxis);
}
}
diff --git a/src/main/java/edu/jhuapl/trinity/utils/statistics/PairGridPane.java b/src/main/java/edu/jhuapl/trinity/utils/statistics/PairGridPane.java
index a84374e4..aa1089a7 100644
--- a/src/main/java/edu/jhuapl/trinity/utils/statistics/PairGridPane.java
+++ b/src/main/java/edu/jhuapl/trinity/utils/statistics/PairGridPane.java
@@ -222,13 +222,7 @@ public CellClick(int index, PairItem item) {
/**
* Range struct for global/fixed usage.
*/
- public static final class Range {
- public final double vmin, vmax;
-
- public Range(double vmin, double vmax) {
- this.vmin = vmin;
- this.vmax = vmax;
- }
+ public record Range(double vmin, double vmax) {
}
public enum RangeMode {AUTO, GLOBAL, FIXED}
@@ -284,14 +278,7 @@ private static final class DisplayState {
private Range globalRange = null;
// Optional export hook
- public static final class ExportRequest {
- public final PairItem item;
- public final WritableImage image;
-
- public ExportRequest(PairItem item, WritableImage image) {
- this.item = item;
- this.image = image;
- }
+ public record ExportRequest(PairItem item, WritableImage image) {
}
private Consumer onExportRequest;
diff --git a/src/main/java/edu/jhuapl/trinity/utils/statistics/PairGridRecord.java b/src/main/java/edu/jhuapl/trinity/utils/statistics/PairGridRecord.java
index 06ec7050..fb045bb7 100644
--- a/src/main/java/edu/jhuapl/trinity/utils/statistics/PairGridRecord.java
+++ b/src/main/java/edu/jhuapl/trinity/utils/statistics/PairGridRecord.java
@@ -167,30 +167,30 @@ public static Triple fromAb(ABCo
String labelB,
String labelDiff) {
Objects.requireNonNull(ab, "ab");
- GridSpec grid = ab.grid;
+ GridSpec grid = ab.grid();
PairGridRecord a = fromSingle(
- xAxis, yAxis, grid, ab.a, ok,
- ab.pdfProvA, ab.cdfProvA, labelA
+ xAxis, yAxis, grid, ab.a(), ok,
+ ab.pdfProvA(), ab.cdfProvA(), labelA
);
PairGridRecord b = fromSingle(
- xAxis, yAxis, grid, ab.b, ok,
- ab.pdfProvB, ab.cdfProvB, labelB
+ xAxis, yAxis, grid, ab.b(), ok,
+ ab.pdfProvB(), ab.cdfProvB(), labelB
);
PairGridRecord diff = null;
boolean needPdf = ok == JpdfRecipe.OutputKind.PDF_ONLY || ok == JpdfRecipe.OutputKind.PDF_AND_CDF;
boolean needCdf = ok == JpdfRecipe.OutputKind.CDF_ONLY || ok == JpdfRecipe.OutputKind.PDF_AND_CDF;
- List> pdf = needPdf ? safeCopy2D(ab.pdfDiff) : null;
- List> cdf = needCdf ? safeCopy2D(ab.cdfDiff) : null;
+ List> pdf = needPdf ? safeCopy2D(ab.pdfDiff()) : null;
+ List> cdf = needCdf ? safeCopy2D(ab.cdfDiff()) : null;
if ((pdf != null) || (cdf != null)) {
diff = PairGridRecord.newBuilder(xAxis, yAxis, grid)
.pdf(pdf)
.cdf(cdf)
- .pdfProvenance(ab.pdfProvDiff)
- .cdfProvenance(ab.cdfProvDiff)
+ .pdfProvenance(ab.pdfProvDiff())
+ .cdfProvenance(ab.cdfProvDiff())
.label(labelDiff)
.build();
}
@@ -244,17 +244,6 @@ private static List> safeCopy2D(List> src) {
/**
* Tiny generic triple carrier (kept local to avoid extra dependencies).
*/
- public static final class Triple implements Serializable {
- @Serial
- private static final long serialVersionUID = 1L;
- public final A first;
- public final B second;
- public final C third;
-
- public Triple(A first, B second, C third) {
- this.first = first;
- this.second = second;
- this.third = third;
- }
+ public record Triple(A first, B second, C third) implements Serializable {
}
}
diff --git a/src/main/java/edu/jhuapl/trinity/utils/statistics/PairScorer.java b/src/main/java/edu/jhuapl/trinity/utils/statistics/PairScorer.java
index 5c282940..67080f8f 100644
--- a/src/main/java/edu/jhuapl/trinity/utils/statistics/PairScorer.java
+++ b/src/main/java/edu/jhuapl/trinity/utils/statistics/PairScorer.java
@@ -4,7 +4,6 @@
import edu.jhuapl.trinity.utils.AnalysisUtils;
import edu.jhuapl.trinity.utils.metric.Metric;
-import java.io.Serial;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
@@ -40,68 +39,36 @@ public final class PairScorer {
// ----------- Result type -----------
- public static final class PairScore implements Serializable, Comparable {
- @Serial
- private static final long serialVersionUID = 1L;
-
- /**
- * For component-mode: i and j are component indices. For axis-mode: both are -1.
- */
- public final int i;
- public final int j;
- public final double score; // normalized score used for ranking (>=0)
- public final long nSamples;
- public final boolean sufficient;
- public final String reason; // optional note (e.g., "low variance", "insufficient N")
-
- public PairScore(int i, int j, double score, long nSamples, boolean sufficient, String reason) {
- this.i = i;
- this.j = j;
- this.score = score;
- this.nSamples = nSamples;
- this.sufficient = sufficient;
- this.reason = reason;
- }
+ /**
+ * @param i For component-mode: i and j are component indices. For axis-mode: both are -1.
+ * @param score normalized score used for ranking (>=0)
+ * @param reason optional note (e.g., "low variance", "insufficient N")
+ */
+ public record PairScore(int i, int j, double score, long nSamples, boolean sufficient, String reason) implements Serializable, Comparable {
@Override
public int compareTo(PairScore o) {
return -Double.compare(this.score, o.score);
} // desc
- @Override
- public String toString() {
- return "PairScore{" +
- "i=" + i + ", j=" + j +
- ", score=" + score +
- ", n=" + nSamples +
- ", sufficient=" + sufficient +
- (reason != null ? (", reason='" + reason + '\'') : "") +
- '}';
- }
}
// ----------- Config -----------
- public static final class Config {
- public final JpdfRecipe.ScoreMetric metric;
- public final int miBins; // for MI-lite (equal-width)
- public final int maxKendallN; // downsample limit for Kendall
- public final Integer binsX; // for sufficiency flag (nullable)
- public final Integer binsY; // for sufficiency flag (nullable)
- public final double minAvgCountPerCell; // sufficiency threshold
-
- public Config(JpdfRecipe.ScoreMetric metric,
- int miBins,
- int maxKendallN,
- Integer binsX,
- Integer binsY,
- double minAvgCountPerCell) {
- this.metric = Objects.requireNonNull(metric);
- this.miBins = Math.max(4, miBins);
- this.maxKendallN = Math.max(50, maxKendallN);
- this.binsX = binsX;
- this.binsY = binsY;
- this.minAvgCountPerCell = Math.max(0.0, minAvgCountPerCell);
+ /**
+ * @param miBins for MI-lite (equal-width)
+ * @param maxKendallN downsample limit for Kendall
+ * @param binsX for sufficiency flag (nullable)
+ * @param binsY for sufficiency flag (nullable)
+ * @param minAvgCountPerCell sufficiency threshold
+ */
+ public record Config(JpdfRecipe.ScoreMetric metric, int miBins, int maxKendallN, Integer binsX, Integer binsY, double minAvgCountPerCell) {
+
+ public Config {
+ Objects.requireNonNull(metric);
+ miBins = Math.max(4, miBins);
+ maxKendallN = Math.max(50, maxKendallN);
+ minAvgCountPerCell = Math.max(0.0, minAvgCountPerCell);
}
public static Config defaultFor(JpdfRecipe.ScoreMetric metric, Integer binsX, Integer binsY, double minAvgPerCell) {
diff --git a/src/main/java/edu/jhuapl/trinity/utils/statistics/PairwiseMatrixEngine.java b/src/main/java/edu/jhuapl/trinity/utils/statistics/PairwiseMatrixEngine.java
index 5b5f8fb3..589f97c7 100644
--- a/src/main/java/edu/jhuapl/trinity/utils/statistics/PairwiseMatrixEngine.java
+++ b/src/main/java/edu/jhuapl/trinity/utils/statistics/PairwiseMatrixEngine.java
@@ -213,14 +213,14 @@ public static MatrixResult computeSimilarityMatrixForComponents(
// Populate from PairScorer results
for (PairScore ps : allScores) {
// Ignore pairs outside requested subset
- int iComp = ps.i;
- int jComp = ps.j;
+ int iComp = ps.i();
+ int jComp = ps.j();
int ai = indexOf(comps, iComp);
int aj = indexOf(comps, jComp);
if (ai < 0 || aj < 0) continue;
- double v = ps.score;
- double q = ps.sufficient ? 1.0 : 0.0;
+ double v = ps.score();
+ double q = ps.sufficient() ? 1.0 : 0.0;
// If scorer gave i==j (allowed when includeSelfPairs=true), it lands on the diagonal.
M[ai][aj] = v;
@@ -268,12 +268,12 @@ public static MatrixResult computeDivergenceMatrix(
);
// Labels/indices already computed by DivergenceComputer
- List labels = (dr.labels != null) ? dr.labels : buildDefaultLabels(dr.componentIndices);
+ List labels = (dr.labels() != null) ? dr.labels() : buildDefaultLabels(dr.componentIndices());
return MatrixResult.of(
- dr.matrix,
- dr.quality,
- dr.componentIndices,
+ dr.matrix(),
+ dr.quality(),
+ dr.componentIndices(),
labels,
legendForDivergence(metric),
"Divergence: " + metric.name()
diff --git a/src/main/java/edu/jhuapl/trinity/utils/statistics/SimilarityComputer.java b/src/main/java/edu/jhuapl/trinity/utils/statistics/SimilarityComputer.java
index e190659a..5e39e807 100644
--- a/src/main/java/edu/jhuapl/trinity/utils/statistics/SimilarityComputer.java
+++ b/src/main/java/edu/jhuapl/trinity/utils/statistics/SimilarityComputer.java
@@ -2,7 +2,6 @@
import edu.jhuapl.trinity.data.messages.xai.FeatureVector;
-import java.io.Serial;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
@@ -56,68 +55,19 @@ public enum Metric {
/**
* Output bundle for a single similarity computation.
+ *
+ * @param matrix Symmetric matrix (F x F). Diagonal is 1.0 when defined.
+ * @param quality Optional quality matrix (F x F), e.g., fraction of finite pairs used. In [0,1].
+ * @param metric Chosen metric.
+ * @param componentIndices Selected component indices (length F).
+ * @param labels Human-readable labels per feature (length F), e.g., "Comp 0", "Comp 1".
+ * @param nSamples Number of sample rows used per pair (ideally equals N unless NaNs encountered).
+ * @param nmiBins Effective bin count used by NMI (null when metric != NMI).
+ * @param minAvgCountPerCell Guard threshold from recipe (for FYI / UI badges).
*/
- public static final class SimilarityResult implements Serializable {
- @Serial
- private static final long serialVersionUID = 1L;
-
- /**
- * Symmetric matrix (F x F). Diagonal is 1.0 when defined.
- */
- public final double[][] matrix;
-
- /**
- * Optional quality matrix (F x F), e.g., fraction of finite pairs used. In [0,1].
- */
- public final double[][] quality;
-
- /**
- * Chosen metric.
- */
- public final Metric metric;
-
- /**
- * Selected component indices (length F).
- */
- public final int[] componentIndices;
+ public record SimilarityResult(double[][] matrix, double[][] quality, Metric metric, int[] componentIndices, List labels, int nSamples,
+ Integer nmiBins, double minAvgCountPerCell) implements Serializable {
- /**
- * Human-readable labels per feature (length F), e.g., "Comp 0", "Comp 1".
- */
- public final List labels;
-
- /**
- * Number of sample rows used per pair (ideally equals N unless NaNs encountered).
- */
- public final int nSamples;
-
- /**
- * Effective bin count used by NMI (null when metric != NMI).
- */
- public final Integer nmiBins;
-
- /**
- * Guard threshold from recipe (for FYI / UI badges).
- */
- public final double minAvgCountPerCell;
-
- public SimilarityResult(double[][] matrix,
- double[][] quality,
- Metric metric,
- int[] componentIndices,
- List labels,
- int nSamples,
- Integer nmiBins,
- double minAvgCountPerCell) {
- this.matrix = matrix;
- this.quality = quality;
- this.metric = metric;
- this.componentIndices = componentIndices;
- this.labels = labels;
- this.nSamples = nSamples;
- this.nmiBins = nmiBins;
- this.minAvgCountPerCell = minAvgCountPerCell;
- }
}
private SimilarityComputer() {
diff --git a/src/main/java/edu/jhuapl/trinity/utils/statistics/StatPdfCdfChart.java b/src/main/java/edu/jhuapl/trinity/utils/statistics/StatPdfCdfChart.java
index 5c88ec25..da529a71 100644
--- a/src/main/java/edu/jhuapl/trinity/utils/statistics/StatPdfCdfChart.java
+++ b/src/main/java/edu/jhuapl/trinity/utils/statistics/StatPdfCdfChart.java
@@ -45,24 +45,7 @@ public enum Mode {PDF_ONLY, CDF_ONLY}
//retain last stat and expose interactions
private StatisticResult lastStat = null;
- public static final class BinSelection {
- public final int bin;
- public final double xCenter;
- public final double xFrom, xTo;
- public final int count;
- public final double fraction;
- public final int[] sampleIdx;
-
- public BinSelection(int bin, double xCenter, double xFrom, double xTo,
- int count, double fraction, int[] sampleIdx) {
- this.bin = bin;
- this.xCenter = xCenter;
- this.xFrom = xFrom;
- this.xTo = xTo;
- this.count = count;
- this.fraction = fraction;
- this.sampleIdx = sampleIdx;
- }
+ public record BinSelection(int bin, double xCenter, double xFrom, double xTo, int count, double fraction, int[] sampleIdx) {
}
private Consumer onBinHover;
@@ -352,7 +335,7 @@ private Double xValueFromPlotPixel(Node plotArea, double xInPlotLocal) {
try {
Point2D scenePt = plotArea.localToScene(xInPlotLocal, 0);
Point2D axisPt = getXAxis().sceneToLocal(scenePt);
- return ((NumberAxis) getXAxis()).getValueForDisplay(axisPt.getX()).doubleValue();
+ return getXAxis().getValueForDisplay(axisPt.getX()).doubleValue();
} catch (Exception ex) {
return null;
}
diff --git a/src/main/java/edu/jhuapl/trinity/utils/statistics/StatPdfCdfChartPanel.java b/src/main/java/edu/jhuapl/trinity/utils/statistics/StatPdfCdfChartPanel.java
index c6c386e8..e18584ba 100644
--- a/src/main/java/edu/jhuapl/trinity/utils/statistics/StatPdfCdfChartPanel.java
+++ b/src/main/java/edu/jhuapl/trinity/utils/statistics/StatPdfCdfChartPanel.java
@@ -313,11 +313,11 @@ private List getCurrentTSValues() {
if (tsMode == TSMode.CONTRIBUTION) {
StatisticEngine.ContributionSeries cs =
StatisticEngine.computeContributions(use, agg, null, contribEps);
- return cs.delta;
+ return cs.delta();
} else if (tsMode == TSMode.CUMULATIVE) {
StatisticEngine.ContributionSeries cs =
StatisticEngine.computeContributions(use, agg, null, contribEps);
- return StatisticEngine.cumulativeFromDeltas(cs.delta);
+ return StatisticEngine.cumulativeFromDeltas(cs.delta());
} else {
// SIMILARITY: show the same scalar values that fed the PDF/CDF
StatisticResult stat = (pdfChart != null) ? pdfChart.getLastStatisticResult() : null;
@@ -1055,11 +1055,11 @@ private void updateTimeSeries() {
StatisticEngine.ContributionSeries cs =
StatisticEngine.computeContributions(use, agg, null, contribEps);
tsChart.setAxisLabels("Sample Index", "Δ log-odds");
- tsChart.setSeries(cs.delta);
+ tsChart.setSeries(cs.delta());
} else if (tsMode == TSMode.CUMULATIVE) {
StatisticEngine.ContributionSeries cs =
StatisticEngine.computeContributions(use, agg, null, contribEps);
- List cum = StatisticEngine.cumulativeFromDeltas(cs.delta);
+ List cum = StatisticEngine.cumulativeFromDeltas(cs.delta());
tsChart.setAxisLabels("Sample Index", "Cumulative log-odds");
tsChart.setSeries(cum);
} else { // SIMILARITY
@@ -1078,67 +1078,67 @@ private void wireChartInteractions() {
// PDF -> TS
pdfChart.setOnBinHover(sel -> {
if (!persistSelection) tsChart.clearHighlights();
- tsChart.highlightSamples(sel.sampleIdx);
+ tsChart.highlightSamples(sel.sampleIdx());
selectionInfo.setText(
String.format("PDF bin %d: [%.4f, %.4f) center≈%.4f • count=%d (%.2f%%)",
- sel.bin, sel.xFrom, sel.xTo, sel.xCenter, sel.count, 100.0 * sel.fraction)
+ sel.bin(), sel.xFrom(), sel.xTo(), sel.xCenter(), sel.count(), 100.0 * sel.fraction())
);
});
pdfChart.setOnBinClick(sel -> {
- tsChart.highlightSamples(sel.sampleIdx);
+ tsChart.highlightSamples(sel.sampleIdx());
selectionInfo.setText(
String.format("PDF bin %d (clicked): [%.4f, %.4f) center≈%.4f • count=%d (%.2f%%)",
- sel.bin, sel.xFrom, sel.xTo, sel.xCenter, sel.count, 100.0 * sel.fraction)
+ sel.bin(), sel.xFrom(), sel.xTo(), sel.xCenter(), sel.count(), 100.0 * sel.fraction())
);
});
// CDF -> TS
cdfChart.setOnBinHover(sel -> {
if (!persistSelection) tsChart.clearHighlights();
- tsChart.highlightSamples(sel.sampleIdx);
+ tsChart.highlightSamples(sel.sampleIdx());
selectionInfo.setText(
String.format("CDF bin %d: [%.4f, %.4f) center≈%.4f • count=%d (%.2f%%)",
- sel.bin, sel.xFrom, sel.xTo, sel.xCenter, sel.count, 100.0 * sel.fraction)
+ sel.bin(), sel.xFrom(), sel.xTo(), sel.xCenter(), sel.count(), 100.0 * sel.fraction())
);
});
cdfChart.setOnBinClick(sel -> {
- tsChart.highlightSamples(sel.sampleIdx);
+ tsChart.highlightSamples(sel.sampleIdx());
selectionInfo.setText(
String.format("CDF bin %d (clicked): [%.4f, %.4f) center≈%.4f • count=%d (%.2f%%)",
- sel.bin, sel.xFrom, sel.xTo, sel.xCenter, sel.count, 100.0 * sel.fraction)
+ sel.bin(), sel.xFrom(), sel.xTo(), sel.xCenter(), sel.count(), 100.0 * sel.fraction())
);
});
// TS -> readout
tsChart.setOnPointHover(p -> {
if (tsMode == TSMode.CONTRIBUTION) {
- selectionInfo.setText(String.format("Sample #%d: Δ log-odds = %.6f", p.sampleIdx, p.y));
+ selectionInfo.setText(String.format("Sample #%d: Δ log-odds = %.6f", p.sampleIdx(), p.y()));
} else if (tsMode == TSMode.CUMULATIVE) {
- selectionInfo.setText(String.format("Sample #%d: cumulative log-odds = %.6f", p.sampleIdx, p.y));
+ selectionInfo.setText(String.format("Sample #%d: cumulative log-odds = %.6f", p.sampleIdx(), p.y()));
} else {
StatisticResult stat = pdfChart.getLastStatisticResult();
String extra = "";
- if (stat != null && stat.getSampleToBin() != null && p.sampleIdx >= 0 && p.sampleIdx < stat.getSampleToBin().length) {
- int b = stat.getSampleToBin()[p.sampleIdx];
+ if (stat != null && stat.getSampleToBin() != null && p.sampleIdx() >= 0 && p.sampleIdx() < stat.getSampleToBin().length) {
+ int b = stat.getSampleToBin()[p.sampleIdx()];
if (b >= 0 && stat.getBinEdges() != null && b + 1 < stat.getBinEdges().length) {
double from = stat.getBinEdges()[b];
double to = stat.getBinEdges()[b + 1];
extra = String.format(" • bin=%d [%.4f, %.4f)", b, from, to);
}
}
- selectionInfo.setText(String.format("Sample #%d: value=%.6f%s", p.sampleIdx, p.y, extra));
+ selectionInfo.setText(String.format("Sample #%d: value=%.6f%s", p.sampleIdx(), p.y(), extra));
}
});
tsChart.setOnPointClick(p -> {
if (!persistSelection) tsChart.clearHighlights();
- tsChart.highlightSamples(new int[]{p.sampleIdx});
+ tsChart.highlightSamples(new int[]{p.sampleIdx()});
if (tsMode == TSMode.CONTRIBUTION) {
- selectionInfo.setText(String.format("Sample #%d (clicked): Δ log-odds = %.6f", p.sampleIdx, p.y));
+ selectionInfo.setText(String.format("Sample #%d (clicked): Δ log-odds = %.6f", p.sampleIdx(), p.y()));
} else if (tsMode == TSMode.CUMULATIVE) {
- selectionInfo.setText(String.format("Sample #%d (clicked): cumulative log-odds = %.6f", p.sampleIdx, p.y));
+ selectionInfo.setText(String.format("Sample #%d (clicked): cumulative log-odds = %.6f", p.sampleIdx(), p.y()));
} else {
- selectionInfo.setText(String.format("Sample #%d (clicked): value=%.6f", p.sampleIdx, p.y));
+ selectionInfo.setText(String.format("Sample #%d (clicked): value=%.6f", p.sampleIdx(), p.y()));
}
});
}
diff --git a/src/main/java/edu/jhuapl/trinity/utils/statistics/StatTimeSeriesChart.java b/src/main/java/edu/jhuapl/trinity/utils/statistics/StatTimeSeriesChart.java
index 78ad2515..a9158798 100644
--- a/src/main/java/edu/jhuapl/trinity/utils/statistics/StatTimeSeriesChart.java
+++ b/src/main/java/edu/jhuapl/trinity/utils/statistics/StatTimeSeriesChart.java
@@ -21,17 +21,13 @@
*/
public class StatTimeSeriesChart extends LineChart {
- // ===== Public event payload =====
- public static final class PointSelection {
- public final int sampleIdx;
- public final double x; // index
- public final double y; // value
-
- public PointSelection(int sampleIdx, double x, double y) {
- this.sampleIdx = sampleIdx;
- this.x = x;
- this.y = y;
- }
+ /**
+ * Public event payload
+ *
+ * @param x index
+ * @param y value
+ */
+ public record PointSelection(int sampleIdx, double x, double y) {
}
// ===== Series =====
@@ -154,8 +150,8 @@ public void clearHighlights() {
* Optional: customize axis labels.
*/
public void setAxisLabels(String xLabel, String yLabel) {
- if (xLabel != null) ((NumberAxis) getXAxis()).setLabel(xLabel);
- if (yLabel != null) ((NumberAxis) getYAxis()).setLabel(yLabel);
+ if (xLabel != null) getXAxis().setLabel(xLabel);
+ if (yLabel != null) getYAxis().setLabel(yLabel);
}
public void setOnPointHover(Consumer handler) {
@@ -195,7 +191,7 @@ private Integer indexFromPlotPixel(Node plotArea, double xInPlotLocal) {
try {
Point2D scenePt = plotArea.localToScene(xInPlotLocal, 0);
Point2D axisPt = getXAxis().sceneToLocal(scenePt);
- double xVal = ((NumberAxis) getXAxis()).getValueForDisplay(axisPt.getX()).doubleValue();
+ double xVal = getXAxis().getValueForDisplay(axisPt.getX()).doubleValue();
if (currentValues == null || currentValues.isEmpty()) return null;
int idx = (int) Math.round(xVal);
if (idx < 0) idx = 0;
diff --git a/src/main/java/edu/jhuapl/trinity/utils/statistics/StatisticEngine.java b/src/main/java/edu/jhuapl/trinity/utils/statistics/StatisticEngine.java
index 90e4ee4a..41d53ef9 100644
--- a/src/main/java/edu/jhuapl/trinity/utils/statistics/StatisticEngine.java
+++ b/src/main/java/edu/jhuapl/trinity/utils/statistics/StatisticEngine.java
@@ -51,17 +51,12 @@ public enum SimilarityAggregator {
/**
* Holder for contribution computation outputs.
+ *
+ * @param similarity S_t in (0,1)
+ * @param logit L_t
+ * @param delta Δ_t = L_t - L_{t-1}, with Δ_0 = L_0
*/
- public static final class ContributionSeries {
- public final List similarity; // S_t in (0,1)
- public final List logit; // L_t
- public final List delta; // Δ_t = L_t - L_{t-1}, with Δ_0 = L_0
-
- public ContributionSeries(List s, List l, List d) {
- this.similarity = s;
- this.logit = l;
- this.delta = d;
- }
+ public record ContributionSeries(List similarity, List logit, List delta) {
}
/**
diff --git a/src/main/java/edu/jhuapl/trinity/utils/statistics/SyntheticMatrixFactory.java b/src/main/java/edu/jhuapl/trinity/utils/statistics/SyntheticMatrixFactory.java
index 07b935e0..0ca77c02 100644
--- a/src/main/java/edu/jhuapl/trinity/utils/statistics/SyntheticMatrixFactory.java
+++ b/src/main/java/edu/jhuapl/trinity/utils/statistics/SyntheticMatrixFactory.java
@@ -3,7 +3,6 @@
import edu.jhuapl.trinity.data.messages.xai.FeatureVector;
import edu.jhuapl.trinity.utils.graph.MatrixToGraphAdapter;
-import java.io.Serial;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
@@ -46,22 +45,12 @@ private SyntheticMatrixFactory() {
// Result bundle
// ---------------------------------------------------------------------
- public static final class SyntheticMatrix implements Serializable {
- @Serial
- private static final long serialVersionUID = 1L;
-
- public final double[][] matrix;
- public final List labels;
- public final List clusterIds; // may be null or size N (useful for coloring)
- public final MatrixToGraphAdapter.MatrixKind kind;
- public final String title;
-
- /**
- * Optional cohorts (may be null). If present, PairwiseMatrixView can fall back to them for JPDF/ΔPDF.
- */
- public final List cohortA;
- public final List cohortB;
-
+ /**
+ * @param clusterIds may be null or size N (useful for coloring)
+ * @param cohortA Optional cohorts (may be null). If present, PairwiseMatrixView can fall back to them for JPDF/ΔPDF.
+ */
+ public record SyntheticMatrix(double[][] matrix, List labels, List clusterIds, MatrixToGraphAdapter.MatrixKind kind, String title,
+ List cohortA, List cohortB) implements Serializable {
public SyntheticMatrix(double[][] matrix,
List labels,
List clusterIds,
@@ -70,22 +59,6 @@ public SyntheticMatrix(double[][] matrix,
this(matrix, labels, clusterIds, kind, title, null, null);
}
- public SyntheticMatrix(double[][] matrix,
- List labels,
- List clusterIds,
- MatrixToGraphAdapter.MatrixKind kind,
- String title,
- List cohortA,
- List cohortB) {
- this.matrix = matrix;
- this.labels = labels;
- this.clusterIds = clusterIds;
- this.kind = kind;
- this.title = title;
- this.cohortA = cohortA;
- this.cohortB = cohortB;
- }
-
/**
* Return a copy of this SyntheticMatrix with cohorts attached (immutably).
*/
@@ -368,14 +341,7 @@ public static Cohorts makeCohorts_GaussianVsUniform(int N, int D,
return new Cohorts(a, b);
}
- public static final class Cohorts {
- public final List cohortA;
- public final List cohortB;
-
- public Cohorts(List a, List b) {
- this.cohortA = a;
- this.cohortB = b;
- }
+ public record Cohorts(List cohortA, List cohortB) {
}
// ---------------------------------------------------------------------
diff --git a/src/main/java/edu/jhuapl/trinity/utils/umap/CooMatrix.java b/src/main/java/edu/jhuapl/trinity/utils/umap/CooMatrix.java
index 85e8d9be..2f4804a6 100644
--- a/src/main/java/edu/jhuapl/trinity/utils/umap/CooMatrix.java
+++ b/src/main/java/edu/jhuapl/trinity/utils/umap/CooMatrix.java
@@ -291,10 +291,9 @@ private int getMaxNonZeroSize() {
@Override
Matrix add(final Matrix matrix) {
- if (!(matrix instanceof CooMatrix)) {
+ if (!(matrix instanceof CooMatrix m)) {
return super.add(matrix).toCoo();
}
- final CooMatrix m = (CooMatrix) matrix;
if (!isShapeSame(m)) {
throw new IllegalArgumentException("Incompatible matrix sizes");
}
@@ -355,10 +354,9 @@ Matrix add(final Matrix matrix) {
@Override
Matrix subtract(final Matrix matrix) {
- if (!(matrix instanceof CooMatrix)) {
+ if (!(matrix instanceof CooMatrix m)) {
return super.subtract(matrix).toCoo();
}
- final CooMatrix m = (CooMatrix) matrix;
if (!isShapeSame(m)) {
throw new IllegalArgumentException("Incompatible matrix sizes");
}
@@ -419,10 +417,9 @@ Matrix subtract(final Matrix matrix) {
@Override
Matrix hadamardMultiply(final Matrix matrix) {
- if (!(matrix instanceof CooMatrix)) {
+ if (!(matrix instanceof CooMatrix m)) {
return super.hadamardMultiply(matrix).toCoo();
}
- final CooMatrix m = (CooMatrix) matrix;
if (!isShapeSame(m)) {
throw new IllegalArgumentException("Incompatible matrix sizes");
}
@@ -514,10 +511,9 @@ Matrix addTranspose() {
@Override
Matrix multiply(final Matrix m) {
- if (!(m instanceof CooMatrix)) {
+ if (!(m instanceof CooMatrix a)) {
return super.multiply(m).toCoo();
}
- final CooMatrix a = (CooMatrix) m;
if (cols() != m.rows()) {
throw new IllegalArgumentException("Incompatible matrix sizes");
}
diff --git a/src/main/java/edu/jhuapl/trinity/utils/umap/CsrMatrix.java b/src/main/java/edu/jhuapl/trinity/utils/umap/CsrMatrix.java
index 3d0d4549..1e60e187 100644
--- a/src/main/java/edu/jhuapl/trinity/utils/umap/CsrMatrix.java
+++ b/src/main/java/edu/jhuapl/trinity/utils/umap/CsrMatrix.java
@@ -187,9 +187,9 @@ void intersect(final CsrMatrix other, final CooMatrix result, final double mixWe
if (leftVal > leftMin || rightVal > rightMin) {
final double f;
if (mixWeight < 0.5) {
- f = (double) (leftVal * Math.pow(rightVal, mixWeight / (1.0 - mixWeight)));
+ f = leftVal * Math.pow(rightVal, mixWeight / (1.0 - mixWeight));
} else {
- f = (double) (Math.pow(leftVal, (1.0 - mixWeight) / mixWeight) * rightVal);
+ f = Math.pow(leftVal, (1.0 - mixWeight) / mixWeight) * rightVal;
}
data[idx] = f;
}
diff --git a/src/main/java/edu/jhuapl/trinity/utils/umap/Curve.java b/src/main/java/edu/jhuapl/trinity/utils/umap/Curve.java
index bb644337..7a49c0a4 100644
--- a/src/main/java/edu/jhuapl/trinity/utils/umap/Curve.java
+++ b/src/main/java/edu/jhuapl/trinity/utils/umap/Curve.java
@@ -86,7 +86,7 @@ private static double curve(final double x, final double a, final double b) {
private static double[] wrapCurve(final double[] x, final double[] y, final double a, final double b) {
final double[] res = new double[x.length];
for (int i = 0; i < x.length; i++) {
- res[i] = (double) (curve(x[i], a, b) - y[i]);
+ res[i] = curve(x[i], a, b) - y[i];
}
return res;
}
diff --git a/src/main/java/edu/jhuapl/trinity/utils/umap/Matrix.java b/src/main/java/edu/jhuapl/trinity/utils/umap/Matrix.java
index ae33a6ab..8b914876 100644
--- a/src/main/java/edu/jhuapl/trinity/utils/umap/Matrix.java
+++ b/src/main/java/edu/jhuapl/trinity/utils/umap/Matrix.java
@@ -96,10 +96,9 @@ protected boolean isShapeSame(Matrix m) {
@Override
public boolean equals(final Object obj) {
- if (!(obj instanceof Matrix)) {
+ if (!(obj instanceof Matrix m)) {
return false;
}
- final Matrix m = (Matrix) obj;
if (!isShapeSame(m)) {
return false;
}
@@ -114,7 +113,7 @@ public boolean equals(final Object obj) {
}
long length() {
- return mRowCount * mColCount;
+ return (long) mRowCount * mColCount;
}
Matrix transpose() {
diff --git a/src/main/java/edu/jhuapl/trinity/utils/umap/Sort.java b/src/main/java/edu/jhuapl/trinity/utils/umap/Sort.java
index f4c9a0de..5a39d2b6 100644
--- a/src/main/java/edu/jhuapl/trinity/utils/umap/Sort.java
+++ b/src/main/java/edu/jhuapl/trinity/utils/umap/Sort.java
@@ -32,14 +32,7 @@ public interface Swapper {
void swap(final int a, final int b);
}
- private static class FloatIntSwapper implements Swapper {
- FloatIntSwapper(final double[] primary, final int[] secondary) {
- mPrimary = primary;
- mSecondary = secondary;
- }
-
- private final double[] mPrimary;
- private final int[] mSecondary;
+ private record FloatIntSwapper(double[] mPrimary, int[] mSecondary) implements Swapper {
@Override
public void swap(final int a, final int b) {
diff --git a/src/main/java/edu/jhuapl/trinity/utils/umap/Umap.java b/src/main/java/edu/jhuapl/trinity/utils/umap/Umap.java
index 009d8399..740cfba8 100644
--- a/src/main/java/edu/jhuapl/trinity/utils/umap/Umap.java
+++ b/src/main/java/edu/jhuapl/trinity/utils/umap/Umap.java
@@ -66,7 +66,7 @@ public class Umap {
* The distance to the first nearest neighbor for each point.
*/
private static double[][] smoothKnnDist(final double[][] distances, final double k, final int nIter, final int localConnectivity, final double bandwidth) {
- final double target = (double) (MathUtils.log2(k) * bandwidth);
+ final double target = MathUtils.log2(k) * bandwidth;
final double[] rho = new double[distances.length];
final double[] result = new double[distances.length];
@@ -256,7 +256,7 @@ static CooMatrix computeMembershipStrengths(final int[][] knnIndices, final doub
} else if (knnDists[i][j] - rhos[i] <= 0) {
val = 1;
} else {
- val = (double) Math.exp(-((knnDists[i][j] - rhos[i]) / (sigmas[i])));
+ val = Math.exp(-((knnDists[i][j] - rhos[i]) / (sigmas[i])));
}
rows[i * nNeighbors + j] = i;
cols[i * nNeighbors + j] = knnIndices[i][j];
@@ -458,7 +458,7 @@ private Matrix optimizeLayout(final Matrix headEmbedding, final Matrix tailEmbed
double gradCoeff;
if (distSquared > 0.0) {
- gradCoeff = (double) ((-2.0 * a * b * Math.pow(distSquared, b - 1.0)) / (a * Math.pow(distSquared, b) + 1.0));
+ gradCoeff = (-2.0 * a * b * Math.pow(distSquared, b - 1.0)) / (a * Math.pow(distSquared, b) + 1.0);
} else {
gradCoeff = 0;
}
@@ -481,7 +481,7 @@ private Matrix optimizeLayout(final Matrix headEmbedding, final Matrix tailEmbed
distSquared = ReducedEuclideanMetric.SINGLETON.distance(current, other);
if (distSquared > 0) {
- gradCoeff = 2.0F * gamma * b / (double) ((0.001 + distSquared) * (a * Math.pow(distSquared, b) + 1));
+ gradCoeff = 2.0F * gamma * b / ((0.001 + distSquared) * (a * Math.pow(distSquared, b) + 1));
} else if (j == kr) {
continue;
} else {
diff --git a/src/main/java/edu/jhuapl/trinity/utils/umap/Utils.java b/src/main/java/edu/jhuapl/trinity/utils/umap/Utils.java
index 70711013..c8c5c27d 100644
--- a/src/main/java/edu/jhuapl/trinity/utils/umap/Utils.java
+++ b/src/main/java/edu/jhuapl/trinity/utils/umap/Utils.java
@@ -103,7 +103,7 @@ static double norm(final double[] vec) {
for (final double v : vec) {
result += v * v;
}
- return (double) Math.sqrt(result);
+ return Math.sqrt(result);
}
/**
diff --git a/src/main/java/edu/jhuapl/trinity/utils/volumetric/Octree.java b/src/main/java/edu/jhuapl/trinity/utils/volumetric/Octree.java
index e1610044..7509f424 100644
--- a/src/main/java/edu/jhuapl/trinity/utils/volumetric/Octree.java
+++ b/src/main/java/edu/jhuapl/trinity/utils/volumetric/Octree.java
@@ -207,7 +207,7 @@ protected void createOctree(int currentDepth, OctreeNode currentNode) {
for (int i : new int[]{-1, 1}) {
for (int j : new int[]{-1, 1}) {
for (int k : new int[]{-1, 1}) {
- long index = (long) (((i + 1) * 2 + (j + 1) * 1 + (k + 1) / 2));
+ long index = ((i + 1) * 2 + (j + 1) * 1 + (k + 1) / 2);
// index <<= (currentDepth - 1) * 3;
index = currentNode.index | (index << (3 * currentDepth + 3));
double length = currentNode.getxExtent(); // xExtent == yExtent == zExtent
diff --git a/src/test/java/SuperMDS/CVAEInverseTest.java b/src/test/java/SuperMDS/CVAEInverseTest.java
index 05619900..0eed303c 100644
--- a/src/test/java/SuperMDS/CVAEInverseTest.java
+++ b/src/test/java/SuperMDS/CVAEInverseTest.java
@@ -76,9 +76,8 @@ public static void main(String[] args) {
Normalizer embeddingNormalizer = new Normalizer(mdsEmbedding, Normalizer.Type.Z_SCORE);
double[][] normalizedEmbedding = embeddingNormalizer.normalizeAll(mdsEmbedding);
double[][] conditions = new double[numPoints][embeddingDim];
- for (int i = 0; i < numPoints; i++) {
- conditions[i] = normalizedEmbedding[i]; // full 3D embedding as condition
- }
+ // full 3D embedding as condition
+ System.arraycopy(normalizedEmbedding, 0, conditions, 0, numPoints);
for (int outerLoop = 0; outerLoop < 10; outerLoop++) {
// Initialize CVAE
diff --git a/src/test/java/edu/jhuapl/trinity/javafx/components/RadarChartTest.java b/src/test/java/edu/jhuapl/trinity/javafx/components/RadarChartTest.java
index 692a1f16..3a39d76b 100644
--- a/src/test/java/edu/jhuapl/trinity/javafx/components/RadarChartTest.java
+++ b/src/test/java/edu/jhuapl/trinity/javafx/components/RadarChartTest.java
@@ -33,7 +33,7 @@
*/
public class RadarChartTest extends Application {
private static final Random RND = new Random();
- private static final long INTERVAL = 10_000_000_000l;
+ private static final long INTERVAL = 10_000_000_000L;
private static final double ANIM_TIME = INTERVAL / 10_000_000;
private static final int ELEMENTS = 30;
private static final ChartType CHART_TYPE = ChartType.SMOOTH_RADAR_POLYGON;
diff --git a/src/test/java/edu/jhuapl/trinity/javafx/components/RidgeLineChartTestApp.java b/src/test/java/edu/jhuapl/trinity/javafx/components/RidgeLineChartTestApp.java
index 7f670176..f85db689 100644
--- a/src/test/java/edu/jhuapl/trinity/javafx/components/RidgeLineChartTestApp.java
+++ b/src/test/java/edu/jhuapl/trinity/javafx/components/RidgeLineChartTestApp.java
@@ -62,7 +62,7 @@ public void init() {
Map> items = createItems();
- for (int i = 0; i < items.keySet().size(); i++) {
+ for (int i = 0; i < items.size(); i++) {
XYSeries xySeries = XYSeriesBuilder.create()
.items(items.get(i))
.chartType(ChartType.SMOOTH_AREA)
diff --git a/src/test/java/edu/jhuapl/trinity/javafx/javafx3d/FastScatter3DTest.java b/src/test/java/edu/jhuapl/trinity/javafx/javafx3d/FastScatter3DTest.java
index fcb95578..81ed2397 100644
--- a/src/test/java/edu/jhuapl/trinity/javafx/javafx3d/FastScatter3DTest.java
+++ b/src/test/java/edu/jhuapl/trinity/javafx/javafx3d/FastScatter3DTest.java
@@ -219,7 +219,6 @@ public void handle(long now) {
updatePositions();
}
- ;
};
animationTimer.start();
}
diff --git a/src/test/java/edu/jhuapl/trinity/javafx/javafx3d/RayShooting.java b/src/test/java/edu/jhuapl/trinity/javafx/javafx3d/RayShooting.java
index a159a2cb..20a7e619 100644
--- a/src/test/java/edu/jhuapl/trinity/javafx/javafx3d/RayShooting.java
+++ b/src/test/java/edu/jhuapl/trinity/javafx/javafx3d/RayShooting.java
@@ -266,12 +266,9 @@ else if (e.isSecondaryButtonDown()) {
}
/**
- * @param r The Ray that holds the info
- * @param tx to x
- * @param ty to y
- * @param tz to z
- * @param dps distance per step to move ray
- * @param time length of animation
+ * @param r The Ray that holds the info
+ * @param target target to move ray
+ * @param time length of animation
*/
private void animateRayTo(final Ray r, final Shape3D target, final Duration time) {
@@ -332,8 +329,8 @@ protected void interpolate(double frac) {
// resets materisl on targets
private void reset() {
- ((Shape3D) ((Group) targetGroup).getChildren().get(0)).setMaterial(red);
- ((Shape3D) ((Group) targetGroup).getChildren().get(1)).setMaterial(blue);
+ ((Shape3D) targetGroup.getChildren().get(0)).setMaterial(red);
+ ((Shape3D) targetGroup.getChildren().get(1)).setMaterial(blue);
}
diff --git a/src/test/java/edu/jhuapl/trinity/javafx/javafx3d/SurfaceWarpTest.java b/src/test/java/edu/jhuapl/trinity/javafx/javafx3d/SurfaceWarpTest.java
index 378a6d43..636a3ed0 100644
--- a/src/test/java/edu/jhuapl/trinity/javafx/javafx3d/SurfaceWarpTest.java
+++ b/src/test/java/edu/jhuapl/trinity/javafx/javafx3d/SurfaceWarpTest.java
@@ -675,7 +675,6 @@ public void handle(long now) {
}
}
- ;
};
tessellationTimer.start();
}
@@ -704,7 +703,7 @@ protected Void call() throws Exception {
for (int height = 0; height < totalHeight - 1; height++) {
randomWidth = rando.nextInt(fivePercent) + halfWidth;
for (int width = 0; width < totalWidth - 1; width++) {
- rgb = ((int) pr.getArgb(width, height));
+ rgb = pr.getArgb(width, height);
r = (rgb >> 16) & 0xFF;
g = (rgb >> 8) & 0xFF;
b = rgb & 0xFF;
@@ -739,10 +738,10 @@ private void vectorizeImage(int pskip, Image image) {
int numVerts = (subDivZ + 1) * numDivX;
final int texCoordSize = 2;
float currZ, currX;
- float texCoords[] = new float[numVerts * texCoordSize];
+ float[] texCoords = new float[numVerts * texCoordSize];
int faceCount = subDivX * subDivZ * 2;
final int faceSize = 6; //should always be 6 for a triangle mesh
- int faces[] = new int[faceCount * faceSize];
+ int[] faces = new int[faceCount * faceSize];
int index, p00, p01, p10, p11, tc00, tc01, tc10, tc11;
double yValue;
for (int z = 0; z < subDivZ; z++) {
@@ -751,7 +750,7 @@ private void vectorizeImage(int pskip, Image image) {
for (int x = 0; x < subDivX; x++) {
currX = (float) x / subDivX;
// color value for pixel at point
- rgb = ((int) image.getPixelReader().getArgb(x * pskip, z * pskip));
+ rgb = image.getPixelReader().getArgb(x * pskip, z * pskip);
r = (rgb >> 16) & 0xFF;
g = (rgb >> 8) & 0xFF;
b = rgb & 0xFF;
diff --git a/src/test/java/edu/jhuapl/trinity/javafx/javafx3d/VectorizeImageTest.java b/src/test/java/edu/jhuapl/trinity/javafx/javafx3d/VectorizeImageTest.java
index 0dc1f530..3aa79a58 100644
--- a/src/test/java/edu/jhuapl/trinity/javafx/javafx3d/VectorizeImageTest.java
+++ b/src/test/java/edu/jhuapl/trinity/javafx/javafx3d/VectorizeImageTest.java
@@ -335,7 +335,6 @@ public void handle(long now) {
}
}
- ;
};
tessellationTimer.start();
}
@@ -363,7 +362,7 @@ protected Void call() throws Exception {
for (int height = 0; height < totalHeight - 1; height++) {
randomWidth = rando.nextInt(fivePercent) + halfWidth;
for (int width = 0; width < totalWidth - 1; width++) {
- rgb = ((int) pr.getArgb(width, height));
+ rgb = pr.getArgb(width, height);
r = (rgb >> 16) & 0xFF;
g = (rgb >> 8) & 0xFF;
b = rgb & 0xFF;
@@ -397,10 +396,10 @@ private void vectorizeImage(Image image) {
int numVerts = (subDivZ + 1) * numDivX;
final int texCoordSize = 2;
float currZ, currX;
- float texCoords[] = new float[numVerts * texCoordSize];
+ float[] texCoords = new float[numVerts * texCoordSize];
int faceCount = subDivX * subDivZ * 2;
final int faceSize = 6; //should always be 6 for a triangle mesh
- int faces[] = new int[faceCount * faceSize];
+ int[] faces = new int[faceCount * faceSize];
int index, p00, p01, p10, p11, tc00, tc01, tc10, tc11;
double yValue;
for (int z = 0; z < subDivZ; z++) {
@@ -409,7 +408,7 @@ private void vectorizeImage(Image image) {
for (int x = 0; x < subDivX; x++) {
currX = (float) x / subDivX;
// color value for pixel at point
- rgb = ((int) image.getPixelReader().getArgb(x * pskip, z * pskip));
+ rgb = image.getPixelReader().getArgb(x * pskip, z * pskip);
r = (rgb >> 16) & 0xFF;
g = (rgb >> 8) & 0xFF;
b = rgb & 0xFF;
diff --git a/src/test/java/edu/jhuapl/trinity/utils/ImageTest.java b/src/test/java/edu/jhuapl/trinity/utils/ImageTest.java
index 6491b16a..b8727d88 100644
--- a/src/test/java/edu/jhuapl/trinity/utils/ImageTest.java
+++ b/src/test/java/edu/jhuapl/trinity/utils/ImageTest.java
@@ -7,7 +7,6 @@
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
-import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
import java.text.DecimalFormat;
@@ -29,7 +28,7 @@ public ImageTest() {
* @throws java.net.MalformedURLException
*/
//@Test
- public void scrapeFlags() throws MalformedURLException, IOException {
+ public void scrapeFlags() throws IOException {
LOG.info("scrapeFlags");
DecimalFormat df = new DecimalFormat("##");
df.setDecimalSeparatorAlwaysShown(false);