Skip to content

Commit a8e7851

Browse files
authored
Add plugin support and fix image size (#162)
* Add plugin support and fix image size * Make xdr and plugin copy libs optional
1 parent fa44406 commit a8e7851

File tree

6 files changed

+210
-15
lines changed

6 files changed

+210
-15
lines changed

build.xml

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,6 +1122,7 @@
11221122
<mkdir dir="${release.dir}/extra" />
11231123
<mkdir dir="${release.dir}/samples" />
11241124
<mkdir dir="${release.dir}/doc" />
1125+
<mkdir dir="${release.dir}/plugin" />
11251126

11261127
<!-- Copy the application and dependencies -->
11271128
<copy todir="${release.dir}">
@@ -1170,7 +1171,6 @@
11701171
<exclude name="slf4j*.jar" />
11711172
<exclude name="*.lib" />
11721173
</fileset>
1173-
11741174
<fileset dir="${hdf5.lib.dir}">
11751175
<include name="*.jar" />
11761176
<include name="hdf5_java.dll" />
@@ -1188,7 +1188,6 @@
11881188
<include name="mfhdf.dll"/>
11891189
<include name="xdr.dll"/>
11901190
</fileset>
1191-
11921191
<fileset dir="${hdf5.lib.dir}">
11931192
<include name="hdf5_java.dll" />
11941193
</fileset>
@@ -1197,6 +1196,18 @@
11971196
<include name="hdf5.dll"/>
11981197
</fileset>
11991198
</copy>
1199+
<!-- Optional copy xdr -->
1200+
<copy todir="${release.dir}/bin" failonerror="false">
1201+
<fileset dir="${hdf.lib.dir}/../bin">
1202+
<include name="xdr.dll"/>
1203+
</fileset>
1204+
</copy>
1205+
<!-- Optional copy plugins -->
1206+
<copy todir="${release.dir}/bin/plugin" failonerror="false">
1207+
<fileset dir="${hdf5.lib.dir}/plugin">
1208+
<include name="*.dll" />
1209+
</fileset>
1210+
</copy>
12001211

12011212
<!-- Create the run batch file -->
12021213
<copy file="${packagefiles.dir}/hdfview.bat.in" tofile="${release.dir}/hdfview.bat" />
@@ -1220,10 +1231,6 @@
12201231
<fileset dir="${hdf.lib.dir}" followsymlinks="true">
12211232
<filename regex="libmfhdf\.so(\.[0-9])$"/>
12221233
</fileset>
1223-
<fileset dir="${hdf.lib.dir}" followsymlinks="true">
1224-
<filename regex="libxdr\.so(\.[0-9])$"/>
1225-
<exclude name="*.a" />
1226-
</fileset>
12271234
<fileset dir="${hdf5.lib.dir}" followsymlinks="true">
12281235
<include name="libhdf5_java.so" />
12291236
<include name="*.jar" />
@@ -1233,6 +1240,19 @@
12331240
<filename regex="libhdf5\.so(\.[0-9][0-9][0-9][0-9]?)$"/>
12341241
</fileset>
12351242
</copy>
1243+
<!-- Optional copy xdr -->
1244+
<copy todir="${release.dir}" failonerror="false">
1245+
<fileset dir="${hdf.lib.dir}" followsymlinks="true">
1246+
<filename regex="libxdr\.so(\.[0-9])$"/>
1247+
<exclude name="*.a" />
1248+
</fileset>
1249+
</copy>
1250+
<!-- Optional copy plugins -->
1251+
<copy todir="${release.dir}/plugin" failonerror="false">
1252+
<fileset dir="${hdf5.lib.dir}/plugin">
1253+
<include name="*.so" />
1254+
</fileset>
1255+
</copy>
12361256

12371257
<!-- Create the .sh run script -->
12381258
<copy file="${packagefiles.dir}/hdfview.sh.in" tofile="${release.dir}/hdfview.sh" />
@@ -1263,10 +1283,6 @@
12631283
<filename regex="libmfhdf(\.[0-9])(\.dylib)$"/>
12641284
<exclude name="*.a" />
12651285
</fileset>
1266-
<fileset dir="${hdf.lib.dir}" followsymlinks="true">
1267-
<filename regex="libxdr(\.[0-9])(\.dylib)$"/>
1268-
<exclude name="*.a" />
1269-
</fileset>
12701286
<fileset dir="${hdf5.lib.dir}" followsymlinks="true">
12711287
<include name="libhdf5_java.dylib" />
12721288
<include name="*.jar" />
@@ -1277,6 +1293,19 @@
12771293
<exclude name="*.a" />
12781294
</fileset>
12791295
</copy>
1296+
<!-- Optional copy xdr -->
1297+
<copy todir="${release.dir}" failonerror="false">
1298+
<fileset dir="${hdf.lib.dir}" followsymlinks="true">
1299+
<filename regex="libxdr(\.[0-9])(\.dylib)$"/>
1300+
<exclude name="*.a" />
1301+
</fileset>
1302+
</copy>
1303+
<!-- Optional copy plugins -->
1304+
<copy todir="${release.dir}/plugin" failonerror="false">
1305+
<fileset dir="${hdf5.lib.dir}/plugin">
1306+
<include name="*.dylib" />
1307+
</fileset>
1308+
</copy>
12801309
</target>
12811310

12821311
<!-- =================================================================

src/org.hdfgroup.hdfview/hdf/view/HDFView.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
import hdf.view.dialog.UserOptionsNode;
9393
import hdf.view.dialog.UserOptionsViewModulesPage;
9494

95+
import hdf.hdf5lib.H5;
9596

9697
/**
9798
* HDFView is the main class of this HDF visual tool. It is used to layout the graphical components of the hdfview. The
@@ -291,6 +292,9 @@ public HDFView(String root, String start_dir) {
291292
currentFont = null;
292293
}
293294

295+
if (FileFormat.getFileFormat(FileFormat.FILE_TYPE_HDF5) != null)
296+
H5.H5PLappend(ViewProperties.getPluginDir());
297+
294298
treeViews = ViewProperties.getTreeViewList();
295299
metaDataViews = ViewProperties.getMetaDataViewList();
296300
tableViews = ViewProperties.getTableViewList();
@@ -907,6 +911,9 @@ public void widgetSelected(SelectionEvent e) {
907911
// this will always overwrite the currentDir until isWorkDirChanged() is fixed
908912
currentDir = ViewProperties.getWorkDir();
909913

914+
if (FileFormat.getFileFormat(FileFormat.FILE_TYPE_HDF5) != null)
915+
H5.H5PLappend(ViewProperties.getPluginDir());
916+
910917
//if (userOptionDialog.isFontChanged()) {
911918
Font font = null;
912919

src/org.hdfgroup.hdfview/hdf/view/TableView/DefaultBaseTableView.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,6 @@ public void widgetDisposed(DisposeEvent e) {
462462
}
463463
}
464464

465-
466465
// Setup subset information
467466
int space_type = dataObject.getSpaceType();
468467
int rank = dataObject.getRank();

src/org.hdfgroup.hdfview/hdf/view/ViewProperties.java

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,9 @@ public static enum BITMASK_OP {
201201
/** default starting file directory */
202202
private static String workDir = System.getProperty("user.dir");
203203

204+
/** default plugin directory */
205+
private static String pluginDir = System.getProperty("user.dir") + "/plugin";
206+
204207
/** default HDF file extensions */
205208
private static String fileExt = "hdf, h4, hdf4, h5, hdf5, he2, he5";
206209

@@ -318,6 +321,8 @@ public ViewProperties(String viewRoot, String viewStart) {
318321

319322
setUsersGuide(rootDir + usersGuide);
320323

324+
setPluginDir(rootDir + "/plugin");
325+
321326
setDefault("users.guide", viewRoot + "/UsersGuide/index.html");
322327
setDefault("image.contrast", false);
323328
setDefault("image.showvalues", false);
@@ -1450,6 +1455,10 @@ public void load() throws IOException {
14501455
if (!isDefault("work.dir"))
14511456
setWorkDir(propVal);
14521457

1458+
propVal = getString("plugin.dir");
1459+
if (!isDefault("plugin.dir"))
1460+
setPluginDir(propVal);
1461+
14531462
propVal = getString("file.extension");
14541463
if (!isDefault("file.extension")) {
14551464
setFileExtension(propVal);
@@ -1554,6 +1563,9 @@ public void save() throws IOException {
15541563

15551564
if (workDir != null) setValue("work.dir", workDir);
15561565

1566+
if (pluginDir != null)
1567+
setValue("plugin.dir", pluginDir);
1568+
15571569
if (fileExt != null) setValue("file.extension", fileExt);
15581570

15591571
if (h4toh5 != null) setValue("h4toh5.converter", h4toh5);
@@ -1693,6 +1705,21 @@ public static String getWorkDir() {
16931705
return workPath;
16941706
}
16951707

1708+
/** @return the default plugin directory. */
1709+
public static String getPluginDir() {
1710+
String pluginPath = pluginDir;
1711+
log.trace("getPluginDir: pluginDir={}", pluginDir);
1712+
if (pluginPath == null) {
1713+
pluginPath = System.getProperty("hdfview.plugindir");
1714+
log.trace("getPluginDir: hdfview.plugindir={}", pluginPath);
1715+
if (pluginPath == null) {
1716+
pluginPath = System.getProperty("user.dir") + "/plugin";
1717+
}
1718+
}
1719+
log.trace("getPluginDir: final pluginPath={}", pluginPath);
1720+
return pluginPath;
1721+
}
1722+
16961723
/** @return the maximum number of the most recent file */
16971724
public static int getMaxRecentFiles() {
16981725
return MAX_RECENT_FILES;
@@ -1868,6 +1895,16 @@ public static void setWorkDir(String wDir) {
18681895
workDir = wDir;
18691896
}
18701897

1898+
/**
1899+
* set the path of the default plugin directory
1900+
*
1901+
* @param plDir the default plugin directory
1902+
*/
1903+
public static void setPluginDir(String plDir) {
1904+
log.trace("ViewProperties:setPluginDir plDir={}", plDir);
1905+
pluginDir = plDir;
1906+
}
1907+
18711908
/** set the file extension
18721909
*
18731910
* @param ext

0 commit comments

Comments
 (0)