X-Git-Url: http://www2.svjatoslav.eu/gitweb/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Feu%2Fsvjatoslav%2Fmeviz%2Fhtmlindexer%2FUtils.java;h=9da4656bc0bccadac2b5cb18417066bcb9cf3e7a;hb=115456739edd5ae7dc67ac9e9f90d628aa65b4a3;hp=f8c82fa54d83f99b8c3e1ac0ab19d4e57c5a6943;hpb=5e2fffbc3363880e2da9c9d282537a8e2653fa8d;p=meviz.git diff --git a/src/main/java/eu/svjatoslav/meviz/htmlindexer/Utils.java b/src/main/java/eu/svjatoslav/meviz/htmlindexer/Utils.java index f8c82fa..9da4656 100755 --- a/src/main/java/eu/svjatoslav/meviz/htmlindexer/Utils.java +++ b/src/main/java/eu/svjatoslav/meviz/htmlindexer/Utils.java @@ -1,7 +1,7 @@ /* * Meviz - Various tools collection to work with multimedia. * Copyright (C) 2012, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu - * + * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public License * as published by the Free Software Foundation. @@ -24,14 +24,10 @@ import eu.svjatoslav.meviz.htmlindexer.layouts.MixedLayout; public class Utils { - private static File lastLoadedFile; - - private static BufferedImage lastLoadedBufferedImage; - /** * Load image into {@link BufferedImage} and return it. Caches last loaded * image to speed up subsequent loading attempts. - * + * * @throws ImageFormatError * @throws IOException */ @@ -44,10 +40,13 @@ public class Utils { lastLoadedBufferedImage = ImageIO.read(file); lastLoadedFile = file; - if (lastLoadedBufferedImage == null) + if (lastLoadedBufferedImage == null) { + System.out.println("Error reading image: " + file); throw new ImageFormatError("File: " + file + " is not a valid image."); + } + return lastLoadedBufferedImage; } @@ -87,8 +86,12 @@ public class Utils { } public static File getThumbnailsDirectory(final File directoryToIndex) { - return new File(directoryToIndex.getAbsolutePath() + "/" - + Constants.THUMBNAILS_DIRECTORY_NAME + "/"); + return new File(getThumbnailsDirectoryPath(directoryToIndex)); + } + + public static String getThumbnailsDirectoryPath(final File directoryToIndex) { + return directoryToIndex.getAbsolutePath() + "/" + + Constants.THUMBNAILS_DIRECTORY_NAME + "/"; } public static boolean isMevizGeneratedIndexFile(final File indexFile) @@ -118,4 +121,8 @@ public class Utils { return isMevizFile; } + private static File lastLoadedFile; + + private static BufferedImage lastLoadedBufferedImage; + }