Class ContourPlot.ExtendedWilkinson

  • All Implemented Interfaces:
    ContourPlot.TickMarkGenerator
    Enclosing class:
    ContourPlot

    public static class ContourPlot.ExtendedWilkinson
    extends java.lang.Object
    implements ContourPlot.TickMarkGenerator
    Implementation of the extended Wilkinson algorithm for tick label positioning. See vis.stanford.edu/papers/tick-labels for details.

    The algorithm uses set of 'nice' value increments which are order by 'niceness', i.e. earlier increment values are to be preferred over the later ones. The algorithm tries to figure out which increments to use at what scale in order to fill a desired value range with ticks. It utilizes a scoring function to decide which tick marks to use.

    By default the ordered set of nice increments is {1, 5, 2, 2.5, 4, 3, 1.5, 6, 8}. This can be changed by sub classing this class and setting the Q array accordingly.

    There is also a set of weights used to calculate the score of a tick mark sequence based on the qualities: simplicity, coverage, density and legibility (legibility calculation is not implemented). The influence of these qualities on the score is determined by the weights in the attribute w.

    Author:
    hageldave
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected double[] Q
      preference-decreasing ordered set of nice increments
      protected double[] w
      weights for simplicity, coverage, density and legibility
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) static double coverage​(double dmin, double dmax, double lmin, double lmax)  
      (package private) static double coverage_max​(double dmin, double dmax, double span)  
      (package private) static double density​(double k, double m, double dmin, double dmax, double lmin, double lmax)  
      (package private) static double density_max​(double k, double m)  
      (package private) static double[] ext_wilk​(double dmin, double dmax, int m, int onlyInside, double[] Q, double[] w)  
      ContourPlot.Pair<double[],​java.lang.String[]> genTicksAndLabels​(double min, double max, int desiredNumTicks, boolean verticalAxis)
      Generates a number of tick marks and corresponding labels.
      (package private) static double[] getTicks​(double dmin, double dmax, int m, double[] Q, double[] w)  
      protected java.lang.String[] labelsForTicks​(double[] ticks)
      Uses either decimal or scientific notation for the labels and strips unnecessary trailing zeros.
      (package private) static double legibility​(double lmin, double lmax, double lstep)  
      (package private) static double score​(double[] weights, double simplicity, double coverage, double density, double legibility)  
      (package private) static double simplicity​(double q, double[] Q, double j, double lmin, double lmax, double lstep)  
      (package private) static double simplicity_max​(double q, double[] Q, int j)  
      • Methods inherited from class java.lang.Object

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

      • Q

        protected double[] Q
        preference-decreasing ordered set of nice increments
      • w

        protected double[] w
        weights for simplicity, coverage, density and legibility
    • Constructor Detail

      • ExtendedWilkinson

        public ExtendedWilkinson()
    • Method Detail

      • labelsForTicks

        protected java.lang.String[] labelsForTicks​(double[] ticks)
        Uses either decimal or scientific notation for the labels and strips unnecessary trailing zeros. If one of the specified tick values is formatted in scientific notation by the String.format(String, Object...) '%g' option, all values will use scientific notation, otherwise decimal is used.
        Parameters:
        ticks - to be labeled
        Returns:
        String[] of labels corresponding to specified tick values
      • genTicksAndLabels

        public ContourPlot.Pair<double[],​java.lang.String[]> genTicksAndLabels​(double min,
                                                                                     double max,
                                                                                     int desiredNumTicks,
                                                                                     boolean verticalAxis)
        Description copied from interface: ContourPlot.TickMarkGenerator
        Generates a number of tick marks and corresponding labels. The first entry of the returned pair are the tick mark values, the second part are the corresponding labels.
        Specified by:
        genTicksAndLabels in interface ContourPlot.TickMarkGenerator
        Parameters:
        min - minimum of value range for which ticks marks are to be generated
        max - maximum of value range for which ticks marks are to be generated
        desiredNumTicks - the desired number of generated tick marks, not obligatory, can also create less or more tick marks if that leads to better tick values.
        verticalAxis - true if marks are for vertical axis, false when for horizontal axis
        Returns:
        pair of a tick mark value array and corresponding label array for these values
      • coverage

        static double coverage​(double dmin,
                               double dmax,
                               double lmin,
                               double lmax)
      • coverage_max

        static double coverage_max​(double dmin,
                                   double dmax,
                                   double span)
      • density

        static double density​(double k,
                              double m,
                              double dmin,
                              double dmax,
                              double lmin,
                              double lmax)
      • density_max

        static double density_max​(double k,
                                  double m)
      • simplicity

        static double simplicity​(double q,
                                 double[] Q,
                                 double j,
                                 double lmin,
                                 double lmax,
                                 double lstep)
      • simplicity_max

        static double simplicity_max​(double q,
                                     double[] Q,
                                     int j)
      • legibility

        static double legibility​(double lmin,
                                 double lmax,
                                 double lstep)
      • score

        static double score​(double[] weights,
                            double simplicity,
                            double coverage,
                            double density,
                            double legibility)
      • ext_wilk

        static double[] ext_wilk​(double dmin,
                                 double dmax,
                                 int m,
                                 int onlyInside,
                                 double[] Q,
                                 double[] w)
      • getTicks

        static double[] getTicks​(double dmin,
                                 double dmax,
                                 int m,
                                 double[] Q,
                                 double[] w)