org.jfree.chart.axis
Class LogAxis
- java.lang.Object
-
- org.jfree.chart.axis.Axis
-
- org.jfree.chart.axis.ValueAxis
-
- org.jfree.chart.axis.LogAxis
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, org.jfree.util.PublicCloneable
public class LogAxis extends ValueAxis
A numerical axis that uses a logarithmic scale. The class is an alternative to theLogarithmicAxisclass.- Since:
- 1.0.7
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class org.jfree.chart.axis.ValueAxis
DEFAULT_AUTO_RANGE, DEFAULT_AUTO_RANGE_MINIMUM_SIZE, DEFAULT_AUTO_TICK_UNIT_SELECTION, DEFAULT_INVERTED, DEFAULT_LOWER_BOUND, DEFAULT_LOWER_MARGIN, DEFAULT_RANGE, DEFAULT_UPPER_BOUND, DEFAULT_UPPER_MARGIN, MAXIMUM_TICK_COUNT
-
Fields inherited from class org.jfree.chart.axis.Axis
DEFAULT_AXIS_LABEL_FONT, DEFAULT_AXIS_LABEL_INSETS, DEFAULT_AXIS_LABEL_PAINT, DEFAULT_AXIS_LINE_PAINT, DEFAULT_AXIS_LINE_STROKE, DEFAULT_AXIS_VISIBLE, DEFAULT_TICK_LABEL_FONT, DEFAULT_TICK_LABEL_INSETS, DEFAULT_TICK_LABEL_PAINT, DEFAULT_TICK_LABELS_VISIBLE, DEFAULT_TICK_MARK_INSIDE_LENGTH, DEFAULT_TICK_MARK_OUTSIDE_LENGTH, DEFAULT_TICK_MARK_PAINT, DEFAULT_TICK_MARK_STROKE, DEFAULT_TICK_MARKS_VISIBLE
-
-
Constructor Summary
Constructors Constructor and Description LogAxis()Creates a newLogAxiswith no label.LogAxis(java.lang.String label)Creates a newLogAxiswith the given label.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method and Description doublecalculateLog(double value)Calculates the log of the given value, using the current base.doublecalculateValue(double log)Calculates the value from a given log.voidconfigure()Configures the axis.static TickUnitSourcecreateLogTickUnits(java.util.Locale locale)Deprecated.This method is no longer used internally and will be removed from a future version. If you need this method, copy the source code into your project.AxisStatedraw(java.awt.Graphics2D g2, double cursor, java.awt.geom.Rectangle2D plotArea, java.awt.geom.Rectangle2D dataArea, org.jfree.ui.RectangleEdge edge, PlotRenderingInfo plotState)Draws the axis on a Java 2D graphics device (such as the screen or a printer).booleanequals(java.lang.Object obj)Tests this axis for equality with an arbitrary object.doubleexponentLengthToJava2D(double length, java.awt.geom.Rectangle2D area, org.jfree.ui.RectangleEdge edge)Converts a length in data coordinates into the corresponding length in Java2D coordinates.doublegetBase()Returns the base for the logarithm calculation.java.text.FormatgetBaseFormatter()Returns the formatter used to format the base value of the logarithmic scale when it is displayed numerically.java.lang.StringgetBaseSymbol()Returns the symbol used to represent the base of the logarithmic scale for the axis.java.text.NumberFormatgetNumberFormatOverride()Returns the number format override.doublegetSmallestValue()Returns the smallest value represented by the axis.NumberTickUnitgetTickUnit()Returns the current tick unit.inthashCode()Returns a hash code for this instance.doublejava2DToValue(double java2DValue, java.awt.geom.Rectangle2D area, org.jfree.ui.RectangleEdge edge)Converts a Java2D coordinate to an axis value, assuming that the axis is aligned to the specifiededgeof thearea.voidpan(double percent)Slides the axis range by the specified percentage.java.util.ListrefreshTicks(java.awt.Graphics2D g2, AxisState state, java.awt.geom.Rectangle2D dataArea, org.jfree.ui.RectangleEdge edge)Calculates the positions of the tick labels for the axis, storing the results in the tick label list (ready for drawing).voidresizeRange(double percent)Increases or decreases the axis range by the specified percentage about the central value and sends anAxisChangeEventto all registered listeners.voidresizeRange(double percent, double anchorValue)Increases or decreases the axis range by the specified percentage about the specified anchor value and sends anAxisChangeEventto all registered listeners.voidresizeRange2(double percent, double anchorValue)Resizes the axis length to the specified percentage of the current range and sends a change event to all registered listeners.voidsetBase(double base)Sets the base for the logarithm calculation and sends a change event to all registered listeners.voidsetBaseFormatter(java.text.Format formatter)Sets the formatter used to format the base value of the logarithmic scale when it is displayed numerically and sends a change event to all registered listeners.voidsetBaseSymbol(java.lang.String symbol)Sets the symbol used to represent the base value of the logarithmic scale and sends a change event to all registered listeners.voidsetNumberFormatOverride(java.text.NumberFormat formatter)Sets the number format override and sends a change event to all registered listeners.voidsetSmallestValue(double value)Sets the smallest value represented by the axis and sends a change event to all registered listeners.voidsetTickUnit(NumberTickUnit unit)Sets the tick unit for the axis and sends anAxisChangeEventto all registered listeners.voidsetTickUnit(NumberTickUnit unit, boolean notify, boolean turnOffAutoSelect)Sets the tick unit for the axis and, if requested, sends anAxisChangeEventto all registered listeners.doublevalueToJava2D(double value, java.awt.geom.Rectangle2D area, org.jfree.ui.RectangleEdge edge)Converts a value on the axis scale to a Java2D coordinate relative to the givenarea, based on the axis running along the specifiededge.voidzoomRange(double lowerPercent, double upperPercent)Zooms in on the current range.-
Methods inherited from class org.jfree.chart.axis.ValueAxis
centerRange, clone, getAutoRangeMinimumSize, getDefaultAutoRange, getDownArrow, getFixedAutoRange, getLeftArrow, getLowerBound, getLowerMargin, getMinorTickCount, getRange, getRightArrow, getStandardTickUnits, getUpArrow, getUpperBound, getUpperMargin, isAutoRange, isAutoTickUnitSelection, isInverted, isNegativeArrowVisible, isPositiveArrowVisible, isVerticalTickLabels, lengthToJava2D, reserveSpace, setAutoRange, setAutoRangeMinimumSize, setAutoRangeMinimumSize, setAutoTickUnitSelection, setAutoTickUnitSelection, setDefaultAutoRange, setDownArrow, setFixedAutoRange, setInverted, setLeftArrow, setLowerBound, setLowerMargin, setMinorTickCount, setNegativeArrowVisible, setPositiveArrowVisible, setRange, setRange, setRange, setRangeAboutValue, setRangeWithMargins, setRangeWithMargins, setRangeWithMargins, setRightArrow, setStandardTickUnits, setUpArrow, setUpperBound, setUpperMargin, setVerticalTickLabels
-
Methods inherited from class org.jfree.chart.axis.Axis
addChangeListener, createAttributedLabel, getAttributedLabel, getAxisLinePaint, getAxisLineStroke, getFixedDimension, getLabel, getLabelAngle, getLabelFont, getLabelInsets, getLabelLocation, getLabelPaint, getMinorTickMarkInsideLength, getMinorTickMarkOutsideLength, getPlot, getTickLabelFont, getTickLabelInsets, getTickLabelPaint, getTickMarkInsideLength, getTickMarkOutsideLength, getTickMarkPaint, getTickMarkStroke, hasListener, isAxisLineVisible, isMinorTickMarksVisible, isTickLabelsVisible, isTickMarksVisible, isVisible, removeChangeListener, setAttributedLabel, setAttributedLabel, setAxisLinePaint, setAxisLineStroke, setAxisLineVisible, setFixedDimension, setLabel, setLabelAngle, setLabelFont, setLabelInsets, setLabelInsets, setLabelLocation, setLabelPaint, setMinorTickMarkInsideLength, setMinorTickMarkOutsideLength, setMinorTickMarksVisible, setPlot, setTickLabelFont, setTickLabelInsets, setTickLabelPaint, setTickLabelsVisible, setTickMarkInsideLength, setTickMarkOutsideLength, setTickMarkPaint, setTickMarkStroke, setTickMarksVisible, setVisible
-
-
-
-
Constructor Detail
-
LogAxis
public LogAxis()
Creates a newLogAxiswith no label.
-
LogAxis
public LogAxis(java.lang.String label)
Creates a newLogAxiswith the given label.- Parameters:
label- the axis label (nullpermitted).
-
-
Method Detail
-
getBase
public double getBase()
Returns the base for the logarithm calculation. The default value is10.0.- Returns:
- The base for the logarithm calculation.
- See Also:
setBase(double)
-
setBase
public void setBase(double base)
Sets the base for the logarithm calculation and sends a change event to all registered listeners.- Parameters:
base- the base value (must be > 1.0).- See Also:
getBase()
-
getBaseSymbol
public java.lang.String getBaseSymbol()
Returns the symbol used to represent the base of the logarithmic scale for the axis. If this isnull(the default) then the numerical value of the base is displayed.- Returns:
- The base symbol (possibly
null). - Since:
- 1.0.18
-
setBaseSymbol
public void setBaseSymbol(java.lang.String symbol)
Sets the symbol used to represent the base value of the logarithmic scale and sends a change event to all registered listeners.- Parameters:
symbol- the symbol (nullpermitted).- Since:
- 1.0.18
-
getBaseFormatter
public java.text.Format getBaseFormatter()
Returns the formatter used to format the base value of the logarithmic scale when it is displayed numerically. The default value isnew DecimalFormat("0").- Returns:
- The base formatter (never
null). - Since:
- 1.0.18
-
setBaseFormatter
public void setBaseFormatter(java.text.Format formatter)
Sets the formatter used to format the base value of the logarithmic scale when it is displayed numerically and sends a change event to all registered listeners.- Parameters:
formatter- the formatter (nullnot permitted).- Since:
- 1.0.18
-
getSmallestValue
public double getSmallestValue()
Returns the smallest value represented by the axis.- Returns:
- The smallest value represented by the axis.
- See Also:
setSmallestValue(double)
-
setSmallestValue
public void setSmallestValue(double value)
Sets the smallest value represented by the axis and sends a change event to all registered listeners.- Parameters:
value- the value.- See Also:
getSmallestValue()
-
getTickUnit
public NumberTickUnit getTickUnit()
Returns the current tick unit.- Returns:
- The current tick unit.
- See Also:
setTickUnit(NumberTickUnit)
-
setTickUnit
public void setTickUnit(NumberTickUnit unit)
Sets the tick unit for the axis and sends anAxisChangeEventto all registered listeners. A side effect of calling this method is that the "auto-select" feature for tick units is switched off (you can restore it using theValueAxis.setAutoTickUnitSelection(boolean)method).- Parameters:
unit- the new tick unit (nullnot permitted).- See Also:
getTickUnit()
-
setTickUnit
public void setTickUnit(NumberTickUnit unit, boolean notify, boolean turnOffAutoSelect)
Sets the tick unit for the axis and, if requested, sends anAxisChangeEventto all registered listeners. In addition, an option is provided to turn off the "auto-select" feature for tick units (you can restore it using theValueAxis.setAutoTickUnitSelection(boolean)method).- Parameters:
unit- the new tick unit (nullnot permitted).notify- notify listeners?turnOffAutoSelect- turn off the auto-tick selection?- See Also:
getTickUnit()
-
getNumberFormatOverride
public java.text.NumberFormat getNumberFormatOverride()
Returns the number format override. If this is non-null, then it will be used to format the numbers on the axis.- Returns:
- The number formatter (possibly
null). - See Also:
setNumberFormatOverride(NumberFormat)
-
setNumberFormatOverride
public void setNumberFormatOverride(java.text.NumberFormat formatter)
Sets the number format override and sends a change event to all registered listeners. If this is non-null, then it will be used to format the numbers on the axis.- Parameters:
formatter- the number formatter (nullpermitted).- See Also:
getNumberFormatOverride()
-
calculateLog
public double calculateLog(double value)
Calculates the log of the given value, using the current base.- Parameters:
value- the value.- Returns:
- The log of the given value.
- See Also:
calculateValue(double),getBase()
-
calculateValue
public double calculateValue(double log)
Calculates the value from a given log.- Parameters:
log- the log value.- Returns:
- The value with the given log.
- See Also:
calculateLog(double),getBase()
-
java2DToValue
public double java2DToValue(double java2DValue, java.awt.geom.Rectangle2D area, org.jfree.ui.RectangleEdge edge)Converts a Java2D coordinate to an axis value, assuming that the axis is aligned to the specifiededgeof thearea.- Specified by:
java2DToValuein classValueAxis- Parameters:
java2DValue- the Java2D coordinate.area- the area for plotting data (nullnot permitted).edge- the edge that the axis is aligned to (nullnot permitted).- Returns:
- A value along the axis scale.
- See Also:
ValueAxis.valueToJava2D(double, Rectangle2D, RectangleEdge)
-
valueToJava2D
public double valueToJava2D(double value, java.awt.geom.Rectangle2D area, org.jfree.ui.RectangleEdge edge)Converts a value on the axis scale to a Java2D coordinate relative to the givenarea, based on the axis running along the specifiededge.- Specified by:
valueToJava2Din classValueAxis- Parameters:
value- the data value.area- the area (nullnot permitted).edge- the edge (nullnot permitted).- Returns:
- The Java2D coordinate corresponding to
value. - See Also:
ValueAxis.java2DToValue(double, Rectangle2D, RectangleEdge)
-
configure
public void configure()
Configures the axis. This method is typically called when an axis is assigned to a new plot.
-
draw
public AxisState draw(java.awt.Graphics2D g2, double cursor, java.awt.geom.Rectangle2D plotArea, java.awt.geom.Rectangle2D dataArea, org.jfree.ui.RectangleEdge edge, PlotRenderingInfo plotState)
Draws the axis on a Java 2D graphics device (such as the screen or a printer).- Specified by:
drawin classAxis- Parameters:
g2- the graphics device (nullnot permitted).cursor- the cursor location (determines where to draw the axis).plotArea- the area within which the axes and plot should be drawn.dataArea- the area within which the data should be drawn.edge- the axis location (nullnot permitted).plotState- collects information about the plot (nullpermitted).- Returns:
- The axis state (never
null).
-
refreshTicks
public java.util.List refreshTicks(java.awt.Graphics2D g2, AxisState state, java.awt.geom.Rectangle2D dataArea, org.jfree.ui.RectangleEdge edge)Calculates the positions of the tick labels for the axis, storing the results in the tick label list (ready for drawing).- Specified by:
refreshTicksin classAxis- Parameters:
g2- the graphics device.state- the axis state.dataArea- the area in which the plot should be drawn.edge- the location of the axis.- Returns:
- A list of ticks.
-
exponentLengthToJava2D
public double exponentLengthToJava2D(double length, java.awt.geom.Rectangle2D area, org.jfree.ui.RectangleEdge edge)Converts a length in data coordinates into the corresponding length in Java2D coordinates.- Parameters:
length- the length.area- the plot area.edge- the edge along which the axis lies.- Returns:
- The length in Java2D coordinates.
- Since:
- 1.0.7
-
zoomRange
public void zoomRange(double lowerPercent, double upperPercent)Zooms in on the current range.
-
pan
public void pan(double percent)
Slides the axis range by the specified percentage.
-
resizeRange
public void resizeRange(double percent)
Increases or decreases the axis range by the specified percentage about the central value and sends anAxisChangeEventto all registered listeners.To double the length of the axis range, use 200% (2.0). To halve the length of the axis range, use 50% (0.5).
- Overrides:
resizeRangein classValueAxis- Parameters:
percent- the resize factor.- See Also:
resizeRange(double, double)
-
resizeRange
public void resizeRange(double percent, double anchorValue)Description copied from class:ValueAxisIncreases or decreases the axis range by the specified percentage about the specified anchor value and sends anAxisChangeEventto all registered listeners.To double the length of the axis range, use 200% (2.0). To halve the length of the axis range, use 50% (0.5).
- Overrides:
resizeRangein classValueAxis- Parameters:
percent- the resize factor.anchorValue- the new central value after the resize.- See Also:
ValueAxis.resizeRange(double)
-
resizeRange2
public void resizeRange2(double percent, double anchorValue)Resizes the axis length to the specified percentage of the current range and sends a change event to all registered listeners. Ifpercentis greater than 1.0 (100 percent) then the axis range is increased (which has the effect of zooming out), while if thepercentis less than 1.0 the axis range is decreased (which has the effect of zooming in). The resize occurs around an anchor value (which may not be in the center of the axis). This is used to support mouse wheel zooming around an arbitrary point on the plot.
This method is overridden to perform the percentage calculations on the log values (which are linear for this axis).- Overrides:
resizeRange2in classValueAxis- Parameters:
percent- the percentage (must be greater than zero).anchorValue- the anchor value.- See Also:
ValueAxis.resizeRange(double)
-
equals
public boolean equals(java.lang.Object obj)
Tests this axis for equality with an arbitrary object.
-
hashCode
public int hashCode()
Returns a hash code for this instance.
-
createLogTickUnits
public static TickUnitSource createLogTickUnits(java.util.Locale locale)
Deprecated. This method is no longer used internally and will be removed from a future version. If you need this method, copy the source code into your project.Returns a collection of tick units for log (base 10) values. Uses a given Locale to create the DecimalFormats.- Parameters:
locale- the locale to use to represent Numbers.- Returns:
- A collection of tick units for integer values.
- Since:
- 1.0.7
-
-
DMelt 3.0 © DataMelt by jWork.ORG