Changeset 6996
- Timestamp:
- 09/28/10 10:59:32 (9 years ago)
- Location:
- branches/4.2
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.2
- Property svn:mergeinfo changed
/trunk merged: 6696,6722-6723,6737,6793
- Property svn:mergeinfo changed
-
branches/4.2/components/bio-formats/src/loci/formats/in
- Property svn:mergeinfo changed
/trunk/components/bio-formats/src/loci/formats/in merged: 6696,6722-6723,6737,6793
- Property svn:mergeinfo changed
-
branches/4.2/components/bio-formats/src/loci/formats/tiff
- Property svn:mergeinfo changed
/trunk/components/bio-formats/src/loci/formats/tiff merged: 6737,6793
- Property svn:mergeinfo changed
-
branches/4.2/components/bio-formats/src/loci/formats/tools/ImageConverter.java
r6843 r6996 27 27 import java.io.IOException; 28 28 29 import loci.common.DebugTools; 29 30 import loci.common.Location; 30 31 import loci.common.services.DependencyException; … … 75 76 throws FormatException, IOException 76 77 { 78 DebugTools.enableLogging("INFO"); 77 79 String in = null, out = null; 78 80 String map = null; … … 85 87 if (args[i].startsWith("-") && args.length > 1) { 86 88 if (args[i].equals("-debug")) { 87 LOGGER.warn("To enable debugging, edit the log4j.properties file,"); 88 LOGGER.warn("changing log4j.rootCategory from INFO to DEBUG"); 89 LOGGER.warn("(or TRACE for extreme verbosity)."); 89 DebugTools.enableLogging("DEBUG"); 90 90 } 91 91 else if (args[i].equals("-stitch")) stitch = true; -
branches/4.2/components/bio-formats/src/loci/formats/tools/ImageInfo.java
r6680 r6996 31 31 import loci.common.ByteArrayHandle; 32 32 import loci.common.DataTools; 33 import loci.common.DebugTools; 33 34 import loci.common.Location; 34 35 import loci.common.RandomAccessInputStream; … … 173 174 else if (args[i].equals("-autoscale")) autoscale = true; 174 175 else if (args[i].equals("-debug")) { 175 LOGGER.warn(""); 176 LOGGER.warn("To enable debugging, edit the log4j.properties file,"); 177 LOGGER.warn("changing log4j.rootCategory from INFO to DEBUG"); 178 LOGGER.warn("(or TRACE for extreme verbosity)."); 176 DebugTools.enableLogging("DEBUG"); 179 177 } 180 178 else if (args[i].equals("-preload")) preload = true; … … 864 862 */ 865 863 public boolean testRead(String[] args) 866 throws FormatException, ServiceException, IOException { 864 throws FormatException, ServiceException, IOException 865 { 866 DebugTools.enableLogging("INFO"); 867 867 parseArgs(args); 868 868 if (printVersion) { -
branches/4.2/components/common/src/loci/common/DataTools.java
r6495 r6996 487 487 488 488 /** @deprecated Use {@link #unpackBytes(long, byte[], int, int, boolean) */ 489 @Deprecated 489 490 public static void unpackShort(short value, byte[] buf, int ndx, 490 491 boolean little) … … 520 521 521 522 /** 522 * Convert a byte array to the appropriate primitive type array. 523 * Convert a byte array to the appropriate 1D primitive type array. 524 * 523 525 * @param b Byte array to convert. 524 526 * @param bpp Denotes the number of bytes in the returned primitive type … … 527 529 * @param little Whether byte array is in little-endian order. 528 530 */ 529 public static Object makeDataArray(byte[] b, int bpp, boolean fp,530 boolean little)531 public static Object makeDataArray(byte[] b, 532 int bpp, boolean fp, boolean little) 531 533 { 532 534 if (bpp == 1) { … … 576 578 * regardless of signedness. 577 579 */ 580 @Deprecated 578 581 public static Object makeDataArray(byte[] b, 579 582 int bpp, boolean fp, boolean little, boolean signed) 580 583 { 581 584 return makeDataArray(b, bpp, fp, little); 585 } 586 587 /** 588 * Convert a byte array to the appropriate 2D primitive type array. 589 * 590 * @param b Byte array to convert. 591 * @param bpp Denotes the number of bytes in the returned primitive type 592 * (e.g. if bpp == 2, we should return an array of type short). 593 * @param fp If set and bpp == 4 or bpp == 8, then return floats or doubles. 594 * @param little Whether byte array is in little-endian order. 595 * @param height The height of the output primitive array (2nd dim length). 596 * 597 * @return a 2D primitive array of appropriate type, 598 * dimensioned [height][b.length / (bpp * height)] 599 * 600 * @throws IllegalArgumentException if input byte array does not divide 601 * evenly into height pieces 602 */ 603 public static Object makeDataArray2D(byte[] b, 604 int bpp, boolean fp, boolean little, int height) 605 { 606 if (b.length % (bpp * height) != 0) { 607 throw new IllegalArgumentException("Array length mismatch: " + 608 "b.length=" + b.length + "; bpp=" + bpp + "; height=" + height); 609 } 610 final int width = b.length / (bpp * height); 611 if (bpp == 1) { 612 byte[][] b2 = new byte[height][width]; 613 for (int y=0; y<height; y++) { 614 int index = width*y; 615 System.arraycopy(b, index, b2[y], 0, width); 616 } 617 return b2; 618 } 619 else if (bpp == 2) { 620 short[][] s = new short[height][width]; 621 for (int y=0; y<height; y++) { 622 for (int x=0; x<width; x++) { 623 int index = 2*(width*y + x); 624 s[y][x] = bytesToShort(b, index, 2, little); 625 } 626 } 627 return s; 628 } 629 else if (bpp == 4 && fp) { 630 float[][] f = new float[height][width]; 631 for (int y=0; y<height; y++) { 632 for (int x=0; x<width; x++) { 633 int index = 4*(width*y + x); 634 f[y][x] = bytesToFloat(b, index, 4, little); 635 } 636 } 637 return f; 638 } 639 else if (bpp == 4) { 640 int[][] i = new int[height][width]; 641 for (int y=0; y<height; y++) { 642 for (int x=0; x<width; x++) { 643 int index = 4*(width*y + x); 644 i[y][x] = bytesToInt(b, index, 4, little); 645 } 646 } 647 return i; 648 } 649 else if (bpp == 8 && fp) { 650 double[][] d = new double[height][width]; 651 for (int y=0; y<height; y++) { 652 for (int x=0; x<width; x++) { 653 int index = 8*(width*y + x); 654 d[y][x] = bytesToDouble(b, index, 8, little); 655 } 656 } 657 return d; 658 } 659 else if (bpp == 8) { 660 long[][] l = new long[height][width]; 661 for (int y=0; y<height; y++) { 662 for (int x=0; x<width; x++) { 663 int index = 8*(width*y + x); 664 l[y][x] = bytesToLong(b, index, 8, little); 665 } 666 } 667 return l; 668 } 669 return null; 582 670 } 583 671 -
branches/4.2/components/common/src/loci/common/DebugTools.java
r6318 r6996 26 26 import java.io.ByteArrayOutputStream; 27 27 import java.io.PrintStream; 28 import java.util.Enumeration; 28 29 29 30 /** … … 51 52 } 52 53 54 /** 55 * Attempts to enable SLF4J logging via log4j 56 * without an external configuration file. 57 * 58 * @param level A string indicating the desired level 59 * (i.e.: ALL, DEBUG, ERROR, FATAL, INFO, OFF, TRACE, WARN). 60 * @return true iff logging was successfully enabled 61 */ 62 public static synchronized boolean enableLogging(String level) { 63 ReflectedUniverse r = new ReflectedUniverse(); 64 try { 65 r.exec("import org.apache.log4j.Level"); 66 r.exec("import org.apache.log4j.Logger"); 67 r.exec("root = Logger.getRootLogger()"); 68 r.exec("root.setLevel(Level." + level + ")"); 69 Enumeration en = (Enumeration) r.exec("root.getAllAppenders()"); 70 if (!en.hasMoreElements()) { 71 // no appenders yet; attach a simple console appender 72 r.exec("import org.apache.log4j.ConsoleAppender"); 73 r.exec("import org.apache.log4j.PatternLayout"); 74 r.setVar("pattern", "%m%n"); 75 r.exec("layout = new PatternLayout(pattern)"); 76 r.exec("appender = new ConsoleAppender(layout)"); 77 r.exec("root.addAppender(appender)"); 78 } 79 } 80 catch (ReflectException exc) { 81 return false; 82 } 83 return true; 84 } 85 53 86 } -
branches/4.2/components/common/src/loci/common/StatusEvent.java
r6132 r6996 86 86 public boolean isWarning() { return warning; } 87 87 88 // -- Object API methods -- 89 90 @Override 91 public String toString() { 92 StringBuilder sb = new StringBuilder(); 93 sb.append("Status"); 94 sb.append(": progress=" + progress); 95 sb.append(", maximum=" + maximum); 96 sb.append(", warning=" + warning); 97 sb.append(", status='" + status + "'"); 98 return sb.toString(); 99 } 100 88 101 } -
branches/4.2/components/common/src/loci/common/services/ServiceFactory.java
r6944 r6996 108 108 } 109 109 catch (Throwable t) { 110 LOGGER. warn("CLASSPATH missing interface: {}", interfaceName, t);110 LOGGER.debug("CLASSPATH missing interface: {}", interfaceName, t); 111 111 continue; 112 112 } -
branches/4.2/components/loci-plugins
- Property svn:mergeinfo changed
/trunk/components/loci-plugins merged: 6696,6722-6723,6737,6793
- Property svn:mergeinfo changed
-
branches/4.2/components/loci-plugins/src/loci/plugins
- Property svn:mergeinfo changed
/trunk/components/loci-plugins/src/loci/plugins merged: 6696,6722-6723,6737,6793
- Property svn:mergeinfo changed
-
branches/4.2/components/loci-plugins/src/loci/plugins/in/Calibrator.java
- Property svn:mergeinfo changed
/trunk/components/loci-plugins/src/loci/plugins/in/Calibrator.java merged: 6696,6722-6723,6737,6793
- Property svn:mergeinfo changed
-
branches/4.2/components/ome-xml
- Property svn:mergeinfo changed
/trunk/components/ome-xml merged: 6696,6722-6723,6737,6793
- Property svn:mergeinfo changed
Note: See TracChangeset
for help on using the changeset viewer.