JIDE 3.5.15

com.jidesoft.chart
Class ZeroAlignedAutoRanger

java.lang.Object
  extended by com.jidesoft.chart.AbstractAutoRanger
      extended by com.jidesoft.chart.ZeroAlignedAutoRanger
All Implemented Interfaces:
AutoRanger, MultiAutoRanger

public class ZeroAlignedAutoRanger
extends AbstractAutoRanger
implements MultiAutoRanger

A class that computes appropriate ranges for the x and y axes of a chart, while keeping y axis aligned at zero. By default the leading and trailing margin proportions for the x and y ranges are 10% of the difference between the maximum and the minimum (that is, the value is 0.1). If required, you can fix corner points of the x and y axes - for example to make sure the origin of the chart is at (0, 0) while allowing the maximum values to be auto-ranged.

ZeroAlignedAutoRanger is a MultiAutoRanger, which means that when a chart contains multiple y axes, the axes are rescaled independently. This is different behaviour to the DefaultAutoRanger, which rescales the axes by maintaining a scaling factor across them (which is useful for axes showing different units of temperature, for example).


Constructor Summary
ZeroAlignedAutoRanger()
          Creates an auto ranger that does not constrain any of the corner points of the x or y axes, and with default values for the leading and trailing margin proportions.
ZeroAlignedAutoRanger(Double fixMinX, Double fixMinY, Double fixMaxX, Double fixMaxY)
          This constructor allows you to fix one or more parts of the ranges that are returned.
 
Method Summary
 Map<Axis,Range<?>> getAxisRanges(Chart chart)
           
 Pair<Range<?>,Range<?>> getRanges(Chart chart)
          Computes appropriate x and y ranges for the supplied chart instance and applies them to the chart.
 boolean isAlwaysIncludeXZero()
          Returns a boolean to indicate whether zero should always be included in the modified x range
 boolean isAlwaysIncludeYZeros()
          Returns a boolean to indicate whether zero should always be included in the modified y ranges
 boolean isAlwaysIncludeZeros()
          Returns a boolean to indicate whether zero inclusion is active for both x and y axes
 void setAlwaysIncludeXZero(boolean alwaysIncludeXZero)
           
 void setAlwaysIncludeYZeros(boolean alwaysIncludeYZeros)
           
 void setAlwaysIncludeZeros(boolean alwaysIncludeZeros)
          When you have all positive or all negative data, auto-ranging would normally home in on the ranges that actually include the data, but sometimes you want the origin to be included.
 
Methods inherited from class com.jidesoft.chart.AbstractAutoRanger
applyRangeConstraints, applyXRangeConstraints, applyYRangeConstraints, getAbsoluteMaxX, getAbsoluteMaxY, getAbsoluteMinX, getAbsoluteMinY, getLeadingXMarginProportion, getLeadingYMarginProportion, getRanges, getStackedRanges, getTrailingXMarginProportion, getTrailingYMarginProportion, isAllowXMarginToCrossZero, isAllowYMarginToCrossZero, setAbsoluteMaxX, setAbsoluteMaxY, setAbsoluteMinX, setAbsoluteMinY, setAllowXMarginToCrossZero, setAllowYMarginToCrossZero, setLeadingXMarginProportion, setLeadingYMarginProportion, setMarginProportions, setTrailingXMarginProportion, setTrailingYMarginProportion
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ZeroAlignedAutoRanger

public ZeroAlignedAutoRanger()
Creates an auto ranger that does not constrain any of the corner points of the x or y axes, and with default values for the leading and trailing margin proportions.


ZeroAlignedAutoRanger

public ZeroAlignedAutoRanger(Double fixMinX,
                             Double fixMinY,
                             Double fixMaxX,
                             Double fixMaxY)
This constructor allows you to fix one or more parts of the ranges that are returned. A common example of this would be when you are plotting a bar chart and you always want the minimum y value to be 0. If you provide null as any of the values here, that part of the returned range is not fixed and an auto-range value is computed as normal.

Parameters:
fixMinX - the fixed value for min x, or null to compute value automatically
fixMinY - the fixed value for min y, or null to compute value automatically
fixMaxX - the fixed value for max x, or null to compute value automatically
fixMaxY - the fixed value for max y, or null to compute value automatically
Method Detail

isAlwaysIncludeZeros

public boolean isAlwaysIncludeZeros()
Returns a boolean to indicate whether zero inclusion is active for both x and y axes

Returns:
a boolean to indicate whether zero inclusion is active for both x and y axes

setAlwaysIncludeZeros

public void setAlwaysIncludeZeros(boolean alwaysIncludeZeros)
When you have all positive or all negative data, auto-ranging would normally home in on the ranges that actually include the data, but sometimes you want the origin to be included. If you set this property to true, then zero will be included on the y axis.

Parameters:
alwaysIncludeZeros - a boolean to indicate whether you want zero to be included

isAlwaysIncludeXZero

public boolean isAlwaysIncludeXZero()
Returns a boolean to indicate whether zero should always be included in the modified x range

Returns:
a boolean to indicate whether zero should always be included in the modified x range

setAlwaysIncludeXZero

public void setAlwaysIncludeXZero(boolean alwaysIncludeXZero)

isAlwaysIncludeYZeros

public boolean isAlwaysIncludeYZeros()
Returns a boolean to indicate whether zero should always be included in the modified y ranges

Returns:
a boolean to indicate whether zero should always be included in the modified y ranges

setAlwaysIncludeYZeros

public void setAlwaysIncludeYZeros(boolean alwaysIncludeYZeros)

getRanges

public Pair<Range<?>,Range<?>> getRanges(Chart chart)
Computes appropriate x and y ranges for the supplied chart instance and applies them to the chart. When used as a MultiAutoRanger, this method is not called and the Chart instance calls getAxisRanges(Chart) instead.

Specified by:
getRanges in interface AutoRanger
Parameters:
chart - the chart instance for which the ranges should be calculated
Returns:
Ranges that can be used for the x and y axes of the supplied chart

getAxisRanges

public Map<Axis,Range<?>> getAxisRanges(Chart chart)
Specified by:
getAxisRanges in interface MultiAutoRanger

JIDE 3.5.15