use of android.graphics.RectF in project EazeGraph by blackfizz.
the class BaseBarChart method onLegendDraw.
@Override
protected void onLegendDraw(Canvas _Canvas) {
super.onLegendDraw(_Canvas);
_Canvas.translate(-mCurrentViewport.left, 0);
for (BaseModel model : getLegendData()) {
if (model.canShowLabel()) {
RectF bounds = model.getLegendBounds();
_Canvas.drawText(model.getLegendLabel(), model.getLegendLabelPosition(), bounds.bottom - mMaxFontHeight, mLegendPaint);
_Canvas.drawLine(bounds.centerX(), bounds.bottom - mMaxFontHeight * 2 - mLegendTopPadding, bounds.centerX(), mLegendTopPadding, mLegendPaint);
}
}
}
use of android.graphics.RectF in project EazeGraph by blackfizz.
the class PieChart method onGraphSizeChanged.
@Override
protected void onGraphSizeChanged(int w, int h, int oldw, int oldh) {
super.onGraphSizeChanged(w, h, oldw, oldh);
// Figure out how big we can make the pie.
mPieDiameter = Math.min(w, h);
mPieRadius = mPieDiameter / 2.f;
// calculate the left and right space to be center aligned
float centeredValueWidth = (w - mPieDiameter) / 2f;
float centeredValueHeight = (h - mPieDiameter) / 2f;
mGraphBounds = new RectF(0.0f, 0.0f, mPieDiameter, mPieDiameter);
mGraphBounds.offsetTo(centeredValueWidth, centeredValueHeight);
mCalculatedInnerPadding = (mPieRadius / 100) * mInnerPadding;
mCalculatedInnerPaddingOutline = (mPieRadius / 100) * mInnerPaddingOutline;
mInnerBounds = new RectF(mGraphBounds.centerX() - mCalculatedInnerPadding - mCalculatedInnerPaddingOutline, mGraphBounds.centerY() - mCalculatedInnerPadding - mCalculatedInnerPaddingOutline, mGraphBounds.centerX() + mCalculatedInnerPadding + mCalculatedInnerPaddingOutline, mGraphBounds.centerY() + mCalculatedInnerPadding + mCalculatedInnerPaddingOutline);
mInnerOutlineBounds = new RectF(mGraphBounds.centerX() - mCalculatedInnerPadding, mGraphBounds.centerY() - mCalculatedInnerPadding, mGraphBounds.centerX() + mCalculatedInnerPadding, mGraphBounds.centerY() + mCalculatedInnerPadding);
}
use of android.graphics.RectF in project EazeGraph by blackfizz.
the class StackedBarChart method drawBars.
/**
* Callback method for drawing the bars in the child classes.
* @param _Canvas The canvas object of the graph view.
*/
protected void drawBars(Canvas _Canvas) {
for (StackedBarModel model : mData) {
float lastTop;
float lastBottom = mGraphHeight;
for (int index = 0; index < model.getBars().size(); index++) {
BarModel barModel = model.getBars().get(index);
RectF bounds = barModel.getBarBounds();
mGraphPaint.setColor(barModel.getColor());
float height = (bounds.height() * mRevealValue);
lastTop = lastBottom - height;
_Canvas.drawRect(bounds.left, lastTop, bounds.right, lastBottom, mGraphPaint);
if (mShowValues && barModel.isShowValue()) {
_Canvas.drawText(String.valueOf(barModel.getValue()), bounds.centerX(), (lastTop + height / 2) + barModel.getValueBounds().height() / 2, mTextPaint);
}
lastBottom = lastTop;
if (mShowSeparators && index < model.getBars().size() - 1) {
lastBottom -= mSeparatorWidth;
}
}
}
}
use of android.graphics.RectF in project fresco by facebook.
the class CircleProgressBarDrawable method drawBar.
private void drawBar(Canvas canvas, int level, int color) {
Rect bounds = getBounds();
RectF rectF = new RectF((float) (bounds.right * .4), (float) (bounds.bottom * .4), (float) (bounds.right * .6), (float) (bounds.bottom * .6));
mPaint.setColor(color);
mPaint.setStyle(Paint.Style.STROKE);
mPaint.setStrokeWidth(6);
if (level != 0)
canvas.drawArc(rectF, 0, (float) (level * 360 / maxLevel), false, mPaint);
}
use of android.graphics.RectF in project fresco by facebook.
the class DefaultZoomableController method limitTranslation.
/**
* Limits the translation so that there are no empty spaces on the sides if possible.
*
* <p> The image is attempted to be centered within the view bounds if the transformed image is
* smaller. There will be no empty spaces within the view bounds if the transformed image is
* bigger. This applies to each dimension (horizontal and vertical) independently.
*
* @param limitTypes whether to limit translation along the specific axis.
* @return whether limiting has been applied or not
*/
private boolean limitTranslation(Matrix transform, @LimitFlag int limitTypes) {
if (!shouldLimit(limitTypes, LIMIT_TRANSLATION_X | LIMIT_TRANSLATION_Y)) {
return false;
}
RectF b = mTempRect;
b.set(mImageBounds);
transform.mapRect(b);
float offsetLeft = shouldLimit(limitTypes, LIMIT_TRANSLATION_X) ? getOffset(b.left, b.right, mViewBounds.left, mViewBounds.right, mImageBounds.centerX()) : 0;
float offsetTop = shouldLimit(limitTypes, LIMIT_TRANSLATION_Y) ? getOffset(b.top, b.bottom, mViewBounds.top, mViewBounds.bottom, mImageBounds.centerY()) : 0;
if (offsetLeft != 0 || offsetTop != 0) {
transform.postTranslate(offsetLeft, offsetTop);
return true;
}
return false;
}
Aggregations