Class AxisTickManagerImpl
- java.lang.Object
-
- org.jplot2d.element.impl.ElementImpl
-
- org.jplot2d.element.impl.AxisTickManagerImpl
-
- All Implemented Interfaces:
- java.lang.Cloneable, AxisTickManager, Element, AxisTickManagerEx, ElementEx, Joinable
public class AxisTickManagerImpl extends ElementImpl implements AxisTickManagerEx, java.lang.Cloneable
Manage tick values and labels of multiple axes.Implementation Notes: This class has some internal cache for properties of its axes to trace the values valid conditions. The
calcTicks()can detect if ticks need to be recalculated.
-
-
Field Summary
Fields Modifier and Type Field and Description static intAUTO_TICKS_MINstatic intDEFAULT_TICKS_NUMBER
-
Constructor Summary
Constructors Constructor and Description AxisTickManagerImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidaddAxis(AxisEx axis)voidcalcTicks()Calculate ticks when tick calculation is needed.AxisTickManagerImplcopyStructure(java.util.Map<ElementEx,ElementEx> orig2copyMap)Create a structural copy of this element and put them into orig2copyMap.RangeexpandRangeToTick(TransformType txfType, Range range)This method not change internal status of TickManager.intgetActualMinorTicks()Return the number of minor ticks displayed between two major ticks.AxisEx[]getAxes()Returns all axes whose ticks are controlled by this tick manager.AxisTransformExgetAxisTransform()java.lang.String[]getFixedLabelStrings()Returns the user assigned substitute labels.java.lang.ObjectgetFixedMinorTickValues()Return an array ofdoublerepresenting the fixed minor tick positions set byAxisTickManager.setFixedMinorTickValues(Object)java.lang.ObjectgetFixedTickValues()Return an array of number to representing the fixed tick positions set byAxisTickManager.setFixedTickValues(Object)java.lang.StringgetFullId()Returns the full id of this component.java.lang.StringgetId()Returns the id string of this elementInvokeStepgetInvokeStepFormParent()Return the invoke step to get this object from its parent.java.lang.StringgetLabelFormat()Returns the printf-style format of the labels of ticks.intgetLabelInterval()Get the label interval.MathElement[]getLabelModels()java.lang.String[]getLabelStrings()Return an array of string representing the labels shown in the axis.java.text.FormatgetLabelTextFormat()Returns the format of the labels of ticks.intgetMinorTicks()Return the number of minor ticks displayed between two major ticks.java.lang.ObjectgetMinorTickValues()Return an array of number representing the minor tick positions shown in the axis.AxisExgetParent()Gets the parent of this component.ElementExgetPrim()Returns the primary referencer.RangegetRange()Returns the tick range of this axis.TickAlgorithmgetTickAlgorithm()doublegetTickInterval()Return the interval in axis units between two ticks.doublegetTickOffset()Return the offset of ticks.intgetTicks()Returns the proposed number of ticks.AxisTickTransformgetTickTransform()Returns the AxisTickTransform, which defines The relationship between user value and tick value.java.lang.ObjectgetTickValues()Return an array of number representing the tick positions shown in the axis.booleanisAutoAdjustTicks()Returns true if the tick number is allowed to be automatically reduced to avoid tick label overlaps.booleanisAutoLabelFormat()Returnstrueif labels format is auto calculated or assigned byAxisTickManager.setLabelFormat(String)booleanisAutoMinorTicks()Returnstrueis the minor ticks number is derived from tick interval.booleanisAutoTickInterval()Returns true if the tick interval is auto calculated from tick number and range, or false if the tick interval is assigned byAxisTickManager.setTickInterval(double)booleanisAutoTickValues()Returnstrueif tick values is auto calculated from interval, orfalseif tick values is assigned by#setFixedTickValues(double[]).voidnotify(Notice msg)Element call this method to notify message to its parent.voidremoveAxis(AxisEx axis)voidsetAutoAdjustTicks(boolean flag)Set to true to allow the tick number to be automatically reduced to avoid tick label overlaps.voidsetAutoLabelFormat(boolean alf)Setstrueto auto calculate proper labels format.voidsetAutoMinorTicks(boolean flag)When autoTickInterval is set to true: if tick interval is 1, the minor interval is 0.2, create 4 minor ticks if tick interval is 2, the minor interval is 0.5, create 3 minor ticks if tick interval is 3, the minor interval is 1, create 2 minor ticks if tick interval is 4, the minor interval is 1, create 3 minor ticks if tick interval is 5, the minor interval is 1, create 4 minor ticks if tick interval is 6, the minor interval is 2, create 2 minor ticks if tick interval is 7, the minor interval is 1, create 6 minor ticks if tick interval is 8, the minor interval is 2, create 3 minor ticks if tick interval is 9, the minor interval is 3, create 2 minor ticks if tick interval is not integer, create 0 minor ticks when autoTickInterval is set to false: minor ticks is exactly the user set by#setMinorTicks(Integer).voidsetAutoTickInterval(boolean autoInterval)Set totrueto indicate the tick interval need to be auto calculated, orfalseto disable auto-calculation and keep using the current interval.voidsetAutoTickValues(boolean atv)Set totrueto indicate the tick values need to be auto calculated orfalseto use user assigned values.voidsetAxisTransform(AxisTransform rangeManager)voidsetFixedLabelStrings(java.lang.String[] labels)Set an array of String to substitute the labels of the fixed ticks.voidsetFixedMinorTickValues(java.lang.Object minorValues)Set an array ofdouble.voidsetFixedTickValues(java.lang.Object values)Set an array of values that ticks will show.voidsetLabelFormat(java.lang.String format)Sets the printf-style format that is used to format the tick labels from tick values.voidsetLabelInterval(int n)Set the tick labels displayed after n ticksvoidsetLabelTextFormat(java.text.Format format)Sets the format object that is used to format the tick labels from tick values.voidsetMinorTicks(int minors)Set the number of minor ticks displayed between two major ticks.voidsetRange(Range range)Set the tick range of the axis.voidsetTickAlgorithm(TickAlgorithm algorithm)voidsetTickInterval(double interval)Set the interval in axis units between two ticks.voidsetTickOffset(double offset)voidsetTicks(int tickNumber)Set the proposed number of ticks in the axis.voidsetTickTransform(AxisTickTransform transform)Sets the AxisTickTransform, which defines The relationship between user value and tick value.voidtransformTypeChanged()Notified by AxisRangeManagerEx that transform type changed.-
Methods inherited from class org.jplot2d.element.impl.ElementImpl
copyFrom, getEnvironment, setParent, toString
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.jplot2d.element.Element
getEnvironment
-
-
-
-
Field Detail
-
DEFAULT_TICKS_NUMBER
public static final int DEFAULT_TICKS_NUMBER
- See Also:
- Constant Field Values
-
AUTO_TICKS_MIN
public static final int AUTO_TICKS_MIN
- See Also:
- Constant Field Values
-
-
Method Detail
-
getId
public java.lang.String getId()
Description copied from interface:ElementReturns the id string of this element
-
getFullId
public java.lang.String getFullId()
Description copied from interface:ElementExReturns the full id of this component. The full id is composed of series of ids concatenated with dots. The 1st id is the id of this element, the 2nd id is the id of the parent of this element, etc, until the root plot.- Specified by:
getFullIdin interfaceElementEx- Overrides:
getFullIdin classElementImpl- Returns:
- the full id of this component
-
getInvokeStepFormParent
public InvokeStep getInvokeStepFormParent()
Description copied from interface:ElementExReturn the invoke step to get this object from its parent.- Specified by:
getInvokeStepFormParentin interfaceElementEx- Returns:
- the invoke step
-
getParent
public AxisEx getParent()
Description copied from interface:ElementGets the parent of this component.- Specified by:
getParentin interfaceElement- Specified by:
getParentin interfaceAxisTickManagerEx- Specified by:
getParentin interfaceElementEx- Overrides:
getParentin classElementImpl- Returns:
- the parent of this component
-
getPrim
public ElementEx getPrim()
Description copied from interface:JoinableReturns the primary referencer.
-
notify
public void notify(Notice msg)
Description copied from interface:ElementExElement call this method to notify message to its parent.- Specified by:
notifyin interfaceElementEx- Overrides:
notifyin classElementImpl- Parameters:
msg- the notice message
-
getAxisTransform
public AxisTransformEx getAxisTransform()
- Specified by:
getAxisTransformin interfaceAxisTickManager- Specified by:
getAxisTransformin interfaceAxisTickManagerEx
-
setAxisTransform
public void setAxisTransform(AxisTransform rangeManager)
- Specified by:
setAxisTransformin interfaceAxisTickManager
-
transformTypeChanged
public void transformTypeChanged()
Description copied from interface:AxisTickManagerExNotified by AxisRangeManagerEx that transform type changed.- Specified by:
transformTypeChangedin interfaceAxisTickManagerEx
-
getAxes
public AxisEx[] getAxes()
Description copied from interface:AxisTickManagerReturns all axes whose ticks are controlled by this tick manager.- Specified by:
getAxesin interfaceAxisTickManager- Specified by:
getAxesin interfaceAxisTickManagerEx- Returns:
- all axes whose ticks are controlled by this tick manager
-
addAxis
public void addAxis(AxisEx axis)
- Specified by:
addAxisin interfaceAxisTickManagerEx
-
removeAxis
public void removeAxis(AxisEx axis)
- Specified by:
removeAxisin interfaceAxisTickManagerEx
-
getTickTransform
public AxisTickTransform getTickTransform()
Description copied from interface:AxisTickManagerReturns the AxisTickTransform, which defines The relationship between user value and tick value.- Specified by:
getTickTransformin interfaceAxisTickManager- Returns:
- the AxisTickTransform.
-
setTickTransform
public void setTickTransform(AxisTickTransform transform)
Description copied from interface:AxisTickManagerSets the AxisTickTransform, which defines The relationship between user value and tick value. The AuxTransform must be efficient immutable.- Specified by:
setTickTransformin interfaceAxisTickManager- Parameters:
transform- the AxisTickTransform object.
-
getRange
public Range getRange()
Description copied from interface:AxisTickManagerReturns the tick range of this axis.- Specified by:
getRangein interfaceAxisTickManager- Returns:
- the tick range of this axis.
-
setRange
public void setRange(Range range)
Description copied from interface:AxisTickManagerSet the tick range of the axis.- Specified by:
setRangein interfaceAxisTickManager- Parameters:
range- the new tick range of the axis
-
isAutoAdjustTicks
public boolean isAutoAdjustTicks()
Description copied from interface:AxisTickManagerReturns true if the tick number is allowed to be automatically reduced to avoid tick label overlaps.- Specified by:
isAutoAdjustTicksin interfaceAxisTickManager- Returns:
- if the tick number is auto calculated.
-
setAutoAdjustTicks
public void setAutoAdjustTicks(boolean flag)
Description copied from interface:AxisTickManagerSet to true to allow the tick number to be automatically reduced to avoid tick label overlaps.- Specified by:
setAutoAdjustTicksin interfaceAxisTickManager
-
getTicks
public int getTicks()
Description copied from interface:AxisTickManagerReturns the proposed number of ticks. The actual number may be different from the given number, to get nice tick values.- Specified by:
getTicksin interfaceAxisTickManager- Returns:
- the number of ticks
-
setTicks
public void setTicks(int tickNumber)
Description copied from interface:AxisTickManagerSet the proposed number of ticks in the axis. The actual number may be different from the given number, to get nice tick values. If the ticks may cause the tick interval close to precision limit, the actual ticks may be less than the given value without throw PrecisionException.- Specified by:
setTicksin interfaceAxisTickManager- Parameters:
tickNumber- the number of ticks.
-
isAutoTickInterval
public boolean isAutoTickInterval()
Description copied from interface:AxisTickManagerReturns true if the tick interval is auto calculated from tick number and range, or false if the tick interval is assigned byAxisTickManager.setTickInterval(double)- Specified by:
isAutoTickIntervalin interfaceAxisTickManager- Returns:
- if the tick number is auto calculated.
-
setAutoTickInterval
public void setAutoTickInterval(boolean autoInterval)
Description copied from interface:AxisTickManagerSet totrueto indicate the tick interval need to be auto calculated, orfalseto disable auto-calculation and keep using the current interval.- Specified by:
setAutoTickIntervalin interfaceAxisTickManager- Parameters:
autoInterval- the flag
-
getTickInterval
public double getTickInterval()
Description copied from interface:AxisTickManagerReturn the interval in axis units between two ticks. For LOG axis, interval is the multiplying factor between two ticks.- Specified by:
getTickIntervalin interfaceAxisTickManager- Returns:
- the interval between two ticks
-
getTickOffset
public double getTickOffset()
Description copied from interface:AxisTickManagerReturn the offset of ticks.- Specified by:
getTickOffsetin interfaceAxisTickManager- Returns:
- the offset.
-
setTickInterval
public void setTickInterval(double interval)
Description copied from interface:AxisTickManagerSet the interval in axis units between two ticks. It change the number of ticks displayed in the axis. For LOG axis, interval is the multiplying factor between two ticks.Setting a new interval will set autoInterval to
false.- Specified by:
setTickIntervalin interfaceAxisTickManager- Parameters:
interval- the interval between two major ticks- See Also:
#setAutoTickInterval(Boolean)
-
setTickOffset
public void setTickOffset(double offset)
- Specified by:
setTickOffsetin interfaceAxisTickManager- Parameters:
offset- the offset of ticks
-
isAutoTickValues
public boolean isAutoTickValues()
Description copied from interface:AxisTickManagerReturnstrueif tick values is auto calculated from interval, orfalseif tick values is assigned by#setFixedTickValues(double[]).- Specified by:
isAutoTickValuesin interfaceAxisTickManager- Returns:
trueif tick values is auto calculated.
-
setAutoTickValues
public void setAutoTickValues(boolean atv)
Description copied from interface:AxisTickManagerSet totrueto indicate the tick values need to be auto calculated orfalseto use user assigned values.- Specified by:
setAutoTickValuesin interfaceAxisTickManager- Parameters:
atv- the flag
-
getFixedTickValues
public java.lang.Object getFixedTickValues()
Description copied from interface:AxisTickManagerReturn an array of number to representing the fixed tick positions set byAxisTickManager.setFixedTickValues(Object)- Specified by:
getFixedTickValuesin interfaceAxisTickManager- Returns:
- the labels of the ticks
-
setFixedTickValues
public void setFixedTickValues(java.lang.Object values)
Description copied from interface:AxisTickManagerSet an array of values that ticks will show. If the given values is null or a empty array, no tick will be drawn.The autoValues will be set to false when this method is called. The minor values will be cleared by this method.
- Specified by:
setFixedTickValuesin interfaceAxisTickManager- Parameters:
values- the values in user unit where ticks are displayed.
-
getFixedMinorTickValues
public java.lang.Object getFixedMinorTickValues()
Description copied from interface:AxisTickManagerReturn an array ofdoublerepresenting the fixed minor tick positions set byAxisTickManager.setFixedMinorTickValues(Object)- Specified by:
getFixedMinorTickValuesin interfaceAxisTickManager- Returns:
- the labels of the ticks
-
setFixedMinorTickValues
public void setFixedMinorTickValues(java.lang.Object minorValues)
Description copied from interface:AxisTickManagerSet an array ofdouble. If the given values is null or a empty array, no tick will be drawn.This method must be called after
#setFixedTickValues(double[])is called.#setFixedTickValues(double[])calling will clear the minor values.- Specified by:
setFixedMinorTickValuesin interfaceAxisTickManager
-
isAutoMinorTicks
public boolean isAutoMinorTicks()
Description copied from interface:AxisTickManagerReturnstrueis the minor ticks number is derived from tick interval.- Specified by:
isAutoMinorTicksin interfaceAxisTickManager- Returns:
trueis the minor ticks number is derived from tick interval.
-
setAutoMinorTicks
public void setAutoMinorTicks(boolean flag)
Description copied from interface:AxisTickManagerWhen autoTickInterval is set to true:- if tick interval is 1, the minor interval is 0.2, create 4 minor ticks
- if tick interval is 2, the minor interval is 0.5, create 3 minor ticks
- if tick interval is 3, the minor interval is 1, create 2 minor ticks
- if tick interval is 4, the minor interval is 1, create 3 minor ticks
- if tick interval is 5, the minor interval is 1, create 4 minor ticks
- if tick interval is 6, the minor interval is 2, create 2 minor ticks
- if tick interval is 7, the minor interval is 1, create 6 minor ticks
- if tick interval is 8, the minor interval is 2, create 3 minor ticks
- if tick interval is 9, the minor interval is 3, create 2 minor ticks
- if tick interval is not integer, create 0 minor ticks
#setMinorTicks(Integer). The Default number is zero, means not shown by default.- Specified by:
setAutoMinorTicksin interfaceAxisTickManager
-
getMinorTicks
public int getMinorTicks()
Description copied from interface:AxisTickManagerReturn the number of minor ticks displayed between two major ticks. This method always returns the number set by#setMinorTicks(Integer), no matter if the actual number has been adjusted.- Specified by:
getMinorTicksin interfaceAxisTickManager- Returns:
- the number of minor ticks displayed
-
setMinorTicks
public void setMinorTicks(int minors)
Description copied from interface:AxisTickManagerSet the number of minor ticks displayed between two major ticks. The actual number may be adjusted, and not equal the number set by this method.Setting a new minor number will set autoMinornumber to
false.- Specified by:
setMinorTicksin interfaceAxisTickManager- Parameters:
minors- the number of minor ticks displayed
-
getActualMinorTicks
public int getActualMinorTicks()
Description copied from interface:AxisTickManagerReturn the number of minor ticks displayed between two major ticks. This method returns the actual number, might be different form the number set by#setMinorTicks(Integer).- Specified by:
getActualMinorTicksin interfaceAxisTickManager- Returns:
- the number of minor ticks displayed
-
isAutoLabelFormat
public boolean isAutoLabelFormat()
Description copied from interface:AxisTickManagerReturnstrueif labels format is auto calculated or assigned byAxisTickManager.setLabelFormat(String)- Specified by:
isAutoLabelFormatin interfaceAxisTickManager- Returns:
trueif labels format is auto calculated
-
setAutoLabelFormat
public void setAutoLabelFormat(boolean alf)
Description copied from interface:AxisTickManagerSetstrueto auto calculate proper labels format. Or setsfalseto assign a label format byAxisTickManager.setLabelFormat(String)- Specified by:
setAutoLabelFormatin interfaceAxisTickManager- Parameters:
alf- the flag
-
getLabelTextFormat
public java.text.Format getLabelTextFormat()
Description copied from interface:AxisTickManagerReturns the format of the labels of ticks.- Specified by:
getLabelTextFormatin interfaceAxisTickManager- Returns:
- the format of the labels.
-
setLabelTextFormat
public void setLabelTextFormat(java.text.Format format)
Description copied from interface:AxisTickManagerSets the format object that is used to format the tick labels from tick values. If this text format is null, the printf-style format will be used to format the labels.Setting a new labelTextFormat will set autoLabelFormat to
false- Specified by:
setLabelTextFormatin interfaceAxisTickManager- Parameters:
format- the format object
-
getLabelFormat
public java.lang.String getLabelFormat()
Description copied from interface:AxisTickManagerReturns the printf-style format of the labels of ticks.- Specified by:
getLabelFormatin interfaceAxisTickManager- Returns:
- the format of the labels.
-
setLabelFormat
public void setLabelFormat(java.lang.String format)
Description copied from interface:AxisTickManagerSets the printf-style format that is used to format the tick labels from tick values. The syntax of format string is described inFormatter. Beside the standard Java formatter conversions, a special conversion 'm' can be used to produce labels in n_10^e format. The usage of conversion 'm' is like the standard conversion 'e'.Setting a new labelFormat will set autoLabelFormat to
false- Specified by:
setLabelFormatin interfaceAxisTickManager- Parameters:
format- the format string, or null to used the auto format.
-
getFixedLabelStrings
public java.lang.String[] getFixedLabelStrings()
Description copied from interface:AxisTickManagerReturns the user assigned substitute labels.nullhas a special meaning of "undecided".- Specified by:
getFixedLabelStringsin interfaceAxisTickManager- Returns:
- the user assigned substitute labels.
-
setFixedLabelStrings
public void setFixedLabelStrings(java.lang.String[] labels)
Description copied from interface:AxisTickManagerSet an array of String to substitute the labels of the fixed ticks. If the length of the array is shorter then the number of fixed ticks, only the first ticks are changed, if the length of the array is longer then the number of ticks only the first labels are used. null in the array means not substitute the label. The given labels can be null or a empty array.If the tick is autoValues mode (a.k.a. no fixedValues assigned), the given fixedLabels will substitute the auto labels of visible ticks.
- Specified by:
setFixedLabelStringsin interfaceAxisTickManager- Parameters:
labels- the new labels to be displayed in the ticks- See Also:
AxisTickManager.setFixedTickValues(Object)
-
getLabelInterval
public int getLabelInterval()
Description copied from interface:AxisTickManagerGet the label interval. The tick labels are displayed after that number of ticks- Specified by:
getLabelIntervalin interfaceAxisTickManager- Returns:
- label interval
-
setLabelInterval
public void setLabelInterval(int n)
Description copied from interface:AxisTickManagerSet the tick labels displayed after n ticks- Specified by:
setLabelIntervalin interfaceAxisTickManager- Parameters:
n- label displayed each n ticks .
-
getTickValues
public java.lang.Object getTickValues()
Description copied from interface:AxisTickManagerReturn an array of number representing the tick positions shown in the axis.- Specified by:
getTickValuesin interfaceAxisTickManager- Returns:
- the values of the ticks
-
getMinorTickValues
public java.lang.Object getMinorTickValues()
Description copied from interface:AxisTickManagerReturn an array of number representing the minor tick positions shown in the axis.- Specified by:
getMinorTickValuesin interfaceAxisTickManager- Returns:
- the values of the ticks
-
getLabelModels
public MathElement[] getLabelModels()
- Specified by:
getLabelModelsin interfaceAxisTickManagerEx
-
getTickAlgorithm
public TickAlgorithm getTickAlgorithm()
- Specified by:
getTickAlgorithmin interfaceAxisTickManagerEx
-
setTickAlgorithm
public void setTickAlgorithm(TickAlgorithm algorithm)
- Specified by:
setTickAlgorithmin interfaceAxisTickManagerEx
-
getLabelStrings
public java.lang.String[] getLabelStrings()
Description copied from interface:AxisTickManagerReturn an array of string representing the labels shown in the axis.- Specified by:
getLabelStringsin interfaceAxisTickManager- Returns:
- the labels of the ticks
-
calcTicks
public void calcTicks()
Description copied from interface:AxisTickManagerExCalculate ticks when tick calculation is needed.- Specified by:
calcTicksin interfaceAxisTickManagerEx
-
expandRangeToTick
public Range expandRangeToTick(TransformType txfType, Range range)
Description copied from interface:AxisTickManagerExThis method not change internal status of TickManager. Only get those values: tickCalculator, tickNumber, labelFormat, labelInterval- Specified by:
expandRangeToTickin interfaceAxisTickManagerEx- Parameters:
txfType- transform typerange- the core range- Returns:
- the expanded range
-
copyStructure
public AxisTickManagerImpl copyStructure(java.util.Map<ElementEx,ElementEx> orig2copyMap)
Description copied from interface:ElementExCreate a structural copy of this element and put them into orig2copyMap. All properties are not copied. The parent of the copy are not set by this method.- Specified by:
copyStructurein interfaceElementEx- Overrides:
copyStructurein classElementImpl- Parameters:
orig2copyMap- original element to copy map- Returns:
- the structural copy of this element
-
-
DMelt 3.0 © DataMelt by jWork.ORG