Class XYSequenceUtils


  • public class XYSequenceUtils
    extends DataContainerUtils
    Utility class for XY sequences.
    Version:
    $Revision$
    Author:
    fracpete (fracpete at waikato dot ac dot nz)
    • Constructor Detail

      • XYSequenceUtils

        public XYSequenceUtils()
    • Method Detail

      • getComparator

        public XYSequencePointComparator getComparator()
        Returns the comparator used for finding x values.
        Returns:
        the comparator
      • getHeader

        protected static XYSequence getHeader​(List<XYSequencePoint> points)
        Creates a header based on the current sequence points.
        Parameters:
        points - the data to process
        Returns:
        the generated header
      • findX

        public static int findX​(List<XYSequencePoint> points,
                                XYSequencePoint p)
        Returns the index in m_Points of the given sequence point.
        Parameters:
        points - the points to process
        p - the point to get the index for
        Returns:
        the index
      • findX

        public static int findX​(List<XYSequencePoint> points,
                                double x)
        Returns the index in m_Points of the given x value.
        Parameters:
        points - the points to process
        x - the x value to get the index for
        Returns:
        the index
      • findClosestX

        public static int findClosestX​(List<XYSequencePoint> points,
                                       double x)
        Returns the index in m_Points closest to the given x value.
        Parameters:
        points - the data to process
        x - the x value to get the closest index for
        Returns:
        the index
      • findClosestXs

        public static int[] findClosestXs​(List<XYSequencePoint> points,
                                          double x,
                                          double wobble)
        Returns the indices of m_Points closest to the given x value.
        Parameters:
        points - the data to process
        x - the x value to get the closest index for
        wobble - the wobble factor to allow left and right
        Returns:
        the indices
      • findEnclosingXs

        public static int[] findEnclosingXs​(List<XYSequencePoint> points,
                                            double x)
        Returns the indices of points in m_Points that enclose the given x value. If the given x value happens to be an exact point, then this points will be stored at index 0. If no index could be determined, then -1 will be stored.
        Parameters:
        points - the data to process
        x - the x value to get the enclosing indices for
        Returns:
        the indices
      • getConsecutiveRegion

        public static XYSequence getConsecutiveRegion​(List<XYSequencePoint> points,
                                                      XYSequencePoint lastEnd,
                                                      XYSequencePoint end)
        Returns a region for the given range, starting just after the x value of "lastEnd" and ending (including) at "end".
        Parameters:
        points - the data to process
        lastEnd - the last end point, if null then the first sequence point will be the first point included.
        end - the last point to include in the region, if null then the last point in the data is used.
        Returns:
        the generated region
      • getRegion

        public static XYSequence getRegion​(List<XYSequencePoint> points,
                                           XYSequencePoint start,
                                           XYSequencePoint end)
        Returns a region for the given range, including both, start and end point.
        Parameters:
        points - the data to process
        start - the starting point, if null the first point in the data is used.
        end - the last point to include in the region, if null then the last point in the data is used.
        Returns:
        the generated region
      • countSignChanges

        public static int countSignChanges​(List<XYSequencePoint> points,
                                           double start,
                                           double end)
        Counts the sign changes in the given data between the given points (incl. the borders).
        Parameters:
        points - the data to process
        start - the x value to start with
        end - the last x value
        Returns:
        the number of changes in sign
      • countRegions

        public static int countRegions​(List<XYSequencePoint> points,
                                       double start,
                                       double end,
                                       boolean positive)
        Counts the positive or negative regions between the given points (incl. the borders).
        Parameters:
        points - the data to process
        start - the x value to start with
        end - the last x value
        positive - if true then positive regions are counted otherwise negative ones
        Returns:
        the number of positive/negative regions
      • getHistogram

        public static double[] getHistogram​(List<XYSequencePoint> points,
                                            int numBins)
        Generates data for a histogram display. It counts how many sequence points have the same y value in the currently stored sequence.
        Parameters:
        points - the data to process
        numBins - the number of bins to generate
        Returns:
        the histogram data
      • add

        protected static void add​(Hashtable<Number,​XYSequencePoint> pool,
                                  XYSequence s)
        Merges the given sequence with the current data pool. New sequence points don't override ones already in the pool, they only get added.
        Parameters:
        pool - the current data pool
        s - the sequence to merge with the pool
      • merge

        public static XYSequence merge​(XYSequence s1,
                                       XYSequence s2)
        Merges the two sequences. The header of the first one is used for the output.
        Parameters:
        s1 - the first sequence
        s2 - the second sequence
        Returns:
        the merged sequence
      • merge

        public static XYSequence merge​(List<XYSequence> list)
        Merges the given sequences. THe header of the first one is used for the output.
        Parameters:
        list - the sequences to merge
        Returns:
        the merged sequence