public class GridLabelRenderer
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
GridLabelRenderer.GridStyle
Definition which lines will be drawn in the background
|
class |
GridLabelRenderer.Styles
wrapper for the styles regarding
to the grid and the labels
|
static class |
GridLabelRenderer.VerticalLabelsVAlign
Hoziontal label alignment
|
Modifier and Type | Field and Description |
---|---|
protected boolean |
mIsAdjusted
flag whether is bounds are automatically
adjusted for nice human-readable numbers
|
protected GridLabelRenderer.Styles |
mStyles
wraps the styles regarding the
grid and labels
|
Constructor and Description |
---|
GridLabelRenderer(GraphView graphView)
create the default grid label renderer.
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
adjustHorizontal(boolean changeBounds)
calculates the horizontal steps.
|
protected void |
adjustSteps()
adjusts the grid and labels to match to the data
this will automatically change the bounds to
nice human-readable values, except the bounds
are manual.
|
protected boolean |
adjustVertical(boolean changeBounds)
calculates the vertical steps.
|
protected boolean |
adjustVerticalSecondScale()
calculates the vertical steps of
the second scale.
|
protected void |
calcLabelHorizontalSize(Canvas canvas)
calculates the horizontal label size
|
protected void |
calcLabelVerticalSecondScaleSize(Canvas canvas)
calculates the vertical second scale
label size
|
protected void |
calcLabelVerticalSize(Canvas canvas)
calculates the vertical label size
|
void |
draw(Canvas canvas)
do the drawing of the grid
and labels
|
protected void |
drawHorizontalAxisTitle(Canvas canvas)
draws the horizontal axis title if
it is set
|
protected void |
drawHorizontalSteps(Canvas canvas)
draws the horizontal steps
vertical lines and horizontal labels
|
protected void |
drawVerticalAxisTitle(Canvas canvas)
draws the vertical axis title if
it is set
|
protected void |
drawVerticalSteps(Canvas canvas)
draws the vertical steps
horizontal lines and vertical labels
|
protected void |
drawVerticalStepsSecondScale(Canvas canvas)
draws the vertical steps for the
second scale on the right side
|
int |
getGridColor() |
GridLabelRenderer.GridStyle |
getGridStyle() |
java.lang.String |
getHorizontalAxisTitle() |
int |
getHorizontalAxisTitleColor() |
int |
getHorizontalAxisTitleHeight() |
float |
getHorizontalAxisTitleTextSize() |
float |
getHorizontalLabelsAngle() |
int |
getHorizontalLabelsColor() |
LabelFormatter |
getLabelFormatter() |
int |
getLabelHorizontalHeight() |
int |
getLabelsSpace() |
int |
getLabelVerticalSecondScaleWidth() |
int |
getLabelVerticalWidth() |
int |
getNumHorizontalLabels() |
int |
getNumVerticalLabels() |
int |
getPadding() |
GridLabelRenderer.Styles |
getStyles() |
float |
getTextSize() |
java.lang.String |
getVerticalAxisTitle() |
int |
getVerticalAxisTitleColor() |
float |
getVerticalAxisTitleTextSize() |
int |
getVerticalAxisTitleWidth() |
Paint.Align |
getVerticalLabelsAlign() |
int |
getVerticalLabelsColor() |
Paint.Align |
getVerticalLabelsSecondScaleAlign() |
int |
getVerticalLabelsSecondScaleColor() |
GridLabelRenderer.VerticalLabelsVAlign |
getVerticalLabelsVAlign()
Get horizontal label align
|
protected double |
humanRound(double in,
boolean roundAlwaysUp)
this will do rounding to generate
nice human-readable bounds.
|
void |
invalidate(boolean keepLabelsSize,
boolean keepViewport)
clears the internal cache and forces
to redraw the grid and labels.
|
boolean |
isHighlightZeroLines() |
boolean |
isHorizontalLabelsVisible() |
boolean |
isHumanRoundingX()
GraphView tries to fit the labels
to display numbers that can be divided by 1, 2, or 5.
|
boolean |
isHumanRoundingY()
GraphView tries to fit the labels
to display numbers that can be divided by 1, 2, or 5.
|
boolean |
isVerticalLabelsVisible() |
void |
reloadStyles()
will load the styles to the internal
paint objects (color, text size, text align)
|
void |
resetStyles()
resets the styles.
|
void |
setGridColor(int gridColor) |
void |
setGridStyle(GridLabelRenderer.GridStyle gridStyle)
Define which grid lines shall be drawn
|
void |
setHighlightZeroLines(boolean highlightZeroLines) |
void |
setHorizontalAxisTitle(java.lang.String mHorizontalAxisTitle) |
void |
setHorizontalAxisTitleColor(int horizontalAxisTitleColor) |
void |
setHorizontalAxisTitleTextSize(float horizontalAxisTitleTextSize) |
void |
setHorizontalLabelsAngle(int horizontalLabelsAngle) |
void |
setHorizontalLabelsColor(int horizontalLabelsColor) |
void |
setHorizontalLabelsVisible(boolean horizontalTitleVisible) |
void |
setHumanRounding(boolean humanRoundingBoth)
activate or deactivate human rounding of the
horizontal axis.
|
void |
setHumanRounding(boolean humanRoundingX,
boolean humanRoundingY)
activate or deactivate human rounding of the
horizontal axis.
|
void |
setLabelFormatter(LabelFormatter mLabelFormatter) |
void |
setLabelHorizontalHeight(java.lang.Integer height)
sets a manual and fixed height of the space for
the horizontal labels.
|
void |
setLabelsSpace(int labelsSpace)
the space between the labels text and the graph content
|
void |
setLabelVerticalWidth(java.lang.Integer width)
sets a manual and fixed with of the space for
the vertical labels.
|
void |
setNumHorizontalLabels(int mNumHorizontalLabels) |
void |
setNumVerticalLabels(int mNumVerticalLabels) |
void |
setPadding(int padding) |
void |
setSecondScaleLabelVerticalWidth(java.lang.Integer newWidth)
sets the space for the vertical labels on the right side
|
void |
setTextSize(float textSize) |
void |
setVerticalAxisTitle(java.lang.String mVerticalAxisTitle) |
void |
setVerticalAxisTitleColor(int verticalAxisTitleColor) |
void |
setVerticalAxisTitleTextSize(float verticalAxisTitleTextSize) |
void |
setVerticalLabelsAlign(Paint.Align verticalLabelsAlign) |
void |
setVerticalLabelsColor(int verticalLabelsColor) |
void |
setVerticalLabelsSecondScaleAlign(Paint.Align verticalLabelsSecondScaleAlign) |
void |
setVerticalLabelsSecondScaleColor(int verticalLabelsSecondScaleColor) |
void |
setVerticalLabelsVAlign(GridLabelRenderer.VerticalLabelsVAlign align)
set horizontal label align
|
void |
setVerticalLabelsVisible(boolean verticalTitleVisible) |
protected GridLabelRenderer.Styles mStyles
protected boolean mIsAdjusted
public GridLabelRenderer(GraphView graphView)
graphView
- the corresponding graphview objectpublic void setSecondScaleLabelVerticalWidth(java.lang.Integer newWidth)
newWidth
- set fixed width. set null to calculate it automaticallypublic void resetStyles()
public void reloadStyles()
public boolean isHumanRoundingX()
public boolean isHumanRoundingY()
public void setHumanRounding(boolean humanRoundingX, boolean humanRoundingY)
humanRoundingX
- false to deactivatehumanRoundingY
- false to deactivatepublic void setHumanRounding(boolean humanRoundingBoth)
humanRoundingBoth
- false to deactivate on both axisespublic float getTextSize()
public int getVerticalLabelsColor()
public Paint.Align getVerticalLabelsAlign()
public int getHorizontalLabelsColor()
public float getHorizontalLabelsAngle()
public void invalidate(boolean keepLabelsSize, boolean keepViewport)
GraphView.onDataChanged(boolean, boolean)
which will call this method.keepLabelsSize
- true if you don't want
to recalculate the size of
the labels. It is recommended
to use "true" because this will
improve performance and prevent
a flickering.keepViewport
- true if you don't want that
the viewport will be recalculated.
It is recommended to use "true" for
performance.protected boolean adjustVerticalSecondScale()
protected boolean adjustVertical(boolean changeBounds)
protected boolean adjustHorizontal(boolean changeBounds)
changeBounds
- This will automatically change the
bounds to nice human-readable min/max.protected void adjustSteps()
protected void calcLabelVerticalSize(Canvas canvas)
canvas
- canvasprotected void calcLabelVerticalSecondScaleSize(Canvas canvas)
canvas
- canvasprotected void calcLabelHorizontalSize(Canvas canvas)
canvas
- canvaspublic void draw(Canvas canvas)
canvas
- canvasprotected void drawHorizontalAxisTitle(Canvas canvas)
canvas
- canvasprotected void drawVerticalAxisTitle(Canvas canvas)
canvas
- canvaspublic int getHorizontalAxisTitleHeight()
public int getVerticalAxisTitleWidth()
protected void drawHorizontalSteps(Canvas canvas)
canvas
- canvasprotected void drawVerticalStepsSecondScale(Canvas canvas)
canvas
- canvasprotected void drawVerticalSteps(Canvas canvas)
canvas
- canvasprotected double humanRound(double in, boolean roundAlwaysUp)
in
- the raw value that is to be roundedroundAlwaysUp
- true if it shall always round up (ceil)public GridLabelRenderer.Styles getStyles()
public int getLabelVerticalWidth()
public void setLabelVerticalWidth(java.lang.Integer width)
width
- the width of the space for the vertical labels.
Use null to let GraphView automatically calculate the width.public int getLabelHorizontalHeight()
public void setLabelHorizontalHeight(java.lang.Integer height)
height
- the height of the space for the horizontal labels.
Use null to let GraphView automatically calculate the height.public int getGridColor()
public boolean isHighlightZeroLines()
public int getPadding()
public void setTextSize(float textSize)
textSize
- the general text size of the axis titles.
can be overwritten with setVerticalAxisTitleTextSize(float)
and setHorizontalAxisTitleTextSize(float)
public void setVerticalLabelsAlign(Paint.Align verticalLabelsAlign)
verticalLabelsAlign
- the alignment of the vertical labelspublic void setVerticalLabelsColor(int verticalLabelsColor)
verticalLabelsColor
- the color of the vertical labelspublic void setHorizontalLabelsColor(int horizontalLabelsColor)
horizontalLabelsColor
- the color of the horizontal labelspublic void setHorizontalLabelsAngle(int horizontalLabelsAngle)
horizontalLabelsAngle
- the angle of the horizontal labels in degreespublic void setGridColor(int gridColor)
gridColor
- the color of the grid linespublic void setHighlightZeroLines(boolean highlightZeroLines)
highlightZeroLines
- flag whether the zero-lines (vertical+
horizontal) shall be highlightedpublic void setPadding(int padding)
padding
- the padding around the graph and labelspublic LabelFormatter getLabelFormatter()
public void setLabelFormatter(LabelFormatter mLabelFormatter)
mLabelFormatter
- the label formatter, that converts
the raw numbers to stringspublic java.lang.String getHorizontalAxisTitle()
public void setHorizontalAxisTitle(java.lang.String mHorizontalAxisTitle)
mHorizontalAxisTitle
- the title of the horizontal axispublic java.lang.String getVerticalAxisTitle()
public void setVerticalAxisTitle(java.lang.String mVerticalAxisTitle)
mVerticalAxisTitle
- the title of the vertical axispublic float getVerticalAxisTitleTextSize()
public void setVerticalAxisTitleTextSize(float verticalAxisTitleTextSize)
verticalAxisTitleTextSize
- font size of the vertical axis titlepublic int getVerticalAxisTitleColor()
public void setVerticalAxisTitleColor(int verticalAxisTitleColor)
verticalAxisTitleColor
- font color of the vertical axis titlepublic float getHorizontalAxisTitleTextSize()
public void setHorizontalAxisTitleTextSize(float horizontalAxisTitleTextSize)
horizontalAxisTitleTextSize
- font size of the horizontal axis titlepublic int getHorizontalAxisTitleColor()
public void setHorizontalAxisTitleColor(int horizontalAxisTitleColor)
horizontalAxisTitleColor
- font color of the horizontal axis titlepublic Paint.Align getVerticalLabelsSecondScaleAlign()
public void setVerticalLabelsSecondScaleAlign(Paint.Align verticalLabelsSecondScaleAlign)
verticalLabelsSecondScaleAlign
- the alignment of the labels on the right sidepublic int getVerticalLabelsSecondScaleColor()
public void setVerticalLabelsSecondScaleColor(int verticalLabelsSecondScaleColor)
verticalLabelsSecondScaleColor
- the color of the labels on the right sidepublic int getLabelVerticalSecondScaleWidth()
public boolean isHorizontalLabelsVisible()
public void setHorizontalLabelsVisible(boolean horizontalTitleVisible)
horizontalTitleVisible
- flag whether the horizontal labels are
visiblepublic boolean isVerticalLabelsVisible()
public void setVerticalLabelsVisible(boolean verticalTitleVisible)
verticalTitleVisible
- flag whether the vertical labels are
visiblepublic int getNumVerticalLabels()
public void setNumVerticalLabels(int mNumVerticalLabels)
mNumVerticalLabels
- count of the vertical labels, that
will be shown at one time.public int getNumHorizontalLabels()
public void setNumHorizontalLabels(int mNumHorizontalLabels)
mNumHorizontalLabels
- count of the horizontal labels, that
will be shown at one time.public GridLabelRenderer.GridStyle getGridStyle()
public void setGridStyle(GridLabelRenderer.GridStyle gridStyle)
gridStyle
- the grid stylepublic int getLabelsSpace()
public void setLabelsSpace(int labelsSpace)
labelsSpace
- the space between the labels text and the graph contentpublic void setVerticalLabelsVAlign(GridLabelRenderer.VerticalLabelsVAlign align)
align
- public GridLabelRenderer.VerticalLabelsVAlign getVerticalLabelsVAlign()