-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'ebremer:master' into master
- Loading branch information
Showing
9 changed files
with
221 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/main/java/edu/stonybrook/bmi/hatch/SingleLineFormatter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package edu.stonybrook.bmi.hatch; | ||
|
||
import java.util.logging.Formatter; | ||
import java.util.logging.LogRecord; | ||
|
||
public class SingleLineFormatter extends Formatter { | ||
|
||
@Override | ||
public String format(LogRecord record) { | ||
return String.format("%1$tF %1$tT %2$s %3$s: %4$s %n", | ||
record.getMillis(), | ||
record.getLevel().getLocalizedName(), | ||
record.getSourceClassName() + "." + record.getSourceMethodName(), | ||
formatMessage(record)); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package edu.stonybrook.bmi.hatch; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Path; | ||
import java.util.Iterator; | ||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
import javax.imageio.ImageIO; | ||
import javax.imageio.stream.ImageInputStream; | ||
|
||
/** | ||
* | ||
* @author erich | ||
*/ | ||
public class Validate2 { | ||
|
||
public static boolean file(Path path) { | ||
Logger LOGGER = Logger.getLogger(Validate2.class.getName()); | ||
javax.imageio.ImageReader reader = null; | ||
ImageInputStream input; | ||
try { | ||
input = ImageIO.createImageInputStream(path.toFile()); | ||
Iterator<javax.imageio.ImageReader> readers = ImageIO.getImageReadersByFormatName("tif"); | ||
javax.imageio.ImageReader ir = null; | ||
while (readers.hasNext()) { | ||
ir = readers.next(); | ||
//System.out.println("IMAGE CLASS --> "+ir.getClass().getCanonicalName()); | ||
if ("com.twelvemonkeys.imageio.plugins.tiff.TIFFImageReader".equals(ir.getClass().getCanonicalName())) { | ||
//System.out.println("YES! : "+ir.getClass().getCanonicalName()); | ||
reader = ir; | ||
} else { | ||
//System.out.println("NOPE : "+ir.getClass().getCanonicalName()); | ||
} | ||
} | ||
if (ir==null) { | ||
throw new IllegalArgumentException("No reader for: " + path); | ||
} | ||
//System.out.println("READER IS ---> "+reader.getClass().getCanonicalName()); | ||
reader.setInput(input); | ||
try { | ||
if (reader.getWidth(0)==0) { | ||
LOGGER.severe(path.toString()+" X dimension is ZERO"); | ||
return false; | ||
} | ||
} catch (IOException ex) { | ||
Logger.getLogger(Validate2.class.getName()).log(Level.SEVERE, null, ex); | ||
return false; | ||
} | ||
try { | ||
if (reader.getHeight(0)==0) { | ||
LOGGER.severe(path.toString()+" Y dimension is ZERO"); | ||
return false; | ||
} | ||
} catch (IOException ex) { | ||
LOGGER.severe(ex.getMessage()); | ||
return false; | ||
} | ||
try { | ||
int last = reader.getNumImages(true)-1; | ||
if ((reader.getWidth(last)>1024)||(reader.getHeight(last)>1024)) { | ||
LOGGER.severe(path.toString()+" smallest scaled image ("+reader.getNumImages(true)+" - "+reader.getWidth(last)+"x"+reader.getHeight(last)+") must be less than 1024x1024"); | ||
return false; | ||
} | ||
} catch (IOException ex) { | ||
LOGGER.severe(ex.getMessage()); | ||
return false; | ||
} | ||
} catch (IOException ex) { | ||
LOGGER.severe(ex.getMessage()); | ||
return false; | ||
} | ||
return true; | ||
} | ||
} |
Oops, something went wrong.