Search in sources :

Example 1 with BorderRender

use of org.xclcharts.renderer.plot.BorderRender in project XCL-Charts by xcltapestry.

the class XChart method setBackgroundColor.

/**
	 * 设置图的渐变背景色
	 * @param direction	渐变方向
	 * @param beginColor 起始颜色
	 * @param endColor	结束颜色
	 */
public void setBackgroundColor(XEnum.Direction direction, int beginColor, int endColor) {
    if (beginColor == endColor) {
        getBackgroundPaint().setColor(beginColor);
    } else {
        LinearGradient linearGradient;
        if (direction == XEnum.Direction.VERTICAL) {
            linearGradient = new LinearGradient(0, 0, 0, getBottom() - getTop(), beginColor, endColor, Shader.TileMode.MIRROR);
        } else {
            linearGradient = new LinearGradient(getLeft(), getBottom(), getRight(), getTop(), beginColor, endColor, Shader.TileMode.CLAMP);
        }
        getBackgroundPaint().setShader(linearGradient);
    }
    if (null == mBorder)
        mBorder = new BorderRender();
    mBorder.getBackgroundPaint().setColor(endColor);
}
Also used : LinearGradient(android.graphics.LinearGradient) BorderRender(org.xclcharts.renderer.plot.BorderRender)

Example 2 with BorderRender

use of org.xclcharts.renderer.plot.BorderRender in project XCL-Charts by xcltapestry.

the class XChart method renderChartBackground.

/**
	 * 绘制图的背景
	 */
protected void renderChartBackground(Canvas canvas) {
    if (this.mBackgroundColorVisible) {
        if (null == mBorder)
            mBorder = new BorderRender();
        if (mShowBorder) {
            mBorder.renderBorder("CHART", canvas, mLeft, mTop, mRight, mBottom);
        } else {
            //要清掉 border的默认间距				
            int borderSpadding = mBorder.getBorderSpadding();
            mBorder.renderBorder("CHART", canvas, mLeft - borderSpadding, mTop - borderSpadding, mRight + borderSpadding, mBottom + borderSpadding);
        }
    }
}
Also used : BorderRender(org.xclcharts.renderer.plot.BorderRender) Paint(android.graphics.Paint) AnchorDataPoint(org.xclcharts.renderer.info.AnchorDataPoint)

Aggregations

BorderRender (org.xclcharts.renderer.plot.BorderRender)2 LinearGradient (android.graphics.LinearGradient)1 Paint (android.graphics.Paint)1 AnchorDataPoint (org.xclcharts.renderer.info.AnchorDataPoint)1