@@ -75,8 +75,9 @@ private static Map<String, String> createBrainAreasResourcePathsMap() {
7575 }
7676
7777 private static JSONObject getJSONfile (final String resourcePath ) {
78- final ClassLoader classloader = Thread .currentThread ().getContextClassLoader ();
79- final InputStream is = classloader .getResourceAsStream (resourcePath );
78+ ClassLoader classLoader = Thread .currentThread ().getContextClassLoader ();
79+ classLoader = (classLoader != null ) ? classLoader : AllenUtils .class .getClassLoader ();
80+ final InputStream is = classLoader .getResourceAsStream (resourcePath );
8081 final JSONTokener tokener = new JSONTokener (is );
8182 final JSONObject json = new JSONObject (tokener );
8283 try {
@@ -500,21 +501,20 @@ private DefaultMutableTreeNode getParentNode(final AllenCompartment parentStruct
500501 public static OBJMesh getRootMesh (final ColorRGB color ) {
501502 final String meshLabel = "Whole Brain" ;
502503 String meshPath ;
503- double volume ;
504- switch (VERSION ) {
505- case V3 :
506- meshPath = "meshes/MouseBrainAllen3.obj" ;
507- volume = 513578693035.138d ; // pre-computed in trimesh
508- break ;
509- case V2_5 :
510- meshPath = "meshes/MouseBrainAllen2.5.obj" ;
511- volume = 513578693035.138d ; // pre-computed in trimesh
512- break ;
513- default :
514- throw new IllegalArgumentException ("Unrecognized CCF version" );
515- }
516- final ClassLoader loader = Thread .currentThread ().getContextClassLoader ();
517- final URL url = loader .getResource (meshPath );
504+ double volume = switch (VERSION ) {
505+ case V3 -> {
506+ meshPath = "meshes/MouseBrainAllen3.obj" ;
507+ yield 513578693035.138d ;
508+ }
509+ case V2_5 -> {
510+ meshPath = "meshes/MouseBrainAllen2.5.obj" ;
511+ yield 513578693035.138d ;
512+ }
513+ default -> throw new IllegalArgumentException ("Unrecognized CCF version" );
514+ };
515+ ClassLoader classLoader = Thread .currentThread ().getContextClassLoader ();
516+ classLoader = (classLoader != null ) ? classLoader : AllenUtils .class .getClassLoader ();
517+ final URL url = classLoader .getResource (meshPath );
518518 if (url == null )
519519 throw new IllegalArgumentException (meshLabel + " not found" );
520520 final OBJMesh mesh = new OBJMesh (url , GuiUtils .micrometer ());
0 commit comments