Package toxi.util

Class FileSequenceDescriptor

java.lang.Object
toxi.util.FileSequenceDescriptor
All Implemented Interfaces:
Iterable<String>

public class FileSequenceDescriptor extends Object implements Iterable<String>
A descriptor and iterator for handling file sequences.
  • Field Details

    • filePattern

      public String filePattern
    • extension

      public String extension
    • numDigits

      public int numDigits
    • start

      public int start
    • end

      public int end
  • Constructor Details

    • FileSequenceDescriptor

      public FileSequenceDescriptor(String filePattern, String extension, int numDigits, int start)
      Creates a new descriptor from the given sequence details.
      Parameters:
      filePattern - file pattern in the format: e.g. "path/basename%d04.ext"
      extension - file extension (e.g. ".tga")
      numDigits - number of digits used for the index
      start - start index
  • Method Details

    • getBasePath

      public String getBasePath()
      Returns the base path of the sequence, i.e. the substring of the sequence's file pattern from the beginning until the first occurence of the % sign indicating the frame numbers.
      Returns:
      path string
    • getDuration

      public int getDuration()
      Calculates sequence duration
      Returns:
      number of files in sequence
    • getFinalIndex

      public int getFinalIndex()
      Identifies the index of the last file of the sequence.
      Returns:
      final index
    • getPathForIndex

      public String getPathForIndex(int i)
      Constructs the file path for the given absolute index
      Parameters:
      i - index
      Returns:
      path
    • getStartIndex

      public int getStartIndex()
      Returns the index of the first file of the sequence.
      Returns:
      start index
    • iterator

      public Iterator<String> iterator()
      Creates an iterator providing paths for each file in the sequence. The iterator does not support the remove() method and attempts to use it results in an UnsupportedOperationException being thrown.
      Specified by:
      iterator in interface Iterable<String>