本文整理汇总了Java中com.github.mikephil.charting.utils.Highlight类的典型用法代码示例。如果您正苦于以下问题:Java Highlight类的具体用法?Java Highlight怎么用?Java Highlight使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Highlight类属于com.github.mikephil.charting.utils包,在下文中一共展示了Highlight类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: onSingleTapUp
import com.github.mikephil.charting.utils.Highlight; //导入依赖的package包/类
@Override
public boolean onSingleTapUp(MotionEvent e) {
OnChartGestureListener l = mChart.getOnChartGestureListener();
if (l != null) {
l.onChartSingleTapped(e);
}
Highlight h = mChart.getHighlightByTouchPoint(e.getX(), e.getY());
if (h == null || h.equalTo(mLastHighlighted)) {
mChart.highlightTouch(null);
mLastHighlighted = null;
} else {
mLastHighlighted = h;
mChart.highlightTouch(h);
}
return super.onSingleTapUp(e);
}
开发者ID:LINKIWI,项目名称:mobile-manager-for-cloudflare,代码行数:23,代码来源:BarLineChartTouchListener.java
示例2: getEntryByTouchPoint
import com.github.mikephil.charting.utils.Highlight; //导入依赖的package包/类
/**
* returns the Entry object displayed at the touched position of the chart
*
* @param x
* @param y
* @return
*/
public Entry getEntryByTouchPoint(float x, float y) {
Highlight h = getHighlightByTouchPoint(x, y);
if (h != null) {
return mData.getEntryForHighlight(h);
}
return null;
}
开发者ID:LINKIWI,项目名称:mobile-manager-for-cloudflare,代码行数:15,代码来源:BarLineChartBase.java
示例3: highlightValues
import com.github.mikephil.charting.utils.Highlight; //导入依赖的package包/类
/**
* Highlights the values at the given indices in the given DataSets. Provide
* null or an empty array to undo all highlighting. This should be used to
* programmatically highlight values. This DOES NOT generate a callback to
* the OnChartValueSelectedListener.
*
* @param highs
*/
public void highlightValues(Highlight[] highs) {
// set the indices to highlight
mIndicesToHightlight = highs;
// redraw the chart
invalidate();
}
开发者ID:LINKIWI,项目名称:mobile-manager-for-cloudflare,代码行数:17,代码来源:Chart.java
示例4: highlightValue
import com.github.mikephil.charting.utils.Highlight; //导入依赖的package包/类
/**
* Highlights the value at the given x-index in the given DataSet. Provide
* -1 as the x-index to undo all highlighting.
*
* @param xIndex
* @param dataSetIndex
*/
public void highlightValue(int xIndex, int dataSetIndex) {
if (xIndex < 0 || dataSetIndex < 0 || xIndex >= mData.getXValCount()
|| dataSetIndex >= mData.getDataSetCount()) {
highlightValues(null);
} else {
highlightValues(new Highlight[] {
new Highlight(xIndex, dataSetIndex)
});
}
}
开发者ID:LINKIWI,项目名称:mobile-manager-for-cloudflare,代码行数:20,代码来源:Chart.java
示例5: highlightTouch
import com.github.mikephil.charting.utils.Highlight; //导入依赖的package包/类
/**
* Highlights the value selected by touch gesture. Unlike
* highlightValues(...), this generates a callback to the
* OnChartValueSelectedListener.
*
* @param highs
*/
public void highlightTouch(Highlight high) {
if (high == null)
mIndicesToHightlight = null;
else {
// set the indices to highlight
mIndicesToHightlight = new Highlight[] {
high
};
}
// redraw the chart
invalidate();
if (mSelectionListener != null) {
if (!valuesToHighlight())
mSelectionListener.onNothingSelected();
else {
Entry e = getEntryByDataSetIndex(high.getXIndex(),
high.getDataSetIndex());
// notify the listener
mSelectionListener.onValueSelected(e, high.getDataSetIndex());
}
}
}
开发者ID:LINKIWI,项目名称:mobile-manager-for-cloudflare,代码行数:37,代码来源:Chart.java
示例6: onValueSelected
import com.github.mikephil.charting.utils.Highlight; //导入依赖的package包/类
@Override
public void onValueSelected(Entry e, int dataSetIndex, Highlight h) {
if (e == null)
return;
RectF bounds = mChart.getBarBounds((BarEntry) e);
PointF position = mChart.getPosition(e, YAxis.AxisDependency.LEFT);
curSelectedBar = h.getXIndex();
curNumDrinks = (int) e.getVal();
Log.d(TAG, Integer.toString(curNumDrinks));
}
开发者ID:kashev,项目名称:wizardstaff,代码行数:14,代码来源:ScoreboardActivity.java
示例7: getEntryByTouchPoint
import com.github.mikephil.charting.utils.Highlight; //导入依赖的package包/类
/**
* returns the Entry object displayed at the touched position of the chart
*
* @param x
* @param y
* @return
*/
public Entry getEntryByTouchPoint(float x, float y) {
Highlight h = getHighlightByTouchPoint(x, y);
if (h != null) {
return mCurrentData.getEntryForHighlight(h);
}
return null;
}
开发者ID:MPieter,项目名称:Notification-Analyser,代码行数:15,代码来源:BarLineChartBase.java
示例8: highlightValue
import com.github.mikephil.charting.utils.Highlight; //导入依赖的package包/类
/**
* Highlights the value at the given x-index in the given DataSet. Provide
* -1 as the x-index to undo all highlighting.
*
* @param xIndex
* @param dataSetIndex
*/
public void highlightValue(int xIndex, int dataSetIndex) {
if (xIndex < 0 || dataSetIndex < 0 || xIndex >= mOriginalData.getXValCount()
|| dataSetIndex >= mOriginalData.getDataSetCount()) {
highlightValues(null);
} else {
highlightValues(new Highlight[] {
new Highlight(xIndex, dataSetIndex)
});
}
}
开发者ID:MPieter,项目名称:Notification-Analyser,代码行数:20,代码来源:Chart.java
示例9: drawHighlights
import com.github.mikephil.charting.utils.Highlight; //导入依赖的package包/类
@Override
protected void drawHighlights() {
int setCount = mData.getDataSetCount();
for (int i = 0; i < mIndicesToHightlight.length; i++) {
Highlight h = mIndicesToHightlight[i];
int index = h.getXIndex();
int dataSetIndex = h.getDataSetIndex();
BarDataSet set = (BarDataSet) mData.getDataSetByIndex(dataSetIndex);
if (set == null)
continue;
mHighlightPaint.setColor(set.getHighLightColor());
mHighlightPaint.setAlpha(set.getHighLightAlpha());
// check outofbounds
if (index < mData.getYValCount() && index >= 0
&& index < (mDeltaX * mPhaseX) / mData.getDataSetCount()) {
Entry e = getEntryByDataSetIndex(index, dataSetIndex);
if (e == null)
continue;
// calculate the correct x-position
float x = index * setCount + dataSetIndex + mData.getGroupSpace() / 2f
+ mData.getGroupSpace() * index;
float y = e.getVal();
prepareBar(x, y, set.getBarSpace());
mDrawCanvas.drawRect(mBarRect, mHighlightPaint);
if (mDrawHighlightArrow) {
mHighlightPaint.setAlpha(255);
// distance between highlight arrow and bar
float offsetY = mDeltaY * 0.07f;
Path arrow = new Path();
arrow.moveTo(x + 0.5f, y + offsetY * 0.3f);
arrow.lineTo(x + 0.2f, y + offsetY);
arrow.lineTo(x + 0.8f, y + offsetY);
mTrans.pathValueToPixel(arrow);
mDrawCanvas.drawPath(arrow, mHighlightPaint);
}
}
}
}
开发者ID:LINKIWI,项目名称:mobile-manager-for-cloudflare,代码行数:56,代码来源:BarChart.java
示例10: getHighlightByTouchPoint
import com.github.mikephil.charting.utils.Highlight; //导入依赖的package包/类
/**
* Returns the Highlight object (contains x-index and DataSet index) of the
* selected value at the given touch point inside the BarChart.
*
* @param x
* @param y
* @return
*/
@Override
public Highlight getHighlightByTouchPoint(float x, float y) {
if (mDataNotSet || mData == null) {
Log.e(LOG_TAG, "Can't select by touch. No data set.");
return null;
}
// create an array of the touch-point
float[] pts = new float[2];
pts[0] = x;
pts[1] = y;
mTrans.pixelsToValue(pts);
// for barchart, we only need x-val
double xTouchVal = pts[0];
double base = xTouchVal;
if (xTouchVal < 0 || xTouchVal > mDeltaX)
return null;
if (base < 0)
base = 0;
if (base >= mDeltaX)
base = mDeltaX - 1;
int setCount = mData.getDataSetCount();
int valCount = setCount * mData.getXValCount();
// calculate the amount of bar-space between index 0 and touch position
float space = (float) (((float) valCount / (float) setCount) / (mDeltaX / base));
float reduction = (float) space * mData.getGroupSpace();
int xIndex = (int) ((base - reduction) / setCount);
int dataSetIndex = ((int) (base - reduction)) % setCount;
if (dataSetIndex == -1)
return null;
return new Highlight(xIndex, dataSetIndex);
}
开发者ID:LINKIWI,项目名称:mobile-manager-for-cloudflare,代码行数:53,代码来源:BarChart.java
示例11: getHighlightByTouchPoint
import com.github.mikephil.charting.utils.Highlight; //导入依赖的package包/类
/**
* Returns the Highlight object (contains x-index and DataSet index) of the
* selected value at the given touch point inside the Line-, Scatter-, or
* CandleStick-Chart.
*
* @param x
* @param y
* @return
*/
public Highlight getHighlightByTouchPoint(float x, float y) {
if (mDataNotSet || mData == null) {
Log.e(LOG_TAG, "Can't select by touch. No data set.");
return null;
}
// create an array of the touch-point
float[] pts = new float[2];
pts[0] = x;
pts[1] = y;
mTrans.pixelsToValue(pts);
double xTouchVal = pts[0];
double yTouchVal = pts[1];
double base = Math.floor(xTouchVal);
double touchOffset = mDeltaX * 0.025;
// Log.i(LOG_TAG, "touchindex x: " + xTouchVal + ", touchindex y: " +
// yTouchVal + ", offset: "
// + touchOffset);
// Toast.makeText(getContext(), "touchindex x: " + xTouchVal +
// ", touchindex y: " + yTouchVal + ", offset: " + touchOffset,
// Toast.LENGTH_SHORT).show();
// touch out of chart
if (xTouchVal < -touchOffset || xTouchVal > mDeltaX + touchOffset)
return null;
if (this instanceof CandleStickChart)
base -= 0.5;
if (base < 0)
base = 0;
if (base >= mDeltaX)
base = mDeltaX - 1;
int xIndex = (int) base;
int dataSetIndex = 0; // index of the DataSet inside the ChartData
// object
// check if we are more than half of a x-value or not
if (xTouchVal - base > 0.5) {
xIndex = (int) base + 1;
}
ArrayList<SelInfo> valsAtIndex = getYValsAtIndex(xIndex);
dataSetIndex = Utils.getClosestDataSetIndex(valsAtIndex, (float) yTouchVal);
if (dataSetIndex == -1)
return null;
// Toast.makeText(getContext(), "xindex: " + xIndex + ", dataSetIndex: "
// + dataSetIndex,
// Toast.LENGTH_SHORT).show();
return new Highlight(xIndex, dataSetIndex);
}
开发者ID:LINKIWI,项目名称:mobile-manager-for-cloudflare,代码行数:71,代码来源:BarLineChartBase.java
示例12: onSingleTapUp
import com.github.mikephil.charting.utils.Highlight; //导入依赖的package包/类
@Override
public boolean onSingleTapUp(MotionEvent e) {
OnChartGestureListener l = mChart.getOnChartGestureListener();
if (l != null) {
l.onChartSingleTapped(e);
}
float distance = mChart.distanceToCenter(e.getX(), e.getY());
// check if a slice was touched
if (distance > mChart.getRadius()) {
// if no slice was touched, highlight nothing
mChart.highlightValues(null);
mLastHighlight = null;
} else {
float angle = mChart.getAngleForPoint(e.getX(), e.getY());
int index = mChart.getIndexForAngle(angle);
// check if the index could be found
if (index < 0) {
mChart.highlightValues(null);
mLastHighlight = null;
} else {
ArrayList<SelInfo> valsAtIndex = mChart.getYValsAtIndex(index);
int dataSetIndex = 0;
// get the dataset that is closest to the selection (PieChart
// only
// has one DataSet)
if (mChart instanceof RadarChart) {
dataSetIndex = Utils.getClosestDataSetIndex(valsAtIndex, distance
/ ((RadarChart) mChart).getFactor());
}
Highlight h = new Highlight(index, dataSetIndex);
if (h.equalTo(mLastHighlight)) {
mChart.highlightTouch(null);
mLastHighlight = null;
} else {
mChart.highlightTouch(h);
mLastHighlight = h;
}
}
}
return true;
}
开发者ID:LINKIWI,项目名称:mobile-manager-for-cloudflare,代码行数:61,代码来源:PieRadarChartTouchListener.java
示例13: drawHighlights
import com.github.mikephil.charting.utils.Highlight; //导入依赖的package包/类
@Override
protected void drawHighlights() {
int setCount = mOriginalData.getDataSetCount();
for (int i = 0; i < mIndicesToHightlight.length; i++) {
Highlight h = mIndicesToHightlight[i];
int index = h.getXIndex();
int dataSetIndex = h.getDataSetIndex();
BarDataSet set = (BarDataSet) mCurrentData.getDataSetByIndex(dataSetIndex);
if (set == null)
continue;
mHighlightPaint.setColor(set.getHighLightColor());
mHighlightPaint.setAlpha(set.getHighLightAlpha());
// check outofbounds
if (index < mCurrentData.getYValCount() && index >= 0
&& index < (mDeltaX * mPhaseX) / mOriginalData.getDataSetCount()) {
Entry e = getEntryByDataSetIndex(index, dataSetIndex);
if (e == null)
continue;
// calculate the correct x-position
float x = index * setCount + dataSetIndex + mOriginalData.getGroupSpace() / 2f
+ mOriginalData.getGroupSpace() * index;
float y = e.getVal();
prepareBar(x, y, set.getBarSpace());
mDrawCanvas.drawRect(mBarRect, mHighlightPaint);
if (mDrawHighlightArrow) {
mHighlightPaint.setAlpha(255);
// distance between highlight arrow and bar
float offsetY = mDeltaY * 0.07f;
Path arrow = new Path();
arrow.moveTo(x + 0.5f, y + offsetY * 0.3f);
arrow.lineTo(x + 0.2f, y + offsetY);
arrow.lineTo(x + 0.8f, y + offsetY);
transformPath(arrow);
mDrawCanvas.drawPath(arrow, mHighlightPaint);
}
}
}
}
开发者ID:MPieter,项目名称:Notification-Analyser,代码行数:56,代码来源:BarChart.java
示例14: getHighlightByTouchPoint
import com.github.mikephil.charting.utils.Highlight; //导入依赖的package包/类
/**
* Returns the Highlight object (contains x-index and DataSet index) of the
* selected value at the given touch point inside the BarChart.
*
* @param x
* @param y
* @return
*/
@Override
public Highlight getHighlightByTouchPoint(float x, float y) {
if (mDataNotSet || mCurrentData == null) {
Log.e(LOG_TAG, "Can't select by touch. No data set.");
return null;
}
// create an array of the touch-point
float[] pts = new float[2];
pts[0] = x;
pts[1] = y;
Matrix tmp = new Matrix();
// invert all matrixes to convert back to the original value
mMatrixOffset.invert(tmp);
tmp.mapPoints(pts);
mMatrixTouch.invert(tmp);
tmp.mapPoints(pts);
mMatrixValueToPx.invert(tmp);
tmp.mapPoints(pts);
// for barchart, we only need x-val
double xTouchVal = pts[0];
double base = xTouchVal;
if (xTouchVal < 0 || xTouchVal > mDeltaX)
return null;
if (base < 0)
base = 0;
if (base >= mDeltaX)
base = mDeltaX - 1;
int setCount = mOriginalData.getDataSetCount();
int valCount = setCount * mOriginalData.getXValCount();
// calculate the amount of bar-space between index 0 and touch position
float space = (float) (((float) valCount / (float) setCount) / (mDeltaX / base));
float reduction = (float) space * mOriginalData.getGroupSpace();
int xIndex = (int) ((base - reduction) / setCount);
int dataSetIndex = ((int) (base - reduction)) % setCount;
if (dataSetIndex == -1)
return null;
return new Highlight(xIndex, dataSetIndex);
}
开发者ID:MPieter,项目名称:Notification-Analyser,代码行数:63,代码来源:BarChart.java
示例15: getHighlightByTouchPoint
import com.github.mikephil.charting.utils.Highlight; //导入依赖的package包/类
/**
* Returns the Highlight object (contains x-index and DataSet index) of the
* selected value at the given touch point inside the Line-, Scatter-, or
* CandleStick-Chart.
*
* @param x
* @param y
* @return
*/
public Highlight getHighlightByTouchPoint(float x, float y) {
if (mDataNotSet || mCurrentData == null) {
Log.e(LOG_TAG, "Can't select by touch. No data set.");
return null;
}
// create an array of the touch-point
float[] pts = new float[2];
pts[0] = x;
pts[1] = y;
Matrix tmp = new Matrix();
// invert all matrixes to convert back to the original value
mMatrixOffset.invert(tmp);
tmp.mapPoints(pts);
mMatrixTouch.invert(tmp);
tmp.mapPoints(pts);
mMatrixValueToPx.invert(tmp);
tmp.mapPoints(pts);
double xTouchVal = pts[0];
double yTouchVal = pts[1];
double base = Math.floor(xTouchVal);
double touchOffset = mDeltaX * 0.025;
// Log.i(LOG_TAG, "touchindex x: " + xTouchVal + ", touchindex y: " +
// yTouchVal + ", offset: "
// + touchOffset);
// Toast.makeText(getContext(), "touchindex x: " + xTouchVal +
// ", touchindex y: " + yTouchVal + ", offset: " + touchOffset,
// Toast.LENGTH_SHORT).show();
// touch out of chart
if (xTouchVal < -touchOffset || xTouchVal > mDeltaX + touchOffset)
return null;
if (this instanceof CandleStickChart)
base -= 0.5;
if (base < 0)
base = 0;
if (base >= mDeltaX)
base = mDeltaX - 1;
int xIndex = (int) base;
int dataSetIndex = 0; // index of the DataSet inside the ChartData
// object
// check if we are more than half of a x-value or not
if (xTouchVal - base > 0.5) {
xIndex = (int) base + 1;
}
ArrayList<SelInfo> valsAtIndex = getYValsAtIndex(xIndex);
dataSetIndex = Utils.getClosestDataSetIndex(valsAtIndex, (float) yTouchVal);
if (dataSetIndex == -1)
return null;
// Toast.makeText(getContext(), "xindex: " + xIndex + ", dataSetIndex: "
// + dataSetIndex,
// Toast.LENGTH_SHORT).show();
return new Highlight(xIndex, dataSetIndex);
}
开发者ID:MPieter,项目名称:Notification-Analyser,代码行数:81,代码来源:BarLineChartBase.java
示例16: onValueSelected
import com.github.mikephil.charting.utils.Highlight; //导入依赖的package包/类
@Override
public void onValueSelected(Entry e, int dataSetIndex, Highlight h) {
}
开发者ID:miguelpalacio,项目名称:MyMacros,代码行数:5,代码来源:StatsFragment.java
示例17: getEntryForHighlight
import com.github.mikephil.charting.utils.Highlight; //导入依赖的package包/类
/**
* Get the Entry for a corresponding highlight object
*
* @param highlight
* @return the entry that is highlighted
*/
public Entry getEntryForHighlight(Highlight highlight) {
return mDataSets.get(highlight.getDataSetIndex()).getEntryForXIndex(
highlight.getXIndex());
}
开发者ID:LINKIWI,项目名称:mobile-manager-for-cloudflare,代码行数:11,代码来源:ChartData.java
示例18: onValueSelected
import com.github.mikephil.charting.utils.Highlight; //导入依赖的package包/类
@Override
public void onValueSelected(Entry entry, int i, Highlight highlight) {
}
开发者ID:ludwigandersson,项目名称:thermospy,代码行数:5,代码来源:RealtimeChartFragment.java
注:本文中的com.github.mikephil.charting.utils.Highlight类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论