1

我知道 ImageJ 有一个插件可以处理 NIfTI-1 文件(http://rsb.info.nih.gov/ij/plugins/nifti.html)。

但是该页面上的所有说明都是将 ImageJ 用作独立程序,但是我正在使用它的 API。如果没有源代码,我如何知道这个 jar 文件中有哪些可用的方法

我也找不到源代码。

对于 imageJ 中支持的存档(例如 DICOM)来说非常简单:

public class ImageJTest {
    public static void main(){
                        String path = "res/vaca.dcm"; 
            FileInputStream fis;
            ImageView image;
            try {
                fis = new FileInputStream(path);
                DICOM d = new DICOM(fis);
                d.run(path);
                // Stretches the histogram because the pictures were being
                // displayed too dark.
                (new ij.plugin.ContrastEnhancer()).stretchHistogram(d, 0.1);
                Image picture = SwingFXUtils.toFXImage(d.getBufferedImage(),
                        null);
                // Makes the size standard for thumbnails
                image = new ImageView(picture);
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
    }
}

如何在 imageJ 中加载 NIfTI-1 文件?

4

3 回答 3

3

一旦有了嵌入到 jar 文件中的类文件(正如@Alvin Thompson 指出的那样,这些只是不同名称的 zip 文件),您可以使用反射 API 来挖掘类文件以获取它们的方法。下面是一个班级的样本,从这里抄袭:

Method[] methods = thisClass.getClass().getMethods(); // thisClass is an instance of the class you're working with

for(Method method : methods){
    System.out.println("method = " + method.getName());
}
于 2014-05-22T22:15:29.923 回答
2

JAR 文件只是精美的 ZIP 文件。您可以将文件重命名为foo.zip,然后使用任何解压缩实用程序来展开其内容。您至少应该能够看到类文件是什么,并且 javadocs 可能与它捆绑在一起(现在不太可能,但可能)。

但是,如果您只想知道可用的方法,可能最好的方法是将 JAR 添加到 NetBeans、Eclipse 或 IntelliJ 中的项目的类路径中,并使用它们的代码完成功能来找出 API 方法和类.

于 2014-05-22T22:01:47.027 回答
0

您甚至可以对 jar 进行反编译,并使用反编译器查看每个类背后的代码。我发现了一个不错的:Java Decompiler JD-GUI 主页:http: //java.decompiler.free.fr

它确实很好,它的工作。至少在我的任务中。

于 2015-02-13T11:23:31.817 回答