de.erichseifert.gral.plots.axes
Class AbstractAxisRenderer2D
- java.lang.Object
-
- de.erichseifert.gral.plots.axes.AbstractAxisRenderer2D
-
- All Implemented Interfaces:
- AxisRenderer, java.io.Serializable
- Direct Known Subclasses:
- LinearRenderer2D, LogarithmicRenderer2D
public abstract class AbstractAxisRenderer2D extends java.lang.Object implements AxisRenderer, java.io.Serializable
Abstract class that provides function for rendering axes in two-dimensional space.
Functionality includes:
- Calculating tick positions of an axis
- Calculating tick normals
- Administration of settings
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description AbstractAxisRenderer2D()Initializes a new instance with default settings.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description java.util.Map<java.lang.Double,java.lang.String>getCustomTicks()Returns custom ticks with their respective position and label.java.lang.NumbergetIntersection()Returns the intersection point of the axis.LabelgetLabel()Returns the label of the axis.doublegetLabelDistance()Returns the distance from the axis to the label.doublegetMinorTickAlignment()Returns the alignment of minor ticks.java.awt.PaintgetMinorTickColor()Returns the paint used to draw the shapes of minor ticks.doublegetMinorTickLength()Returns the length of minor tick strokes.intgetMinorTicksCount()Returns the count of minor ticks.java.awt.StrokegetMinorTickStroke()Returns the stroke used to draw all minor ticks.PointND<java.lang.Double>getNormal(Axis axis, java.lang.Number value, boolean extrapolate, boolean forceLinear)Returns the normal vector at the position of the specified value.PointND<java.lang.Double>getPosition(Axis axis, java.lang.Number value, boolean extrapolate, boolean forceLinear)Returns the position of the specified value on the axis.DrawablegetRendererComponent(Axis axis)Returns a component that displays the specified axis.java.awt.ShapegetShape()Returns the shape of the axis.java.awt.PaintgetShapeColor()Returns the paint used to draw the axis, its ticks and its labels.java.awt.StrokegetShapeStroke()Returns the stroke which defines the shape of the axis.doublegetTickAlignment()Returns the alignment of major ticks relative to the axis.java.awt.PaintgetTickColor()Returns the paint used to draw the shapes of major ticks.java.awt.FontgetTickFont()Returns the font used to display the text of major ticks.doublegetTickLabelDistance()Returns the distance of labels to their ticks.java.text.FormatgetTickLabelFormat()Returns the format which converts the tick values to labels.doublegetTickLabelRotation()Returns the rotation of the tick labels.doublegetTickLength()Returns the length of major tick strokes.java.util.List<Tick>getTicks(Axis axis)Returns a list of all tick element on the axis.java.lang.NumbergetTickSpacing()Returns the interval for major ticks.java.awt.StrokegetTickStroke()Returns the stroke which is used to draw all major ticks.booleanisMinorTicksVisible()Returns whether minor ticks are drawn.booleanisShapeDirectionSwapped()Returns whether the axis direction is changed.booleanisShapeNormalOrientationClockwise()Returns whether the normal vector of the shape is calculated using clockwise or counterclockwise rotation.booleanisShapeVisible()Returns whether the shape of the axis will be drawn.booleanisTickLabelsOutside()Returns whether the tick labels are drawn outside of the plot.booleanisTickLabelsVisible()Returns whether tick labels will be shown.booleanisTicksAutoSpaced()Returns whether the interval for major and minor ticks is chosen automatically.booleanisTicksVisible()Returns whether major ticks are drawn.voidsetCustomTicks(java.util.Map<java.lang.Double,java.lang.String> positionsAndLabels)Sets custom ticks with their respective position and label.voidsetIntersection(java.lang.Number intersection)Sets the intersection point of the axis.voidsetLabel(Label label)Sets the label of the axis.voidsetLabelDistance(double distance)Sets the distance from the axis to the label.voidsetMinorTickAlignment(double alignment)Sets the alignment of minor ticks.voidsetMinorTickColor(java.awt.Paint color)Sets the paint used to draw the shapes of minor ticks.voidsetMinorTickLength(double length)Sets the length of minor tick strokes.voidsetMinorTicksCount(int count)Sets the count of minor ticks.voidsetMinorTickStroke(java.awt.Stroke stroke)Sets the stroke used to draw all minor ticks.voidsetMinorTicksVisible(boolean minorTicksVisible)Sets whether minor ticks are drawn.voidsetShape(java.awt.Shape shape)Sets the shape of the axis.voidsetShapeColor(java.awt.Paint color)Sets the paint used to draw the axis, its ticks and its labels.voidsetShapeDirectionSwapped(boolean directionSwapped)Sets whether the axis direction will be changed.voidsetShapeNormalOrientationClockwise(boolean clockwise)Sets whether the normal vector of the shape is calculated using clockwise or counterclockwise rotation.voidsetShapeStroke(java.awt.Stroke stroke)Sets the stroke which defines the shape of the axis.voidsetShapeVisible(boolean shapeVisible)Sets whether the shape of the axis will be drawn.voidsetTickAlignment(double alignment)Sets the alignment of major ticks relative to the axis.voidsetTickColor(java.awt.Paint color)Sets the paint used to draw the shapes of major ticks.voidsetTickFont(java.awt.Font font)Sets the font used to display the text of major ticks.voidsetTickLabelDistance(double distance)Sets the distance of labels to their ticks.voidsetTickLabelFormat(java.text.Format format)Sets the format which converts the tick values to labels.voidsetTickLabelRotation(double angle)Sets the rotation of the tick labels.voidsetTickLabelsOutside(boolean labelsOutside)Sets whether the tick labels are drawn outside of the plot.voidsetTickLabelsVisible(boolean tickLabelsVisible)Sets whether tick labels will be shown.voidsetTickLength(double length)Sets the length of major tick strokes.voidsetTicksAutoSpaced(boolean autoSpaced)Sets whether the interval for major and minor ticks is chosen automatically.voidsetTickSpacing(java.lang.Number spacing)Sets the interval for major ticks.voidsetTickStroke(java.awt.Stroke stroke)Sets the stroke which is used to draw all major ticks.voidsetTicksVisible(boolean ticksVisible)Sets whether major ticks will be drawn.-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface de.erichseifert.gral.plots.axes.AxisRenderer
viewToWorld, worldToView
-
-
-
-
Constructor Detail
-
AbstractAxisRenderer2D
public AbstractAxisRenderer2D()
Initializes a new instance with default settings.
-
-
Method Detail
-
getRendererComponent
public Drawable getRendererComponent(Axis axis)
Returns a component that displays the specified axis.- Specified by:
getRendererComponentin interfaceAxisRenderer- Parameters:
axis- axis to be displayed- Returns:
- component displaying the axis
- See Also:
Axis
-
getTicks
public java.util.List<Tick> getTicks(Axis axis)
Returns a list of all tick element on the axis.- Specified by:
getTicksin interfaceAxisRenderer- Parameters:
axis- Axis- Returns:
- A list of
Tickinstances
-
getNormal
public PointND<java.lang.Double> getNormal(Axis axis, java.lang.Number value, boolean extrapolate, boolean forceLinear)
Returns the normal vector at the position of the specified value. The vector is normalized.- Specified by:
getNormalin interfaceAxisRenderer- Parameters:
axis- Axisvalue- World coordinate value to convertextrapolate- Option to activate extrapolation value that are not on the axisforceLinear- Force linear interpolation.- Returns:
- N-dimensional normal vector at the position
-
getPosition
public PointND<java.lang.Double> getPosition(Axis axis, java.lang.Number value, boolean extrapolate, boolean forceLinear)
Returns the position of the specified value on the axis. The value is returned in view coordinates.- Specified by:
getPositionin interfaceAxisRenderer- Parameters:
axis- Axisvalue- World coordinate value to convertextrapolate- Option to activate extrapolation value that are not on the axisforceLinear- Force linear interpolation.- Returns:
- N-dimensional point of the value
-
getIntersection
public java.lang.Number getIntersection()
Description copied from interface:AxisRendererReturns the intersection point of the axis.- Specified by:
getIntersectionin interfaceAxisRenderer- Returns:
- Point at which this axis intersects other axes.
-
setIntersection
public void setIntersection(java.lang.Number intersection)
Description copied from interface:AxisRendererSets the intersection point of the axis.- Specified by:
setIntersectionin interfaceAxisRenderer- Parameters:
intersection- Point at which this axis intersects other axes.
-
getShape
public java.awt.Shape getShape()
Description copied from interface:AxisRendererReturns the shape of the axis.- Specified by:
getShapein interfaceAxisRenderer- Returns:
- Shape used for drawing.
-
setShape
public void setShape(java.awt.Shape shape)
Description copied from interface:AxisRendererSets the shape of the axis.- Specified by:
setShapein interfaceAxisRenderer- Parameters:
shape- Shape used for drawing.
-
isShapeVisible
public boolean isShapeVisible()
Description copied from interface:AxisRendererReturns whether the shape of the axis will be drawn. This doesn't influence ticks or labels.- Specified by:
isShapeVisiblein interfaceAxisRenderer- Returns:
trueif the shape should be drawn, false otherwise.
-
setShapeVisible
public void setShapeVisible(boolean shapeVisible)
Description copied from interface:AxisRendererSets whether the shape of the axis will be drawn. This doesn't influence ticks or labels.- Specified by:
setShapeVisiblein interfaceAxisRenderer- Parameters:
shapeVisible-trueif the shape should be drawn, false otherwise.
-
isShapeNormalOrientationClockwise
public boolean isShapeNormalOrientationClockwise()
Description copied from interface:AxisRendererReturns whether the normal vector of the shape is calculated using clockwise or counterclockwise rotation.- Specified by:
isShapeNormalOrientationClockwisein interfaceAxisRenderer- Returns:
trueif the orientation is clockwise,falseif it is counterclockwise.
-
setShapeNormalOrientationClockwise
public void setShapeNormalOrientationClockwise(boolean clockwise)
Description copied from interface:AxisRendererSets whether the normal vector of the shape is calculated using clockwise or counterclockwise rotation.- Specified by:
setShapeNormalOrientationClockwisein interfaceAxisRenderer- Parameters:
clockwise-trueif the orientation is clockwise,falseif it is counterclockwise.
-
getShapeColor
public java.awt.Paint getShapeColor()
Description copied from interface:AxisRendererReturns the paint used to draw the axis, its ticks and its labels.- Specified by:
getShapeColorin interfaceAxisRenderer- Returns:
- Paint used for drawing.
-
setShapeColor
public void setShapeColor(java.awt.Paint color)
Description copied from interface:AxisRendererSets the paint used to draw the axis, its ticks and its labels.- Specified by:
setShapeColorin interfaceAxisRenderer- Parameters:
color- Paint used for drawing.
-
getShapeStroke
public java.awt.Stroke getShapeStroke()
Description copied from interface:AxisRendererReturns the stroke which defines the shape of the axis.- Specified by:
getShapeStrokein interfaceAxisRenderer- Returns:
- Stroke used for drawing the shape.
-
setShapeStroke
public void setShapeStroke(java.awt.Stroke stroke)
Description copied from interface:AxisRendererSets the stroke which defines the shape of the axis.- Specified by:
setShapeStrokein interfaceAxisRenderer- Parameters:
stroke- Stroke used for drawing the shape.
-
isShapeDirectionSwapped
public boolean isShapeDirectionSwapped()
Description copied from interface:AxisRendererReturns whether the axis direction is changed.- Specified by:
isShapeDirectionSwappedin interfaceAxisRenderer- Returns:
trueif the shape of the axis is inverted,falseotherwise.
-
setShapeDirectionSwapped
public void setShapeDirectionSwapped(boolean directionSwapped)
Description copied from interface:AxisRendererSets whether the axis direction will be changed.- Specified by:
setShapeDirectionSwappedin interfaceAxisRenderer- Parameters:
directionSwapped-trueif the shape of the axis should be inverted,falseotherwise.
-
isTicksVisible
public boolean isTicksVisible()
Description copied from interface:AxisRendererReturns whether major ticks are drawn.- Specified by:
isTicksVisiblein interfaceAxisRenderer- Returns:
trueif major ticks are drawn,falseotherwise.
-
setTicksVisible
public void setTicksVisible(boolean ticksVisible)
Description copied from interface:AxisRendererSets whether major ticks will be drawn.- Specified by:
setTicksVisiblein interfaceAxisRenderer- Parameters:
ticksVisible-trueif major ticks should be drawn,falseotherwise.
-
getTickSpacing
public java.lang.Number getTickSpacing()
Description copied from interface:AxisRendererReturns the interval for major ticks.- Specified by:
getTickSpacingin interfaceAxisRenderer- Returns:
- Distance on axis in which major ticks are drawn.
-
setTickSpacing
public void setTickSpacing(java.lang.Number spacing)
Description copied from interface:AxisRendererSets the interval for major ticks.- Specified by:
setTickSpacingin interfaceAxisRenderer- Parameters:
spacing- Distance on axis in which major ticks are drawn.
-
isTicksAutoSpaced
public boolean isTicksAutoSpaced()
Description copied from interface:AxisRendererReturns whether the interval for major and minor ticks is chosen automatically.- Specified by:
isTicksAutoSpacedin interfaceAxisRenderer- Returns:
trueif auto-spacing is enabled,falseotherwise.
-
setTicksAutoSpaced
public void setTicksAutoSpaced(boolean autoSpaced)
Description copied from interface:AxisRendererSets whether the interval for major and minor ticks is chosen automatically.- Specified by:
setTicksAutoSpacedin interfaceAxisRenderer- Parameters:
autoSpaced-trueif auto-spacing is enabled,falseotherwise.
-
getTickLength
public double getTickLength()
Description copied from interface:AxisRendererReturns the length of major tick strokes.- Specified by:
getTickLengthin interfaceAxisRenderer- Returns:
- Tick length relative to the font height.
-
setTickLength
public void setTickLength(double length)
Description copied from interface:AxisRendererSets the length of major tick strokes.- Specified by:
setTickLengthin interfaceAxisRenderer- Parameters:
length- Tick length relative to the font height.
-
getTickStroke
public java.awt.Stroke getTickStroke()
Description copied from interface:AxisRendererReturns the stroke which is used to draw all major ticks.- Specified by:
getTickStrokein interfaceAxisRenderer- Returns:
- Stroke used for major tick drawing.
-
setTickStroke
public void setTickStroke(java.awt.Stroke stroke)
Description copied from interface:AxisRendererSets the stroke which is used to draw all major ticks.- Specified by:
setTickStrokein interfaceAxisRenderer- Parameters:
stroke- Stroke used for major tick drawing.
-
getTickAlignment
public double getTickAlignment()
Description copied from interface:AxisRendererReturns the alignment of major ticks relative to the axis. 0.0 means outside the plotting area, 0.5 means centered on the axis, 1.0 means inside the plotting area.- Specified by:
getTickAlignmentin interfaceAxisRenderer- Returns:
- Major tick alignment relative to the axis.
-
setTickAlignment
public void setTickAlignment(double alignment)
Description copied from interface:AxisRendererSets the alignment of major ticks relative to the axis. 0.0 means outside the plotting area, 0.5 means centered on the axis, 1.0 means inside the plotting area.- Specified by:
setTickAlignmentin interfaceAxisRenderer- Parameters:
alignment- Major tick alignment relative to the axis.
-
getTickFont
public java.awt.Font getTickFont()
Description copied from interface:AxisRendererReturns the font used to display the text of major ticks.- Specified by:
getTickFontin interfaceAxisRenderer- Returns:
- Font used for tick labels.
-
setTickFont
public void setTickFont(java.awt.Font font)
Description copied from interface:AxisRendererSets the font used to display the text of major ticks.- Specified by:
setTickFontin interfaceAxisRenderer- Parameters:
font- Font used for tick labels.
-
getTickColor
public java.awt.Paint getTickColor()
Description copied from interface:AxisRendererReturns the paint used to draw the shapes of major ticks.- Specified by:
getTickColorin interfaceAxisRenderer- Returns:
- Paint used for major tick drawing.
-
setTickColor
public void setTickColor(java.awt.Paint color)
Description copied from interface:AxisRendererSets the paint used to draw the shapes of major ticks.- Specified by:
setTickColorin interfaceAxisRenderer- Parameters:
color- Paint used for major tick drawing.
-
isTickLabelsVisible
public boolean isTickLabelsVisible()
Description copied from interface:AxisRendererReturns whether tick labels will be shown.- Specified by:
isTickLabelsVisiblein interfaceAxisRenderer- Returns:
trueif tick labels will be drawn,falseotherwise.
-
setTickLabelsVisible
public void setTickLabelsVisible(boolean tickLabelsVisible)
Description copied from interface:AxisRendererSets whether tick labels will be shown.- Specified by:
setTickLabelsVisiblein interfaceAxisRenderer- Parameters:
tickLabelsVisible-trueif tick labels will be drawn,falseotherwise.
-
getTickLabelFormat
public java.text.Format getTickLabelFormat()
Description copied from interface:AxisRendererReturns the format which converts the tick values to labels.- Specified by:
getTickLabelFormatin interfaceAxisRenderer- Returns:
- Format used for tick labels.
-
setTickLabelFormat
public void setTickLabelFormat(java.text.Format format)
Description copied from interface:AxisRendererSets the format which converts the tick values to labels.- Specified by:
setTickLabelFormatin interfaceAxisRenderer- Parameters:
format- Format used for tick labels.
-
getTickLabelDistance
public double getTickLabelDistance()
Description copied from interface:AxisRendererReturns the distance of labels to their ticks.- Specified by:
getTickLabelDistancein interfaceAxisRenderer- Returns:
- Label distance relative to the font height.
-
setTickLabelDistance
public void setTickLabelDistance(double distance)
Description copied from interface:AxisRendererSets the distance of labels to their ticks.- Specified by:
setTickLabelDistancein interfaceAxisRenderer- Parameters:
distance- Label distance relative to the font height.
-
isTickLabelsOutside
public boolean isTickLabelsOutside()
Description copied from interface:AxisRendererReturns whether the tick labels are drawn outside of the plot.- Specified by:
isTickLabelsOutsidein interfaceAxisRenderer- Returns:
trueif the labels are drawn outside of the plot,falseotherwise.
-
setTickLabelsOutside
public void setTickLabelsOutside(boolean labelsOutside)
Description copied from interface:AxisRendererSets whether the tick labels are drawn outside of the plot.- Specified by:
setTickLabelsOutsidein interfaceAxisRenderer- Parameters:
labelsOutside-trueif the labels are drawn outside of the plot,falseotherwise.
-
getTickLabelRotation
public double getTickLabelRotation()
Description copied from interface:AxisRendererReturns the rotation of the tick labels.- Specified by:
getTickLabelRotationin interfaceAxisRenderer- Returns:
- Tick label rotation in degrees.
-
setTickLabelRotation
public void setTickLabelRotation(double angle)
Description copied from interface:AxisRendererSets the rotation of the tick labels.- Specified by:
setTickLabelRotationin interfaceAxisRenderer- Parameters:
angle- Tick label rotation in degrees.
-
isMinorTicksVisible
public boolean isMinorTicksVisible()
Description copied from interface:AxisRendererReturns whether minor ticks are drawn.- Specified by:
isMinorTicksVisiblein interfaceAxisRenderer- Returns:
trueif minor ticks are drawn,falseotherwise.
-
setMinorTicksVisible
public void setMinorTicksVisible(boolean minorTicksVisible)
Description copied from interface:AxisRendererSets whether minor ticks are drawn.- Specified by:
setMinorTicksVisiblein interfaceAxisRenderer- Parameters:
minorTicksVisible-trueif minor ticks are drawn,falseotherwise.
-
getMinorTicksCount
public int getMinorTicksCount()
Description copied from interface:AxisRendererReturns the count of minor ticks.- Specified by:
getMinorTicksCountin interfaceAxisRenderer- Returns:
- Number of minor ticks between two major ticks.
-
setMinorTicksCount
public void setMinorTicksCount(int count)
Description copied from interface:AxisRendererSets the count of minor ticks.- Specified by:
setMinorTicksCountin interfaceAxisRenderer- Parameters:
count- Number of minor ticks between two major ticks.
-
getMinorTickLength
public double getMinorTickLength()
Description copied from interface:AxisRendererReturns the length of minor tick strokes.- Specified by:
getMinorTickLengthin interfaceAxisRenderer- Returns:
- Tick length relative to font height.
-
setMinorTickLength
public void setMinorTickLength(double length)
Description copied from interface:AxisRendererSets the length of minor tick strokes.- Specified by:
setMinorTickLengthin interfaceAxisRenderer- Parameters:
length- Tick length relative to font height.
-
getMinorTickStroke
public java.awt.Stroke getMinorTickStroke()
Description copied from interface:AxisRendererReturns the stroke used to draw all minor ticks.- Specified by:
getMinorTickStrokein interfaceAxisRenderer- Returns:
- Stroke used for minor tick drawing.
-
setMinorTickStroke
public void setMinorTickStroke(java.awt.Stroke stroke)
Description copied from interface:AxisRendererSets the stroke used to draw all minor ticks.- Specified by:
setMinorTickStrokein interfaceAxisRenderer- Parameters:
stroke- Stroke used for minor tick drawing.
-
getMinorTickAlignment
public double getMinorTickAlignment()
Description copied from interface:AxisRendererReturns the alignment of minor ticks. 0.0 means outside the plotting area, 0.5 means centered on the axis, 1.0 means inside the plotting area.- Specified by:
getMinorTickAlignmentin interfaceAxisRenderer- Returns:
- Minor tick alignment relative to the axis.
-
setMinorTickAlignment
public void setMinorTickAlignment(double alignment)
Description copied from interface:AxisRendererSets the alignment of minor ticks. 0.0 means outside the plotting area, 0.5 means centered on the axis, 1.0 means inside the plotting area.- Specified by:
setMinorTickAlignmentin interfaceAxisRenderer- Parameters:
alignment- Minor tick alignment relative to the axis.
-
getMinorTickColor
public java.awt.Paint getMinorTickColor()
Description copied from interface:AxisRendererReturns the paint used to draw the shapes of minor ticks.- Specified by:
getMinorTickColorin interfaceAxisRenderer- Returns:
- Paint used for minor tick drawing.
-
setMinorTickColor
public void setMinorTickColor(java.awt.Paint color)
Description copied from interface:AxisRendererSets the paint used to draw the shapes of minor ticks.- Specified by:
setMinorTickColorin interfaceAxisRenderer- Parameters:
color- Paint used for minor tick drawing.
-
getCustomTicks
public java.util.Map<java.lang.Double,java.lang.String> getCustomTicks()
Description copied from interface:AxisRendererReturns custom ticks with their respective position and label.- Specified by:
getCustomTicksin interfaceAxisRenderer- Returns:
- A map of custom tick positions and labels.
-
setCustomTicks
public void setCustomTicks(java.util.Map<java.lang.Double,java.lang.String> positionsAndLabels)
Description copied from interface:AxisRendererSets custom ticks with their respective position and label.- Specified by:
setCustomTicksin interfaceAxisRenderer- Parameters:
positionsAndLabels- A map of custom tick positions and labels.
-
getLabel
public Label getLabel()
Description copied from interface:AxisRendererReturns the label of the axis.- Specified by:
getLabelin interfaceAxisRenderer- Returns:
- Axis label.
-
setLabel
public void setLabel(Label label)
Description copied from interface:AxisRendererSets the label of the axis.- Specified by:
setLabelin interfaceAxisRenderer- Parameters:
label- Axis label.
-
getLabelDistance
public double getLabelDistance()
Description copied from interface:AxisRendererReturns the distance from the axis to the label.- Specified by:
getLabelDistancein interfaceAxisRenderer- Returns:
- Distance relative to font height.
-
setLabelDistance
public void setLabelDistance(double distance)
Description copied from interface:AxisRendererSets the distance from the axis to the label.- Specified by:
setLabelDistancein interfaceAxisRenderer- Parameters:
distance- Distance relative to font height.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG