Module org.jpo

Class WebsiteGenerator

java.lang.Object
javax.swing.SwingWorker<Integer,String>
org.jpo.export.WebsiteGenerator
All Implemented Interfaces:
Runnable, Future<Integer>, RunnableFuture<Integer>

public class WebsiteGenerator extends SwingWorker<Integer,String>
This class generates a set of HTML pages that allows a user to browse groups of pictures in a web-browser. The resulting html pages can be posted to the Internet. Relative addressing has been used throughout.
  • Field Details

  • Method Details

    • generateWebsite

      public static WebsiteGenerator generateWebsite(GenerateWebsiteRequest request)
    • cleanupFilename

      public static String cleanupFilename(String string)
      Translates characters which are problematic in a filename into unproblematic characters
      Parameters:
      string - The filename to clean up
      Returns:
      The cleaned up filename
    • writeCss

      public static void writeCss(File targetDirectory, List<File> websiteMemberFiles)
      Write the jpo.css file to the target directory.
      Parameters:
      targetDirectory - The directory to write to
    • writeRobotsTxt

      public static void writeRobotsTxt(File targetDirectory, List<File> websiteMemberFiles)
      Write the robots.txt file to the target directory.
      Parameters:
      targetDirectory - The directory to write to
    • writeJpoJs

      public static void writeJpoJs(File targetDirectory, List<File> websiteMemberFiles)
      Write the jpo.js file to the target directory.
      Parameters:
      targetDirectory - The directory to write to
      websiteMemberFiles - A reference to the list of files where we shall add our entry.
    • writeFileFromJar

      public static void writeFileFromJar(String file, File targetDirectory, List<File> websiteMemberFiles)
      Write the specified file from the classloader to the target directory.
      Parameters:
      file - the file to copy from the classloader
      targetDirectory - The directory to write to
      websiteMemberFiles - A reference to the list of files where we shall add our entry.
    • writeFolderIconTest

      @TestOnly public static void writeFolderIconTest(GenerateWebsiteRequest request, List<File> files) throws IOException
      Throws:
      IOException
    • generateZipfileTest

      @TestOnly public static void generateZipfileTest(GenerateWebsiteRequest request)
    • doInBackground

      protected Integer doInBackground() throws Exception
      Entry point for the SwingWorker when execute() is called.
      Specified by:
      doInBackground in class SwingWorker<Integer,String>
      Returns:
      an Integer (not sure what to do with this...)
      Throws:
      Exception - hopefully not
    • process

      protected void process(List<String> messages)
      This method is called by SwingWorker when the background process sends a publish event.
      Overrides:
      process in class SwingWorker<Integer,String>
      Parameters:
      messages - A message that will be written to the logfile.
    • done

      protected void done()
      SwingWorker calls here when the background task is done.
      Overrides:
      done in class SwingWorker<Integer,String>
    • writeLowresGroup

      public void writeLowresGroup(SortableDefaultMutableTreeNode groupNode)
      This method writes out an HTML page with the small images aligned next to each other. Each Group and picture is created in an html file called jpo_1234.htm except for the first one that gets named index.htm. 1234 is the internal hashCode of the node so that we can translate parents and children to each other.
      Parameters:
      groupNode - The node at which the extraction is to start.
    • getStartIndex

      public static int getStartIndex(int childNumber, int indexPerRow)
    • getEndIndex

      public static int getEndIndex(int startIndex, int childCount, int indexPerRow)
    • getSshSession

      @NotNull public static @NotNull com.jcraft.jsch.Session getSshSession(com.jcraft.jsch.JSch jsch, GenerateWebsiteRequest request) throws com.jcraft.jsch.JSchException
      Throws:
      com.jcraft.jsch.JSchException