Class AxisBuilder.Log

Enclosing class:
AxisBuilder<T extends Graph.Axis>

public static class AxisBuilder.Log extends AxisBuilder<Graph.LogAxis>
AxisBuilder for a log axis. This axis builder creates an axis whose tick marks are spaced on a logarithmic scale. The coarsest spacings on on boundaries that are spaced by factors of 10 so that the logarithms to base 10 have integral values. From 1.0 to 10.0, there are 9 possible locations for tick marks. Each level of additional subdivisions will multiple the possible number of tick marks from 1.0 to 10.0 by factors of 10.

For a logarithmic axis, the coordinate of the graph (X or Y) is the logarithm to base 10 of the desired value. Thus, a graph whose X values are on a logarithmic scale for values from 1.0 to 100.0 would set the range for the X coordinate from 0.0 to 2.0.

The constructors use the same arguments as used by AxisBuilder and AxisBuilder.Linear. After constructing an axis builder, one will proceed by calling the methods addTickSpec(int,boolean,String), addTickSpec(int,boolean,String,String), addTickSpec(int,int), addTickSpec(int,int,int), addTickSpec(int,int,int,int), and/or addOneTick(int,double). Finally one will call createAxis(). The following figure shows the effect of calling these methods:

axis example

  • Constructor Details

    • Log

      public Log(Graph g, double startX, double startY, double length, boolean horizontal, String label)
      Constructor.
      Parameters:
      g - the graph
      startX - the X value in graph coordinate space for the start of the axis.
      startY - the Y value in graph coordinate space for the start of the axis
      length - the length of the axis in graph coordinate space units
      horizontal - true if the axis is horizontal; false if it is vertical
      label - the level for an axis; null if none is provided
    • Log

      public Log(Graph g, double startX, double startY, double length, boolean horizontal, boolean flip, String label)
      Constructor with a "flip" option. Normally the tick marks for an axis are below the axis for a horizontal axis and to the left of an axis for a vertical axis. An option to flip the tick marks and labels to the opposite side of the axis is provided by this constructor for cases where an axis appears at the top of a graph or at its right side.
      Parameters:
      g - the graph
      startX - the X value in graph coordinate space for the start of the axis.
      startY - the Y value in graph coordinate space for the start of the axis
      length - the length of the axis in graph coordinate space units
      horizontal - true if the axis is horizontal; false if it is vertical
      flip - true of the tick marks should be flipped to the opposite side of the axis; false to use the default side
      label - the level for an axis; null if none is provided
  • Method Details

    • addTickSpec

      public void addTickSpec(int level, boolean middle, String format)
      Add a top-level tick specification with a format. This will place tick marks at values that are integral values of 10. The format string will be used by the class SciFormatter to generate the label. When the second argument is true, a second set of tick marks will appear at values equal to 5 multiplied by a 10 raised to an integral power.

      Note: the level is by default an integer in the range [0, 5). The range and corresponding dimensions can be changed by calling AxisBuilder.configureLevels(double[],double[],double[]). For this method, the level 0 is always used, If the second argument is true, level 1 is also used.

      Parameters:
      level - a non-negative integer specifying the dimensions of tick marks and the separation between a tick mark and any tick-mark label
      middle - true if a tick mark should appear for values equal to 5 multiplied by a 10 raised to an integral power; false otherwise.
      format - the format string used to construct a tick-mark label; null if no label should be shown
    • addTickSpec

      public void addTickSpec(int level, boolean middle, String format, String mFormat)
      Add a top-level tick specification with two formats. This will place tick marks at values that are integral values of 10. The format string will be used by the class SciFormatter to generate the label. When the second argument is true, a second set of tick marks will appear at values equal to 5 multiplied by a 10 raised to an integral power. The final argument provides a format string for this case and will cause a label to be generated when the string is not null;

      Note: the level is by default an integer in the range [0, 5). The range and corresponding dimensions can be changed by calling AxisBuilder.configureLevels(double[],double[],double[]).

      Parameters:
      level - a non-negative integer specifying the dimensions of tick marks and the separation between a tick mark and any tick-mark label
      middle - true if a tick mark should appear for values equal to 5 multiplied by a 10 raised to an integral power; false otherwise.
      format - the format string used to construct a tick-mark label; null if no label should be shown
      mFormat - the format string used to construct a tick-mark label in the middle of a decade; null if no label should be shown
    • addTickSpec

      public void addTickSpec(int level, int depth)
      Add a tick specification given a level and a depth. The level determines the visual appearance of the tick mark and its separation from an tick-mark labels. A depth of zero corresponds to tick marks at values equal to 10 raised to an integral power. Increasing the depth by 1 reduces the spacing between tick marks by a factor of 10. Thus, for a depth of 1, tick marks may appear at the values 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, and 9.0 for the decade starting at 1.0 and ending at 10.0 and will be printed at locations determined by computing the logarithm to base 10 of these values.

      Note: the level is by default an integer in the range [0, 5). The range and corresponding dimensions can be changed by calling AxisBuilder.configureLevels(double[],double[],double[]).

      Parameters:
      level - a non-negative integer specifying the dimensions of tick marks and the separation between a tick mark and any tick-mark label
      depth - the depth of the tick marks
    • addTickSpec

      public void addTickSpec(int level, int depth, int cutoff)
      Add a tick specification given a level, depth, and cutoff. The level determines the visual appearance of the tick mark and its separation from an tick-mark labels. A depth of zero corresponds to tick marks at values equal to 10 raised to an integral power. Increasing the depth by 1 reduces the spacing between tick marks by a factor of 10. Thus, for a depth of 1, tick marks may appear at the values 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, and 9.0 for the decade starting at 1.0 and ending at 10.0 and will be printed at locations determined by computing the logarithm to base 10 of these values. The cutoff limits a sequence of tick marks in each decade. For the decade from 1.0 to 10.0, the cutoff indicates the highest value for which a tick (associated with this tick specification) will be shown. This point is independent of the depth argument. Legal values for the cutoff are 2, 3, 4, 5, 6, 7, 8, and 9.

      Note: the level is by default an integer in the range [0, 5). The range and corresponding dimensions can be changed by calling AxisBuilder.configureLevels(double[],double[],double[]). The reason for providing a cutoff is that tick marks higher in a decade are closer together than those lower in a decade, and may start running into each other if shown over the full decade.

      Parameters:
      level - a non-negative integer specifying the dimensions of tick marks and the separation between a tick mark and any tick-mark label
      depth - the depth of the tick marks
      cutoff - the value of the cutoff
    • addTickSpec

      public void addTickSpec(int level, int depth, int divisor, int cutoff)
      Add a tick specification given a level, depth, divisor, and cutoff. The level determines the visual appearance of the tick mark and its separation from an tick-mark labels. A depth of zero corresponds to tick marks at values equal to 10 raised to an integral power. Increasing the depth by 1 reduces the spacing between tick marks by a factor of 10. If the divisor is equal to 1, it is ignored. For values higher then 1, The tick-mark spacing indicated by the depth is partitioned. For a divisor of two, an additional tick mark at a level of (level + 1) is added to divide the interval in half and for a divisor of 5, 4 additional tick marks at a level of (level + 1) are added* to divide the interval into fifths.

      Thus, for a depth of 1, tick marks may appear at the values 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, and 9.0 for the decade starting at 1.0 and ending at 10.0 and will be printed at locations determined by computing the logarithm to base 10 of these values. With a divisor set to 2, additional tick marks may be shown at 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, and 9.5.

      The cutoff limits a sequence of tick marks in each decade. For the decade from 1.0 to 10.0, the cutoff indicates the highest value for which a tick (associated with this tick specification) will be shown. This point is independent of the depth argument. Legal values for the cutoff are 2, 3, 4, 5, 6, 7, 8, and 9.

      Note: the level is by default an integer in the range [0, 5). The range and corresponding dimensions can be changed by calling AxisBuilder.configureLevels(double[],double[],double[]). The reason for providing a cutoff is that tick marks higher in a decade are closer together than those lower in a decade, and may start running into each other if shown over the full decade.

      Parameters:
      level - a non-negative integer specifying the dimensions of tick marks and the separation between a tick mark and any tick-mark label
      depth - the depth for the tick mark
      divisor - the divisor
      cutoff - the cutoff
    • addOneTick

      public void addOneTick(int level, double position) throws IllegalArgumentException
      Add a tick specification for one location per decade. The level determines the visual appearance of the tick mark and its separation from an tick-mark labels. The position determines the location of a single tick mark in each decade, and is specified for the decade from 1.0 to 10.0. Thus, a position of 7.5 will place tick marks at 7.5 multiplied by 10 raised to an integral power.

      The rational for providing this method is that there are a few corner cases in which the cutoff mechanism will prevent tick marks from being shown in the desired location. For example, with a divisor of 5 and a cutoff, one would not also create a sequence with a divisor of 2 with a higher cutoff as the two would overlap.

      Note: the level is by default an integer in the range [0, 5). The range and corresponding dimensions can be changed by calling AxisBuilder.configureLevels(double[],double[],double[]).

      Parameters:
      level - a non-negative integer specifying the dimensions of tick marks and the separation between a tick mark and any tick-mark label
      position - a position within the decade from 1.0 to 10.0
      Throws:
      IllegalArgumentException
    • newAxisInstance

      protected Graph.LogAxis newAxisInstance(double startX, double startY, Graph.Axis.Dir direction, double length, double tickBase, double tickIncr, boolean counterclockwise)
      Description copied from class: AxisBuilder
      Create a new instance of an axis. This is called by implementations of AxisBuilder.createAxis() to create a new instance of an axis. This method is provided to reduce the necessity of reimplementing AxisBuilder.createAxis() in subclasses of (for example) AxisBuilder.Linear and AxisBuilder.Log that a user might write.

      Note: for AxisBuilder.Log, the tickBase argument for this method is ignored (the value is computed from the other parameters in this case).

      Specified by:
      newAxisInstance in class AxisBuilder<Graph.LogAxis>
      Parameters:
      startX - the x coordinate of the axis' starting point in graph coordinate space
      startY - the y coordinate of the axis' starting point in graph coordinate space
      direction - the direction of the graph
      length - the length of the axis in graph coordinate space
      tickBase - the starting coordinate along the axis for graph ticks, given in graph-coordinate space
      tickIncr - the increment between possible tick locations in graph coordinate space units
      counterclockwise - the angular direction to follow to reach a graph's labels and tick marks
      Returns:
      a new axis
    • createAxis

      public Graph.LogAxis createAxis()
      Description copied from class: AxisBuilder
      Create an axis. Users may add additional tick marks if desired.
      Specified by:
      createAxis in class AxisBuilder<Graph.LogAxis>
      Returns:
      the axis that was created with its tick marks added