001/***************************************************************************** 002 * Copyright by The HDF Group. * 003 * Copyright by the Board of Trustees of the University of Illinois. * 004 * All rights reserved. * 005 * * 006 * This file is part of the HDF Java Products distribution. * 007 * The full copyright notice, including terms governing use, modification, * 008 * and redistribution, is contained in the file COPYING. * 009 * COPYING can be found at the root of the source code distribution tree. * 010 * If you do not have access to this file, you may request a copy from * 011 * help@hdfgroup.org. * 012 ****************************************************************************/ 013 014package hdf.view; 015 016import java.io.File; 017import java.io.FileInputStream; 018import java.io.BufferedReader; 019import java.io.InputStreamReader; 020import java.io.FileOutputStream; 021import java.net.MalformedURLException; 022import java.net.URL; 023import java.net.URLClassLoader; 024import java.util.Collections; 025import java.util.Enumeration; 026import java.util.Properties; 027import java.util.Vector; 028import java.util.jar.JarEntry; 029import java.util.jar.JarFile; 030 031import javax.swing.Icon; 032import javax.swing.ImageIcon; 033 034import hdf.object.FileFormat; 035import hdf.HDFVersions; 036 037public class ViewProperties extends Properties { 038 private static final long serialVersionUID = -6411465283887959066L; 039 040 private final static org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(ViewProperties.class); 041 042 /** the version of the HDFViewer */ 043 public static final String VERSION = HDFVersions.HDFVIEW_VERSION; 044 045 /** the local property file name */ 046 private static final String USER_PROPERTY_FILE = ".hdfview" + VERSION; 047 048 /** the maximum number of most recent files */ 049 public static final int MAX_RECENT_FILES = 15; 050 051 /** name of the tab delimiter */ 052 public static final String DELIMITER_TAB = "Tab"; 053 054 /** name of the tab delimiter */ 055 public static final String DELIMITER_COMMA = "Comma"; 056 057 /** name of the tab delimiter */ 058 public static final String DELIMITER_SPACE = "Space"; 059 060 /** name of the tab delimiter */ 061 public static final String DELIMITER_COLON = "Colon"; 062 063 /** image origin: UpperLeft */ 064 public static final String ORIGIN_UL = "UpperLeft"; 065 066 /** image origin: LowerLeft */ 067 public static final String ORIGIN_LL = "LowerLeft"; 068 069 /** image origin: UpperRight */ 070 public static final String ORIGIN_UR = "UpperRight"; 071 072 /** image origin: LowerRight */ 073 public static final String ORIGIN_LR = "LowerRight"; 074 075 /** name of the tab delimiter */ 076 public static final String DELIMITER_SEMI_COLON = "Semi-Colon"; 077 078 /** 079 * Property keys control how the data is displayed. 080 */ 081 public static enum DATA_VIEW_KEY { 082 CHAR, CONVERTBYTE, TRANSPOSED, READONLY, OBJECT, BITMASK, BITMASKOP, BORDER, INFO, INDEXBASE1 083 } 084 085 /** 086 * Property keys control how the data is displayed. 087 */ 088 public static enum BITMASK_OP { 089 AND, EXTRACT 090 } 091 092 /** the root directory of the HDFView */ 093 private static String rootDir = System.getProperty("user.dir"); 094 095 /** user's guide */ 096 private static String usersGuide = rootDir + "/UsersGuide/index.html"; 097 098 /** the font size */ 099 private static int fontSize = 12; 100 101 /** the font type */ 102 private static String fontType = null; 103 104 /** the full path of H4toH5 converter */ 105 private static String h4toh5 = ""; 106 107 /** data delimiter */ 108 private static String delimiter = DELIMITER_TAB; 109 110 /** image origin */ 111 private static String origin = ORIGIN_UL; 112 113 /** default index type */ 114 private static String indexType = "H5_INDEX_NAME"; 115 116 /** default index order */ 117 private static String indexOrder = "H5_ITER_INC"; 118 119 /** a list of most recent files */ 120 private static Vector<String> recentFiles; 121 122 /** default starting file directory */ 123 private static String workDir = "user.home"; 124 125 /** default HDF file extensions */ 126 private static String fileExt = "hdf, h4, hdf4, h5, hdf5, he2, he5"; 127 128 private static ClassLoader extClassLoader = null; 129 130 /** a list of srb accounts */ 131 private static Vector<String[]> srbAccountList = new Vector<String[]>(5); 132 133 /** 134 * flag to indicate if auto contrast is used in image processing. Do not use 135 * autocontrast by default (2.6 change). 136 */ 137 private static boolean isAutoContrast = false; 138 139 private static boolean showImageValues = false; 140 141 private static boolean showRegRefValues = false; 142 143 /** 144 * flag to indicate if default open file mode is read only. By default, use 145 * read/write. 146 */ 147 private static boolean isReadOnly = false; 148 149 private static boolean isEarlyLib = true; 150 151 /** a list of palette files */ 152 private static Vector<String> paletteList = new Vector<String>(5); 153 154 /** flag to indicate if enum data is converted to strings */ 155 private static boolean convertEnum = true; 156 157 /** flag to indicate if data is 1-based index */ 158 private static boolean isIndexBase1 = false; 159 160 /** 161 * Current Java applications such as HDFView cannot handle files with a large 162 * number of objects such as 1,000,000 objects. max_members defines the maximum 163 * number of objects that will be loaded into memory. 164 */ 165 private static int max_members = Integer.MAX_VALUE; // load all by default 166 /** 167 * Current Java applications such as HDFView cannot handle files with a large 168 * number of objects such 1,000,000 objects. start_members defines the 169 * starting index of objects that will be loaded into memory. 170 */ 171 private static int start_members = 0; 172 173 private static ImageIcon hdfIcon, h4Icon, h4IconR, h5Icon, h5IconR, largeHdfIcon, blankIcon, helpIcon, fileopenIcon, 174 filesaveIcon, filenewIcon, filecloseIcon, foldercloseIcon, folderopenIcon, foldercloseIconA, 175 folderopenIconA, datasetIcon, imageIcon, tableIcon, textIcon, datasetIconA, imageIconA, tableIconA, 176 textIconA, zoominIcon, zoomoutIcon, paletteIcon, chartIcon, brightIcon, autocontrastIcon, copyIcon, 177 cutIcon, pasteIcon, previousIcon, nextIcon, firstIcon, lastIcon, animationIcon, datatypeIcon, 178 datatypeIconA, linkIcon, iconAPPS, iconURL, iconVIDEO, iconXLS, iconPDF, iconAUDIO, questionIcon; 179 180 private static String propertyFile; 181 182 /** a list of treeview modules */ 183 private static Vector<String> moduleListTreeView = new Vector<String>(5); 184 185 /** a list of metaview modules */ 186 private static Vector<String> moduleListMetaDataView = new Vector<String>(5); 187 188 /** a list of textview modules */ 189 private static Vector<String> moduleListTextView = new Vector<String>(5); 190 191 /** a list of tableview modules */ 192 private static Vector<String> moduleListTableView = new Vector<String>(5); 193 194 /** a list of imageview modules */ 195 private static Vector<String> moduleListImageView = new Vector<String>(5); 196 197 /** a list of paletteview modules */ 198 private static Vector<String> moduleListPaletteView = new Vector<String>(5); 199 200 /** a list of helpview modules */ 201 private static Vector<String> moduleListHelpView = new Vector<String>(5); 202 203 /** 204 * Creates a property list with given root directory of the HDFView. 205 * 206 * @param viewRoot 207 * the root directory of the HDFView 208 */ 209 public ViewProperties(String viewRoot) { 210 super(); 211 rootDir = viewRoot; 212 log.trace("rootDir is {}", rootDir); 213 String workPath = System.getProperty("hdfview.workdir"); 214 log.trace("hdfview.workdir={}", workPath); 215 if (workPath != null) { 216 workDir = workPath; 217 } 218 219 recentFiles = new Vector<String>(MAX_RECENT_FILES + 5); 220 221 // find the property file 222 String userHome, userDir, propertyFileName, h5v; 223 224 // look for the property file in the user's home directory 225 propertyFileName = USER_PROPERTY_FILE; 226 userHome = System.getProperty("user.home") + File.separator + propertyFileName; 227 userDir = System.getProperty("user.dir") + File.separator + propertyFileName; 228 h5v = workDir + File.separator + propertyFileName; 229 230 if ((new File(userHome)).exists()) { 231 propertyFile = userHome; 232 } 233 else if ((new File(userDir)).exists()) { 234 propertyFile = userDir; 235 } 236 else // create new property file at user home directory 237 { 238 propertyFile = h5v; 239 File pFile = new File(h5v); 240 try { 241 pFile.createNewFile(); 242 } 243 catch (Exception ex) { 244 // Last resort: create new property file at user home directory 245 propertyFile = userHome; 246 try { 247 pFile = new File(userHome); 248 pFile.createNewFile(); 249 } 250 catch (Exception ex2) { 251 propertyFile = null; 252 } 253 } 254 } 255 } 256 257 /* the properties are sorted by keys */ 258 @SuppressWarnings("unchecked") 259 public synchronized Enumeration<Object> keys() { 260 Enumeration<?> keysEnum = super.keys(); 261 @SuppressWarnings("rawtypes") 262 Vector keyList = new Vector(50); 263 while (keysEnum.hasMoreElements()) { 264 keyList.add(keysEnum.nextElement()); 265 } 266 Collections.sort(keyList); 267 return keyList.elements(); 268 } 269 270 /** 271 * load module classes 272 * 273 * @return the ClassLoader 274 */ 275 public static ClassLoader loadExtClass() { 276 if (extClassLoader != null) { 277 return extClassLoader; 278 } 279 else { 280 // default classloader 281 extClassLoader = ClassLoader.getSystemClassLoader(); 282 } 283 log.trace("loadExtClass: default classloader is {}", extClassLoader); 284 285 String rootPath = System.getProperty("hdfview.root"); 286 if (rootPath == null) { 287 rootPath = rootDir; 288 log.debug("loadExtClass: rootDir rootPath is {}", rootPath); 289 } 290 log.debug("loadExtClass: rootPath is {}", rootPath); 291 292 String dirname = rootPath + File.separator + "lib" + File.separator + "ext" + File.separator; 293 String[] jars = null; 294 File extdir = null; 295 try { 296 extdir = new File(dirname); 297 jars = extdir.list(); 298 log.trace("loadExtClass: dirname is {} with {} jars", dirname, jars.length); 299 } 300 catch (Exception ex0) { 301 log.debug("loadExtClass: load dirname: {}+lib/ext failed", rootPath, ex0); 302 } 303 304 if ((jars == null) || (jars.length <= 0)) { 305 return extClassLoader; 306 } 307 308 Vector<String> jarList = new Vector<String>(50); 309 Vector<String> classList = new Vector<String>(50); 310 for (int i = 0; i < jars.length; i++) { 311 log.trace("loadExtClass: load jar[{}]", i); 312 if (jars[i].endsWith(".jar")) { 313 jarList.add(jars[i]); 314 // add class names to the list of classes 315 File tmpFile = new File(extdir, jars[i]); 316 try { 317 JarFile jarFile = new JarFile(tmpFile, false, JarFile.OPEN_READ); 318 Enumeration<?> emu = jarFile.entries(); 319 while (emu.hasMoreElements()) { 320 JarEntry jarEntry = (JarEntry) emu.nextElement(); 321 String entryName = jarEntry.getName(); 322 log.trace("loadExtClass: reading jar[{}] class={}", i, entryName); 323 int idx = entryName.indexOf(".class"); 324 if ((idx > 0) && (entryName.indexOf('$') <= 0)) { 325 entryName = entryName.replace('/', '.'); 326 classList.add(entryName.substring(0, idx)); 327 } 328 } 329 330 jarFile.close(); 331 } 332 catch (Exception ex) { 333 log.debug("loadExtClass: load jar[{}] failed", i, ex); 334 } 335 } // if (jars[i].endsWith(".jar")) { 336 } // for (int i=0; i<jars.length; i++) { 337 338 int n = jarList.size(); 339 if (n <= 0) { 340 log.debug("loadExtClass: jarList empty"); 341 return extClassLoader; 342 } 343 344 URL[] urls = new URL[n]; 345 for (int i = 0; i < n; i++) { 346 try { 347 urls[i] = new URL("file:///" + rootPath + "/lib/ext/" + jarList.get(i)); 348 log.trace("loadExtClass: load urls[{}] is {}", i, urls[i]); 349 } 350 catch (MalformedURLException mfu) { 351 log.debug("loadExtClass: load urls[{}] failed", i, mfu); 352 } 353 } 354 355 // try { extClassLoader = new URLClassLoader(urls); } 356 try { 357 extClassLoader = URLClassLoader.newInstance(urls); 358 } 359 catch (Exception ex) { 360 ex.printStackTrace(); 361 } 362 363 // load user modules into their list 364 n = classList.size(); 365 for (int i = 0; i < n; i++) { 366 String theName = classList.get(i); 367 log.trace("loadExtClass: load classList[{}] is {}", i, theName); 368 try { 369 // enables use of JHDF5 in JNLP (Web Start) applications, the 370 // system class loader with reflection first. 371 Class<?> theClass = null; 372 try { 373 theClass = Class.forName(theName); 374 } 375 catch (Exception ex) { 376 try { 377 theClass = extClassLoader.loadClass(theName); 378 } 379 catch (Exception exc) { 380 log.debug("load: loadClass({}) failed", theName, ex); 381 } 382 } 383 384 if(theClass != null) { 385 Class<?>[] interfaces = theClass.getInterfaces(); 386 if (interfaces != null) { 387 for (int j = 0; j < interfaces.length; j++) { 388 String interfaceName = interfaces[j].getName(); 389 log.trace("loadExtClass: load interfaces[{}] is {}", j, interfaceName); 390 391 if ("hdf.view.TreeView".equals(interfaceName) && !moduleListTreeView.contains(theName)) { 392 moduleListTreeView.add(theName); 393 break; 394 } 395 else if ("hdf.view.MetaDataView".equals(interfaceName) 396 && !moduleListMetaDataView.contains(theName)) { 397 moduleListMetaDataView.add(theName); 398 break; 399 } 400 else if ("hdf.view.TextView".equals(interfaceName) 401 && !moduleListTextView.contains(theName)) { 402 moduleListTextView.add(theName); 403 break; 404 } 405 else if ("hdf.view.TableView".equals(interfaceName) 406 && !moduleListTableView.contains(theName)) { 407 moduleListTableView.add(theName); 408 break; 409 } 410 else if ("hdf.view.ImageView".equals(interfaceName) 411 && !moduleListImageView.contains(theName)) { 412 moduleListImageView.add(theName); 413 break; 414 } 415 else if ("hdf.view.PaletteView".equals(interfaceName) 416 && !moduleListPaletteView.contains(theName)) { 417 moduleListPaletteView.add(theName); 418 break; 419 } 420 else if ("hdf.view.HelpView".equals(interfaceName) 421 && !moduleListHelpView.contains(theName)) { 422 moduleListHelpView.add(theName); 423 break; 424 } 425 } // for (int j=0; j<interfaces.length; j++) { 426 } // if (interfaces != null) { 427 } 428 } 429 catch (Exception ex) { 430 log.debug("loadExtClass: load classList[{}] of {} failed", i, theName, ex); 431 } 432 } // for (int i=0; i<n; i++) 433 log.trace("loadExtClass: finished"); 434 435 return extClassLoader; 436 } 437 438 /** @return the root directory where the HDFView is installed. */ 439 public static String getViewRoot() { 440 return rootDir; 441 } 442 443 public static Icon getFoldercloseIcon() { 444 return foldercloseIcon; 445 } 446 447 public static Icon getFoldercloseIconA() { 448 return foldercloseIconA; 449 } 450 451 public static Icon getFolderopenIcon() { 452 return folderopenIcon; 453 } 454 455 public static Icon getFolderopenIconA() { 456 return folderopenIconA; 457 } 458 459 public static Icon getHdfIcon() { 460 return hdfIcon; 461 } 462 463 public static Icon getH4Icon() { 464 return h4Icon; 465 } 466 467 public static Icon getH4IconR() { 468 return h4IconR; 469 } 470 471 public static Icon getH5Icon() { 472 return h5Icon; 473 } 474 475 public static Icon getH5IconR() { 476 return h5IconR; 477 } 478 479 public static Icon getDatasetIcon() { 480 return datasetIcon; 481 } 482 483 public static Icon getDatasetIconA() { 484 return datasetIconA; 485 } 486 487 public static Icon getDatatypeIcon() { 488 return datatypeIcon; 489 } 490 491 public static Icon getDatatypeIconA() { 492 return datatypeIconA; 493 } 494 495 public static Icon getLinkIcon() { 496 return linkIcon; 497 } 498 499 public static Icon getFileopenIcon() { 500 return fileopenIcon; 501 } 502 503 public static Icon getFilesaveIcon() { 504 return filesaveIcon; 505 } 506 507 public static Icon getFilenewIcon() { 508 return filenewIcon; 509 } 510 511 public static Icon getFilecloseIcon() { 512 return filecloseIcon; 513 } 514 515 public static Icon getPaletteIcon() { 516 return paletteIcon; 517 } 518 519 public static Icon getBrightIcon() { 520 return brightIcon; 521 } 522 523 public static Icon getAutocontrastIcon() { 524 return autocontrastIcon; 525 } 526 527 public static Icon getImageIcon() { 528 return imageIcon; 529 } 530 531 public static Icon getTableIcon() { 532 return tableIcon; 533 } 534 535 public static Icon getTextIcon() { 536 return textIcon; 537 } 538 539 public static Icon getImageIconA() { 540 return imageIconA; 541 } 542 543 public static Icon getTableIconA() { 544 return tableIconA; 545 } 546 547 public static Icon getTextIconA() { 548 return textIconA; 549 } 550 551 public static Icon getZoominIcon() { 552 return zoominIcon; 553 } 554 555 public static Icon getZoomoutIcon() { 556 return zoomoutIcon; 557 } 558 559 public static Icon getBlankIcon() { 560 return blankIcon; 561 } 562 563 public static Icon getHelpIcon() { 564 return helpIcon; 565 } 566 567 public static Icon getCopyIcon() { 568 return copyIcon; 569 } 570 571 public static Icon getCutIcon() { 572 return cutIcon; 573 } 574 575 public static Icon getPasteIcon() { 576 return pasteIcon; 577 } 578 579 public static Icon getLargeHdfIcon() { 580 return largeHdfIcon; 581 } 582 583 public static Icon getPreviousIcon() { 584 return previousIcon; 585 } 586 587 public static Icon getNextIcon() { 588 return nextIcon; 589 } 590 591 public static Icon getFirstIcon() { 592 return firstIcon; 593 } 594 595 public static Icon getLastIcon() { 596 return lastIcon; 597 } 598 599 public static Icon getChartIcon() { 600 return chartIcon; 601 } 602 603 public static Icon getAnimationIcon() { 604 return animationIcon; 605 } 606 607 public static ImageIcon getAppsIcon() { 608 return iconAPPS; 609 } 610 611 public static ImageIcon getUrlIcon() { 612 return iconURL; 613 } 614 615 public static ImageIcon getVideoIcon() { 616 return iconVIDEO; 617 } 618 619 public static ImageIcon getXlsIcon() { 620 return iconXLS; 621 } 622 623 public static ImageIcon getPdfIcon() { 624 return iconPDF; 625 } 626 627 public static ImageIcon getAudioIcon() { 628 return iconAUDIO; 629 } 630 631 public static Icon getQuestionIcon() { 632 return questionIcon; 633 } 634 635 public static void loadIcons() { 636 URL u = null; 637 638 // load icon images 639 if (hdfIcon == null) { 640 u = ViewProperties.class.getResource("/hdf/view/icons/hdf.gif"); 641 if (u != null) { 642 hdfIcon = new ImageIcon(u); 643 } 644 } 645 646 if (h4Icon == null) { 647 u = ViewProperties.class.getResource("/hdf/view/icons/hdf4.gif"); 648 if (u != null) { 649 h4Icon = new ImageIcon(u); 650 } 651 } 652 653 if (h4IconR == null) { 654 u = ViewProperties.class.getResource("/hdf/view/icons/hdf4R.gif"); 655 if (u != null) { 656 h4IconR = new ImageIcon(u); 657 } 658 } 659 660 if (h5Icon == null) { 661 u = ViewProperties.class.getResource("/hdf/view/icons/hdf5.gif"); 662 if (u != null) { 663 h5Icon = new ImageIcon(u); 664 } 665 } 666 667 if (h5IconR == null) { 668 u = ViewProperties.class.getResource("/hdf/view/icons/hdf5R.gif"); 669 if (u != null) { 670 h5IconR = new ImageIcon(u); 671 } 672 } 673 674 if (foldercloseIcon == null) { 675 u = ViewProperties.class.getResource("/hdf/view/icons/folderclose.gif"); 676 if (u != null) { 677 foldercloseIcon = new ImageIcon(u); 678 } 679 } 680 681 if (foldercloseIconA == null) { 682 u = ViewProperties.class.getResource("/hdf/view/icons/foldercloseA.gif"); 683 if (u != null) { 684 foldercloseIconA = new ImageIcon(u); 685 } 686 } 687 688 if (folderopenIcon == null) { 689 u = ViewProperties.class.getResource("/hdf/view/icons/folderopen.gif"); 690 if (u != null) { 691 folderopenIcon = new ImageIcon(u); 692 } 693 } 694 695 if (folderopenIconA == null) { 696 u = ViewProperties.class.getResource("/hdf/view/icons/folderopenA.gif"); 697 if (u != null) { 698 folderopenIconA = new ImageIcon(u); 699 } 700 } 701 702 if (datasetIcon == null) { 703 u = ViewProperties.class.getResource("/hdf/view/icons/dataset.gif"); 704 if (u != null) { 705 datasetIcon = new ImageIcon(u); 706 } 707 } 708 709 if (datasetIconA == null) { 710 u = ViewProperties.class.getResource("/hdf/view/icons/datasetA.gif"); 711 if (u != null) { 712 datasetIconA = new ImageIcon(u); 713 } 714 } 715 716 if (datatypeIcon == null) { 717 u = ViewProperties.class.getResource("/hdf/view/icons/datatype.gif"); 718 if (u != null) { 719 datatypeIcon = new ImageIcon(u); 720 } 721 } 722 723 if (datatypeIconA == null) { 724 u = ViewProperties.class.getResource("/hdf/view/icons/datatypeA.gif"); 725 if (u != null) { 726 datatypeIconA = new ImageIcon(u); 727 } 728 } 729 730 if (linkIcon == null) { 731 u = ViewProperties.class.getResource("/hdf/view/icons/link.gif"); 732 if (u != null) { 733 linkIcon = new ImageIcon(u); 734 } 735 } 736 737 if (fileopenIcon == null) { 738 u = ViewProperties.class.getResource("/hdf/view/icons/fileopen.gif"); 739 if (u != null) { 740 fileopenIcon = new ImageIcon(u); 741 } 742 } 743 744 if (filesaveIcon == null) { 745 u = ViewProperties.class.getResource("/hdf/view/icons/filesave.gif"); 746 if (u != null) { 747 filesaveIcon = new ImageIcon(u); 748 } 749 } 750 751 if (filenewIcon == null) { 752 u = ViewProperties.class.getResource("/hdf/view/icons/filenew.gif"); 753 if (u != null) { 754 filenewIcon = new ImageIcon(u); 755 } 756 } 757 758 if (filecloseIcon == null) { 759 u = ViewProperties.class.getResource("/hdf/view/icons/fileclose.gif"); 760 if (u != null) { 761 filecloseIcon = new ImageIcon(u); 762 } 763 } 764 765 if (paletteIcon == null) { 766 u = ViewProperties.class.getResource("/hdf/view/icons/palette.gif"); 767 if (u != null) { 768 paletteIcon = new ImageIcon(u); 769 } 770 } 771 772 if (brightIcon == null) { 773 u = ViewProperties.class.getResource("/hdf/view/icons/brightness.gif"); 774 if (u != null) { 775 brightIcon = new ImageIcon(u); 776 } 777 } 778 779 if (autocontrastIcon == null) { 780 u = ViewProperties.class.getResource("/hdf/view/icons/autocontrast.gif"); 781 if (u != null) { 782 autocontrastIcon = new ImageIcon(u); 783 } 784 } 785 786 if (imageIcon == null) { 787 u = ViewProperties.class.getResource("/hdf/view/icons/image.gif"); 788 if (u != null) { 789 imageIcon = new ImageIcon(u); 790 } 791 } 792 793 if (imageIconA == null) { 794 u = ViewProperties.class.getResource("/hdf/view/icons/imageA.gif"); 795 if (u != null) { 796 imageIconA = new ImageIcon(u); 797 } 798 } 799 800 if (tableIcon == null) { 801 u = ViewProperties.class.getResource("/hdf/view/icons/table.gif"); 802 if (u != null) { 803 tableIcon = new ImageIcon(u); 804 } 805 } 806 807 if (tableIconA == null) { 808 u = ViewProperties.class.getResource("/hdf/view/icons/tableA.gif"); 809 if (u != null) { 810 tableIconA = new ImageIcon(u); 811 } 812 } 813 814 if (textIcon == null) { 815 u = ViewProperties.class.getResource("/hdf/view/icons/text.gif"); 816 if (u != null) { 817 textIcon = new ImageIcon(u); 818 } 819 } 820 821 if (textIconA == null) { 822 u = ViewProperties.class.getResource("/hdf/view/icons/textA.gif"); 823 if (u != null) { 824 textIconA = new ImageIcon(u); 825 } 826 } 827 828 if (zoominIcon == null) { 829 u = ViewProperties.class.getResource("/hdf/view/icons/zoomin.gif"); 830 if (u != null) { 831 zoominIcon = new ImageIcon(u); 832 } 833 } 834 835 if (zoomoutIcon == null) { 836 u = ViewProperties.class.getResource("/hdf/view/icons/zoomout.gif"); 837 if (u != null) { 838 zoomoutIcon = new ImageIcon(u); 839 } 840 } 841 842 if (blankIcon == null) { 843 u = ViewProperties.class.getResource("/hdf/view/icons/blank.gif"); 844 if (u != null) { 845 blankIcon = new ImageIcon(u); 846 } 847 } 848 849 if (helpIcon == null) { 850 u = ViewProperties.class.getResource("/hdf/view/icons/help.gif"); 851 if (u != null) { 852 helpIcon = new ImageIcon(u); 853 } 854 } 855 856 if (copyIcon == null) { 857 u = ViewProperties.class.getResource("/hdf/view/icons/copy.gif"); 858 if (u != null) { 859 copyIcon = new ImageIcon(u); 860 } 861 } 862 863 if (cutIcon == null) { 864 u = ViewProperties.class.getResource("/hdf/view/icons/cut.gif"); 865 if (u != null) { 866 cutIcon = new ImageIcon(u); 867 } 868 } 869 870 if (pasteIcon == null) { 871 u = ViewProperties.class.getResource("/hdf/view/icons/paste.gif"); 872 if (u != null) { 873 pasteIcon = new ImageIcon(u); 874 } 875 } 876 877 if (largeHdfIcon == null) { 878 u = ViewProperties.class.getResource("/hdf/view/icons/hdf_large.gif"); 879 if (u != null) { 880 largeHdfIcon = new ImageIcon(u); 881 } 882 } 883 884 if (previousIcon == null) { 885 u = ViewProperties.class.getResource("/hdf/view/icons/previous.gif"); 886 if (u != null) { 887 previousIcon = new ImageIcon(u); 888 } 889 } 890 891 if (nextIcon == null) { 892 u = ViewProperties.class.getResource("/hdf/view/icons/next.gif"); 893 if (u != null) { 894 nextIcon = new ImageIcon(u); 895 } 896 } 897 898 if (firstIcon == null) { 899 u = ViewProperties.class.getResource("/hdf/view/icons/first.gif"); 900 if (u != null) { 901 firstIcon = new ImageIcon(u); 902 } 903 } 904 905 if (lastIcon == null) { 906 u = ViewProperties.class.getResource("/hdf/view/icons/last.gif"); 907 if (u != null) { 908 lastIcon = new ImageIcon(u); 909 } 910 } 911 912 if (chartIcon == null) { 913 u = ViewProperties.class.getResource("/hdf/view/icons/chart.gif"); 914 if (u != null) { 915 chartIcon = new ImageIcon(u); 916 } 917 } 918 919 if (animationIcon == null) { 920 u = ViewProperties.class.getResource("/hdf/view/icons/animation.gif"); 921 if (u != null) { 922 animationIcon = new ImageIcon(u); 923 } 924 } 925 926 if (questionIcon == null) { 927 u = ViewProperties.class.getResource("/hdf/view/icons/question.gif"); 928 if (u != null) { 929 questionIcon = new ImageIcon(u); 930 } 931 } 932 933 try { 934 u = ViewProperties.class.getResource("/hdf/view/icons/audio.gif"); 935 iconAUDIO = new ImageIcon(u); 936 } 937 catch (Exception ex) { 938 iconAUDIO = null; 939 } 940 941 try { 942 u = ViewProperties.class.getResource("/hdf/view/icons/xls.gif"); 943 iconXLS = new ImageIcon(u); 944 } 945 catch (Exception ex) { 946 iconXLS = null; 947 } 948 949 try { 950 u = ViewProperties.class.getResource("/hdf/view/icons/pdf.gif"); 951 iconPDF = new ImageIcon(u); 952 } 953 catch (Exception ex) { 954 iconPDF = null; 955 } 956 957 try { 958 u = ViewProperties.class.getResource("/hdf/view/icons/apps.gif"); 959 iconAPPS = new ImageIcon(u); 960 } 961 catch (Exception ex) { 962 iconAPPS = null; 963 } 964 965 try { 966 u = ViewProperties.class.getResource("/hdf/view/icons/url.gif"); 967 iconURL = new ImageIcon(u); 968 } 969 catch (Exception ex) { 970 iconURL = null; 971 } 972 973 try { 974 u = ViewProperties.class.getResource("/hdf/view/icons/video.gif"); 975 iconVIDEO = new ImageIcon(u); 976 } 977 catch (Exception ex) { 978 iconVIDEO = null; 979 } 980 } 981 982 /** Load user properties from property file 983 * @throws Exception if a failure occurred 984 */ 985 @SuppressWarnings({ "rawtypes", "unchecked" }) 986 public void load() throws Exception { 987 if (propertyFile == null) 988 return; 989 990 log.trace("load user properties: begin"); 991 992 String propVal = null; 993 994 // add default module. 995 String[] moduleKeys = { "module.treeview", "module.metadataview", "module.textview", "module.tableview", 996 "module.imageview", "module.paletteview" }; 997 Vector[] moduleList = { moduleListTreeView, moduleListMetaDataView, moduleListTextView, moduleListTableView, 998 moduleListImageView, moduleListPaletteView }; 999 String[] moduleNames = { "hdf.view.DefaultTreeView", "hdf.view.DefaultMetaDataView", 1000 "hdf.view.DefaultTextView", "hdf.view.DefaultTableView", "hdf.view.DefaultImageView", 1001 "hdf.view.DefaultPaletteView" }; 1002 1003 // add default implementation of modules 1004 for (int i = 0; i < 6; i++) { 1005 log.trace("load: add default moduleList[{}] is {}", i, moduleNames[i]); 1006 if (!moduleList[i].contains(moduleNames[i])) { 1007 moduleList[i].addElement(moduleNames[i]); 1008 } 1009 } 1010 if (extClassLoader == null) loadExtClass(); 1011 1012 // set default selection of data views 1013 for (int i = 0; i < 6; i++) { 1014 Vector<String> theList = moduleList[i]; 1015 propVal = (String) get(moduleKeys[i]); 1016 1017 if (propVal != null) { 1018 // set default to the module specified in property file 1019 theList.remove(propVal); 1020 theList.add(0, propVal); 1021 } 1022 else { 1023 // use default module 1024 theList.remove(moduleNames[i]); 1025 theList.add(0, moduleNames[i]); 1026 } 1027 } 1028 1029 try { 1030 FileInputStream fis = new FileInputStream(propertyFile); 1031 load(fis); 1032 fis.close(); 1033 } 1034 catch (Exception e) { 1035 log.debug("load: loading propertyFile failed", e); 1036 } 1037 1038 // add fileformat modules 1039 Enumeration local_enum = this.keys(); 1040 String theKey = null; 1041 String fExt = null; 1042 while (local_enum.hasMoreElements()) { 1043 theKey = (String) local_enum.nextElement(); 1044 log.trace("load: add file format {}", theKey); 1045 if (theKey.startsWith("module.fileformat")) { 1046 fExt = theKey.substring(18); 1047 try { 1048 // enables use of JHDF5 in JNLP (Web Start) applications, 1049 // the system class loader with reflection first. 1050 String className = (String) get(theKey); 1051 Class theClass = null; 1052 try { 1053 theClass = Class.forName(className); 1054 } 1055 catch (Exception ex) { 1056 try { 1057 theClass = extClassLoader.loadClass(className); 1058 } 1059 catch (Exception ex2) { 1060 log.debug("load: extClassLoader.loadClass({}) failed", className, ex2); 1061 } 1062 } 1063 1064 Object theObject = theClass.newInstance(); 1065 if (theObject instanceof FileFormat) { 1066 FileFormat.addFileFormat(fExt, (FileFormat) theObject); 1067 } 1068 } 1069 catch (Throwable err) { 1070 log.debug("load: load file format failed", err); 1071 } 1072 } 1073 } 1074 1075 propVal = (String) get("users.guide"); 1076 if (propVal != null) { 1077 usersGuide = propVal; 1078 } 1079 1080 propVal = (String) get("image.contrast"); 1081 if (propVal != null) { 1082 isAutoContrast = ("auto".equalsIgnoreCase(propVal)); 1083 } 1084 1085 propVal = (String) get("image.showvalues"); 1086 if (propVal != null) { 1087 showImageValues = ("true".equalsIgnoreCase(propVal)); 1088 } 1089 1090 propVal = (String) get("file.mode"); 1091 if (propVal != null) { 1092 isReadOnly = ("r".equalsIgnoreCase(propVal)); 1093 } 1094 1095 propVal = (String) get("lib.version"); 1096 if (propVal != null) { 1097 isEarlyLib = ("early".equalsIgnoreCase(propVal)); 1098 } 1099 1100 propVal = (String) get("enum.conversion"); 1101 if (propVal != null) { 1102 convertEnum = ("true".equalsIgnoreCase(propVal)); 1103 } 1104 1105 propVal = (String) get("regref.showvalues"); 1106 if (propVal != null) { 1107 showRegRefValues = ("true".equalsIgnoreCase(propVal)); 1108 } 1109 1110 propVal = (String) get("index.base1"); 1111 if (propVal != null) { 1112 isIndexBase1 = ("true".equalsIgnoreCase(propVal)); 1113 } 1114 1115 propVal = (String) get("data.delimiter"); 1116 if ((propVal != null) && (propVal.length() > 0)) { 1117 delimiter = propVal; 1118 } 1119 1120 propVal = (String) get("image.origin"); 1121 if ((propVal != null) && (propVal.length() > 0)) { 1122 origin = propVal; 1123 } 1124 1125 propVal = (String) get("h5file.indexType"); 1126 if ((propVal != null) && (propVal.length() > 0)) { 1127 indexType = propVal; 1128 } 1129 1130 propVal = (String) get("h5file.indexOrder"); 1131 if ((propVal != null) && (propVal.length() > 0)) { 1132 indexOrder = propVal; 1133 } 1134 1135 propVal = (String) get("h4toh5.converter"); 1136 if ((propVal != null) && (propVal.length() > 0)) { 1137 h4toh5 = propVal; 1138 } 1139 1140 propVal = (String) get("work.dir"); 1141 if ((propVal != null) && (propVal.length() > 0)) { 1142 workDir = propVal; 1143 } 1144 1145 propVal = (String) get("file.extension"); 1146 if ((propVal != null) && (propVal.length() > 0)) { 1147 fileExt = propVal; 1148 FileFormat.addFileExtension(fileExt); 1149 } 1150 1151 propVal = (String) get("font.size"); 1152 if ((propVal != null) && (propVal.length() > 0)) { 1153 try { 1154 fontSize = Integer.parseInt(propVal); 1155 } 1156 catch (Exception ex) { 1157 log.debug("load: load fontSize failed", ex); 1158 } 1159 } 1160 1161 propVal = (String) get("font.type"); 1162 if ((propVal != null) && (propVal.length() > 0)) { 1163 fontType = propVal.trim(); 1164 } 1165 1166 propVal = (String) get("max.members"); 1167 if ((propVal != null) && (propVal.length() > 0)) { 1168 try { 1169 max_members = Integer.parseInt(propVal); 1170 } 1171 catch (Exception ex) { 1172 log.debug("load: load max.members failed", ex); 1173 } 1174 } 1175 1176 // load the most recent file list from the property file 1177 String theFile = null; 1178 for (int i = 0; i < MAX_RECENT_FILES; i++) { 1179 theFile = getProperty("recent.file" + i); 1180 if ((theFile != null) && !recentFiles.contains(theFile)) { 1181 if (theFile.startsWith("http://") || theFile.startsWith("ftp://") || (new File(theFile)).exists()) { 1182 recentFiles.addElement(theFile); 1183 } 1184 } 1185 else { 1186 this.remove("recent.file" + i); 1187 } 1188 } 1189 1190 // load the most recent palette file list from the property file 1191 theFile = null; 1192 for (int i = 0; i < MAX_RECENT_FILES; i++) { 1193 theFile = getProperty("palette.file" + i); 1194 if (theFile != null) theFile = theFile.trim(); 1195 1196 if ((theFile != null && theFile.length() > 0) && !paletteList.contains(theFile)) { 1197 if ((new File(theFile)).exists()) { 1198 paletteList.addElement(theFile); 1199 } 1200 } 1201 else { 1202 this.remove("palette.file" + i); 1203 } 1204 } 1205 1206 // load srb account 1207 propVal = null; 1208 String srbaccount[] = new String[7]; 1209 for (int i = 0; i < MAX_RECENT_FILES; i++) { 1210 if (null == (srbaccount[0] = getProperty("srbaccount" + i + ".host"))) { 1211 continue; 1212 } 1213 if (null == (srbaccount[1] = getProperty("srbaccount" + i + ".port"))) { 1214 continue; 1215 } 1216 if (null == (srbaccount[2] = getProperty("srbaccount" + i + ".user"))) { 1217 continue; 1218 } 1219 if (null == (srbaccount[3] = getProperty("srbaccount" + i + ".password"))) { 1220 continue; 1221 } 1222 if (null == (srbaccount[4] = getProperty("srbaccount" + i + ".home"))) { 1223 continue; 1224 } 1225 if (null == (srbaccount[5] = getProperty("srbaccount" + i + ".domain"))) { 1226 continue; 1227 } 1228 if (null == (srbaccount[6] = getProperty("srbaccount" + i + ".resource"))) { 1229 continue; 1230 } 1231 srbAccountList.add(srbaccount); 1232 srbaccount = new String[7]; 1233 } 1234 1235 // set default modules from user property files 1236 for (int i = 0; i < 6; i++) { 1237 String moduleName = (String) get(moduleKeys[i]); 1238 log.trace("load: default modules from user property is {}", moduleName); 1239 if ((moduleName != null) && (moduleName.length() > 0)) { 1240 if (moduleList[i].contains(moduleName)) moduleList[i].remove(moduleName); 1241 moduleList[i].add(0, moduleName); 1242 } 1243 } 1244 log.trace("load: finish"); 1245 } 1246 1247 /** Save user properties into property file */ 1248 public void save() { 1249 if (propertyFile == null) 1250 return; 1251 1252 clear(); 1253 1254 // update data saving options 1255 if (delimiter == null) { 1256 put("data.delimiter", DELIMITER_TAB); 1257 } 1258 else { 1259 put("data.delimiter", delimiter); 1260 } 1261 1262 if (origin == null) { 1263 put("image.origin", ORIGIN_UL); 1264 } 1265 else { 1266 put("image.origin", origin); 1267 } 1268 1269 if (indexType != null) { 1270 put("h5file.indexType", indexType); 1271 } 1272 1273 if (indexOrder != null) { 1274 put("h5file.indexOrder", indexOrder); 1275 } 1276 1277 if (usersGuide != null) { 1278 put("users.guide", usersGuide); 1279 } 1280 1281 if (workDir != null) { 1282 put("work.dir", workDir); 1283 } 1284 1285 if (fileExt != null) { 1286 put("file.extension", fileExt); 1287 } 1288 1289 if (h4toh5 != null) { 1290 put("h4toh5.converter", h4toh5); 1291 } 1292 1293 put("font.size", String.valueOf(fontSize)); 1294 1295 if (fontType != null) { 1296 put("font.type", fontType); 1297 } 1298 1299 put("max.members", String.valueOf(max_members)); 1300 1301 if (isAutoContrast) { 1302 put("image.contrast", "auto"); 1303 } 1304 else { 1305 put("image.contrast", "general"); 1306 } 1307 1308 if (showImageValues) 1309 put("image.showvalues", "true"); 1310 else 1311 put("image.showvalues", "false"); 1312 1313 if (isReadOnly) { 1314 put("file.mode", "r"); 1315 } 1316 else { 1317 put("file.mode", "rw"); 1318 } 1319 1320 if (isEarlyLib) { 1321 put("lib.version", "early"); 1322 } 1323 else { 1324 put("lib.version", "latest"); 1325 } 1326 1327 put("enum.conversion", String.valueOf(convertEnum)); 1328 if (showRegRefValues) 1329 put("regref.showvalues", "true"); 1330 else 1331 put("regref.showvalues", "false"); 1332 put("index.base1", String.valueOf(isIndexBase1)); 1333 1334 // save the list of most recent files 1335 String theFile; 1336 int size = recentFiles.size(); 1337 int minSize = Math.min(size, MAX_RECENT_FILES); 1338 for (int i = 0; i < minSize; i++) { 1339 theFile = recentFiles.elementAt(i); 1340 if ((theFile != null) && (theFile.length() > 0)) { 1341 put("recent.file" + i, theFile); 1342 } 1343 } 1344 1345 // save the list of most recent palette files 1346 size = paletteList.size(); 1347 minSize = Math.min(size, MAX_RECENT_FILES); 1348 for (int i = 0; i < minSize; i++) { 1349 theFile = paletteList.elementAt(i); 1350 if ((theFile != null) && (theFile.length() > 0)) { 1351 put("palette.file" + i, theFile); 1352 } 1353 } 1354 1355 // save srb account 1356 String srbaccount[] = null; 1357 size = srbAccountList.size(); 1358 minSize = Math.min(size, MAX_RECENT_FILES); 1359 for (int i = 0; i < minSize; i++) { 1360 srbaccount = srbAccountList.get(i); 1361 if ((srbaccount[0] != null) && (srbaccount[1] != null) && (srbaccount[2] != null) 1362 && (srbaccount[3] != null) && (srbaccount[4] != null) && (srbaccount[5] != null) 1363 && (srbaccount[6] != null)) { 1364 put("srbaccount" + i + ".host", srbaccount[0]); 1365 put("srbaccount" + i + ".port", srbaccount[1]); 1366 put("srbaccount" + i + ".user", srbaccount[2]); 1367 put("srbaccount" + i + ".password", srbaccount[3]); 1368 put("srbaccount" + i + ".home", srbaccount[4]); 1369 put("srbaccount" + i + ".domain", srbaccount[5]); 1370 put("srbaccount" + i + ".resource", srbaccount[6]); 1371 } 1372 } 1373 1374 // save default modules 1375 String moduleName = moduleListTreeView.elementAt(0); 1376 if ((moduleName != null) && (moduleName.length() > 0)) { 1377 put("module.treeview", moduleName); 1378 } 1379 1380 moduleName = moduleListMetaDataView.elementAt(0); 1381 if ((moduleName != null) && (moduleName.length() > 0)) { 1382 put("module.metadataview", moduleName); 1383 } 1384 1385 moduleName = moduleListTextView.elementAt(0); 1386 if ((moduleName != null) && (moduleName.length() > 0)) { 1387 put("module.textview", moduleName); 1388 } 1389 1390 moduleName = moduleListTableView.elementAt(0); 1391 if ((moduleName != null) && (moduleName.length() > 0)) { 1392 put("module.tableview", moduleName); 1393 } 1394 1395 moduleName = moduleListImageView.elementAt(0); 1396 if ((moduleName != null) && (moduleName.length() > 0)) { 1397 put("module.imageview", moduleName); 1398 } 1399 1400 moduleName = moduleListPaletteView.elementAt(0); 1401 if ((moduleName != null) && (moduleName.length() > 0)) { 1402 put("module.paletteview", moduleName); 1403 } 1404 1405 // save the current supported fileformat 1406 Enumeration<?> keys = FileFormat.getFileFormatKeys(); 1407 String theKey = null; 1408 while (keys.hasMoreElements()) { 1409 theKey = (String) keys.nextElement(); 1410 FileFormat theformat = FileFormat.getFileFormat(theKey); 1411 put("module.fileformat." + theKey, theformat.getClass().getName()); 1412 } 1413 1414 try { 1415 FileOutputStream fos = new FileOutputStream(propertyFile); 1416 store(fos, "User properties modified on "); 1417 fos.close(); 1418 } 1419 catch (Exception e) { 1420 ; 1421 } 1422 } 1423 1424 /** @return the name of the user property file */ 1425 public static String getPropertyFile() { 1426 return propertyFile; 1427 } 1428 1429 /** @return the default work directory, where the open file starts. */ 1430 public static String getWorkDir() { 1431 String workPath = workDir; 1432 log.trace("getWorkDir: workDir={}", workDir); 1433 if (workPath == null) { 1434 workPath = System.getProperty("hdfview.workdir"); 1435 log.trace("getWorkDir: hdfview.workdir={}", workPath); 1436 if (workPath == null) { 1437 workPath = System.getProperty("user.home"); 1438 } 1439 } 1440 log.trace("getWorkDir: final workPath={}", workPath); 1441 return workPath; 1442 } 1443 1444 /** @return the maximum number of the most recent file */ 1445 public static int getMaxRecentFiles() { 1446 return MAX_RECENT_FILES; 1447 } 1448 1449 /** @return the path of the HDFView users guide */ 1450 public static String getUsersGuide() { 1451 return usersGuide; 1452 }; 1453 1454 /** @return the delimiter of data values */ 1455 public static String getDataDelimiter() { 1456 return delimiter; 1457 } 1458 1459 /** @return the image origin */ 1460 public static String getImageOrigin() { 1461 return origin; 1462 } 1463 1464 /** @return the default index type for display */ 1465 public static String getIndexType() { 1466 return indexType; 1467 } 1468 1469 /** @return the default index order for display */ 1470 public static String getIndexOrder() { 1471 return indexOrder; 1472 } 1473 1474 /** @return the font size */ 1475 public static int getFontSize() { 1476 return fontSize; 1477 } 1478 1479 /** @return the font type */ 1480 public static String getFontType() { 1481 return fontType; 1482 } 1483 1484 /** @return the file extensions of supported file formats */ 1485 public static String getFileExtension() { 1486 return fileExt; 1487 } 1488 1489 /** sets the font size 1490 * 1491 * @param fsize 1492 * the font size 1493 */ 1494 public static void setFontSize(int fsize) { 1495 fontSize = (fsize / 2) * 2; 1496 1497 if (fontSize < 8) { 1498 fontSize = 8; 1499 } 1500 } 1501 1502 /** sets the font type 1503 * 1504 * @param ftype 1505 * the font type 1506 */ 1507 public static void setFontType(String ftype) { 1508 if (ftype != null) { 1509 fontType = ftype.trim(); 1510 } 1511 } 1512 1513 /** @return the path of the H5toH5 converter */ 1514 public static String getH4toH5() { 1515 return h4toh5; 1516 } 1517 1518 /** @return the list of most recent files */ 1519 public static Vector<String> getMRF() { 1520 return recentFiles; 1521 } 1522 1523 /** @return the list of palette files */ 1524 public static Vector<String> getPaletteList() { 1525 return paletteList; 1526 } 1527 1528 public static Vector<String[]> getSrbAccount() { 1529 return srbAccountList; 1530 } 1531 1532 /** @return a list of treeview modules */ 1533 public static Vector<String> getTreeViewList() { 1534 return moduleListTreeView; 1535 } 1536 1537 /** @return a list of metadataview modules */ 1538 public static Vector<String> getMetaDataViewList() { 1539 return moduleListMetaDataView; 1540 } 1541 1542 /** @return a list of textview modules */ 1543 public static Vector<String> getTextViewList() { 1544 return moduleListTextView; 1545 } 1546 1547 /** @return a list of tableview modules */ 1548 public static Vector<String> getTableViewList() { 1549 return moduleListTableView; 1550 } 1551 1552 /** @return a list of imageview modules */ 1553 public static Vector<String> getImageViewList() { 1554 return moduleListImageView; 1555 } 1556 1557 /** @return a list of paletteview modules */ 1558 public static Vector<String> getPaletteViewList() { 1559 return moduleListPaletteView; 1560 } 1561 1562 /** @return a list of helpview modules */ 1563 public static Vector<String> getHelpViewList() { 1564 return moduleListHelpView; 1565 } 1566 1567 /** set the path of H5View User's guide 1568 * 1569 * @param str 1570 * the path 1571 */ 1572 public static void setUsersGuide(String str) { 1573 if ((str == null) || (str.length() <= 0)) { 1574 return; 1575 } 1576 usersGuide = str; 1577 } 1578 1579 /** set the path of the H4 to H5 converter 1580 * 1581 * @param tool 1582 * the path of the H4 to H5 converter 1583 */ 1584 public static void setH4toH5(String tool) { 1585 h4toh5 = tool; 1586 } 1587 1588 /** set the path of the default work directory 1589 * 1590 * @param wDir 1591 * the default work directory 1592 */ 1593 public static void setWorkDir(String wDir) { 1594 log.trace("ViewProperties:setWorkDir wDir={}", wDir); 1595 workDir = wDir; 1596 } 1597 1598 /** set the file extension 1599 * 1600 * @param ext 1601 * the file extension 1602 */ 1603 public static void setFileExtension(String ext) { 1604 fileExt = ext; 1605 } 1606 1607 /** set the delimiter of data values 1608 * 1609 * @param delim 1610 * the delimiter of data values 1611 */ 1612 public static void setDataDelimiter(String delim) { 1613 delimiter = delim; 1614 } 1615 1616 /** set the image origin 1617 * 1618 * @param o 1619 * the image origin 1620 */ 1621 public static void setImageOrigin(String o) { 1622 origin = o; 1623 } 1624 1625 /** set the index type 1626 * 1627 * @param idxType 1628 * the index type 1629 */ 1630 public static void setIndexType(String idxType) { 1631 indexType = idxType; 1632 } 1633 1634 /** set the index order 1635 * 1636 * @param idxOrder 1637 * the index order 1638 */ 1639 public static void setIndexOrder(String idxOrder) { 1640 indexOrder = idxOrder; 1641 } 1642 1643 /** 1644 * Current Java applications such as HDFView cannot handle files with large 1645 * number of objects such as 1,000,000 objects. setMaxMembers() sets the 1646 * maximum number of objects that will be loaded into memory. 1647 * 1648 * @param n 1649 * the maximum number of objects to load into memory 1650 */ 1651 public static void setMaxMembers(int n) { 1652 max_members = n; 1653 } 1654 1655 /** 1656 * Current Java applications such as HDFView cannot handle files with large 1657 * number of objects such as 1,000,000 objects. setStartMember() sets the 1658 * starting index of objects that will be loaded into memory. 1659 * 1660 * @param idx 1661 * the maximum number of objects to load into memory 1662 */ 1663 public static void setStartMembers(int idx) { 1664 if (idx < 0) { 1665 idx = 0; 1666 } 1667 1668 start_members = idx; 1669 } 1670 1671 /** 1672 * Current Java applications such as HDFView cannot handle files with large 1673 * number of objects such as 1,000,000 objects. getMaxMembers() returns the 1674 * maximum number of objects that will be loaded into memory. 1675 * 1676 * @return the maximum members 1677 */ 1678 public static int getMaxMembers() { 1679 if (max_members < 0) 1680 return Integer.MAX_VALUE; // load the whole file 1681 1682 return max_members; 1683 } 1684 1685 /** 1686 * Current Java applications such as HDFView cannot handle files with large 1687 * number of objects such as 1,000,000 objects. getStartMembers() returns the 1688 * starting index of objects that will be loaded into memory. 1689 * 1690 * @return the start members 1691 */ 1692 public static int getStartMembers() { 1693 return start_members; 1694 } 1695 1696 /** 1697 * Returns true if auto contrast is used in image processing. 1698 * 1699 * @return true if auto contrast is used in image processing; otherwise, 1700 * returns false. 1701 */ 1702 public static boolean isAutoContrast() { 1703 return isAutoContrast; 1704 } 1705 1706 /** 1707 * Returns true if "show image values" is set. 1708 * 1709 * @return true if "show image values" is set; otherwise, returns false. 1710 */ 1711 public static boolean showImageValues() { 1712 return showImageValues; 1713 } 1714 1715 /** 1716 * Set the flag to indicate if auto contrast is used in image process. 1717 * 1718 * @param b 1719 * the flag to indicate if auto contrast is used in image 1720 * process. 1721 */ 1722 public static void setAutoContrast(boolean b) { 1723 isAutoContrast = b; 1724 } 1725 1726 /** 1727 * Set the flag to indicate if "show image values" is set. 1728 * 1729 * @param b 1730 * the flag to indicate if if "show image values" is set. 1731 */ 1732 public static void setShowImageValue(boolean b) { 1733 showImageValues = b; 1734 } 1735 1736 /** 1737 * Returns true if default file access is read only. 1738 * 1739 * @return true if default file access is read only; otherwise, returns 1740 * false. 1741 */ 1742 public static boolean isReadOnly() { 1743 return isReadOnly; 1744 } 1745 1746 /** 1747 * Set the flag to indicate if default file access is read only. 1748 * 1749 * @param b 1750 * the flag to indicate if default file access is read only. 1751 */ 1752 public static void setReadOnly(boolean b) { 1753 isReadOnly = b; 1754 } 1755 1756 /** 1757 * Returns true if default lib version is the earliest. 1758 * 1759 * @return true if default lib version is the earliest; otherwise, returns 1760 * false. 1761 */ 1762 public static boolean isEarlyLib() { 1763 return isEarlyLib; 1764 } 1765 1766 /** 1767 * Set the flag to indicate if default lib version is the earliest. 1768 * 1769 * @param b 1770 * the flag to indicate if default lib version is the earliest. 1771 */ 1772 public static void setEarlyLib(boolean b) { 1773 isEarlyLib = b; 1774 } 1775 1776 /** 1777 * @return the convertEnum 1778 */ 1779 public static boolean isConvertEnum() { 1780 return convertEnum; 1781 } 1782 1783 /** 1784 * Returns true if "show regref values" is set. 1785 * 1786 * @return true if "show regref values" is set; otherwise, returns false. 1787 */ 1788 public static boolean showRegRefValues() { 1789 return showRegRefValues; 1790 } 1791 1792 /** 1793 * @return the isIndexBase1 1794 */ 1795 public static boolean isIndexBase1() { 1796 return isIndexBase1; 1797 } 1798 1799 /** 1800 * @param convertEnum 1801 * the convertEnum to set 1802 */ 1803 public static void setConvertEnum(boolean convertEnum) { 1804 ViewProperties.convertEnum = convertEnum; 1805 } 1806 1807 /** 1808 * Set the flag to indicate if "show RegRef values" is set. 1809 * 1810 * @param b 1811 * the flag to indicate if if "show RegRef values" is set. 1812 */ 1813 public static void setShowRegRefValue(boolean b) { 1814 showRegRefValues = b; 1815 } 1816 1817 /** 1818 * Set the flag to indicate if IndexBase should start at 1. 1819 * 1820 * @param b 1821 * the flag to indicate if IndexBase should start at 1. 1822 */ 1823 public static void setIndexBase1(boolean b) { 1824 ViewProperties.isIndexBase1 = b; 1825 } 1826 1827}