use of org.xclcharts.renderer.line.PlotDot in project XCL-Charts by xcltapestry.
the class RadarChart method renderDotAndLabel.
private void renderDotAndLabel(Canvas canvas, RadarData lineData, float currentX, float currentY, int dataID, int childID) {
PlotLine plotLine = lineData.getPlotLine();
float itemAngle = lineData.getItemLabelRotateAngle();
if (!plotLine.getDotStyle().equals(XEnum.DotStyle.HIDE)) {
PlotDot pDot = plotLine.getPlotDot();
float radius = pDot.getDotRadius();
PlotDotRender.getInstance().renderDot(canvas, pDot, currentX, currentY, lineData.getPlotLine().getDotPaint());
savePointRecord(dataID, childID, currentX, currentY, currentX - radius, currentY - radius, currentX + radius, currentY + radius);
}
// 是否显示标签
if (lineData.getLabelVisible()) {
DrawHelper.getInstance().drawRotateText(this.getFormatterDotLabel(lineData.getLinePoint().get(childID)), currentX, currentY, itemAngle, canvas, lineData.getPlotLine().getDotLabelPaint());
}
}
use of org.xclcharts.renderer.line.PlotDot in project XCL-Charts by xcltapestry.
the class LineChart method renderLine.
/**
* 绘制线
* @param canvas 画布
* @param bd 数据类
* @param type 处理类型
*/
private boolean renderLine(Canvas canvas, LineData bd, String type, int dataID) {
if (null == categoryAxis || null == dataAxis)
return false;
if (null == bd) {
Log.i(TAG, "传入的线的数据序列参数为空.");
return false;
}
float initX = plotArea.getLeft();
float initY = plotArea.getBottom();
float lineStartX = initX, lineStartY = initY;
float lineStopX = 0.0f, lineStopY = 0.0f;
// 得到分类轴数据集
List<String> dataSet = categoryAxis.getDataSet();
if (null == dataSet || dataSet.size() == 0) {
Log.w(TAG, "分类轴数据为空.");
return false;
}
// 数据序列
List<Double> chartValues = bd.getLinePoint();
if (null == chartValues || chartValues.size() == 0) {
Log.w(TAG, "当前分类的线数据序列值为空.");
return false;
}
// 步长
float XSteps = 0.0f;
// ,childID = 0;
int j = 0;
int tickCount = dataSet.size();
// label仅一个时右移 !mXCoordFirstTickmarksBegin &&
if (1 == tickCount)
j = 1;
int labeltickCount = getCategoryAxisCount();
XSteps = getVerticalXSteps(labeltickCount);
float itemAngle = bd.getItemLabelRotateAngle();
PlotLine pLine = bd.getPlotLine();
PlotDot pDot = pLine.getPlotDot();
float radius = pDot.getDotRadius();
double bv = 0.d;
// 画线
int count = chartValues.size();
for (int i = 0; i < count; i++) {
bv = chartValues.get(i);
lineStopY = getVPValPosition(bv);
if (mXCoordFirstTickmarksBegin) {
lineStopX = add(initX, mul((j + 1), XSteps));
} else {
lineStopX = add(initX, mul(j, XSteps));
}
// 当柱图与线图混合,且柱图柱形为BarCenterStyle.SPACE时
if (mXCoordFirstTickmarksBegin && XEnum.BarCenterStyle.SPACE == mBarCenterStyle)
lineStopX = sub(lineStopX, div(XSteps, 2));
if (0 == j) {
lineStartX = lineStopX;
lineStartY = lineStopY;
}
if (getLineAxisIntersectVisible() == false && Double.compare(bv, dataAxis.getAxisMin()) == 0) {
// 如果值与最小值相等,即到了轴上,则忽略掉
lineStartX = lineStopX;
lineStartY = lineStopY;
j++;
} else {
if (type.equalsIgnoreCase("LINE")) {
if (getLineAxisIntersectVisible() == true || Float.compare(lineStartY, initY) != 0) {
DrawHelper.getInstance().drawLine(bd.getLineStyle(), lineStartX, lineStartY, lineStopX, lineStopY, canvas, pLine.getLinePaint());
}
} else if (type.equalsIgnoreCase("DOT2LABEL")) {
if (!pLine.getDotStyle().equals(XEnum.DotStyle.HIDE)) {
PlotDotRender.getInstance().renderDot(canvas, pDot, lineStopX, lineStopY, // 标识图形
pLine.getDotPaint());
savePointRecord(dataID, i, lineStopX + mMoveX, lineStopY + mMoveY, lineStopX - radius + mMoveX, lineStopY - radius + mMoveY, lineStopX + radius + mMoveX, lineStopY + radius + mMoveY);
lineStopX = add(lineStopX, radius);
}
// 显示批注形状
drawAnchor(getAnchorDataPoint(), dataID, i, canvas, lineStopX - radius, lineStopY, radius);
if (// 标签
bd.getLabelVisible()) {
bd.getLabelOptions().drawLabel(canvas, pLine.getDotLabelPaint(), getFormatterItemLabel(bv), lineStopX - radius, lineStopY, itemAngle, bd.getLineColor());
}
} else {
// 我不认识你,我不认识你。
Log.w(TAG, "未知的参数标识。");
return false;
}
lineStartX = lineStopX;
lineStartY = lineStopY;
j++;
}
// if(bv != dataAxis.getAxisMin())
}
return true;
}
use of org.xclcharts.renderer.line.PlotDot in project XCL-Charts by xcltapestry.
the class ScatterChart method renderPoints.
private void renderPoints(Canvas canvas, ScatterData bd, int dataID) {
if (null == bd) {
Log.w(TAG, "传入的数据序列参数为空.");
return;
}
if (Double.compare(mMaxValue, mMinValue) == -1) {
Log.w(TAG, "轴最大值小于最小值.");
return;
}
if (Double.compare(mMaxValue, mMinValue) == 0) {
Log.w(TAG, "轴最大值与最小值相等.");
return;
}
float axisDataHeight = dataAxis.getAxisRange();
if (Float.compare(axisDataHeight, 0.0f) == 0 || Float.compare(axisDataHeight, 0.0f) == -1) {
Log.w(TAG, "数据轴高度小于或等于0.");
return;
}
// 得到标签对应的值数据集
List<PointD> chartValues = bd.getDataSet();
if (null == chartValues)
return;
// 画出数据集对应的线条
float YvaluePos = 0.0f, XvaluePos = 0.0f;
float itemAngle = bd.getItemLabelRotateAngle();
PlotDot dot = bd.getPlotDot();
float radius = dot.getDotRadius();
int count = chartValues.size();
for (int i = 0; i < count; i++) {
PointD entry = chartValues.get(i);
XvaluePos = getLnXValPosition(entry.x, mMaxValue, mMinValue);
YvaluePos = getVPValPosition(entry.y);
if (!dot.getDotStyle().equals(XEnum.DotStyle.HIDE)) {
getPointPaint().setColor(dot.getColor());
getPointPaint().setAlpha(dot.getAlpha());
PlotDotRender.getInstance().renderDot(canvas, dot, XvaluePos, YvaluePos, getPointPaint());
savePointRecord(dataID, i, XvaluePos + mMoveX, YvaluePos + mMoveY, XvaluePos - radius + mMoveX, YvaluePos - radius + mMoveY, XvaluePos + radius + mMoveX, YvaluePos + radius + mMoveY);
}
// 显示批注形状
drawAnchor(getAnchorDataPoint(), dataID, i, canvas, XvaluePos, YvaluePos, radius);
if (bd.getLabelVisible()) {
// 请自行在回调函数中处理显示格式
DrawHelper.getInstance().drawRotateText(getFormatterDotLabel(Double.toString(entry.x) + "," + Double.toString(entry.y)), XvaluePos, YvaluePos, itemAngle, canvas, bd.getDotLabelPaint());
}
}
}
use of org.xclcharts.renderer.line.PlotDot in project XCL-Charts by xcltapestry.
the class DyInfo method getContentRect.
private void getContentRect() {
int countDots = (null != mClickedDotStyle) ? mClickedDotStyle.size() : 0;
int countPaint = (null != mClickedPaint) ? mClickedPaint.size() : 0;
int countText = (null != mClickedPaint) ? mClickedPaint.size() : 0;
// if(0 == countText && 0 == countDots ) return;
float textWidth = 0.0f, textHeight = 0.0f;
float maxWidth = 0.0f;
float maxHeight = 0.0f;
float rowWidth = 0.0f;
Paint paint = null;
String text = "";
for (int i = 0; i < countText; i++) {
if (countPaint > i)
paint = mClickedPaint.get(i);
if (null == paint)
break;
text = mClickedText.get(i);
textHeight = DrawHelper.getInstance().getPaintFontHeight(paint);
textWidth = DrawHelper.getInstance().getTextWidth(paint, text);
rowWidth = textWidth;
if (countDots > i) {
PlotDot plot = mClickedDotStyle.get(i);
if (plot.getDotStyle() != XEnum.DotStyle.HIDE) {
rowWidth += textHeight + mColSpan;
}
}
if (Float.compare(rowWidth, maxWidth) == 1) {
maxWidth = rowWidth;
}
maxHeight += textHeight;
}
// paint.reset();
maxHeight += 2 * mMargin + countText * mRowSpan;
maxWidth += 2 * mMargin;
mRectWidth = maxWidth;
mRectHeight = maxHeight;
getInfoRect();
}
use of org.xclcharts.renderer.line.PlotDot in project XCL-Charts by xcltapestry.
the class DyInfo method drawInfo.
protected // hint ToolTips
void drawInfo(// hint ToolTips
Canvas canvas) {
if (validateParams() == false)
return;
int countDots = (null != mClickedDotStyle) ? mClickedDotStyle.size() : 0;
int countPaint = (null != mClickedPaint) ? mClickedPaint.size() : 0;
int countText = (null != mClickedPaint) ? mClickedPaint.size() : 0;
if (0 == countText && 0 == countDots)
return;
getContentRect();
if (null == mRect)
return;
if (XEnum.DyInfoStyle.RECT == mStyle) {
if (mShowBackground)
canvas.drawRect(mRect, this.getBackgroundPaint());
if (mShowBoxBorder)
canvas.drawRect(mRect, this.getBorderPaint());
} else if (XEnum.DyInfoStyle.CAPRECT == mStyle) {
renderCapRect(canvas, mRect);
} else if (XEnum.DyInfoStyle.CAPROUNDRECT == mStyle) {
renderCapRound(canvas, mRect);
} else if (XEnum.DyInfoStyle.CIRCLE == mStyle) {
renderCircle(canvas, mRect);
// }else if(XEnum.DyInfoStyle.ELLIPSE == mStyle){
} else {
if (mShowBackground)
canvas.drawRoundRect(mRect, mRoundRectX, mRoundRectY, this.getBackgroundPaint());
if (mShowBoxBorder)
canvas.drawRoundRect(mRect, mRoundRectX, mRoundRectY, this.getBorderPaint());
}
float currDotsX = mRect.left + mMargin;
float currRowY = mRect.top + mMargin;
float textHeight = 0.0f;
float currTextX = currDotsX;
int j = 0;
for (int i = 0; i < countText; i++) {
if (countPaint > i)
j = i;
if (null == mClickedPaint.get(j))
break;
textHeight = DrawHelper.getInstance().getPaintFontHeight(mClickedPaint.get(j));
if (countDots > i) {
PlotDot plot = mClickedDotStyle.get(i);
if (// 画dot
plot.getDotStyle() != XEnum.DotStyle.HIDE) {
PlotDotRender.getInstance().renderDot(canvas, plot, currDotsX + (textHeight / 2), currRowY + (textHeight / 2), mClickedPaint.get(j));
currTextX = currDotsX + textHeight + mColSpan;
}
}
if (countText > i)
DrawHelper.getInstance().drawText(canvas, mClickedPaint.get(j), mClickedText.get(i), currTextX, currRowY + textHeight);
currRowY += textHeight + mRowSpan;
currTextX = currDotsX;
}
}
Aggregations