import java.util.HashSet;
import java.util.List;
+import static eu.svjatoslav.meviz.htmlindexer.Constants.THUMBNAILS_DIRECTORY_NAME;
+import static eu.svjatoslav.meviz.htmlindexer.Utils.getThumbnailsDirectoryPath;
+import static eu.svjatoslav.meviz.htmlindexer.Utils.urlEncode;
+import static eu.svjatoslav.meviz.htmlindexer.metadata.fileTypes.Picture.makeThumbnail;
+
/**
* Main class of HTML indexer.
*/
}
private void generateHtmlFromMetadata(final HashSet<Layout> layouts) {
- // Generate HTML from metadata
for (final Layout layout : layouts)
try {
final File indexFile = Utils.getLayoutIndexFile(layout,
@Override
public String getDirectoryUrl(final AbstractFile directory,
final IndexingContext context) {
- return Utils.urlEncode(directory.fileName) + "/index.html";
+ return urlEncode(directory.fileName) + "/index.html";
}
@Override
validMetadataFiles.add(thumbnailFileName);
final File thumbnailFile = new File(
- Utils.getThumbnailsDirectoryPath(directoryToIndex)
- + thumbnailFileName);
+ getThumbnailsDirectoryPath(directoryToIndex) + thumbnailFileName);
if (!thumbnailFile.exists()) {
final File originalFile = new File(
directoryToIndex.getAbsolutePath() + "/" + picture.fileName);
- // generate new thumbnail
- Picture.makeThumbnail(originalFile, thumbnailFile,
- desiredDimension.getAwtDimension());
+ makeThumbnail(originalFile, thumbnailFile, desiredDimension.getAwtDimension());
}
- return Constants.THUMBNAILS_DIRECTORY_NAME + "/"
- + Utils.urlEncode(thumbnailFileName);
+ return THUMBNAILS_DIRECTORY_NAME + "/" + urlEncode(thumbnailFileName);
}
private void initializeLayouts() {
private void loadOrCreateMetadata() {
metadataFile = new File(
- Utils.getThumbnailsDirectoryPath(directoryToIndex)
+ getThumbnailsDirectoryPath(directoryToIndex)
+ Constants.METADATA_FILE_NAME);
metadata = MetadadaHelper.initDirectoryMetadata(metadataFile);
import java.util.List;
import static eu.svjatoslav.meviz.htmlindexer.Utils.getBufferedImage;
+import static java.awt.image.BufferedImage.TYPE_INT_RGB;
public class Picture extends AbstractFile {
final BufferedImage bufferedImage = new BufferedImage(
scaledImage.getWidth(null), scaledImage.getHeight(null),
- BufferedImage.TYPE_INT_RGB);
+ TYPE_INT_RGB);
final Graphics2D g = bufferedImage.createGraphics();
g.drawImage(scaledImage, 0, 0, null);
// compute new thumbnails hash number
final String forMagicHash = fileName + " "
- + String.valueOf(targetDimension.width) + " "
- + String.valueOf(targetDimension.height) + " "
- + String.valueOf(getFileLength()) + " "
+ + targetDimension.width + " "
+ + targetDimension.height + " "
+ + getFileLength() + " "
+ Constants.THUMBNAIL_VERSION;
// System.out.println("Computing hash from: " + forMagicHash);
*/
public String getRelativeThumbnailFileName(final Dimension targetDimension) {
return FilePathParser.getFileNameWithoutExtension(fileName) + " ("
- + computeThumbnailHash(targetDimension) + ").jpeg";
+ + computeThumbnailHash(targetDimension) + ")." + getFileExtension();
}
@Override