List of usage examples for android.graphics Canvas drawLine
public void drawLine(float startX, float startY, float stopX, float stopY, @NonNull Paint paint)
From source file:com.linkloving.dyh08.logic.UI.launch.view.wheelview.WheelView.java
/** * Draws rect for current value/*from w w w.j a v a2s . com*/ * * @param canvas the canvas for drawing */ private void drawCenterRect(Canvas canvas) { int center = getHeight() / 2; int offset = (int) (getItemHeight() / 2 * 1.2); // Remarked by wulianghuan // Rect rect = new Rect(left, top, right, bottom) // centerDrawable.setBounds(bounds) // centerDrawable.setBounds(0, center - offset, getWidth(), center + offset); // centerDrawable.draw(canvas); Paint paint = new Paint(); paint.setColor(Color.parseColor("#FFD0D0D0")); // paint.setStrokeWidth((float) 1); // canvas.drawLine(0, center - offset, getWidth(), center - offset, paint); // canvas.drawLine(0, center + offset, getWidth(), center + offset, paint); // */ }
From source file:com.wiipu.bimu.adapter.AreaSelect.WheelView.java
/** * Draws rect for current value/* w ww . j a v a 2 s . c om*/ * @param canvas the canvas for drawing */ private void drawCenterRect(Canvas canvas) { int center = getHeight() / 2; int offset = (int) (getItemHeight() / 2 * 1.2); /*/ Remarked by wulianghuan 2014-11-27 ??? Rect rect = new Rect(left, top, right, bottom) centerDrawable.setBounds(bounds) centerDrawable.setBounds(0, center - offset, getWidth(), center + offset); centerDrawable.draw(canvas); //*/ Paint paint = new Paint(); paint.setColor(Color.parseColor("#999999")); // paint.setStrokeWidth((float) 3); // canvas.drawLine(0, center - offset, getWidth(), center - offset, paint); // canvas.drawLine(0, center + offset, getWidth(), center + offset, paint); //*/ }
From source file:de.vanita5.twittnuker.view.LinePageIndicator.java
@Override protected void onDraw(final Canvas canvas) { super.onDraw(canvas); if (mViewPager == null) return;/*from w w w . java2 s . c om*/ final int count = mViewPager.getAdapter().getCount(); if (count == 0) return; if (mCurrentPage >= count) { setCurrentItem(count - 1); return; } final float lineWidthAndGap = mLineWidth + mGapWidth; final float indicatorWidth = count * lineWidthAndGap - mGapWidth; final float paddingTop = getPaddingTop(); final float paddingLeft = getPaddingLeft(); final float paddingRight = getPaddingRight(); final float verticalOffset = paddingTop + (getHeight() - paddingTop - getPaddingBottom()) / 2.0f; float horizontalOffset = paddingLeft; if (mCentered) { horizontalOffset += (getWidth() - paddingLeft - paddingRight) / 2.0f - indicatorWidth / 2.0f; } // Draw stroked circles for (int i = 0; i < count; i++) { final float dx1 = horizontalOffset + i * lineWidthAndGap; final float dx2 = dx1 + mLineWidth; canvas.drawLine(dx1, verticalOffset, dx2, verticalOffset, i == mCurrentPage ? mPaintSelected : mPaintUnselected); } }
From source file:com.benefit.buy.library.viewpagerindicator.LinePageIndicator.java
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (mViewPager == null) { return;//from w ww. j a va 2 s . com } final int count = mViewPager.getAdapter().getCount(); if (count == 0) { return; } if (mCurrentPage >= count) { setCurrentItem(count - 1); return; } final float lineWidthAndGap = mLineWidth + mGapWidth; final float indicatorWidth = (count * lineWidthAndGap) - mGapWidth; final float paddingTop = getPaddingTop(); final float paddingLeft = getPaddingLeft(); final float paddingRight = getPaddingRight(); float verticalOffset = paddingTop + ((getHeight() - paddingTop - getPaddingBottom()) / 2.0f); float horizontalOffset = paddingLeft; if (mCentered) { horizontalOffset += ((getWidth() - paddingLeft - paddingRight) / 2.0f) - (indicatorWidth / 2.0f); } // Draw stroked circles for (int i = 0; i < count; i++) { float dx1 = horizontalOffset + (i * lineWidthAndGap); float dx2 = dx1 + mLineWidth; canvas.drawLine(dx1, verticalOffset, dx2, verticalOffset, (i == mCurrentPage) ? mPaintSelected : mPaintUnselected); } }
From source file:com.tsingning.view.TabPageIndicators.LinePageIndicator.java
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (mViewPager == null) { return;//from ww w. j ava 2 s . co m } final int count = mViewPager.getAdapter().getCount(); if (count == 0) { return; } if (mCurrentPage >= count) { setCurrentItem(count - 1); return; } final float lineWidthAndGap = mLineWidth + mGapWidth; final float indicatorWidth = count * lineWidthAndGap - mGapWidth; final float paddingTop = getPaddingTop(); final float paddingLeft = getPaddingLeft(); final float paddingRight = getPaddingRight(); float verticalOffset = paddingTop + (getHeight() - paddingTop - getPaddingBottom()) / 2.0f; float horizontalOffset = paddingLeft; if (mCentered) { horizontalOffset += (getWidth() - paddingLeft - paddingRight) / 2.0f - indicatorWidth / 2.0f; } //Draw stroked circles for (int i = 0; i < count; i++) { float dx1 = horizontalOffset + i * lineWidthAndGap; float dx2 = dx1 + mLineWidth; canvas.drawLine(dx1, verticalOffset, dx2, verticalOffset, i == mCurrentPage ? mPaintSelected : mPaintUnselected); } }
From source file:com.along.altmcssd.pda.widget.viewpagerindicator.LinePageIndicator.java
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (mViewPager == null) { return;/*from w w w . ja v a 2 s . c o m*/ } final int count = mViewPager.getAdapter().getCount(); if (count == 0) { return; } if (mCurrentPage >= count) { setCurrentItem(count - 1); return; } final float lineWidthAndGap = mLineWidth + mGapWidth; final float indicatorWidth = (count * lineWidthAndGap) - mGapWidth; final float paddingTop = getPaddingTop(); final float paddingLeft = getPaddingLeft(); final float paddingRight = getPaddingRight(); float verticalOffset = paddingTop + ((getHeight() - paddingTop - getPaddingBottom()) / 2.0f); float horizontalOffset = paddingLeft; if (mCentered) { horizontalOffset += ((getWidth() - paddingLeft - paddingRight) / 2.0f) - (indicatorWidth / 2.0f); } // Draw stroked circles for (int i = 0; i < count; i++) { float dx1 = horizontalOffset + (i * lineWidthAndGap); float dx2 = dx1 + mLineWidth; canvas.drawLine(dx1, verticalOffset, dx2, verticalOffset, (i == mCurrentPage) ? mPaintSelected : mPaintUnselected); } }
From source file:android.hqs.view.pager.indicator.LinePageIndicator.java
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (mViewPager == null) { return;/*ww w . j a va 2s. c om*/ } final int count = mViewPager.getAdapter().getCount(); if (count == 0) { return; } if (mCurrentPage >= count) { setCurrentItem(count - 1); return; } final float lineWidthAndGap = mLineWidth + mGapWidth; final float indicatorWidth = (count * lineWidthAndGap) - mGapWidth; final float paddingTop = getPaddingTop(); final float paddingLeft = getPaddingLeft(); final float paddingRight = getPaddingRight(); float verticalOffset = paddingTop + ((getHeight() - paddingTop - getPaddingBottom()) / 2.0f); float horizontalOffset = paddingLeft; if (mCentered) { horizontalOffset += ((getWidth() - paddingLeft - paddingRight) / 2.0f) - (indicatorWidth / 2.0f); } //Draw stroked circles for (int i = 0; i < count; i++) { float dx1 = horizontalOffset + (i * lineWidthAndGap); float dx2 = dx1 + mLineWidth; canvas.drawLine(dx1, verticalOffset, dx2, verticalOffset, (i == mCurrentPage) ? mPaintSelected : mPaintUnselected); } }
From source file:com.velocityviewpagerindicator.VelocityLinePageIndicator.java
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (mVelocityViewPager == null) { return;/*from w w w . j a v a 2s. co m*/ } final int count = mVelocityViewPager.getAdapter().getCount(); if (count == 0) { return; } if (mCurrentPage >= count) { setCurrentItem(count - 1); return; } final float lineWidthAndGap = mLineWidth + mGapWidth; final float indicatorWidth = (count * lineWidthAndGap) - mGapWidth; final float paddingTop = getPaddingTop(); final float paddingLeft = getPaddingLeft(); final float paddingRight = getPaddingRight(); float verticalOffset = paddingTop + ((getHeight() - paddingTop - getPaddingBottom()) / 2.0f); float horizontalOffset = paddingLeft; if (mCentered) { horizontalOffset += ((getWidth() - paddingLeft - paddingRight) / 2.0f) - (indicatorWidth / 2.0f); } //Draw stroked circles for (int i = 0; i < count; i++) { float dx1 = horizontalOffset + (i * lineWidthAndGap); float dx2 = dx1 + mLineWidth; canvas.drawLine(dx1, verticalOffset, dx2, verticalOffset, (i == mCurrentPage) ? mPaintSelected : mPaintUnselected); } }
From source file:cn.chuangblog.simplebanner1.indicator.LinePageIndicator.java
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (mViewPager == null) { return;/*from w w w . j ava 2 s.com*/ } final int count = InfiniteViewPager.FakePositionHelper.getAdapterSize(mViewPager); if (count == 0) { return; } if (mCurrentPage >= count) { setCurrentItem(count - 1); return; } final float lineWidthAndGap = mLineWidth + mGapWidth; final float indicatorWidth = (count * lineWidthAndGap) - mGapWidth; final float paddingTop = getPaddingTop(); final float paddingLeft = getPaddingLeft(); final float paddingRight = getPaddingRight(); float verticalOffset = paddingTop + ((getHeight() - paddingTop - getPaddingBottom()) / 2.0f); float horizontalOffset = paddingLeft; if (mCentered) { horizontalOffset += ((getWidth() - paddingLeft - paddingRight) / 2.0f) - (indicatorWidth / 2.0f); } //Draw stroked circles for (int i = 0; i < count; i++) { float dx1 = horizontalOffset + (i * lineWidthAndGap); float dx2 = dx1 + mLineWidth; canvas.drawLine(dx1, verticalOffset, dx2, verticalOffset, (i == mCurrentPage) ? mPaintSelected : mPaintUnselected); } }
From source file:com.dirkgassen.wator.ui.view.RollingGraphView.java
/** * Paints the data points of one series vertically. * * @param c canvas to paint to// w ww . j a va 2s .c o m * @param nameBounds bounds of the label * @param seriesNo index of the series to paint * @param width width of the view * @param height height of the view * @param maxValue calculated possible maximum data value */ private void paintSeriesVertical(Canvas c, Rect nameBounds, int seriesNo, int width, @SuppressWarnings("UnusedParameters") int height, float maxValue) { float paddingLeft = getPaddingLeft(); float paddingTop = getPaddingTop(); float paddingRight = getPaddingRight(); float paddingBottom = getPaddingBottom(); float y = nameBounds.height() + paddingTop; float x; if (currentValue == -1) { x = (width - paddingLeft - paddingRight) / (seriesNames.length + 1) * (seriesNo + 1) + paddingLeft; } else { if (dataValues == null) { Log.e("Wa-Tor", "NO DATA VALUES although currentValue is " + currentValue); } else if (dataValues[currentValue] == null) { Log.e("Wa-Tor", "NO SERIES DATA although currentValue is " + currentValue); } x = dataValues[currentValue][seriesNo] * (width - paddingLeft - paddingRight) / maxValue + paddingLeft; } c.drawText(seriesNames[seriesNo], x - nameBounds.width() / 2, y, seriesPaints[seriesNo]); float scale = seriesPaints[seriesNo].getStrokeWidth(); y += 6f * scale; c.drawLine(x, y, x, y - 3f * scale, seriesPaints[seriesNo]); c.drawLine(x, y, x - 1.5f * scale, y - 1.5f * scale, seriesPaints[seriesNo]); c.drawLine(x, y, x + 1.5f * scale, y - 1.5f * scale, seriesPaints[seriesNo]); if (currentValue != -1) { int no = currentValue; do { if (dataValues[no] == null) { break; } float newX = dataValues[no][seriesNo] * (width - paddingLeft - paddingRight) / maxValue + paddingLeft; float newY = y + 1; c.drawLine(x, y, newX, newY, seriesPaints[seriesNo]); x = newX; y = newY; no = no == 0 ? dataValues.length - 1 : no - 1; } while (no != oldestValue && y < height - paddingBottom); } }