X-Git-Url: http://git.nikiroo.be/?p=fanfix.git;a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2FLibrary.java;fp=src%2Fbe%2Fnikiroo%2Ffanfix%2FLibrary.java;h=7819eff65d15e665a97b124ac412260e79821927;hp=bc9a4da4532d5787ac4b29a82dcf7a07cf0edbac;hb=57f02339393c9997391b76ffcb22ae72fd0a45cb;hpb=5ce869b82f28c4d288b266d7dee03aa4898fff21 diff --git a/src/be/nikiroo/fanfix/Library.java b/src/be/nikiroo/fanfix/Library.java index bc9a4da..7819eff 100644 --- a/src/be/nikiroo/fanfix/Library.java +++ b/src/be/nikiroo/fanfix/Library.java @@ -1,5 +1,6 @@ package be.nikiroo.fanfix; +import java.awt.image.BufferedImage; import java.io.File; import java.io.FileFilter; import java.io.IOException; @@ -27,6 +28,9 @@ import be.nikiroo.utils.Progress; *
* Each {@link Story} object will be associated with a (local to the library) * unique ID, the LUID, which will be used to identify the {@link Story}. + *
+ * Most of the {@link Library} functions work on either the LUID or a partial + * (cover not included) {@link MetaData} object. * * @author niki */ @@ -106,6 +110,8 @@ public class Library { /** * List all the stories of the given author in the {@link Library}, or all * the stories if NULL is passed as an author. + *
+ * Cover images not included. * * @param author * the author of the stories to retrieve, or NULL for all @@ -128,6 +134,8 @@ public class Library { /** * List all the stories of the given source type in the {@link Library}, or * all the stories if NULL is passed as a type. + *
+ * Cover images not included.
*
* @param type
* the type of story to retrieve, or NULL for all
@@ -148,7 +156,8 @@ public class Library {
}
/**
- * Retrieve a {@link File} corresponding to the given {@link Story}.
+ * Retrieve a {@link File} corresponding to the given {@link Story}, cover
+ * image not included.
*
* @param luid
* the Library UID of the story
@@ -187,6 +196,29 @@ public class Library {
return null;
}
+ /**
+ * Return the cover image associated to this story.
+ *
+ * @param luid
+ * the Library UID of the story
+ *
+ * @return the cover image
+ */
+ public synchronized BufferedImage getCover(String luid) {
+ MetaData meta = getInfo(luid);
+ if (meta != null) {
+ try {
+ File infoFile = new File(getFile(meta).getPath() + ".info");
+ meta = readMeta(infoFile, true).getKey();
+ return meta.getCover();
+ } catch (IOException e) {
+ Instance.syserr(e);
+ }
+ }
+
+ return null;
+ }
+
/**
* Retrieve a specific {@link Story}.
*
@@ -477,12 +509,12 @@ public class Library {
Progress pgDirs = new Progress(0, 100 * dirs.length);
pg.addProgress(pgDirs, 100);
- final String ext = ".info";
for (File dir : dirs) {
File[] files = dir.listFiles(new FileFilter() {
public boolean accept(File file) {
return file != null
- && file.getPath().toLowerCase().endsWith(ext);
+ && file.getPath().toLowerCase()
+ .endsWith(".info");
}
});
@@ -491,34 +523,22 @@ public class Library {
pgDirs.setName("Loading from: " + dir.getName());
for (File file : files) {
+ pgFiles.setName(file.getName());
try {
- pgFiles.setName(file.getName());
- MetaData meta = InfoReader.readMeta(file);
+ Entry