Class JAlbumUtilities

java.lang.Object
se.datadosen.jalbum.JAlbumUtilities

public class JAlbumUtilities extends Object
Miscellaneous JAlbum related utility methods that doesn't fit elsewhere
  • Method Details

    • importProject

      public static Properties importProject(File projectFile) throws IOException
      Throws:
      IOException
    • countComponentTree

      public static int countComponentTree(JComponent root)
      Internal tests. Don't use
      Parameters:
      root -
      Returns:
    • fillCombo

      public static void fillCombo(JComboBox combo, File dir, FileFilter filter)
    • fillCombo

      public static void fillCombo(JComboBox combo, ChainedDirectory dir, FileFilter filter)
    • getUserVariables

      public static Map getUserVariables(Properties props)
    • getSkinVariables

      public static Map getSkinVariables(Properties props)
    • getOrdinaryVariables

      public static Map getOrdinaryVariables(Properties props)
    • hasWebPages

      public static boolean hasWebPages(AlbumObject folder)
      Test if the passed folder contains any web template pages Skins can use this test to determine if to include top-level navigation links for instance
      Since:
      10.4
    • countCategories

      public static CategoryCounters countCategories(AlbumObject folder) throws CircularFolderReferenceException
      Return an object holding the number of objects per category under this folder.
      Usage examples:
      JAlbumUtilities.countCategories(currentFolder).getCount(Category.image); // Get number of images in current folder
      JAlbumUtilities.countCategories(currentFolder).getCount(Category.webPage); // Get number of web pages in current folder
      JAlbumUtilities.countCategories(currentFolder).getTotalCount()); // Get total number of objects in current folder
      JAlbumUtilities.countCategories(currentFolder).getFileCount()); // Get total number of files (not folders) in current folder
      JAlbumUtilities.countCategories(rootFolder, true); // Get total number of objects per category in album
      Parameters:
      folder -
      Returns:
      Throws:
      CircularFolderReferenceException
      See Also:
    • countCategories

      public static CategoryCounters countCategories(AlbumObject folder, boolean recursive)
    • countCategories

      public static CategoryCounters countCategories(AlbumObject folder, CategoryCounters counters, boolean recursive)
      Return an object holding the number of objects per category under this folder
      Parameters:
      folder -
      counters -
      recursive -
      Returns:
    • countCategories

      public static CategoryCounters countCategories(List<AlbumObject> objects, CategoryCounters counters, boolean recursive)
      For jAlbum use only
      Since:
      13
    • getThemeObject

      public static AlbumObject getThemeObject(AlbumObject folder)
      Get the theme image object for the specified folder. Will fall back to delivering the representing object if an explicit theme image hasn't been set and the folder hasn't had its theme image explicitly removed.
      Parameters:
      folder - Theme object for folder or null if no theme image designated
      Returns:
      Since:
      15
    • deepLastModified

      public static long deepLastModified(AlbumObject folder) throws IOException
      Throws:
      IOException
    • deepLastModified

      public static long deepLastModified(AlbumObject folder, ForkJoinPool pool) throws IOException, OperationAbortedException
      Variant of deepLastModified accepting a ForkJoinPool to control parallelism, isolation and abortion of long running calculation. Abort ongoing calculation by calling pool.shutdownNow();
      Parameters:
      folder -
      pool - create preferably with new ForkJoinPool(4)
      Returns:
      Throws:
      IOException
      OperationAbortedException - if aborted with pool.shutdownNow();
      Since:
      25.1
    • getDeepCameraDates

      public static DateRange getDeepCameraDates(AlbumObject folder)
      Get the first and last camera date of the included objects of given folder and its sub folders. Relies on disk based cacheing for speed
      Parameters:
      folder -
      Returns:
      DateRange object specifying the first and last camera dates
      Since:
      14.1
    • getCameraDates

      public static DateRange getCameraDates(AlbumObject folder)
      Get the first and last camera date of the included objects of given folder. Relies on disk based cacheing for speed
      Parameters:
      folder -
      Returns:
      DateRange object specifying the first and last camera dates
      Since:
      14.1
    • getLastAdded

      public static long getLastAdded(AlbumObject folder)
      For folders, returns the newest added date (getWhenAdded) of objects within the folder that are included, not hidden and not folders
      Returns:
      last added date formatted as the number of milliseconds since epoch or zero if no objects added at all
      Since:
      11.6
    • getDeepLastAdded

      public static long getDeepLastAdded(AlbumObject folder)
      For folders, returns the newest added date (getWhenAdded) of objects within the folder and its sub folders that are included, not hidden and not folders
      Returns:
      last added date formatted as the number of milliseconds since epoch or zero if no objects added at all
      Since:
      11.6
    • isDirty

      public static boolean isDirty(File dest, AlbumObject source)
      Return true if either dest does not exist or is older than source New since v13.3: Also considers videos with updated representing images dirty
      Since:
      v11
    • isDirty

      public static boolean isDirty(File dest, File source)
      Return true if either dest does not exist or is older than source
      Since:
      v11
    • runOnAWT

      public static void runOnAWT(Runnable r)
      Ensure that passed code runs on the AWT thread If caller is on the AWT thread already, simply execute the code, otherwise put it onto the event queue for later dispatching
      Parameters:
      r -
      Since:
      20
    • schedule

      public static ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit)
      Submits a one-shot task that becomes enabled after the given delay.
      Parameters:
      command - the task to execute
      delay - the time from now to delay execution
      unit - the time unit of the delay parameter
      Returns:
      a ScheduledFuture representing pending completion of the task and whose get() method will return null upon completion
      Throws:
      NullPointerException - if command or unit is null
    • schedule

      public static <V> ScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit)
      Submits a value-returning one-shot task that becomes enabled after the given delay.
      Type Parameters:
      V - the type of the callable's result
      Parameters:
      callable - the function to execute
      delay - the time from now to delay execution
      unit - the time unit of the delay parameter
      Returns:
      a ScheduledFuture that can be used to extract result or cancel
      Throws:
      NullPointerException - if callable or unit is null