本文整理汇总了Java中com.github.mikephil.charting.utils.ViewPortHandler.isInBoundsRight方法的典型用法代码示例。如果您正苦于以下问题:Java ViewPortHandler.isInBoundsRight方法的具体用法?Java ViewPortHandler.isInBoundsRight怎么用?Java ViewPortHandler.isInBoundsRight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.mikephil.charting.utils.ViewPortHandler
的用法示例。
在下文中一共展示了ViewPortHandler.isInBoundsRight方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: renderShape
import com.github.mikephil.charting.utils.ViewPortHandler; //导入方法依赖的package包/类
@Override
public void renderShape(
Canvas c, IScatterDataSet dataSet,
ViewPortHandler mViewPortHandler, ScatterBuffer buffer, Paint mRenderPaint, final float shapeSize) {
final float shapeHalf = shapeSize / 2f;
mRenderPaint.setStyle(Paint.Style.STROKE);
mRenderPaint.setStrokeWidth(Utils.convertDpToPixel(1f));
for (int i = 0; i < buffer.size(); i += 2) {
if (!mViewPortHandler.isInBoundsRight(buffer.buffer[i]))
break;
if (!mViewPortHandler.isInBoundsLeft(buffer.buffer[i])
|| !mViewPortHandler.isInBoundsY(buffer.buffer[i + 1]))
continue;
mRenderPaint.setColor(dataSet.getColor(i / 2));
c.drawLine(
buffer.buffer[i] - shapeHalf,
buffer.buffer[i + 1] - shapeHalf,
buffer.buffer[i] + shapeHalf,
buffer.buffer[i + 1] + shapeHalf,
mRenderPaint);
c.drawLine(
buffer.buffer[i] + shapeHalf,
buffer.buffer[i + 1] - shapeHalf,
buffer.buffer[i] - shapeHalf,
buffer.buffer[i + 1] + shapeHalf,
mRenderPaint);
}
}
示例2: renderShape
import com.github.mikephil.charting.utils.ViewPortHandler; //导入方法依赖的package包/类
@Override
public void renderShape(
Canvas c, IScatterDataSet dataSet,
ViewPortHandler mViewPortHandler, ScatterBuffer buffer, Paint mRenderPaint, final float shapeSize) {
final float shapeHalf = shapeSize / 2f;
mRenderPaint.setStyle(Paint.Style.STROKE);
mRenderPaint.setStrokeWidth(Utils.convertDpToPixel(1f));
for (int i = 0; i < buffer.size(); i += 2) {
if (!mViewPortHandler.isInBoundsRight(buffer.buffer[i]))
break;
if (!mViewPortHandler.isInBoundsLeft(buffer.buffer[i])
|| !mViewPortHandler.isInBoundsY(buffer.buffer[i + 1]))
continue;
mRenderPaint.setColor(dataSet.getColor(i / 2));
c.drawLine(
buffer.buffer[i] - shapeHalf,
buffer.buffer[i + 1],
buffer.buffer[i] + shapeHalf,
buffer.buffer[i + 1],
mRenderPaint);
c.drawLine(
buffer.buffer[i],
buffer.buffer[i + 1] - shapeHalf,
buffer.buffer[i],
buffer.buffer[i + 1] + shapeHalf,
mRenderPaint);
}
}
示例3: renderShape
import com.github.mikephil.charting.utils.ViewPortHandler; //导入方法依赖的package包/类
@Override
public void renderShape(Canvas c, IScatterDataSet dataSet,
ViewPortHandler mViewPortHandler, ScatterBuffer buffer, Paint mRenderPaint, final float shapeSize) {
final float shapeHalf = shapeSize / 2f;
mRenderPaint.setStyle(Paint.Style.STROKE);
mRenderPaint.setStrokeWidth(Utils.convertDpToPixel(1f));
for (int i = 0; i < buffer.size(); i += 2) {
if (!mViewPortHandler.isInBoundsRight(buffer.buffer[i]))
break;
if (!mViewPortHandler.isInBoundsLeft(buffer.buffer[i])
|| !mViewPortHandler.isInBoundsY(buffer.buffer[i + 1]))
continue;
mRenderPaint.setColor(dataSet.getColor(i / 2));
c.drawLine(
buffer.buffer[i],
buffer.buffer[i + 1] - (2 * shapeHalf),
buffer.buffer[i] + (2 * shapeHalf),
buffer.buffer[i + 1],
mRenderPaint);
c.drawLine(
buffer.buffer[i],
buffer.buffer[i + 1] - (2 * shapeHalf),
buffer.buffer[i] - (2 * shapeHalf),
buffer.buffer[i + 1],
mRenderPaint);
}
}
示例4: renderShape
import com.github.mikephil.charting.utils.ViewPortHandler; //导入方法依赖的package包/类
@Override
public void renderShape(
Canvas c, IScatterDataSet dataSet,
ViewPortHandler mViewPortHandler, ScatterBuffer buffer, Paint mRenderPaint, final float shapeSize) {
final float shapeHalf = shapeSize / 2f;
mRenderPaint.setStyle(Paint.Style.STROKE);
mRenderPaint.setStrokeWidth(Utils.convertDpToPixel(1f));
for (int i = 0; i < buffer.size(); i += 2) {
if (!mViewPortHandler.isInBoundsRight(buffer.buffer[i]))
break;
if (!mViewPortHandler.isInBoundsLeft(buffer.buffer[i])
|| !mViewPortHandler.isInBoundsY(buffer.buffer[i + 1]))
continue;
mRenderPaint.setColor(dataSet.getColor(i / 2));
c.drawLine(
buffer.buffer[i],
buffer.buffer[i + 1] + (2 * shapeHalf),
buffer.buffer[i] + (2 * shapeHalf),
buffer.buffer[i + 1],
mRenderPaint);
c.drawLine(
buffer.buffer[i],
buffer.buffer[i + 1] + (2 * shapeHalf),
buffer.buffer[i] - (2 * shapeHalf),
buffer.buffer[i + 1],
mRenderPaint);
}
}
示例5: renderShape
import com.github.mikephil.charting.utils.ViewPortHandler; //导入方法依赖的package包/类
@Override
public void renderShape(Canvas c, IScatterDataSet dataSet, ViewPortHandler viewPortHandler, ScatterBuffer buffer, Paint
renderPaint, final float shapeSize) {
final float shapeHalf = shapeSize / 2f;
renderPaint.setStyle(Paint.Style.STROKE);
renderPaint.setStrokeWidth(Utils.convertDpToPixel(1f));
for (int i = 0; i < buffer.size(); i += 2) {
if (!viewPortHandler.isInBoundsRight(buffer.buffer[i]))
break;
if (!viewPortHandler.isInBoundsLeft(buffer.buffer[i])
|| !viewPortHandler.isInBoundsY(buffer.buffer[i + 1]))
continue;
renderPaint.setColor(dataSet.getColor(i / 2));
c.drawLine(
buffer.buffer[i] - shapeHalf,
buffer.buffer[i + 1] - shapeHalf,
buffer.buffer[i] + shapeHalf,
buffer.buffer[i + 1] + shapeHalf,
renderPaint);
c.drawLine(
buffer.buffer[i] + shapeHalf,
buffer.buffer[i + 1] - shapeHalf,
buffer.buffer[i] - shapeHalf,
buffer.buffer[i + 1] + shapeHalf,
renderPaint);
}
}
示例6: renderShape
import com.github.mikephil.charting.utils.ViewPortHandler; //导入方法依赖的package包/类
@Override
public void renderShape(Canvas c, IScatterDataSet dataSet, ViewPortHandler viewPortHandler, ScatterBuffer buffer, Paint
renderPaint, final float shapeSize) {
final float shapeHalf = shapeSize / 2f;
renderPaint.setStyle(Paint.Style.STROKE);
renderPaint.setStrokeWidth(Utils.convertDpToPixel(1f));
for (int i = 0; i < buffer.size(); i += 2) {
if (!viewPortHandler.isInBoundsRight(buffer.buffer[i]))
break;
if (!viewPortHandler.isInBoundsLeft(buffer.buffer[i])
|| !viewPortHandler.isInBoundsY(buffer.buffer[i + 1]))
continue;
renderPaint.setColor(dataSet.getColor(i / 2));
c.drawLine(
buffer.buffer[i] - shapeHalf,
buffer.buffer[i + 1],
buffer.buffer[i] + shapeHalf,
buffer.buffer[i + 1],
renderPaint);
c.drawLine(
buffer.buffer[i],
buffer.buffer[i + 1] - shapeHalf,
buffer.buffer[i],
buffer.buffer[i + 1] + shapeHalf,
renderPaint);
}
}
示例7: renderShape
import com.github.mikephil.charting.utils.ViewPortHandler; //导入方法依赖的package包/类
@Override
public void renderShape(Canvas c, IScatterDataSet dataSet, ViewPortHandler viewPortHandler, ScatterBuffer buffer, Paint
renderPaint, final float shapeSize) {
final float shapeHalf = shapeSize / 2f;
renderPaint.setStyle(Paint.Style.STROKE);
renderPaint.setStrokeWidth(Utils.convertDpToPixel(1f));
for (int i = 0; i < buffer.size(); i += 2) {
if (!viewPortHandler.isInBoundsRight(buffer.buffer[i]))
break;
if (!viewPortHandler.isInBoundsLeft(buffer.buffer[i])
|| !viewPortHandler.isInBoundsY(buffer.buffer[i + 1]))
continue;
renderPaint.setColor(dataSet.getColor(i / 2));
c.drawLine(
buffer.buffer[i],
buffer.buffer[i + 1] - (2 * shapeHalf),
buffer.buffer[i] + (2 * shapeHalf),
buffer.buffer[i + 1],
renderPaint);
c.drawLine(
buffer.buffer[i],
buffer.buffer[i + 1] - (2 * shapeHalf),
buffer.buffer[i] - (2 * shapeHalf),
buffer.buffer[i + 1],
renderPaint);
}
}
示例8: renderShape
import com.github.mikephil.charting.utils.ViewPortHandler; //导入方法依赖的package包/类
@Override
public void renderShape(Canvas c, IScatterDataSet dataSet, ViewPortHandler viewPortHandler, ScatterBuffer buffer, Paint
renderPaint, final float shapeSize) {
final float shapeHalf = shapeSize / 2f;
renderPaint.setStyle(Paint.Style.STROKE);
renderPaint.setStrokeWidth(Utils.convertDpToPixel(1f));
for (int i = 0; i < buffer.size(); i += 2) {
if (!viewPortHandler.isInBoundsRight(buffer.buffer[i]))
break;
if (!viewPortHandler.isInBoundsLeft(buffer.buffer[i])
|| !viewPortHandler.isInBoundsY(buffer.buffer[i + 1]))
continue;
renderPaint.setColor(dataSet.getColor(i / 2));
c.drawLine(
buffer.buffer[i],
buffer.buffer[i + 1] + (2 * shapeHalf),
buffer.buffer[i] + (2 * shapeHalf),
buffer.buffer[i + 1],
renderPaint);
c.drawLine(
buffer.buffer[i],
buffer.buffer[i + 1] + (2 * shapeHalf),
buffer.buffer[i] - (2 * shapeHalf),
buffer.buffer[i + 1],
renderPaint);
}
}
示例9: drawDataSet
import com.github.mikephil.charting.utils.ViewPortHandler; //导入方法依赖的package包/类
protected void drawDataSet(Canvas c, IScatterDataSet dataSet) {
ViewPortHandler viewPortHandler = mViewPortHandler;
Transformer trans = mChart.getTransformer(dataSet.getAxisDependency());
float phaseY = mAnimator.getPhaseY();
IShapeRenderer renderer = dataSet.getShapeRenderer();
if (renderer == null) {
Log.i("MISSING", "There's no IShapeRenderer specified for ScatterDataSet");
return;
}
int max = (int)(Math.min(
Math.ceil((float)dataSet.getEntryCount() * mAnimator.getPhaseX()),
(float)dataSet.getEntryCount()));
for (int i = 0; i < max; i++) {
Entry e = dataSet.getEntryForIndex(i);
mPixelBuffer[0] = e.getX();
mPixelBuffer[1] = e.getY() * phaseY;
trans.pointValuesToPixel(mPixelBuffer);
if (!viewPortHandler.isInBoundsRight(mPixelBuffer[0]))
break;
if (!viewPortHandler.isInBoundsLeft(mPixelBuffer[0])
|| !viewPortHandler.isInBoundsY(mPixelBuffer[1]))
continue;
mRenderPaint.setColor(dataSet.getColor(i / 2));
renderer.renderShape(
c, dataSet, mViewPortHandler,
mPixelBuffer[0], mPixelBuffer[1],
mRenderPaint);
}
}
示例10: renderShape
import com.github.mikephil.charting.utils.ViewPortHandler; //导入方法依赖的package包/类
@Override
public void renderShape(
Canvas c, IScatterDataSet dataSet,
ViewPortHandler mViewPortHandler, ScatterBuffer buffer, Paint mRenderPaint, final float shapeSize) {
final float shapeHalf = shapeSize / 2f;
final float shapeHoleSizeHalf = Utils.convertDpToPixel(dataSet.getScatterShapeHoleRadius());
final float shapeHoleSize = shapeHoleSizeHalf * 2.f;
final float shapeStrokeSize = (shapeSize - shapeHoleSize) / 2.f;
final float shapeStrokeSizeHalf = shapeStrokeSize / 2.f;
final int shapeHoleColor = dataSet.getScatterShapeHoleColor();
for (int i = 0; i < buffer.size(); i += 2) {
if (!mViewPortHandler.isInBoundsRight(buffer.buffer[i]))
break;
if (!mViewPortHandler.isInBoundsLeft(buffer.buffer[i])
|| !mViewPortHandler.isInBoundsY(buffer.buffer[i + 1]))
continue;
mRenderPaint.setColor(dataSet.getColor(i / 2));
if (shapeSize > 0.0) {
mRenderPaint.setStyle(Paint.Style.STROKE);
mRenderPaint.setStrokeWidth(shapeStrokeSize);
c.drawCircle(
buffer.buffer[i],
buffer.buffer[i + 1],
shapeHoleSizeHalf + shapeStrokeSizeHalf,
mRenderPaint);
if (shapeHoleColor != ColorTemplate.COLOR_NONE) {
mRenderPaint.setStyle(Paint.Style.FILL);
mRenderPaint.setColor(shapeHoleColor);
c.drawCircle(
buffer.buffer[i],
buffer.buffer[i + 1],
shapeHoleSizeHalf,
mRenderPaint);
}
} else {
mRenderPaint.setStyle(Paint.Style.FILL);
c.drawCircle(
buffer.buffer[i],
buffer.buffer[i + 1],
shapeHalf,
mRenderPaint);
}
}
}
示例11: renderShape
import com.github.mikephil.charting.utils.ViewPortHandler; //导入方法依赖的package包/类
@Override
public void renderShape(
Canvas c, IScatterDataSet dataSet,
ViewPortHandler mViewPortHandler, ScatterBuffer buffer, Paint mRenderPaint, final float shapeSize) {
final float shapeHalf = shapeSize / 2f;
final float shapeHoleSizeHalf = Utils.convertDpToPixel(dataSet.getScatterShapeHoleRadius());
final float shapeHoleSize = shapeHoleSizeHalf * 2.f;
final float shapeStrokeSize = (shapeSize - shapeHoleSize) / 2.f;
final int shapeHoleColor = dataSet.getScatterShapeHoleColor();
mRenderPaint.setStyle(Paint.Style.FILL);
// create a triangle path
Path tri = new Path();
for (int i = 0; i < buffer.size(); i += 2) {
if (!mViewPortHandler.isInBoundsRight(buffer.buffer[i]))
break;
if (!mViewPortHandler.isInBoundsLeft(buffer.buffer[i])
|| !mViewPortHandler.isInBoundsY(buffer.buffer[i + 1]))
continue;
mRenderPaint.setColor(dataSet.getColor(i / 2));
tri.moveTo(buffer.buffer[i], buffer.buffer[i + 1] - shapeHalf);
tri.lineTo(buffer.buffer[i] + shapeHalf, buffer.buffer[i + 1] + shapeHalf);
tri.lineTo(buffer.buffer[i] - shapeHalf, buffer.buffer[i + 1] + shapeHalf);
if (shapeSize > 0.0) {
tri.lineTo(buffer.buffer[i], buffer.buffer[i + 1] - shapeHalf);
tri.moveTo(buffer.buffer[i] - shapeHalf + shapeStrokeSize,
buffer.buffer[i + 1] + shapeHalf - shapeStrokeSize);
tri.lineTo(buffer.buffer[i] + shapeHalf - shapeStrokeSize,
buffer.buffer[i + 1] + shapeHalf - shapeStrokeSize);
tri.lineTo(buffer.buffer[i],
buffer.buffer[i + 1] - shapeHalf + shapeStrokeSize);
tri.lineTo(buffer.buffer[i] - shapeHalf + shapeStrokeSize,
buffer.buffer[i + 1] + shapeHalf - shapeStrokeSize);
}
tri.close();
c.drawPath(tri, mRenderPaint);
tri.reset();
if (shapeSize > 0.0 &&
shapeHoleColor != ColorTemplate.COLOR_NONE) {
mRenderPaint.setColor(shapeHoleColor);
tri.moveTo(buffer.buffer[i],
buffer.buffer[i + 1] - shapeHalf + shapeStrokeSize);
tri.lineTo(buffer.buffer[i] + shapeHalf - shapeStrokeSize,
buffer.buffer[i + 1] + shapeHalf - shapeStrokeSize);
tri.lineTo(buffer.buffer[i] - shapeHalf + shapeStrokeSize,
buffer.buffer[i + 1] + shapeHalf - shapeStrokeSize);
tri.close();
c.drawPath(tri, mRenderPaint);
tri.reset();
}
}
}
示例12: renderShape
import com.github.mikephil.charting.utils.ViewPortHandler; //导入方法依赖的package包/类
@Override
public void renderShape(
Canvas c, IScatterDataSet dataSet,
ViewPortHandler mViewPortHandler, ScatterBuffer buffer, Paint mRenderPaint, final float shapeSize) {
final float shapeHalf = shapeSize / 2f;
final float shapeHoleSizeHalf = Utils.convertDpToPixel(dataSet.getScatterShapeHoleRadius());
final float shapeHoleSize = shapeHoleSizeHalf * 2.f;
final float shapeStrokeSize = (shapeSize - shapeHoleSize) / 2.f;
final float shapeStrokeSizeHalf = shapeStrokeSize / 2.f;
final int shapeHoleColor = dataSet.getScatterShapeHoleColor();
for (int i = 0; i < buffer.size(); i += 2) {
if (!mViewPortHandler.isInBoundsRight(buffer.buffer[i]))
break;
if (!mViewPortHandler.isInBoundsLeft(buffer.buffer[i])
|| !mViewPortHandler.isInBoundsY(buffer.buffer[i + 1]))
continue;
mRenderPaint.setColor(dataSet.getColor(i / 2));
if (shapeSize > 0.0) {
mRenderPaint.setStyle(Paint.Style.STROKE);
mRenderPaint.setStrokeWidth(shapeStrokeSize);
c.drawRect(buffer.buffer[i] - shapeHoleSizeHalf - shapeStrokeSizeHalf,
buffer.buffer[i + 1] - shapeHoleSizeHalf - shapeStrokeSizeHalf,
buffer.buffer[i] + shapeHoleSizeHalf + shapeStrokeSizeHalf,
buffer.buffer[i + 1] + shapeHoleSizeHalf + shapeStrokeSizeHalf,
mRenderPaint);
if (shapeHoleColor != ColorTemplate.COLOR_NONE) {
mRenderPaint.setStyle(Paint.Style.FILL);
mRenderPaint.setColor(shapeHoleColor);
c.drawRect(buffer.buffer[i] - shapeHoleSizeHalf,
buffer.buffer[i + 1] - shapeHoleSizeHalf,
buffer.buffer[i] + shapeHoleSizeHalf,
buffer.buffer[i + 1] + shapeHoleSizeHalf,
mRenderPaint);
}
} else {
mRenderPaint.setStyle(Paint.Style.FILL);
c.drawRect(buffer.buffer[i] - shapeHalf,
buffer.buffer[i + 1] - shapeHalf,
buffer.buffer[i] + shapeHalf,
buffer.buffer[i + 1] + shapeHalf,
mRenderPaint);
}
}
}
示例13: renderShape
import com.github.mikephil.charting.utils.ViewPortHandler; //导入方法依赖的package包/类
@Override
public void renderShape(Canvas c, IScatterDataSet dataSet, ViewPortHandler viewPortHandler, ScatterBuffer buffer, Paint
renderPaint, final float shapeSize) {
final float shapeHalf = shapeSize / 2f;
final float shapeHoleSizeHalf = Utils.convertDpToPixel(dataSet.getScatterShapeHoleRadius());
final float shapeHoleSize = shapeHoleSizeHalf * 2.f;
final float shapeStrokeSize = (shapeSize - shapeHoleSize) / 2.f;
final float shapeStrokeSizeHalf = shapeStrokeSize / 2.f;
final int shapeHoleColor = dataSet.getScatterShapeHoleColor();
for (int i = 0; i < buffer.size(); i += 2) {
if (!viewPortHandler.isInBoundsRight(buffer.buffer[i]))
break;
if (!viewPortHandler.isInBoundsLeft(buffer.buffer[i])
|| !viewPortHandler.isInBoundsY(buffer.buffer[i + 1]))
continue;
renderPaint.setColor(dataSet.getColor(i / 2));
if (shapeSize > 0.0) {
renderPaint.setStyle(Paint.Style.STROKE);
renderPaint.setStrokeWidth(shapeStrokeSize);
c.drawCircle(
buffer.buffer[i],
buffer.buffer[i + 1],
shapeHoleSizeHalf + shapeStrokeSizeHalf,
renderPaint);
if (shapeHoleColor != ColorTemplate.COLOR_NONE) {
renderPaint.setStyle(Paint.Style.FILL);
renderPaint.setColor(shapeHoleColor);
c.drawCircle(
buffer.buffer[i],
buffer.buffer[i + 1],
shapeHoleSizeHalf,
renderPaint);
}
} else {
renderPaint.setStyle(Paint.Style.FILL);
c.drawCircle(
buffer.buffer[i],
buffer.buffer[i + 1],
shapeHalf,
renderPaint);
}
}
}
示例14: renderShape
import com.github.mikephil.charting.utils.ViewPortHandler; //导入方法依赖的package包/类
@Override
public void renderShape(Canvas c, IScatterDataSet dataSet, ViewPortHandler viewPortHandler, ScatterBuffer buffer, Paint
renderPaint, final float shapeSize) {
final float shapeHalf = shapeSize / 2f;
final float shapeHoleSizeHalf = Utils.convertDpToPixel(dataSet.getScatterShapeHoleRadius());
final float shapeHoleSize = shapeHoleSizeHalf * 2.f;
final float shapeStrokeSize = (shapeSize - shapeHoleSize) / 2.f;
final int shapeHoleColor = dataSet.getScatterShapeHoleColor();
renderPaint.setStyle(Paint.Style.FILL);
// create a triangle path
Path tri = mTrianglePathBuffer;
tri.reset();
for (int i = 0; i < buffer.size(); i += 2) {
if (!viewPortHandler.isInBoundsRight(buffer.buffer[i]))
break;
if (!viewPortHandler.isInBoundsLeft(buffer.buffer[i])
|| !viewPortHandler.isInBoundsY(buffer.buffer[i + 1]))
continue;
renderPaint.setColor(dataSet.getColor(i / 2));
tri.moveTo(buffer.buffer[i], buffer.buffer[i + 1] - shapeHalf);
tri.lineTo(buffer.buffer[i] + shapeHalf, buffer.buffer[i + 1] + shapeHalf);
tri.lineTo(buffer.buffer[i] - shapeHalf, buffer.buffer[i + 1] + shapeHalf);
if (shapeSize > 0.0) {
tri.lineTo(buffer.buffer[i], buffer.buffer[i + 1] - shapeHalf);
tri.moveTo(buffer.buffer[i] - shapeHalf + shapeStrokeSize,
buffer.buffer[i + 1] + shapeHalf - shapeStrokeSize);
tri.lineTo(buffer.buffer[i] + shapeHalf - shapeStrokeSize,
buffer.buffer[i + 1] + shapeHalf - shapeStrokeSize);
tri.lineTo(buffer.buffer[i],
buffer.buffer[i + 1] - shapeHalf + shapeStrokeSize);
tri.lineTo(buffer.buffer[i] - shapeHalf + shapeStrokeSize,
buffer.buffer[i + 1] + shapeHalf - shapeStrokeSize);
}
tri.close();
c.drawPath(tri, renderPaint);
tri.reset();
if (shapeSize > 0.0 &&
shapeHoleColor != ColorTemplate.COLOR_NONE) {
renderPaint.setColor(shapeHoleColor);
tri.moveTo(buffer.buffer[i],
buffer.buffer[i + 1] - shapeHalf + shapeStrokeSize);
tri.lineTo(buffer.buffer[i] + shapeHalf - shapeStrokeSize,
buffer.buffer[i + 1] + shapeHalf - shapeStrokeSize);
tri.lineTo(buffer.buffer[i] - shapeHalf + shapeStrokeSize,
buffer.buffer[i + 1] + shapeHalf - shapeStrokeSize);
tri.close();
c.drawPath(tri, renderPaint);
tri.reset();
}
}
}
示例15: renderShape
import com.github.mikephil.charting.utils.ViewPortHandler; //导入方法依赖的package包/类
@Override
public void renderShape(Canvas c, IScatterDataSet dataSet, ViewPortHandler viewPortHandler, ScatterBuffer buffer, Paint
renderPaint, final float shapeSize) {
final float shapeHalf = shapeSize / 2f;
final float shapeHoleSizeHalf = Utils.convertDpToPixel(dataSet.getScatterShapeHoleRadius());
final float shapeHoleSize = shapeHoleSizeHalf * 2.f;
final float shapeStrokeSize = (shapeSize - shapeHoleSize) / 2.f;
final float shapeStrokeSizeHalf = shapeStrokeSize / 2.f;
final int shapeHoleColor = dataSet.getScatterShapeHoleColor();
for (int i = 0; i < buffer.size(); i += 2) {
if (!viewPortHandler.isInBoundsRight(buffer.buffer[i]))
break;
if (!viewPortHandler.isInBoundsLeft(buffer.buffer[i])
|| !viewPortHandler.isInBoundsY(buffer.buffer[i + 1]))
continue;
renderPaint.setColor(dataSet.getColor(i / 2));
if (shapeSize > 0.0) {
renderPaint.setStyle(Paint.Style.STROKE);
renderPaint.setStrokeWidth(shapeStrokeSize);
c.drawRect(buffer.buffer[i] - shapeHoleSizeHalf - shapeStrokeSizeHalf,
buffer.buffer[i + 1] - shapeHoleSizeHalf - shapeStrokeSizeHalf,
buffer.buffer[i] + shapeHoleSizeHalf + shapeStrokeSizeHalf,
buffer.buffer[i + 1] + shapeHoleSizeHalf + shapeStrokeSizeHalf,
renderPaint);
if (shapeHoleColor != ColorTemplate.COLOR_NONE) {
renderPaint.setStyle(Paint.Style.FILL);
renderPaint.setColor(shapeHoleColor);
c.drawRect(buffer.buffer[i] - shapeHoleSizeHalf,
buffer.buffer[i + 1] - shapeHoleSizeHalf,
buffer.buffer[i] + shapeHoleSizeHalf,
buffer.buffer[i + 1] + shapeHoleSizeHalf,
renderPaint);
}
} else {
renderPaint.setStyle(Paint.Style.FILL);
c.drawRect(buffer.buffer[i] - shapeHalf,
buffer.buffer[i + 1] - shapeHalf,
buffer.buffer[i] + shapeHalf,
buffer.buffer[i + 1] + shapeHalf,
renderPaint);
}
}
}