util工具包已看完,下面准备Interface接口定义理解,以便于下次data包的理解,先打好基础再说
dataprovider
ChartInterface
数据提供接口,在众多接口中我们先从基类接口入手,ChartInterface定义了Chart需要用到的基本方法(上图UML拖拽到新窗口查看可以清晰查看不受压缩影响)
/**
* 该接口提供chart视图已知的尺寸、界限、范围、
* Interface that provides everything there is to know about the dimensions,
* bounds, and range of the chart.
*
* @author Philipp Jahoda
*/
public interface ChartInterface {
/**
* 不管放大还是平移,返回x轴的x最小值
* Returns the minimum x-value of the chart, regardless of zoom or translation.
*
* @return
*/
float getXChartMin();
/**
* 不管放大还是平移,返回x轴的x最大值
* Returns the maximum x-value of the chart, regardless of zoom or translation.
*
* @return
*/
float getXChartMax();
/**
* 不管放大还是平移,返回y轴的y最小值
* Returns the minimum y-value of the chart, regardless of zoom or translation.
*
* @return
*/
float getYChartMin();
/**
* 不管放大还是平移,返回y轴的y最大值
* Returns the maximum y-value of the chart, regardless of zoom or translation.
*
* @return
*/
float getYChartMax();
/**
* x轴上的描绘的所有值的size
* @return
*/
int getXValCount();
int getWidth();
int getHeight();
/**
* 获取Chart的中心点
* @return
*/
PointF getCenterOfView();
/**
* 获取chart的中心点,考虑了偏移量因素
* @return
*/
PointF getCenterOffsets();
/**
* 获取内容视图的Rect测量到的范围
* @return
*/
RectF getContentRect();
/**
* chart图标labText被绘制之前,定制自己的格式,这里已经有了一个默认的格式DefaultValueFormatter实例
* @return
*/
ValueFormatter getDefaultValueFormatter();
/**
*返回已设置图表的chartdata对象
* @return
*/
ChartData getData();
}
BarLineScatterCandleBubbleDataProvider
Line Scatter Candle Bubble的公共数据提供者,而各自的具体实现继承该父类
public interface BarLineScatterCandleBubbleDataProvider extends ChartInterface {
/**
* 根据AxisDependency获取构造函数内初始化的矩阵变换器
* AxisDependency LEFT RIGHT:枚举指定数据集应绘制轴,或左或右
* @param axis
* @return
*/
Transformer getTransformer(AxisDependency axis);
/**
* 获取显示的最大数量
* @return
*/
int getMaxVisibleCount();
/**
* 是否颠倒反向
* AxisBase基类下面的两个子类YAxis XAxis,根据AxisDependency方向选择子类调用其自身isInverted
* @param axis
* @return
*/
boolean isInverted(AxisDependency axis);
/**
* x轴上的值(最小)的可见性
* @return
*/
int getLowestVisibleXIndex();
/**
* x轴上的值(最大)的可见性
* @return
*/
int getHighestVisibleXIndex();
/**
* 获取封装数据的对象,在chart通过泛型获取对象
* @return
*/
BarLineScatterCandleBubbleData getData();
}
BarDataProvider
BarDataProvider内部方法并没有在BarChart里面直接调用,通过find usages发现基本都是在Renderer子类调用,具体下次细解
public interface BarDataProvider extends BarLineScatterCandleBubbleDataProvider {
/**
* BarChart所需要的BarData数据对象(setData传入)
* @return
*/
BarData getBarData();
/**
* 是否能绘制阴影
* @return
*/
boolean isDrawBarShadowEnabled();
/**
* 是否绘制在bar上面的值
* @return
*/
boolean isDrawValueAboveBarEnabled();
/**
* 绘制判断是否允许高亮显示
* @return
*/
boolean isDrawHighlightArrowEnabled();
}
BubbleDataProvider
public interface BubbleDataProvider extends BarLineScatterCandleBubbleDataProvider {
/**
* 弹出泡泡类的Chart的数据对象
*
* @return
*/
BubbleData getBubbleData();
}
CandleDataProvider
public interface CandleDataProvider extends BarLineScatterCandleBubbleDataProvider {
/**
* 烛形物图标类的数据
* @return
*/
CandleData getCandleData();
}
LineDataProvider
public interface LineDataProvider extends BarLineScatterCandleBubbleDataProvider {
/**
* LineChar图表的数据对象
* @return
*/
LineData getLineData();
/**
* Y轴的数据封装对象
* @param dependency
* @return
*/
YAxis getAxis(YAxis.AxisDependency dependency);
}
ScatterDataProvider
public interface ScatterDataProvider extends BarLineScatterCandleBubbleDataProvider {
/**
* 分散性图表的数据对象
* @return
*/
ScatterData getScatterData();
}
datasets
数据设置相关接口,下面是他们之间的关系的uml图,碍于截图问题一分为二,抱歉!!(如果你的浏览器支持缩放页面可以放大后查看清晰uml图结构)
IDataSet
/**
* Created by Philipp Jahoda on 21/10/15.
*/
public interface IDataSet<T extends Entry> {
/** ###### ###### DATA RELATED METHODS ###### ###### */
/**
* 返回Y轴上的最小值
* returns the minimum y-value this DataSet holds
*
* @return
*/
float getYMin();
/**
* 返回Y轴上的最大值
* returns the maximum y-value this DataSet holds
*
* @return
*/
float getYMax();
/**
* 返回Y轴上的显示数据Entry的总数量
* Returns the number of y-values this DataSet represents -> the size of the y-values array
* -> yvals.size()
*
* @return
*/
int getEntryCount();
/**
* 根据索引计算出索引范围内值的最大值和最小值
* Calculates the minimum and maximum y value (mYMin, mYMax). From the specified starting to ending index.
*
* @param start starting index in your data list
* @param end ending index in your data list
*/
void calcMinMax(int start, int end);
/**
* 根据索引值返回Entry,如果没有索引对应的对象则返回最近的对象,如果没有对象则返回空,建议不要过度使用
* Returns the first Entry object found at the given xIndex with binary
* search. If the no Entry at the specified x-index is found, this method
* returns the index at the closest x-index. Returns null if no Entry object
* at that index. INFORMATION: This method does calculations at runtime. Do
* not over-use in performance critical situations.
*
* @param xIndex
* @param rounding determine to round up/down/closest if there is no Entry matching the provided x-index
* @return
*/
T getEntryForXIndex(int xIndex, DataSet.Rounding rounding);
T getEntryForXIndex(int xIndex);
List<T> getEntriesForXIndex(int xIndex);
T getEntryForIndex(int index);
int getEntryIndex(int xIndex, DataSet.Rounding rounding);
int getEntryIndex(T e);
float getYValForXIndex(int xIndex);
float[] getYValsForXIndex(int xIndex);
int getIndexInEntries(int xIndex);
/**
* 动态添加到数据集的结尾。这也将重新计算最小值和最大值、count
* Adds an Entry to the DataSet dynamically.
* Entries are added to the end of the list.
* This will also recalculate the current minimum and maximum
* values of the DataSet and the value-sum.
*
* @param e
*/
boolean addEntry(T e);
/**
* 删除一条数据,如果成功了要重新计算最大值和最小值以及数据集的count
* Removes an Entry from the DataSets entries array. This will also
* recalculate the current minimum and maximum values of the DataSet and the
* value-sum. Returns true if an Entry was removed, false if no Entry could
* be removed.
*
* @param e
*/
boolean removeEntry(T e);
/**
* 有序添加一条数据,并且要重新计算最大值和最小值以及数据集的count
* Adds an Entry to the DataSet dynamically.
* Entries are added to their appropriate index respective to it's x-index.
* This will also recalculate the current minimum and maximum
* values of the DataSet and the value-sum.
*
* @param e
*/
void addEntryOrdered(T e);
/**
* 移除第一条数据
* Removes the first Entry (at index 0) of this DataSet from the entries array.
* Returns true if successful, false if not.
*
* @return
*/
boolean removeFirst();
/**
* 移除最后一条数据
* Removes the last Entry (at index size-1) of this DataSet from the entries array.
* Returns true if successful, false if not.
*
* @return
*/
boolean removeLast();
/**
* 移除数据集指定位置的数据对象
* Removes the Entry object that has the given xIndex from the DataSet.
* Returns true if an Entry was removed, false if no Entry could be removed.
*
* @param xIndex
*/
boolean removeEntry(int xIndex);
/**
* 检查数据集是否包含指定对象,在性能不好的情况下不建议使用
* Checks if this DataSet contains the specified Entry. Returns true if so,
* false if not. NOTE: Performance is pretty bad on this one, do not
* over-use in performance critical situations.
*
* @param entry
* @return
*/
boolean contains(T entry);
/**
* 清除所有的DataSet值,不用再重新计算
* Removes all values from this DataSet and does all necessary recalculations.
*/
void clear();
/** ###### ###### STYLING RELATED (& OTHER) METHODS ###### ###### */
/**
* 获取描述数据集的标签值
* Returns the label string that describes the DataSet.
*
* @return
*/
String getLabel();
/**
* 设置描述数据集的标签
* Sets the label string that describes the DataSet.
*
* @param label
*/
void setLabel(String label);
/**
* 获取轴的方向
* Returns the axis this DataSet should be plotted against.
*
* @return
*/
YAxis.AxisDependency getAxisDependency();
/**
* 设置轴方向
* Set the y-axis this DataSet should be plotted against (either LEFT or
* RIGHT). Default: LEFT
*
* @param dependency
*/
void setAxisDependency(YAxis.AxisDependency dependency);
/**
* 获取所有数据对应的颜色值集合
* returns all the colors that are set for this DataSet
*
* @return
*/
List<Integer> getColors();
/**
* 获取给定数据集的颜色
* Returns the first color (index 0) of the colors-array this DataSet
* contains. This is only used for performance reasons when only one color is in the colors array (size == 1)
*
* @return
*/
int getColor();
/**
* 给定数据集的索引颜色值
* Returns the color at the given index of the DataSet's color array.
* Performs a IndexOutOfBounds check by modulus.
*
* @param index
* @return
*/
int getColor(int index);
/**
* 判断是否支持高亮显示
* returns true if highlighting of values is enabled, false if not
*
* @return
*/
boolean isHighlightEnabled();
/**
* 设置触摸是否支持高亮显示
* If set to true, value highlighting is enabled which means that values can
* be highlighted programmatically or by touch gesture.
*
* @param enabled
*/
void setHighlightEnabled(boolean enabled);
/**
* 设置用于绘制图表的格式化值类。如果没有格式化设置,图表会自动确定选择默认的格式(关于小数)的所有值,getdefaultvalueformatter()
* Sets the formatter to be used for drawing the values inside the chart. If
* no formatter is set, the chart will automatically determine a reasonable
* formatting (concerning decimals) for all the values that are drawn inside
* the chart. Use chart.getDefaultValueFormatter() to use the formatter
* calculated by the chart.
*
* @param f
*/
void setValueFormatter(ValueFormatter f);
/**
* 获取格式化类
* Returns the formatter used for drawing the values inside the chart.
*
* @return
*/
ValueFormatter getValueFormatter();
/**
* 设置文字颜色
* Sets the color the value-labels of this DataSet should have.
*
* @param color
*/
void setValueTextColor(int color);
/**
* 设置文字颜色(不同位置对应文字的不同颜色值)
* Sets a list of colors to be used as the colors for the drawn values.
*
* @param colors
*/
void setValueTextColors(List<Integer> colors);
/**
* 设置字体
* Sets a Typeface for the value-labels of this DataSet.
*
* @param tf
*/
void setValueTypeface(Typeface tf);
/**
* 设置文字大小
* Sets the text-size of the value-labels of this DataSet in dp.
*
* @param size
*/
void setValueTextSize(float size);
/**
* 返回图表上的文字颜色
* Returns only the first color of all colors that are set to be used for the values.
*
* @return
*/
int getValueTextColor();
/**
* 返回图表上index对应位置的文字颜色
* Returns the color at the specified index that is used for drawing the values inside the chart.
* Uses modulus internally.
*
* @param index
* @return
*/
int getValueTextColor(int index);
/**
* 返回图表上文字的字体
* Returns the typeface that is used for drawing the values inside the chart
*
* @return
*/
Typeface getValueTypeface();
/**
* 返回chart图表上的文字大小
* Returns the text size that is used for drawing the values inside the chart
*
* @return
*/
float getValueTextSize();
/**
* 动态设置Y轴的值是否要绘制
* set this to true to draw y-values on the chart NOTE (for bar and
* linechart): if "maxvisiblecount" is reached, no values will be drawn even
* if this is enabled
*
* @param enabled
*/
void setDrawValues(boolean enabled);
/**
* 是否绘制Y轴的值
* Returns true if y-value drawing is enabled, false if not
*
* @return
*/
boolean isDrawValuesEnabled();
/**
* 动态设置DataSet的可见性
* Set the visibility of this DataSet. If not visible, the DataSet will not
* be drawn to the chart upon refreshing it.
*
* @param visible
*/
void setVisible(boolean visible);
/**
* 在chart中是否可见,默认隐藏
* Returns true if this DataSet is visible inside the chart, or false if it
* is currently hidden.
*
* @return
*/
boolean isVisible();
}
IBarLineScatterCandleBubbleDataSet
/**
* Created by philipp on 21/10/15.
*/
public interface IBarLineScatterCandleBubbleDataSet<T extends Entry> extends IDataSet<T> {
/**
* 返回绘制高亮显示的颜色值
* Returns the color that is used for drawing the highlight indicators.
*
* @return
*/
int getHighLightColor();
}
IBarDataSet
/**
* Created by philipp on 21/10/15.
*/
public interface IBarDataSet extends IBarLineScatterCandleBubbleDataSet<BarEntry> {
/**
* 返回Bar直接的间隙
* Returns the space between bars as the actual value (0 - 1.0f)
*
* @return
*/
float getBarSpace();
/**
* 是否放进堆栈
* Returns true if this DataSet is stacked (stacksize > 1) or not.
*
* @return
*/
boolean isStacked();
/**
* 返回的最大条数
* Returns the maximum number of bars that can be stacked upon another in
* this DataSet. This should return 1 for non stacked bars, and > 1 for stacked bars.
*
* @return
*/
int getStackSize();
/**
* bar的阴影颜色
* Returns the color used for drawing the bar-shadows. The bar shadows is a
* surface behind the bar that indicates the maximum value.
*
* @return
*/
int getBarShadowColor();
/**
* bar边框的宽度
* Returns the width used for drawing borders around the bars.
* If borderWidth == 0, no border will be drawn.
*
* @return
*/
float getBarBorderWidth();
/**
* 绘制bar边框有暗色
* Returns the color drawing borders around the bars.
*
* @return
*/
int getBarBorderColor();
/**
* 高亮显示的透明度
* Returns the alpha value (transparency) that is used for drawing the
* highlight indicator.
*
* @return
*/
int getHighLightAlpha();
/**
* 柱状图相关的,LegendRenderer准备所需要的标签文字和颜色时会被调用
* Returns the labels used for the different value-stacks in the legend.
* This is only relevant for stacked bar entries.
*
* @return
*/
String[] getStackLabels();
}
IBubbleDataSet
/**
* Created by philipp on 21/10/15.
*/
public interface IBubbleDataSet extends IBarLineScatterCandleBubbleDataSet<BubbleEntry> {
/**
* 设置泡泡的宽度
* Sets the width of the circle that surrounds the bubble when highlighted,
* in dp.
*
* @param width
*/
void setHighlightCircleWidth(float width);
/**
* X轴最大值
* @return
*/
float getXMax();
/**
* X轴最小值
* @return
*/
float getXMin();
/**
* 用于计算shapeSize
* @return
*/
float getMaxSize();
boolean isNormalizeSizeEnabled();
/**
* 泡泡的宽度
* Returns the width of the highlight-circle that surrounds the bubble
* @return
*/
float getHighlightCircleWidth();
}
ICandleDataSet
/**
* Created by philipp on 21/10/15.
*/
public interface ICandleDataSet extends ILineScatterCandleRadarDataSet<CandleEntry> {
float getBarSpace();
boolean getShowCandleBar();
float getShadowWidth();
int getShadowColor();
int getNeutralColor();
int getIncreasingColor();
int getDecreasingColor();
/**
* 画笔的style(打开时)
* Returns paint style when open < close
*
* @return
*/
Paint.Style getIncreasingPaintStyle();
/**
* 画笔的Style(关闭时)
* Returns paint style when open > close
*
* @return
*/
Paint.Style getDecreasingPaintStyle();
/**
* CandleChart图表的阴影颜色
* Is the shadow color same as the candle color?
*
* @return
*/
boolean getShadowColorSameAsCandle();
}
ILineDataSet
/**
* Created by Philpp Jahoda on 21/10/15.
*/
public interface ILineDataSet extends ILineRadarDataSet<Entry> {
/**
*线的绘制模式
*
* @return
*/
LineDataSet.Mode getMode();
float getCubicIntensity();
@Deprecated
boolean isDrawCubicEnabled();
@Deprecated
boolean isDrawSteppedEnabled();
float getCircleRadius();
int getCircleColor(int index);
boolean isDrawCirclesEnabled();
int getCircleHoleColor();
/**
*是否启用小圆点
*
* @return
*/
boolean isDrawCircleHoleEnabled();
/**
* Returns the DashPathEffect that is used for drawing the lines.
*
* @return
*/
DashPathEffect getDashPathEffect();
/**
*是否启用虚线效果
* Returns true if the dashed-line effect is enabled, false if not.
* If the DashPathEffect object is null, also return false here.
*
* @return
*/
boolean isDashedLineEnabled();
/**
* 返回填充的formatter
* Returns the FillFormatter that is set for this DataSet.
*
* @return
*/
FillFormatter getFillFormatter();
}
ILineRadarDataSet
/**
* Created by Philipp Jahoda on 21/10/15.
*/
public interface ILineRadarDataSet<T extends Entry> extends ILineScatterCandleRadarDataSet<T> {
/**
* 填充颜色
*
* @return
*/
int getFillColor();
/**
* 填充图Drawable
*
* @return
*/
Drawable getFillDrawable();
/**
* 填充透明度默认值85
*
* @return
*/
int getFillAlpha();
float getLineWidth();
/**
* 数据集是否画满(表面)
*
* @return
*/
boolean isDrawFilledEnabled();
/**
* 设置为true,如果数据集应该画满(表面),,禁用将带来巨大的性能提升。请注意,这个方法使用canvas.clipPath(…)方法来画填充区域。
* 设备与API级别< 18(Android 4.3),硬件加速的图表被关闭。默认值是错误的
* @param enabled
*/
void setDrawFilled(boolean enabled);
}
ILineScatterCandleRadarDataSet
/**
* Created by Philipp Jahoda on 21/10/15.
*/
public interface ILineScatterCandleRadarDataSet<T extends Entry> extends IBarLineScatterCandleBubbleDataSet<T> {
/**
* 是否垂直突出标线
* Returns true if vertical highlight indicator lines are enabled (drawn)
* @return
*/
boolean isVerticalHighlightIndicatorEnabled();
/**
* 是否水平突出标线
* Returns true if vertical highlight indicator lines are enabled (drawn)
* @return
*/
boolean isHorizontalHighlightIndicatorEnabled();
/**
*返回高亮显示是线宽
* Returns the line-width in which highlight lines are to be drawn.
* @return
*/
float getHighlightLineWidth();
/**
* 高亮破折线
* Returns the DashPathEffect that is used for highlighting.
* @return
*/
DashPathEffect getDashPathEffectHighlight();
}
IPieDataSet
/**
* Created by Philipp Jahoda on 03/11/15.
*/
public interface IPieDataSet extends IDataSet<Entry> {
/**
* 获取饼图间距
* Returns the space that is set to be between the piechart-slices of this
* DataSet, in pixels.
*
* @return
*/
float getSliceSpace();
/**
* 选中的饼状图的位移量
* Returns the distance a highlighted piechart slice is "shifted" away from
* the chart-center in dp.
*
* @return
*/
float getSelectionShift();
/**
* 获取X值在饼状图的位置是内部还是外部
*
* @return
*/
PieDataSet.ValuePosition getXValuePosition();
/**
* 获取Y值在饼状图的位置是内部还是外部
*
* @return
*/
PieDataSet.ValuePosition getYValuePosition();
/**
* 饼状图外部指示线的颜色
* When valuePosition is OutsideSlice, indicates line color
*/
int getValueLineColor();
/**
* 饼状图外部指示线的宽度
* When valuePosition is OutsideSlice, indicates line width
*/
float getValueLineWidth();
/**
* 饼状图外部指示线的偏移百分比对应大小
* When valuePosition is OutsideSlice, indicates offset as percentage out of the slice size
*/
float getValueLinePart1OffsetPercentage();
float getValueLinePart1Length();
float getValueLinePart2Length();
boolean isValueLineVariableLength();
}
IRadarDataSet
/**
* 透明度 stoke相关属性配置
* Created by Philipp Jahoda on 03/11/15.
*/
public interface IRadarDataSet extends ILineRadarDataSet<Entry> {
/// flag indicating whether highlight circle should be drawn or not
boolean isDrawHighlightCircleEnabled();
/// Sets whether highlight circle should be drawn or not
void setDrawHighlightCircleEnabled(boolean enabled);
int getHighlightCircleFillColor();
/// The stroke color for highlight circle.
/// If Utils.COLOR_NONE, the color of the dataset is taken.
int getHighlightCircleStrokeColor();
int getHighlightCircleStrokeAlpha();
float getHighlightCircleInnerRadius();
float getHighlightCircleOuterRadius();
float getHighlightCircleStrokeWidth();
}
IScatterDataSet
/**
* Created by philipp on 21/10/15.
*/
public interface IScatterDataSet extends ILineScatterCandleRadarDataSet<Entry> {
/**
* shape的size大小
* Returns the currently set scatter shape size
*
* @return
*/
float getScatterShapeSize();
/**
* 获取ScatterShape
* Returns all the different scattershapes the chart uses
*
* @return
*/
ScatterChart.ScatterShape getScatterShape();
/**
* ScatterChart的shape的半径
* Returns radius of the hole in the shape
*
* @return
*/
float getScatterShapeHoleRadius();
/**
* ScatterChart的shape颜色值
* Returns the color for the hole in the shape
*
* @return
*/
int getScatterShapeHoleColor();
}
不得不承认,这篇写的非常搓的,感觉就是流水代码,感觉个别方法解释有误,欢迎指出!!不要看得太仔细,简单的一晃而过吧