Package de.sciss.io

Class Region

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable

    public class Region
    extends java.lang.Object
    implements java.io.Serializable, java.lang.Cloneable
    A struct class: region in an audio file. (copied from FScape).
    See Also:
    AudioFileDescr.KEY_REGIONS, Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      java.lang.String name
      A region's name
      Span span
      A region's time span in sample frames
    • Constructor Summary

      Constructors 
      Constructor Description
      Region​(Region orig)
      Constructs a new immutable region identical to a given region.
      Region​(Span span, java.lang.String name)
      Constructs a new immutable region
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static int add​(java.util.List regions, Region region, boolean byBegin)
      Adds region chronologically to a pre-sorted list.
      java.lang.Object clone()
      Returns a new region which is equal to this one.
      static int find​(java.util.List regions, java.lang.String name, int startIndex)
      Gets the index for specific region in a list.
      static java.util.List sort​(java.util.List regions, boolean byBegin)
      Sorts regions chronologically
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • span

        public final Span span
        A region's time span in sample frames
      • name

        public final java.lang.String name
        A region's name
    • Constructor Detail

      • Region

        public Region​(Span span,
                      java.lang.String name)
        Constructs a new immutable region
        Parameters:
        span - time span in sample frames
        name - region's name
      • Region

        public Region​(Region orig)
        Constructs a new immutable region identical to a given region.
        Parameters:
        orig - the region to copy
    • Method Detail

      • clone

        public java.lang.Object clone()
                               throws java.lang.CloneNotSupportedException
        Returns a new region which is equal to this one. CloneNotSupportedException is never thrown.
        Overrides:
        clone in class java.lang.Object
        Returns:
        a new region with the same name and span as this region
        Throws:
        java.lang.CloneNotSupportedException
      • sort

        public static java.util.List sort​(java.util.List regions,
                                          boolean byBegin)
        Sorts regions chronologically
        Parameters:
        regions - a vector whose elements are instanceof Region.
        byBegin - true to sort by region begin points; false to sort by region end points
        Returns:
        sorted region list. Each region is guaranteed to have a time span's begin (byBegin==true) or end (byBegin==false) less or equal its successor
      • add

        public static int add​(java.util.List regions,
                              Region region,
                              boolean byBegin)
        Adds region chronologically to a pre-sorted list.
        Parameters:
        regions - a vector whose elements are instanceof Region and which are chronologically sorted according to the byBegin flag.
        region - the region to insert such that its predecessor has a time span's start (byBegin==true) or stop (byBegin==false) less or equal this region's time span start or stop and the regions's successor has a time span's start or stop greater than this regions's time span start or stop.
        byBegin - true to sort by region begin points; false to sort by region end points
        Returns:
        region index in vector at which it was inserted
      • find

        public static int find​(java.util.List regions,
                               java.lang.String name,
                               int startIndex)
        Gets the index for specific region in a list.
        Parameters:
        regions - a vector whose elements are instanceof Region.
        name - region name to find
        startIndex - where to begin
        Returns:
        The list index of the first occurance (beginning at startIndex) of a region whose name equals the given name.