本文整理汇总了Java中com.github.mikephil.charting.utils.MPPointF.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Java MPPointF.getInstance方法的具体用法?Java MPPointF.getInstance怎么用?Java MPPointF.getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.mikephil.charting.utils.MPPointF
的用法示例。
在下文中一共展示了MPPointF.getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTrans
import com.github.mikephil.charting.utils.MPPointF; //导入方法依赖的package包/类
/**
* Returns a recyclable MPPointF instance.
* returns the correct translation depending on the provided x and y touch
* points
*
* @param x
* @param y
* @return
*/
public MPPointF getTrans(float x, float y) {
ViewPortHandler vph = mChart.getViewPortHandler();
float xTrans = x - vph.offsetLeft();
float yTrans = 0f;
// check if axis is inverted
if (inverted()) {
yTrans = -(y - vph.offsetTop());
} else {
yTrans = -(mChart.getMeasuredHeight() - y - vph.offsetBottom());
}
return MPPointF.getInstance(xTrans, yTrans);
}
示例2: getPosition
import com.github.mikephil.charting.utils.MPPointF; //导入方法依赖的package包/类
/**
* Returns a recyclable MPPointF instance.
*
* @param e
* @param axis
* @return
*/
@Override
public MPPointF getPosition(Entry e, AxisDependency axis) {
if (e == null)
return null;
float[] vals = mGetPositionBuffer;
vals[0] = e.getY();
vals[1] = e.getX();
getTransformer(axis).pointValuesToPixel(vals);
return MPPointF.getInstance(vals[0], vals[1]);
}
示例3: renderAxisLabels
import com.github.mikephil.charting.utils.MPPointF; //导入方法依赖的package包/类
@Override
public void renderAxisLabels(Canvas c) {
if (!mYAxis.isEnabled() || !mYAxis.isDrawLabelsEnabled())
return;
mAxisLabelPaint.setTypeface(mYAxis.getTypeface());
mAxisLabelPaint.setTextSize(mYAxis.getTextSize());
mAxisLabelPaint.setColor(mYAxis.getTextColor());
MPPointF center = mChart.getCenterOffsets();
MPPointF pOut = MPPointF.getInstance(0,0);
float factor = mChart.getFactor();
final int from = mYAxis.isDrawBottomYLabelEntryEnabled() ? 0 : 1;
final int to = mYAxis.isDrawTopYLabelEntryEnabled()
? mYAxis.mEntryCount
: (mYAxis.mEntryCount - 1);
for (int j = from; j < to; j++) {
float r = (mYAxis.mEntries[j] - mYAxis.mAxisMinimum) * factor;
Utils.getPosition(center, r, mChart.getRotationAngle(), pOut);
String label = mYAxis.getFormattedLabel(j);
c.drawText(label, pOut.x + 10, pOut.y, mAxisLabelPaint);
}
MPPointF.recycleInstance(center);
MPPointF.recycleInstance(pOut);
}
示例4: renderAxisLabels
import com.github.mikephil.charting.utils.MPPointF; //导入方法依赖的package包/类
@Override
public void renderAxisLabels(Canvas c) {
if (!mXAxis.isEnabled() || !mXAxis.isDrawLabelsEnabled())
return;
final float labelRotationAngleDegrees = mXAxis.getLabelRotationAngle();
final MPPointF drawLabelAnchor = MPPointF.getInstance(0.5f, 0.25f);
mAxisLabelPaint.setTypeface(mXAxis.getTypeface());
mAxisLabelPaint.setTextSize(mXAxis.getTextSize());
mAxisLabelPaint.setColor(mXAxis.getTextColor());
float sliceangle = mChart.getSliceAngle();
// calculate the factor that is needed for transforming the value to
// pixels
float factor = mChart.getFactor();
MPPointF center = mChart.getCenterOffsets();
MPPointF pOut = MPPointF.getInstance(0,0);
for (int i = 0; i < mChart.getData().getMaxEntryCountSet().getEntryCount(); i++) {
String label = mXAxis.getValueFormatter().getFormattedValue(i, mXAxis);
float angle = (sliceangle * i + mChart.getRotationAngle()) % 360f;
Utils.getPosition(center, mChart.getYRange() * factor
+ mXAxis.mLabelRotatedWidth / 2f, angle, pOut);
drawLabel(c, label, pOut.x, pOut.y - mXAxis.mLabelRotatedHeight / 2.f,
drawLabelAnchor, labelRotationAngleDegrees);
}
MPPointF.recycleInstance(center);
MPPointF.recycleInstance(pOut);
MPPointF.recycleInstance(drawLabelAnchor);
}
示例5: setPosition
import com.github.mikephil.charting.utils.MPPointF; //导入方法依赖的package包/类
/**
* Sets a custom position for the description text in pixels on the screen.
*
* @param x - xcoordinate
* @param y - ycoordinate
*/
public void setPosition(float x, float y) {
if (mPosition == null) {
mPosition = MPPointF.getInstance(x, y);
} else {
mPosition.x = x;
mPosition.y = y;
}
}
示例6: setDescriptionPosition
import com.github.mikephil.charting.utils.MPPointF; //导入方法依赖的package包/类
/**
* Sets a custom position for the description text in pixels on the screen.
*
* @param x - xcoordinate
* @param y - ycoordinate
*/
public void setDescriptionPosition(float x, float y) {
if (mDescriptionPosition == null) {
mDescriptionPosition = MPPointF.getInstance(x, y);
} else {
mDescriptionPosition.x = x;
mDescriptionPosition.y = y;
}
}
示例7: renderAxisLabels
import com.github.mikephil.charting.utils.MPPointF; //导入方法依赖的package包/类
@Override
public void renderAxisLabels(Canvas c) {
if (!mYAxis.isEnabled() || !mYAxis.isDrawLabelsEnabled())
return;
mAxisLabelPaint.setTypeface(mYAxis.getTypeface());
mAxisLabelPaint.setTextSize(mYAxis.getTextSize());
mAxisLabelPaint.setColor(mYAxis.getTextColor());
MPPointF center = mChart.getCenterOffsets();
MPPointF pOut = MPPointF.getInstance(0,0);
float factor = mChart.getFactor();
int labelCount = mYAxis.mEntryCount;
for (int j = 0; j < labelCount; j++) {
if (j == labelCount - 1 && mYAxis.isDrawTopYLabelEntryEnabled() == false)
break;
float r = (mYAxis.mEntries[j] - mYAxis.mAxisMinimum) * factor;
Utils.getPosition(center, r, mChart.getRotationAngle(), pOut);
String label = mYAxis.getFormattedLabel(j);
c.drawText(label, pOut.x + 10, pOut.y, mAxisLabelPaint);
}
MPPointF.recycleInstance(center);
MPPointF.recycleInstance(pOut);
}
示例8: renderLimitLines
import com.github.mikephil.charting.utils.MPPointF; //导入方法依赖的package包/类
@Override
public void renderLimitLines(Canvas c) {
List<LimitLine> limitLines = mYAxis.getLimitLines();
if (limitLines == null)
return;
float sliceangle = mChart.getSliceAngle();
// calculate the factor that is needed for transforming the value to
// pixels
float factor = mChart.getFactor();
MPPointF center = mChart.getCenterOffsets();
MPPointF pOut = MPPointF.getInstance(0,0);
for (int i = 0; i < limitLines.size(); i++) {
LimitLine l = limitLines.get(i);
if (!l.isEnabled())
continue;
mLimitLinePaint.setColor(l.getLineColor());
mLimitLinePaint.setPathEffect(l.getDashPathEffect());
mLimitLinePaint.setStrokeWidth(l.getLineWidth());
float r = (l.getLimit() - mChart.getYChartMin()) * factor;
Path limitPath = mRenderLimitLinesPathBuffer;
limitPath.reset();
for (int j = 0; j < mChart.getData().getMaxEntryCountSet().getEntryCount(); j++) {
Utils.getPosition(center, r, sliceangle * j + mChart.getRotationAngle(), pOut);
if (j == 0)
limitPath.moveTo(pOut.x, pOut.y);
else
limitPath.lineTo(pOut.x, pOut.y);
}
limitPath.close();
c.drawPath(limitPath, mLimitLinePaint);
}
MPPointF.recycleInstance(center);
MPPointF.recycleInstance(pOut);
}
示例9: drawDataSet
import com.github.mikephil.charting.utils.MPPointF; //导入方法依赖的package包/类
/**
* Draws the RadarDataSet
*
* @param c
* @param dataSet
* @param mostEntries the entry count of the dataset with the most entries
*/
protected void drawDataSet(Canvas c, IRadarDataSet dataSet, int mostEntries) {
float phaseX = mAnimator.getPhaseX();
float phaseY = mAnimator.getPhaseY();
float sliceangle = mChart.getSliceAngle();
// calculate the factor that is needed for transforming the value to
// pixels
float factor = mChart.getFactor();
MPPointF center = mChart.getCenterOffsets();
MPPointF pOut = MPPointF.getInstance(0,0);
Path surface = mDrawDataSetSurfacePathBuffer;
surface.reset();
boolean hasMovedToPoint = false;
for (int j = 0; j < dataSet.getEntryCount(); j++) {
mRenderPaint.setColor(dataSet.getColor(j));
RadarEntry e = dataSet.getEntryForIndex(j);
Utils.getPosition(
center,
(e.getY() - mChart.getYChartMin()) * factor * phaseY,
sliceangle * j * phaseX + mChart.getRotationAngle(), pOut);
if (Float.isNaN(pOut.x))
continue;
if (!hasMovedToPoint) {
surface.moveTo(pOut.x, pOut.y);
hasMovedToPoint = true;
} else
surface.lineTo(pOut.x, pOut.y);
}
if (dataSet.getEntryCount() > mostEntries) {
// if this is not the largest set, draw a line to the center before closing
surface.lineTo(center.x, center.y);
}
surface.close();
if (dataSet.isDrawFilledEnabled()) {
final Drawable drawable = dataSet.getFillDrawable();
if (drawable != null) {
drawFilledPath(c, surface, drawable);
} else {
drawFilledPath(c, surface, dataSet.getFillColor(), dataSet.getFillAlpha());
}
}
mRenderPaint.setStrokeWidth(dataSet.getLineWidth());
mRenderPaint.setStyle(Paint.Style.STROKE);
// draw the line (only if filled is disabled or alpha is below 255)
if (!dataSet.isDrawFilledEnabled() || dataSet.getFillAlpha() < 255)
c.drawPath(surface, mRenderPaint);
MPPointF.recycleInstance(center);
MPPointF.recycleInstance(pOut);
}
示例10: drawWeb
import com.github.mikephil.charting.utils.MPPointF; //导入方法依赖的package包/类
protected void drawWeb(Canvas c) {
float sliceangle = mChart.getSliceAngle();
// calculate the factor that is needed for transforming the value to
// pixels
float factor = mChart.getFactor();
float rotationangle = mChart.getRotationAngle();
MPPointF center = mChart.getCenterOffsets();
// draw the web lines that come from the center
mWebPaint.setStrokeWidth(mChart.getWebLineWidth());
mWebPaint.setColor(mChart.getWebColor());
mWebPaint.setAlpha(mChart.getWebAlpha());
final int xIncrements = 1 + mChart.getSkipWebLineCount();
int maxEntryCount = mChart.getData().getMaxEntryCountSet().getEntryCount();
MPPointF p = MPPointF.getInstance(0,0);
for (int i = 0; i < maxEntryCount; i += xIncrements) {
Utils.getPosition(
center,
mChart.getYRange() * factor,
sliceangle * i + rotationangle,
p);
c.drawLine(center.x, center.y, p.x, p.y, mWebPaint);
}
MPPointF.recycleInstance(p);
// draw the inner-web
mWebPaint.setStrokeWidth(mChart.getWebLineWidthInner());
mWebPaint.setColor(mChart.getWebColorInner());
mWebPaint.setAlpha(mChart.getWebAlpha());
int labelCount = mChart.getYAxis().mEntryCount;
MPPointF p1out = MPPointF.getInstance(0,0);
MPPointF p2out = MPPointF.getInstance(0,0);
for (int j = 0; j < labelCount; j++) {
for (int i = 0; i < mChart.getData().getEntryCount(); i++) {
float r = (mChart.getYAxis().mEntries[j] - mChart.getYChartMin()) * factor;
Utils.getPosition(center, r, sliceangle * i + rotationangle, p1out);
Utils.getPosition(center, r, sliceangle * (i + 1) + rotationangle, p2out);
c.drawLine(p1out.x, p1out.y, p2out.x, p2out.y, mWebPaint);
}
}
MPPointF.recycleInstance(p1out);
MPPointF.recycleInstance(p2out);
}
示例11: drawHighlighted
import com.github.mikephil.charting.utils.MPPointF; //导入方法依赖的package包/类
@Override
public void drawHighlighted(Canvas c, Highlight[] indices) {
float sliceangle = mChart.getSliceAngle();
// calculate the factor that is needed for transforming the value to
// pixels
float factor = mChart.getFactor();
MPPointF center = mChart.getCenterOffsets();
MPPointF pOut = MPPointF.getInstance(0,0);
RadarData radarData = mChart.getData();
for (Highlight high : indices) {
IRadarDataSet set = radarData.getDataSetByIndex(high.getDataSetIndex());
if (set == null || !set.isHighlightEnabled())
continue;
RadarEntry e = set.getEntryForIndex((int) high.getX());
if (!isInBoundsX(e, set))
continue;
float y = (e.getY() - mChart.getYChartMin());
Utils.getPosition(center,
y * factor * mAnimator.getPhaseY(),
sliceangle * high.getX() * mAnimator.getPhaseX() + mChart.getRotationAngle(),
pOut);
high.setDraw(pOut.x, pOut.y);
// draw the lines
drawHighlightLines(c, pOut.x, pOut.y, set);
if (set.isDrawHighlightCircleEnabled()) {
if (!Float.isNaN(pOut.x) && !Float.isNaN(pOut.y)) {
int strokeColor = set.getHighlightCircleStrokeColor();
if (strokeColor == ColorTemplate.COLOR_NONE) {
strokeColor = set.getColor(0);
}
if (set.getHighlightCircleStrokeAlpha() < 255) {
strokeColor = ColorTemplate.colorWithAlpha(strokeColor, set.getHighlightCircleStrokeAlpha());
}
drawHighlightCircle(c,
pOut,
set.getHighlightCircleInnerRadius(),
set.getHighlightCircleOuterRadius(),
set.getHighlightCircleFillColor(),
strokeColor,
set.getHighlightCircleStrokeWidth());
}
}
}
MPPointF.recycleInstance(center);
MPPointF.recycleInstance(pOut);
}
示例12: renderAxisLabels
import com.github.mikephil.charting.utils.MPPointF; //导入方法依赖的package包/类
@Override
public void renderAxisLabels(Canvas c) {
if (!mXAxis.isEnabled() || !mXAxis.isDrawLabelsEnabled())
return;
float xoffset = mXAxis.getXOffset();
mAxisLabelPaint.setTypeface(mXAxis.getTypeface());
mAxisLabelPaint.setTextSize(mXAxis.getTextSize());
mAxisLabelPaint.setColor(mXAxis.getTextColor());
MPPointF pointF = MPPointF.getInstance(0,0);
if (mXAxis.getPosition() == XAxisPosition.TOP) {
pointF.x = 0.0f;
pointF.y = 0.5f;
drawLabels(c, mViewPortHandler.contentRight() + xoffset, pointF);
} else if (mXAxis.getPosition() == XAxisPosition.TOP_INSIDE) {
pointF.x = 1.0f;
pointF.y = 0.5f;
drawLabels(c, mViewPortHandler.contentRight() - xoffset, pointF);
} else if (mXAxis.getPosition() == XAxisPosition.BOTTOM) {
pointF.x = 1.0f;
pointF.y = 0.5f;
drawLabels(c, mViewPortHandler.contentLeft() - xoffset, pointF);
} else if (mXAxis.getPosition() == XAxisPosition.BOTTOM_INSIDE) {
pointF.x = 1.0f;
pointF.y = 0.5f;
drawLabels(c, mViewPortHandler.contentLeft() + xoffset, pointF);
} else { // BOTH SIDED
pointF.x = 0.0f;
pointF.y = 0.5f;
drawLabels(c, mViewPortHandler.contentRight() + xoffset, pointF);
pointF.x = 1.0f;
pointF.y = 0.5f;
drawLabels(c, mViewPortHandler.contentLeft() - xoffset, pointF);
}
MPPointF.recycleInstance(pointF);
}
示例13: renderAxisLabels
import com.github.mikephil.charting.utils.MPPointF; //导入方法依赖的package包/类
@Override
public void renderAxisLabels(Canvas c) {
if (!mXAxis.isEnabled() || !mXAxis.isDrawLabelsEnabled())
return;
float yoffset = mXAxis.getYOffset();
mAxisLabelPaint.setTypeface(mXAxis.getTypeface());
mAxisLabelPaint.setTextSize(mXAxis.getTextSize());
mAxisLabelPaint.setColor(mXAxis.getTextColor());
MPPointF pointF = MPPointF.getInstance(0,0);
if (mXAxis.getPosition() == XAxisPosition.TOP) {
pointF.x = 0.5f;
pointF.y = 1.0f;
drawLabels(c, mViewPortHandler.contentTop() - yoffset, pointF);
} else if (mXAxis.getPosition() == XAxisPosition.TOP_INSIDE) {
pointF.x = 0.5f;
pointF.y = 1.0f;
drawLabels(c, mViewPortHandler.contentTop() + yoffset + mXAxis.mLabelRotatedHeight, pointF);
} else if (mXAxis.getPosition() == XAxisPosition.BOTTOM) {
pointF.x = 0.5f;
pointF.y = 0.0f;
drawLabels(c, mViewPortHandler.contentBottom() + yoffset, pointF);
} else if (mXAxis.getPosition() == XAxisPosition.BOTTOM_INSIDE) {
pointF.x = 0.5f;
pointF.y = 0.0f;
drawLabels(c, mViewPortHandler.contentBottom() - yoffset - mXAxis.mLabelRotatedHeight, pointF);
} else { // BOTH SIDED
pointF.x = 0.5f;
pointF.y = 1.0f;
drawLabels(c, mViewPortHandler.contentTop() - yoffset, pointF);
pointF.x = 0.5f;
pointF.y = 0.0f;
drawLabels(c, mViewPortHandler.contentBottom() + yoffset, pointF);
}
MPPointF.recycleInstance(pointF);
}
示例14: drawValues
import com.github.mikephil.charting.utils.MPPointF; //导入方法依赖的package包/类
@Override
public void drawValues(Canvas c) {
// if values are drawn
if (isDrawingValuesAllowed(mChart)) {
List<IScatterDataSet> dataSets = mChart.getScatterData().getDataSets();
for (int i = 0; i < mChart.getScatterData().getDataSetCount(); i++) {
IScatterDataSet dataSet = dataSets.get(i);
if (!shouldDrawValues(dataSet))
continue;
// apply the text-styling defined by the DataSet
applyValueTextStyle(dataSet);
mXBounds.set(mChart, dataSet);
float[] positions = mChart.getTransformer(dataSet.getAxisDependency())
.generateTransformedValuesScatter(dataSet,
mAnimator.getPhaseX(), mAnimator.getPhaseY(), mXBounds.min, mXBounds.max);
float shapeSize = Utils.convertDpToPixel(dataSet.getScatterShapeSize());
MPPointF iconsOffset = MPPointF.getInstance(dataSet.getIconsOffset());
iconsOffset.x = Utils.convertDpToPixel(iconsOffset.x);
iconsOffset.y = Utils.convertDpToPixel(iconsOffset.y);
for (int j = 0; j < positions.length; j += 2) {
if (!mViewPortHandler.isInBoundsRight(positions[j]))
break;
// make sure the lines don't do shitty things outside bounds
if ((!mViewPortHandler.isInBoundsLeft(positions[j])
|| !mViewPortHandler.isInBoundsY(positions[j + 1])))
continue;
Entry entry = dataSet.getEntryForIndex(j / 2 + mXBounds.min);
if (dataSet.isDrawValuesEnabled()) {
drawValue(c,
dataSet.getValueFormatter(),
entry.getY(),
entry,
i,
positions[j],
positions[j + 1] - shapeSize,
dataSet.getValueTextColor(j / 2 + mXBounds.min));
}
if (entry.getIcon() != null && dataSet.isDrawIconsEnabled()) {
Drawable icon = entry.getIcon();
Utils.drawImage(
c,
icon,
(int)(positions[j] + iconsOffset.x),
(int)(positions[j + 1] + iconsOffset.y),
icon.getIntrinsicWidth(),
icon.getIntrinsicHeight());
}
}
MPPointF.recycleInstance(iconsOffset);
}
}
}
示例15: drawValues
import com.github.mikephil.charting.utils.MPPointF; //导入方法依赖的package包/类
@Override
public void drawValues(Canvas c) {
float phaseX = mAnimator.getPhaseX();
float phaseY = mAnimator.getPhaseY();
float sliceangle = mChart.getSliceAngle();
// calculate the factor that is needed for transforming the value to
// pixels
float factor = mChart.getFactor();
MPPointF center = mChart.getCenterOffsets();
MPPointF pOut = MPPointF.getInstance(0,0);
float yoffset = Utils.convertDpToPixel(5f);
for (int i = 0; i < mChart.getData().getDataSetCount(); i++) {
IRadarDataSet dataSet = mChart.getData().getDataSetByIndex(i);
if (!shouldDrawValues(dataSet))
continue;
// apply the text-styling defined by the DataSet
applyValueTextStyle(dataSet);
for (int j = 0; j < dataSet.getEntryCount(); j++) {
RadarEntry entry = dataSet.getEntryForIndex(j);
Utils.getPosition(
center,
(entry.getY() - mChart.getYChartMin()) * factor * phaseY,
sliceangle * j * phaseX + mChart.getRotationAngle(),
pOut);
drawValue(c, dataSet.getValueFormatter(), entry.getY(), entry, i, pOut.x, pOut.y - yoffset, dataSet.getValueTextColor
(j));
}
}
MPPointF.recycleInstance(center);
MPPointF.recycleInstance(pOut);
}