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:gov.sfmta.sfpark.AnnotationsOverlay.java
public void draw(Canvas canvas, MapView mapv, boolean shadow) { if (shadow) { return;/*from w ww . j a v a 2 s . com*/ } Projection projection = mapv.getProjection(); Point from = new Point(); Point to = new Point(); Paint mPaint = new Paint(); mPaint.setStyle(Style.STROKE); mPaint.setAntiAlias(true); mPaint.setStrokeWidth(6); mPaint.setStrokeCap(Paint.Cap.ROUND); // could have NPE: try { for (MyAnnotation a : MainScreenActivity.annotations) { if (a.onStreet) { projection.toPixels(a.nw, from); projection.toPixels(a.se, to); if (MainScreenActivity.showPrice) { mPaint.setColor(a.blockColorPrice); canvas.drawLine(from.x, from.y, to.x, to.y, mPaint); } else { // new: no more availability data on blockfaces. // mPaint.setColor(a.blockColorAvailability); } } } } catch (NullPointerException npe) { // oh sadface! just ignore. } super.draw(canvas, mapv, shadow); }
From source file:com.shawnway.nav.app.wtw.view.PagerSlidingTabStrip.java
private void drawRectangle(Canvas canvas, final int height, View currentTab, float lineLeft, float lineRight) { canvas.drawRect(lineLeft, currentTab.getTop(), lineRight, currentTab.getBottom(), rectPaint); // draw underline rectPaint.setColor(underlineColor);/* w w w.j av a 2s . co m*/ canvas.drawRect(0, height - underlineHeight, tabsContainer.getWidth(), height, rectPaint); // draw divider dividerPaint.setColor(dividerColor); for (int i = 0; i < tabCount - 1; i++) { View tab = tabsContainer.getChildAt(i); canvas.drawLine(tab.getRight(), dividerPadding, tab.getRight(), height - dividerPadding, dividerPaint); } }
From source file:net.exclaimindustries.geohashdroid.util.KnownLocation.java
@NonNull private Bitmap buildMarkerBitmap(@NonNull Context c) { // Oh, this is going to be FUN. int dim = c.getResources().getDimensionPixelSize(R.dimen.known_location_marker_canvas_size); float radius = c.getResources().getDimension(R.dimen.known_location_pin_head_radius); Bitmap bitmap = Bitmap.createBitmap(dim, dim, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); Paint paint = new Paint(); paint.setAntiAlias(true);// w w w. ja v a 2s . c o m KnownLocationPinData pinData = new KnownLocationPinData(c, mLocation); // Draw the pin line first. That goes from the bottom-center up to // wherever the radius and length take us. float topX = Double.valueOf((dim / 2) + (pinData.getLength() * Math.cos(pinData.getAngle()))).floatValue(); float topY = Double.valueOf(dim - (pinData.getLength() * Math.sin(pinData.getAngle()))).floatValue(); paint.setStrokeWidth(c.getResources().getDimension(R.dimen.known_location_stroke)); paint.setStyle(Paint.Style.STROKE); paint.setColor(Color.BLACK); canvas.drawLine(dim / 2, dim, topX, topY, paint); // On the top of that line, fill in a circle. paint.setColor(pinData.getColor()); paint.setStyle(Paint.Style.FILL); canvas.drawCircle(topX, topY, radius, paint); // And outline it. paint.setColor(Color.BLACK); paint.setStyle(Paint.Style.STROKE); canvas.drawCircle(topX, topY, radius, paint); return bitmap; }
From source file:net.yaly.ViewPagerDoubleIndicator.java
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (isInEditMode() || mTabCount == 0) { return;/*from w ww. ja va 2s . c o m*/ } final int height = getHeight(); //TODO // LogUtil.i("onDraw"); mPaintLine.setColor(mBaseLineColor); mPaintLine.setStrokeWidth(4); // canvas.drawLine(0, 0, getWidth(), mIndicatorHeight, mPaintLine); // canvas.drawLine(0, getHeight(), getWidth(), getHeight() - mIndicatorHeight, mPaintLine); // draw divider if (mDividerWidth > 0) { mDividerPaint.setStrokeWidth(mDividerWidth); mDividerPaint.setColor(mDividerColor); for (int i = 0; i < mTabCount - 1; i++) { View tab = mTabsContainer.getChildAt(i); canvas.drawLine(tab.getRight(), mDividerPadding, tab.getRight(), height - mDividerPadding, mDividerPaint); } } // draw underline if (mUnderlineHeight > 0) { mRectPaint.setColor(mUnderlineColor); canvas.drawRect(mPaddingLeft, height - mUnderlineHeight, mTabsContainer.getWidth() + mPaddingRight, height, mRectPaint); } // draw indicator line TODO if (mIndicatorHeight > 0) { mRectPaint.setColor(mIndicatorColor); Pair<Float, Float> lines = getIndicatorCoordinates(); // canvas.drawRect(lines.first + mPaddingLeft, height - mIndicatorHeight, lines.second + mPaddingLeft, height, mRectPaint); // canvas.drawRect(lines.first + mPaddingLeft, 0, lines.second - mPaddingLeft, mIndicatorHeight, mRectPaint); // LogUtil.i(""+""+(height - mIndicatorHeight)+""+height+""+lines.first + mPaddingLeft+"?"+(lines.second + mPaddingLeft)); } }
From source file:com.xiaosu.lib.base.widget.PagerSlidingTabStrip.java
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (isInEditMode() || mTabCount == 0) { return;/* w w w . ja v a 2s . co m*/ } final int height = getHeight(); // draw divider if (mDividerWidth > 0) { mDividerPaint.setStrokeWidth(mDividerWidth); mDividerPaint.setColor(mDividerColor); for (int i = 0; i < mTabCount - 1; i++) { View tab = mTabsContainer.getChildAt(i); canvas.drawLine(tab.getRight(), mDividerPadding, tab.getRight(), height - mDividerPadding, mDividerPaint); } } // draw underline if (mUnderlineHeight > 0) { mRectPaint.setColor(mUnderlineColor); canvas.drawRect(mPaddingLeft, height - mUnderlineHeight, mTabsContainer.getWidth() + mPaddingRight, height, mRectPaint); } // draw indicator line if (mIndicatorHeight > 0) { mRectPaint.setColor(mIndicatorColor); Pair<Float, Float> lines = getIndicatorCoordinates(); canvas.drawRect(lines.first + mPaddingLeft + mIndicatorPadding, height - mIndicatorHeight, lines.second + mPaddingLeft - mIndicatorPadding, height, mRectPaint); } }
From source file:com.zaparound.PagerSlidingTabStrip.java
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (isInEditMode() || mTabCount == 0) { return;//from w ww .j ava2 s . c o m } final int height = getHeight(); // draw divider if (mDividerWidth > 0) { mDividerPaint.setStrokeWidth(mDividerWidth); mDividerPaint.setColor(mDividerColor); for (int i = 0; i < mTabCount; i++) { View tab = mTabsContainer.getChildAt(i); canvas.drawLine(tab.getRight(), mDividerPadding, tab.getRight(), height - mDividerPadding, mDividerPaint); canvas.drawLine(tab.getLeft(), mDividerPadding, tab.getLeft(), height - mDividerPadding, mDividerPaint); } } // draw underline if (mUnderlineHeight > 0) { mRectPaint.setColor(mUnderlineColor); canvas.drawRect(mPaddingLeft, height - mUnderlineHeight, mTabsContainer.getWidth() + mPaddingRight, height, mRectPaint); } // draw indicator line if (mIndicatorHeight > 0) { mRectPaint.setColor(mIndicatorColor); Pair<Float, Float> lines = getIndicatorCoordinates(); canvas.drawRect(lines.first + mPaddingLeft, height - mIndicatorHeight, lines.second + mPaddingLeft, height - 1, mRectPaint); } }
From source file:com.bei.test.view.tab.PagerSlidingTabStrip.java
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (isInEditMode() || mTabCount == 0) { return;//w w w. j ava 2 s . c om } final int height = getHeight(); // draw divider if (mDividerWidth > 0) { mDividerPaint.setStrokeWidth(mDividerWidth); mDividerPaint.setColor(mDividerColor); for (int i = 0; i < mTabCount - 1; i++) { View tab = mTabsContainer.getChildAt(i); canvas.drawLine(tab.getRight(), mDividerPadding, tab.getRight(), height - mDividerPadding, mDividerPaint); } } // draw underline if (mUnderlineHeight > 0) { mRectPaint.setColor(mUnderlineColor); canvas.drawRect(mPaddingLeft, height - mUnderlineHeight, mTabsContainer.getWidth() + mPaddingRight, height, mRectPaint); } // draw indicator line if (mIndicatorHeight > 0) { mRectPaint.setColor(mIndicatorColor); Pair<Float, Float> lines = getIndicatorCoordinates(); canvas.drawRect(lines.first + mPaddingLeft, height - mIndicatorHeight, lines.second + mPaddingLeft, height, mRectPaint); } }
From source file:com.ecomnationmobile.library.Control.PagerSlidingTabStrip.java
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (isInEditMode() || mTabCount == 0) { return;// ww w . jav a 2 s. co m } final int height = getHeight(); // draw horizontal_divider if (mDividerWidth > 0) { mDividerPaint.setStrokeWidth(mDividerWidth); mDividerPaint.setColor(mDividerColor); for (int i = 0; i < mTabCount - 1; i++) { View tab = mTabsContainer.getChildAt(i); canvas.drawLine(tab.getRight(), mDividerPadding, tab.getRight(), height - mDividerPadding, mDividerPaint); } } // draw underline if (mUnderlineHeight > 0) { mRectPaint.setColor(mUnderlineColor); canvas.drawRect(mPaddingLeft, height - mUnderlineHeight, mTabsContainer.getWidth() + mPaddingRight, height, mRectPaint); } // draw indicator line if (mIndicatorHeight > 0) { mRectPaint.setColor(mIndicatorColor); Pair<Float, Float> lines = getIndicatorCoordinates(); canvas.drawRect(lines.first + mPaddingLeft, height - mIndicatorHeight, lines.second + mPaddingLeft, height, mRectPaint); } }
From source file:com.karthikb351.vitinfo2.customwidget.TimeLineView.java
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); width = getWidth();//from ww w . java2s . c o m height = getHeight(); cx = width / 2; cy = PADDING_TOP + CIRCLE_RADIUS; switch (widgetState) { case STATE_CURRENT: rectF.set(cx - BORDER_THICKNESS, cy - BORDER_THICKNESS, cx + BORDER_THICKNESS, cy + BORDER_THICKNESS); mPath.reset(); for (int i = 0; i <= 360; i++) { mPath.addArc(rectF, i, 1); } canvas.drawPath(mPath, paintBorder); case STATE_SCHEDULED: rectF.set(cx - CIRCLE_RADIUS, cy - CIRCLE_RADIUS, cx + CIRCLE_RADIUS, cy + CIRCLE_RADIUS); mPath.reset(); for (int i = 0; i <= 360; i += 1) { mPath.addArc(rectF, i, 1); } canvas.drawPath(mPath, paintRing); break; case STATE_FINISHED: canvas.drawCircle(cx, cy, CIRCLE_RADIUS, paintDot); break; } switch (widgetType) { case TYPE_INITIAL: canvas.drawLine(cx, cy + (11 * density), cx, height, paintLine); break; case TYPE_INNER: canvas.drawLine(cx, cy - (11 * density), cx, 0, paintLine); canvas.drawLine(cx, cy + (11 * density), cx, height, paintLine); break; case TYPE_END: canvas.drawLine(cx, cy - (11 * density), cx, 0, paintLine); break; } }
From source file:ch.pantas.billsplitter.ui.FixedTabsView.java
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); final int height = getHeight(); rectPaint.setColor(indicatorColor);//w ww. j av a 2 s . co m View currentTab = tabsContainer.getChildAt(currentTabPosition); float lineLeft = currentTab.getLeft(); float lineRight = currentTab.getRight(); if (currentPositionOffset > 0f && currentTabPosition < tabCount - 1) { View nextTab = tabsContainer.getChildAt(currentTabPosition + 1); final float nextTabLeft = nextTab.getLeft(); final float nextTabRight = nextTab.getRight(); lineLeft = (currentPositionOffset * nextTabLeft + (1f - currentPositionOffset) * lineLeft); lineRight = (currentPositionOffset * nextTabRight + (1f - currentPositionOffset) * lineRight); } canvas.drawRect(lineLeft, height - indicatorHeight, lineRight, height, rectPaint); dividerPaint.setColor(dividerColor); for (int i = 0; i < tabCount - 1; i++) { View tab = tabsContainer.getChildAt(i); canvas.drawLine(tab.getRight(), dividerPadding, tab.getRight(), height - dividerPadding, dividerPaint); } }