Skip to content

Add biomech window#31

Open
aymanhab wants to merge 18 commits into
use_precompiled_jxbrowserfrom
add_biomech_win
Open

Add biomech window#31
aymanhab wants to merge 18 commits into
use_precompiled_jxbrowserfrom
add_biomech_win

Conversation

@aymanhab

Copy link
Copy Markdown
Member

No description provided.

remove licensekey ref and download prebuilt jar instead
…utes of a trial (name, segments, .... etc.) and use to enable users to select actions accordingly.
…ad prematurely, also guard against missing grf file(s)
@aymanhab

Copy link
Copy Markdown
Member Author

This PR adds the AddBiomechanics window to the OpenSim GUI allowing users to download and handle zip files on OpenSim format.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces an “AddBiomechanics” window built on the existing embedded JxBrowser integration, adds UI/resources to support downloading and importing datasets from addbiomechanics.org, and updates a couple of documentation links/notes.

Changes:

  • Added a new AddBiomechanicsTopComponent that embeds JxBrowser and wires download handling into an “import” flow.
  • Added org.opensim.addBiomech classes to unpack downloaded zips, discover models/trials, and load motions into the app.
  • Updated JxBrowser engine initialization/caching and refreshed README / welcome page links.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 16 comments.

Show a summary per file
File Description
README.md Updates note about JxBrowser7 license.
jxbrowser/src/org/opensim/javabrowser/welcome.html Updates “What’s New” link to OpenSim 4.6 page.
jxbrowser/src/org/opensim/javabrowser/jxBrowserTopComponent.java Refactors Engine creation into a shared cached engine and tweaks model-change event handling.
jxbrowser/src/org/opensim/javabrowser/Bundle.properties Adds localized strings for the new AddBiomechanics window UI.
jxbrowser/src/org/opensim/javabrowser/AddBiomechanicsTopComponent.java New TopComponent embedding JxBrowser with download callbacks.
jxbrowser/src/org/opensim/javabrowser/AddBiomechanicsTopComponent.form NetBeans form definition for the new TopComponent.
jxbrowser/src/org/opensim/addBiomech/Installer.java Module shutdown hook to clean up downloads directory.
jxbrowser/src/org/opensim/addBiomech/Bundle.properties UI strings for the download-handling panel.
jxbrowser/src/org/opensim/addBiomech/AddBiomechPrefs.java Preferences helper for download directory location.
jxbrowser/src/org/opensim/addBiomech/AddBiomechanicsTrial.java Trial abstraction + “stitching” helpers for multi-segment downloads.
jxbrowser/src/org/opensim/addBiomech/AddBiomechanicsHandleDownloadJPanel.java Zip extraction + UI flow to open/associate downloaded content.
jxbrowser/src/org/opensim/addBiomech/AddBiomechanicsHandleDownloadJPanel.form NetBeans form definition for the download-handling panel.
jxbrowser/nbproject/project.xml Adds module dependencies needed for dialogs/UI and modeling/logger usage.
jxbrowser/manifest.mf Registers module installer and changes public package exports.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread README.md
If you would like to use JxBrowser in your development, please contact TeamDev.

Upgraded to jXBrowser7 in 10/25
Upgraded to jXBrowser7 in 10/25 with new dedicated project license rather then OpenSource one.
Comment on lines +108 to +110
Engine engine = Engine.newInstance(EngineOptions.newBuilder(RenderingMode.OFF_SCREEN)
.licenseKey("4UNGXAXTRYIHI4S4DZYH52OM3U0NQ188QVOUJDS0M7QMDCF0RKIL1YBWQJT0U6L5GCDZK7J949904OT7JYQUSHQ7ETBOBK9A3RD2ENRJK48F9HH2F8CWAD3MAP1BZKBN4ZVYC0D9R89R75KTYLN")
.addSwitch("--js-flags=--max-old-space-size=256") // JS heap in MB
Comment on lines +5 to +18
package org.opensim.addBiomech;

import org.opensim.utils.TheApp;
import static org.opensim.utils.TheApp.getCurrentVersionPreferences;

/**
*
* @author ayman
*/
public final class AddBiomechPrefs {
public static String getDownloadsDir() {
return getCurrentVersionPreferences().get("AddBiomechDownloadFolder", TheApp.getInstallDir()+"/"+"AddBiomechDownloads");
}
}
Comment on lines +24 to +43
@Override
public void close() {
// Called when shutdown is confirmed — do your cleanup here
deleteTempFiles();
}

private void deleteTempFiles() {
Path downloadPath = Paths.get(AddBiomechPrefs.getDownloadsDir());
File tempDir = new File(downloadPath.toString());
deleteRecursively(tempDir);
}

private void deleteRecursively(File f) {
if (f.isDirectory()) {
for (File child : f.listFiles()) {
deleteRecursively(child);
}
}
f.delete();
}
Comment on lines +111 to +112
browser.navigation().loadUrl("addbiomechanics.org/login");
setName(Bundle.CTL_AddBiomechanicsTopComponent());
Comment on lines +392 to +396
int[] indices = jTrialsList.getSelectedIndices();

for (int i : indices) { // Single select
selectedTrialIndex = i;
}
Comment on lines +457 to +463
if (grfPath != null)
MotionsDB.getInstance().loadMotionFile(grfPath, false);
trialLoadingStatus = 2;
}
});
}});

Comment on lines +213 to +218
private String getSegmentFileName(String firstSegmentFilename, int segNumber) {
// Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
if (segNumber == -1)
return (firstSegmentFilename.replace("_0", "_all"));
return (firstSegmentFilename.replace("_0", "_"+String.valueOf(segNumber)));
}
Comment on lines +156 to +165
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane)
);
Comment thread jxbrowser/manifest.mf
OpenIDE-Module-Requires: org.openide.windows.WindowManager
OpenIDE-Module-Specification-Version: 1.0

OpenIDE-Module-Public-Packages: org.opensim.javabrowser.*
public void update(Observable o, Object arg) {
if (arg instanceof ObjectSetCurrentEvent){
ObjectSetCurrentEvent ev = (ObjectSetCurrentEvent) arg;
//System.out.println("jxBrowserTC.update "+arg.toString());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this commented line needed for debugging?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be removed

if (cacheEngine==null){
// This is the hardcoded trial license, eventually this will go into private repo
Engine engine = Engine.newInstance(EngineOptions.newBuilder(RenderingMode.OFF_SCREEN)
.licenseKey("4UNGXAXTRYIHI4S4DZYH52OM3U0NQ188QVOUJDS0M7QMDCF0RKIL1YBWQJT0U6L5GCDZK7J949904OT7JYQUSHQ7ETBOBK9A3RD2ENRJK48F9HH2F8CWAD3MAP1BZKBN4ZVYC0D9R89R75KTYLN")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it ok to have this license key in this public repo?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the eval license key we had since we upgraded. The real key is embedded in an nbm file

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good to me then. I though that to be a stale license, but just wanted to make sure. I will test this branch on the GUI next then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants