mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-12-04 15:52:35 -08:00
Eclipse formatting (#176)
* Make eclipse formatter better follow our conventions and format all of it * Don't join wrapped lines to allow for hand-formatting * Fix formatting of switch statements and add breaks in enum declarations * Use new formatter by @thebutlah, adjust formatter more
This commit is contained in:
1 parent
c74cc539c9
commit
1dea626422
114 files changed
+5580
-2661
No files matched your search
@@ -19,6 +19,7 @@ import java.awt.event.MouseEvent;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
|
||||
public class AutoBoneWindow extends JFrame {
|
||||
|
||||
private final transient VRServer server;
|
||||
@@ -46,16 +47,23 @@ public class AutoBoneWindow extends JFrame {
|
||||
this.autoBone = new AutoBone(server);
|
||||
|
||||
getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.PAGE_AXIS));
|
||||
add(new JScrollPane(pane = new EJBox(BoxLayout.PAGE_AXIS), ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED));
|
||||
add(
|
||||
new JScrollPane(
|
||||
pane = new EJBox(BoxLayout.PAGE_AXIS),
|
||||
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
|
||||
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED
|
||||
)
|
||||
);
|
||||
|
||||
build();
|
||||
}
|
||||
|
||||
private float processFrames(PoseFrames frames) {
|
||||
return autoBone.processFrames(frames, autoBone.calcInitError, autoBone.targetHeight, (epoch) -> {
|
||||
processLabel.setText(epoch.toString());
|
||||
lengthsLabel.setText(autoBone.getLengthsString());
|
||||
});
|
||||
return autoBone
|
||||
.processFrames(frames, autoBone.calcInitError, autoBone.targetHeight, (epoch) -> {
|
||||
processLabel.setText(epoch.toString());
|
||||
lengthsLabel.setText(autoBone.getLengthsString());
|
||||
});
|
||||
}
|
||||
|
||||
@AWTThread
|
||||
@@ -79,31 +87,46 @@ public class AutoBoneWindow extends JFrame {
|
||||
try {
|
||||
if (poseRecorder.isReadyToRecord()) {
|
||||
setText("Recording...");
|
||||
// 1000 samples at 20 ms per sample is 20 seconds
|
||||
int sampleCount = server.config.getInt("autobone.sampleCount", 1000);
|
||||
long sampleRate = server.config.getLong("autobone.sampleRateMs", 20L);
|
||||
Future<PoseFrames> framesFuture = poseRecorder.startFrameRecording(sampleCount, sampleRate);
|
||||
// 1000 samples at 20 ms per
|
||||
// sample is
|
||||
// 20 seconds
|
||||
int sampleCount = server.config
|
||||
.getInt("autobone.sampleCount", 1000);
|
||||
long sampleRate = server.config
|
||||
.getLong("autobone.sampleRateMs", 20L);
|
||||
Future<PoseFrames> framesFuture = poseRecorder
|
||||
.startFrameRecording(sampleCount, sampleRate);
|
||||
PoseFrames frames = framesFuture.get();
|
||||
LogManager.log.info("[AutoBone] Done recording!");
|
||||
LogManager.info("[AutoBone] Done recording!");
|
||||
|
||||
saveRecordingButton.setEnabled(true);
|
||||
adjustButton.setEnabled(true);
|
||||
|
||||
if (server.config.getBoolean("autobone.saveRecordings", false)) {
|
||||
if (
|
||||
server.config
|
||||
.getBoolean(
|
||||
"autobone.saveRecordings",
|
||||
false
|
||||
)
|
||||
) {
|
||||
setText("Saving...");
|
||||
autoBone.saveRecording(frames);
|
||||
}
|
||||
} else {
|
||||
setText("Not Ready...");
|
||||
LogManager.log.severe("[AutoBone] Unable to record...");
|
||||
Thread.sleep(3000); // Wait for 3 seconds
|
||||
LogManager.severe("[AutoBone] Unable to record...");
|
||||
Thread.sleep(3000); // Wait for
|
||||
// 3
|
||||
// seconds
|
||||
return;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
setText("Recording Failed...");
|
||||
LogManager.log.severe("[AutoBone] Failed recording!", e);
|
||||
LogManager.severe("[AutoBone] Failed recording!", e);
|
||||
try {
|
||||
Thread.sleep(3000); // Wait for 3 seconds
|
||||
Thread.sleep(3000); // Wait for
|
||||
// 3
|
||||
// seconds
|
||||
} catch (Exception e1) {
|
||||
// Ignore
|
||||
}
|
||||
@@ -136,17 +159,22 @@ public class AutoBoneWindow extends JFrame {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
Future<PoseFrames> framesFuture = poseRecorder.getFramesAsync();
|
||||
Future<PoseFrames> framesFuture = poseRecorder
|
||||
.getFramesAsync();
|
||||
if (framesFuture != null) {
|
||||
setText("Waiting for Recording...");
|
||||
PoseFrames frames = framesFuture.get();
|
||||
|
||||
if (frames.getTrackerCount() <= 0) {
|
||||
throw new IllegalStateException("Recording has no trackers");
|
||||
throw new IllegalStateException(
|
||||
"Recording has no trackers"
|
||||
);
|
||||
}
|
||||
|
||||
if (frames.getMaxFrameCount() <= 0) {
|
||||
throw new IllegalStateException("Recording has no frames");
|
||||
throw new IllegalStateException(
|
||||
"Recording has no frames"
|
||||
);
|
||||
}
|
||||
|
||||
setText("Saving...");
|
||||
@@ -154,15 +182,22 @@ public class AutoBoneWindow extends JFrame {
|
||||
|
||||
setText("Recording Saved!");
|
||||
try {
|
||||
Thread.sleep(3000); // Wait for 3 seconds
|
||||
Thread.sleep(3000); // Wait
|
||||
// for 3
|
||||
// seconds
|
||||
} catch (Exception e1) {
|
||||
// Ignore
|
||||
}
|
||||
} else {
|
||||
setText("No Recording...");
|
||||
LogManager.log.severe("[AutoBone] Unable to save, no recording was done...");
|
||||
LogManager
|
||||
.severe(
|
||||
"[AutoBone] Unable to save, no recording was done..."
|
||||
);
|
||||
try {
|
||||
Thread.sleep(3000); // Wait for 3 seconds
|
||||
Thread.sleep(3000); // Wait
|
||||
// for 3
|
||||
// seconds
|
||||
} catch (Exception e1) {
|
||||
// Ignore
|
||||
}
|
||||
@@ -170,9 +205,12 @@ public class AutoBoneWindow extends JFrame {
|
||||
}
|
||||
} catch (Exception e) {
|
||||
setText("Saving Failed...");
|
||||
LogManager.log.severe("[AutoBone] Failed to save recording!", e);
|
||||
LogManager
|
||||
.severe("[AutoBone] Failed to save recording!", e);
|
||||
try {
|
||||
Thread.sleep(3000); // Wait for 3 seconds
|
||||
Thread.sleep(3000); // Wait for
|
||||
// 3
|
||||
// seconds
|
||||
} catch (Exception e1) {
|
||||
// Ignore
|
||||
}
|
||||
@@ -193,7 +231,11 @@ public class AutoBoneWindow extends JFrame {
|
||||
add(adjustButton = new JButton("Auto-Adjust") {
|
||||
{
|
||||
// If there are files to load, enable the button
|
||||
setEnabled(poseRecorder.hasRecording() || (AutoBone.getLoadDir().isDirectory() && AutoBone.getLoadDir().list().length > 0));
|
||||
setEnabled(
|
||||
poseRecorder.hasRecording()
|
||||
|| (AutoBone.getLoadDir().isDirectory()
|
||||
&& AutoBone.getLoadDir().list().length > 0)
|
||||
);
|
||||
addMouseListener(new MouseInputAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
@@ -207,30 +249,44 @@ public class AutoBoneWindow extends JFrame {
|
||||
public void run() {
|
||||
try {
|
||||
setText("Load...");
|
||||
List<Pair<String, PoseFrames>> frameRecordings = autoBone.loadRecordings();
|
||||
List<Pair<String, PoseFrames>> frameRecordings = autoBone
|
||||
.loadRecordings();
|
||||
|
||||
if (!frameRecordings.isEmpty()) {
|
||||
LogManager.log.info("[AutoBone] Done loading frames!");
|
||||
LogManager.info("[AutoBone] Done loading frames!");
|
||||
} else {
|
||||
Future<PoseFrames> framesFuture = poseRecorder.getFramesAsync();
|
||||
Future<PoseFrames> framesFuture = poseRecorder
|
||||
.getFramesAsync();
|
||||
if (framesFuture != null) {
|
||||
setText("Waiting for Recording...");
|
||||
PoseFrames frames = framesFuture.get();
|
||||
|
||||
if (frames.getTrackerCount() <= 0) {
|
||||
throw new IllegalStateException("Recording has no trackers");
|
||||
throw new IllegalStateException(
|
||||
"Recording has no trackers"
|
||||
);
|
||||
}
|
||||
|
||||
if (frames.getMaxFrameCount() <= 0) {
|
||||
throw new IllegalStateException("Recording has no frames");
|
||||
throw new IllegalStateException(
|
||||
"Recording has no frames"
|
||||
);
|
||||
}
|
||||
|
||||
frameRecordings.add(Pair.of("<Recording>", frames));
|
||||
frameRecordings
|
||||
.add(Pair.of("<Recording>", frames));
|
||||
} else {
|
||||
setText("No Recordings...");
|
||||
LogManager.log.severe("[AutoBone] No recordings found in \"" + AutoBone.getLoadDir().getPath() + "\" and no recording was done...");
|
||||
LogManager
|
||||
.severe(
|
||||
"[AutoBone] No recordings found in \""
|
||||
+ AutoBone.getLoadDir().getPath()
|
||||
+ "\" and no recording was done..."
|
||||
);
|
||||
try {
|
||||
Thread.sleep(3000); // Wait for 3 seconds
|
||||
Thread.sleep(3000); // Wait
|
||||
// for 3
|
||||
// seconds
|
||||
} catch (Exception e1) {
|
||||
// Ignore
|
||||
}
|
||||
@@ -239,34 +295,93 @@ public class AutoBoneWindow extends JFrame {
|
||||
}
|
||||
|
||||
setText("Processing...");
|
||||
LogManager.log.info("[AutoBone] Processing frames...");
|
||||
FastList<Float> heightPercentError = new FastList<Float>(frameRecordings.size());
|
||||
for (Pair<String, PoseFrames> recording : frameRecordings) {
|
||||
LogManager.log.info("[AutoBone] Processing frames from \"" + recording.getKey() + "\"...");
|
||||
LogManager.info("[AutoBone] Processing frames...");
|
||||
FastList<Float> heightPercentError = new FastList<Float>(
|
||||
frameRecordings.size()
|
||||
);
|
||||
for (
|
||||
Pair<String, PoseFrames> recording : frameRecordings
|
||||
) {
|
||||
LogManager
|
||||
.info(
|
||||
"[AutoBone] Processing frames from \""
|
||||
+ recording.getKey()
|
||||
+ "\"..."
|
||||
);
|
||||
|
||||
heightPercentError.add(processFrames(recording.getValue()));
|
||||
LogManager.log.info("[AutoBone] Done processing!");
|
||||
heightPercentError
|
||||
.add(processFrames(recording.getValue()));
|
||||
LogManager.info("[AutoBone] Done processing!");
|
||||
applyButton.setEnabled(true);
|
||||
|
||||
//#region Stats/Values
|
||||
Float neckLength = autoBone.getConfig(SkeletonConfigValue.NECK);
|
||||
Float chestDistance = autoBone.getConfig(SkeletonConfigValue.CHEST);
|
||||
Float torsoLength = autoBone.getConfig(SkeletonConfigValue.TORSO);
|
||||
Float hipWidth = autoBone.getConfig(SkeletonConfigValue.HIPS_WIDTH);
|
||||
Float legsLength = autoBone.getConfig(SkeletonConfigValue.LEGS_LENGTH);
|
||||
Float kneeHeight = autoBone.getConfig(SkeletonConfigValue.KNEE_HEIGHT);
|
||||
// #region Stats/Values
|
||||
Float neckLength = autoBone
|
||||
.getConfig(SkeletonConfigValue.NECK);
|
||||
Float chestDistance = autoBone
|
||||
.getConfig(SkeletonConfigValue.CHEST);
|
||||
Float torsoLength = autoBone
|
||||
.getConfig(SkeletonConfigValue.TORSO);
|
||||
Float hipWidth = autoBone
|
||||
.getConfig(SkeletonConfigValue.HIPS_WIDTH);
|
||||
Float legsLength = autoBone
|
||||
.getConfig(SkeletonConfigValue.LEGS_LENGTH);
|
||||
Float kneeHeight = autoBone
|
||||
.getConfig(SkeletonConfigValue.KNEE_HEIGHT);
|
||||
|
||||
float neckTorso = neckLength != null && torsoLength != null ? neckLength / torsoLength : 0f;
|
||||
float chestTorso = chestDistance != null && torsoLength != null ? chestDistance / torsoLength : 0f;
|
||||
float torsoWaist = hipWidth != null && torsoLength != null ? hipWidth / torsoLength : 0f;
|
||||
float legTorso = legsLength != null && torsoLength != null ? legsLength / torsoLength : 0f;
|
||||
float legBody = legsLength != null && torsoLength != null && neckLength != null ? legsLength / (torsoLength + neckLength) : 0f;
|
||||
float kneeLeg = kneeHeight != null && legsLength != null ? kneeHeight / legsLength : 0f;
|
||||
float neckTorso = neckLength != null
|
||||
&& torsoLength != null
|
||||
? neckLength
|
||||
/ torsoLength
|
||||
: 0f;
|
||||
float chestTorso = chestDistance != null
|
||||
&& torsoLength != null
|
||||
? chestDistance
|
||||
/ torsoLength
|
||||
: 0f;
|
||||
float torsoWaist = hipWidth != null
|
||||
&& torsoLength != null
|
||||
? hipWidth
|
||||
/ torsoLength
|
||||
: 0f;
|
||||
float legTorso = legsLength != null
|
||||
&& torsoLength != null
|
||||
? legsLength
|
||||
/ torsoLength
|
||||
: 0f;
|
||||
float legBody = legsLength != null
|
||||
&& torsoLength != null
|
||||
&& neckLength != null
|
||||
? legsLength
|
||||
/ (torsoLength + neckLength)
|
||||
: 0f;
|
||||
float kneeLeg = kneeHeight != null
|
||||
&& legsLength != null
|
||||
? kneeHeight
|
||||
/ legsLength
|
||||
: 0f;
|
||||
|
||||
LogManager.log.info("[AutoBone] Ratios: [{Neck-Torso: " + StringUtils.prettyNumber(neckTorso) + "}, {Chest-Torso: " + StringUtils.prettyNumber(chestTorso) + "}, {Torso-Waist: " + StringUtils.prettyNumber(torsoWaist) + "}, {Leg-Torso: " + StringUtils.prettyNumber(legTorso) + "}, {Leg-Body: " + StringUtils.prettyNumber(legBody) + "}, {Knee-Leg: " + StringUtils.prettyNumber(kneeLeg) + "}]");
|
||||
LogManager
|
||||
.info(
|
||||
"[AutoBone] Ratios: [{Neck-Torso: "
|
||||
+ StringUtils.prettyNumber(neckTorso)
|
||||
+ "}, {Chest-Torso: "
|
||||
+ StringUtils.prettyNumber(chestTorso)
|
||||
+ "}, {Torso-Waist: "
|
||||
+ StringUtils.prettyNumber(torsoWaist)
|
||||
+ "}, {Leg-Torso: "
|
||||
+ StringUtils.prettyNumber(legTorso)
|
||||
+ "}, {Leg-Body: "
|
||||
+ StringUtils.prettyNumber(legBody)
|
||||
+ "}, {Knee-Leg: "
|
||||
+ StringUtils.prettyNumber(kneeLeg)
|
||||
+ "}]"
|
||||
);
|
||||
|
||||
String lengthsString = autoBone.getLengthsString();
|
||||
LogManager.log.info("[AutoBone] Length values: " + lengthsString);
|
||||
LogManager
|
||||
.info(
|
||||
"[AutoBone] Length values: " + lengthsString
|
||||
);
|
||||
lengthsLabel.setText(lengthsString);
|
||||
}
|
||||
|
||||
@@ -282,16 +397,26 @@ public class AutoBoneWindow extends JFrame {
|
||||
float stdVal = val - mean;
|
||||
std += stdVal * stdVal;
|
||||
}
|
||||
std = (float) Math.sqrt(std / heightPercentError.size());
|
||||
std = (float) Math
|
||||
.sqrt(std / heightPercentError.size());
|
||||
|
||||
LogManager.log.info("[AutoBone] Average height error: " + StringUtils.prettyNumber(mean, 6) + " (SD " + StringUtils.prettyNumber(std, 6) + ")");
|
||||
LogManager
|
||||
.info(
|
||||
"[AutoBone] Average height error: "
|
||||
+ StringUtils.prettyNumber(mean, 6)
|
||||
+ " (SD "
|
||||
+ StringUtils.prettyNumber(std, 6)
|
||||
+ ")"
|
||||
);
|
||||
}
|
||||
//#endregion
|
||||
// #endregion
|
||||
} catch (Exception e) {
|
||||
setText("Failed...");
|
||||
LogManager.log.severe("[AutoBone] Failed adjustment!", e);
|
||||
LogManager.severe("[AutoBone] Failed adjustment!", e);
|
||||
try {
|
||||
Thread.sleep(3000); // Wait for 3 seconds
|
||||
Thread.sleep(3000); // Wait for
|
||||
// 3
|
||||
// seconds
|
||||
} catch (Exception e1) {
|
||||
// Ignore
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user