Skip to content

Commit

Permalink
Merge pull request #93 from FedericoPonzi/diamond-shape
Browse files Browse the repository at this point in the history
Diamond shape
  • Loading branch information
lecho committed Mar 25, 2015
2 parents a7591d9 + 5412690 commit c073645
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package lecho.lib.hellocharts.model;

public enum ValueShape {
CIRCLE, SQUARE
CIRCLE, SQUARE, DIAMOND
}
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,28 @@ private void drawPoint(Canvas canvas, Line line, PointValue pointValue, float ra
pointPaint);
} else if (ValueShape.CIRCLE.equals(line.getShape())) {
canvas.drawCircle(rawX, rawY, pointRadius, pointPaint);
}else if (ValueShape.DIAMOND.equals(line.getShape()))
{
Path diamond = new Path();

float leftPointX = rawX - pointRadius;
float leftPointY = rawY;
float rightPointY = rawY;
float rightPointX = rawX + pointRadius;
float topPointY = rawY + pointRadius;
float topPointX = rawX;
float bottomPointY = rawY - pointRadius;
float bottomPointX = rawX;


diamond.moveTo(topPointX, topPointY);
diamond.lineTo(rightPointX, rightPointY);
diamond.lineTo(bottomPointX, bottomPointY);
diamond.lineTo(leftPointX, leftPointY);
diamond.lineTo(topPointX, topPointY);
diamond.close();

canvas.drawPath(diamond, pointPaint);
} else {
throw new IllegalArgumentException("Invalid point shape: " + line.getShape());
}
Expand Down

0 comments on commit c073645

Please sign in to comment.