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