Class TickFactory
- java.lang.Object
-
- org.eclipse.nebula.visualization.xygraph.linearscale.TickFactory
-
public class TickFactory extends java.lang.Object
Tick factory produces the different axis ticks. When specifying a format and given the screen size parameters and range it will return a list of Ticks
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TickFactory.TickFormatting
tick formatting modes
-
Field Summary
Fields Modifier and Type Field Description private static java.math.BigDecimal
BREL_ERROR
private static int
DIGITS_LOWER_LIMIT
limit for number of zeros to display right of decimal pointprivate static int
DIGITS_UPPER_LIMIT
limit for number of digits to display left of decimal pointprivate static java.math.BigDecimal
EPSILON
private TickFactory.TickFormatting
formatOfTicks
private double
graphMax
private double
graphMin
private static int
HIGHEST_LOG_10
private static java.text.DecimalFormat
INDEX_FORMAT
private boolean
isReversed
private static int
LOWER_LOG_10
private static int
LOWEST_LOG_10
private int
numberOfIntervals
private static double
REL_ERROR
private static double
ROUND_FRACTION
fraction of denominator to round toprivate IScaleProvider
scale
private java.lang.String
tickFormat
-
Constructor Summary
Constructors Constructor Description TickFactory(IScaleProvider scale)
TickFactory(TickFactory.TickFormatting format, IScaleProvider scale)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static boolean
compare(boolean isGreaterThan, double a, double b)
private void
createFormatString(int precision, boolean useExponent)
private int
determineNumLogTicks(double min, double max, int maxTicks, boolean allowMinMaxOver)
private double
determineNumTicks(double min, double max, int maxTicks, boolean allowMinMaxOver)
private static java.math.BigDecimal
divide(java.math.BigDecimal dividend, int divisor)
java.util.List<Tick>
generateIndexBasedTicks(double min, double max, int maxTicks)
Generate a list of ticks that span range given by min and max.java.util.List<Tick>
generateLogTicks(double min, double max, int maxTicks, boolean allowMinMaxOver, boolean tight)
java.util.List<Tick>
generateTicks(double min, double max, int maxTicks, boolean allowMinMaxOver, boolean tight)
Generate a list of ticks that span range given by min and max.private java.lang.String
getTickString(double value)
private boolean
inRange(double x, double min, double max)
private boolean
inRangeLog(double x, double min, double max)
private static int
log10(java.math.BigDecimal x)
protected static java.math.BigDecimal
nicenum(java.math.BigDecimal x, boolean round)
protected static double
roundDown(java.math.BigDecimal numerator, java.math.BigDecimal denominator)
Round numerator down to multiples of denominatorsprotected static double
roundUp(java.math.BigDecimal numerator, java.math.BigDecimal denominator)
Round numerator up to multiples of denominators
-
-
-
Field Detail
-
formatOfTicks
private TickFactory.TickFormatting formatOfTicks
-
EPSILON
private static final java.math.BigDecimal EPSILON
-
DIGITS_UPPER_LIMIT
private static final int DIGITS_UPPER_LIMIT
limit for number of digits to display left of decimal point- See Also:
- Constant Field Values
-
DIGITS_LOWER_LIMIT
private static final int DIGITS_LOWER_LIMIT
limit for number of zeros to display right of decimal point- See Also:
- Constant Field Values
-
ROUND_FRACTION
private static final double ROUND_FRACTION
fraction of denominator to round to- See Also:
- Constant Field Values
-
BREL_ERROR
private static final java.math.BigDecimal BREL_ERROR
-
REL_ERROR
private static final double REL_ERROR
-
graphMin
private double graphMin
-
graphMax
private double graphMax
-
tickFormat
private java.lang.String tickFormat
-
scale
private IScaleProvider scale
-
numberOfIntervals
private int numberOfIntervals
-
isReversed
private boolean isReversed
-
INDEX_FORMAT
private static final java.text.DecimalFormat INDEX_FORMAT
-
LOWEST_LOG_10
private static final int LOWEST_LOG_10
- See Also:
- Constant Field Values
-
LOWER_LOG_10
private static final int LOWER_LOG_10
- See Also:
- Constant Field Values
-
HIGHEST_LOG_10
private static final int HIGHEST_LOG_10
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
TickFactory
public TickFactory(IScaleProvider scale)
- Parameters:
format
-
-
TickFactory
public TickFactory(TickFactory.TickFormatting format, IScaleProvider scale)
- Parameters:
format
-
-
-
Method Detail
-
getTickString
private java.lang.String getTickString(double value)
-
createFormatString
private void createFormatString(int precision, boolean useExponent)
-
roundDown
protected static double roundDown(java.math.BigDecimal numerator, java.math.BigDecimal denominator)
Round numerator down to multiples of denominators- Parameters:
numerator
-denominator
-- Returns:
- rounded down value
-
roundUp
protected static double roundUp(java.math.BigDecimal numerator, java.math.BigDecimal denominator)
Round numerator up to multiples of denominators- Parameters:
numerator
-denominator
-- Returns:
- rounded up value
-
log10
private static int log10(java.math.BigDecimal x)
- Parameters:
x
-- Returns:
- floor of log 10
-
divide
private static java.math.BigDecimal divide(java.math.BigDecimal dividend, int divisor)
-
nicenum
protected static java.math.BigDecimal nicenum(java.math.BigDecimal x, boolean round)
- Parameters:
x
-round
- if true, then round else take ceiling- Returns:
- a nice number
-
determineNumTicks
private double determineNumTicks(double min, double max, int maxTicks, boolean allowMinMaxOver)
-
inRange
private boolean inRange(double x, double min, double max)
-
generateTicks
public java.util.List<Tick> generateTicks(double min, double max, int maxTicks, boolean allowMinMaxOver, boolean tight)
Generate a list of ticks that span range given by min and max. The maximum number of ticks is exceed by one in the case where the range straddles zero.- Parameters:
min
-max
-maxTicks
-allowMinMaxOver
- allow min/maximum overwritetight
- if true then remove ticks outside range- Returns:
- a list of the ticks for the axis
-
compare
private static boolean compare(boolean isGreaterThan, double a, double b)
-
generateIndexBasedTicks
public java.util.List<Tick> generateIndexBasedTicks(double min, double max, int maxTicks)
Generate a list of ticks that span range given by min and max.- Parameters:
min
-max
-maxTicks
-- Returns:
- a list of the ticks for the axis
-
determineNumLogTicks
private int determineNumLogTicks(double min, double max, int maxTicks, boolean allowMinMaxOver)
-
inRangeLog
private boolean inRangeLog(double x, double min, double max)
-
generateLogTicks
public java.util.List<Tick> generateLogTicks(double min, double max, int maxTicks, boolean allowMinMaxOver, boolean tight)
- Parameters:
min
- (must be >0)max
- (must be >0)maxTicks
-allowMinMaxOver
- allow min/maximum overwritetight
- if true then remove ticks outside range- Returns:
- a list of the ticks for the axis
-
-