1 package com.github.mikephil.charting.renderer.scatter; 2 3 import android.graphics.Canvas; 4 import android.graphics.Paint; 5 6 import com.github.mikephil.charting.interfaces.datasets.IScatterDataSet; 7 import com.github.mikephil.charting.utils.ColorTemplate; 8 import com.github.mikephil.charting.utils.Utils; 9 import com.github.mikephil.charting.utils.ViewPortHandler; 10 11 /** 12 * Created by wajdic on 15/06/2016. 13 * Created at Time 09:08 14 */ 15 public class CircleShapeRenderer implements IShapeRenderer 16 { 17 18 @Override renderShape(Canvas c, IScatterDataSet dataSet, ViewPortHandler viewPortHandler, float posX, float posY, Paint renderPaint)19 public void renderShape(Canvas c, IScatterDataSet dataSet, ViewPortHandler viewPortHandler, 20 float posX, float posY, Paint renderPaint) { 21 22 final float shapeSize = dataSet.getScatterShapeSize(); 23 final float shapeHalf = shapeSize / 2f; 24 final float shapeHoleSizeHalf = Utils.convertDpToPixel(dataSet.getScatterShapeHoleRadius()); 25 final float shapeHoleSize = shapeHoleSizeHalf * 2.f; 26 final float shapeStrokeSize = (shapeSize - shapeHoleSize) / 2.f; 27 final float shapeStrokeSizeHalf = shapeStrokeSize / 2.f; 28 29 final int shapeHoleColor = dataSet.getScatterShapeHoleColor(); 30 31 if (shapeSize > 0.0) { 32 renderPaint.setStyle(Paint.Style.STROKE); 33 renderPaint.setStrokeWidth(shapeStrokeSize); 34 35 c.drawCircle( 36 posX, 37 posY, 38 shapeHoleSizeHalf + shapeStrokeSizeHalf, 39 renderPaint); 40 41 if (shapeHoleColor != ColorTemplate.COLOR_NONE) { 42 renderPaint.setStyle(Paint.Style.FILL); 43 44 renderPaint.setColor(shapeHoleColor); 45 c.drawCircle( 46 posX, 47 posY, 48 shapeHoleSizeHalf, 49 renderPaint); 50 } 51 } else { 52 renderPaint.setStyle(Paint.Style.FILL); 53 54 c.drawCircle( 55 posX, 56 posY, 57 shapeHalf, 58 renderPaint); 59 } 60 61 } 62 63 } 64