- Enclosing class:
- AxisBuilder<T extends Graph.Axis>
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:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.bzdev.graphs.AxisBuilder
AxisBuilder.ClockTime, AxisBuilder.Linear, AxisBuilder.Log, AxisBuilder.Spacing
-
Field Summary
Fields inherited from class org.bzdev.graphs.AxisBuilder
axisScale, color, counterclockwise, direction, fontParms, graph, label, labelSep, labelSeps, length, levelLengths, levelWidths, lower, offset, startX, startY, stdLength, tickLabelsHorizontal, upper, userLength, width
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addOneTick
(int level, double position) Add a tick specification for one location per decade.void
addTickSpec
(int level, boolean middle, String format) Add a top-level tick specification with a format.void
addTickSpec
(int level, boolean middle, String format, String mFormat) Add a top-level tick specification with two formats.void
addTickSpec
(int level, int depth) Add a tick specification given a level and a depth.void
addTickSpec
(int level, int depth, int cutoff) Add a tick specification given a level, depth, and cutoff.void
addTickSpec
(int level, int depth, int divisor, int cutoff) Add a tick specification given a level, depth, divisor, and cutoff.Create an axis.protected Graph.LogAxis
newAxisInstance
(double startX, double startY, Graph.Axis.Dir direction, double length, double tickBase, double tickIncr, boolean counterclockwise) Create a new instance of an axis.Methods inherited from class org.bzdev.graphs.AxisBuilder
configureLevels, getAxisScale, getLabelOffset, getNumberOfLevels, getTickScaling, getTickScalingFactor, setAxisScale, setColor, setFontParms, setLabelOffset, setLinearTickScaling, setTickLabelsHorizontal, setTickScalingFactor, setWidth, tickLabelsAreHorizontal, usesLinearTickScaling
-
Constructor Details
-
Log
Constructor.- Parameters:
g
- the graphstartX
- 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 axislength
- the length of the axis in graph coordinate space unitshorizontal
- true if the axis is horizontal; false if it is verticallabel
- 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 graphstartX
- 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 axislength
- the length of the axis in graph coordinate space unitshorizontal
- true if the axis is horizontal; false if it is verticalflip
- true of the tick marks should be flipped to the opposite side of the axis; false to use the default sidelabel
- the level for an axis; null if none is provided
-
-
Method Details
-
addTickSpec
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 classSciFormatter
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 labelmiddle
- 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
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 classSciFormatter
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 labelmiddle
- 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 shownmFormat
- 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 labeldepth
- 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 labeldepth
- the depth of the tick markscutoff
- 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 labeldepth
- the depth for the tick markdivisor
- the divisorcutoff
- the cutoff
-
addOneTick
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 labelposition
- 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 ofAxisBuilder.createAxis()
to create a new instance of an axis. This method is provided to reduce the necessity of reimplementingAxisBuilder.createAxis()
in subclasses of (for example)AxisBuilder.Linear
andAxisBuilder.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 classAxisBuilder<Graph.LogAxis>
- Parameters:
startX
- the x coordinate of the axis' starting point in graph coordinate spacestartY
- the y coordinate of the axis' starting point in graph coordinate spacedirection
- the direction of the graphlength
- the length of the axis in graph coordinate spacetickBase
- the starting coordinate along the axis for graph ticks, given in graph-coordinate spacetickIncr
- the increment between possible tick locations in graph coordinate space unitscounterclockwise
- the angular direction to follow to reach a graph's labels and tick marks- Returns:
- a new axis
-
createAxis
Description copied from class:AxisBuilder
Create an axis. Users may add additional tick marks if desired.- Specified by:
createAxis
in classAxisBuilder<Graph.LogAxis>
- Returns:
- the axis that was created with its tick marks added
-