List of usage examples for android.graphics Paint setAntiAlias
public void setAntiAlias(boolean aa)
From source file:net.networksaremadeofstring.rhybudd.RhybuddDock.java
private void drawScale(Canvas canvas, Boolean Colors, int Count, int Max) { RectF faceRect = new RectF(); faceRect.set(10, 10, 190, 190);//w ww . ja v a 2 s. c o m Paint scalePaint = new Paint(); scalePaint.setStyle(Paint.Style.STROKE); scalePaint.setColor(getResources().getColor(R.color.WarningGreen)); scalePaint.setStrokeWidth(1); scalePaint.setAntiAlias(true); scalePaint.setTextSize(12); scalePaint.setTypeface(Typeface.createFromAsset(this.getAssets(), "fonts/chivo.ttf")); scalePaint.setTextAlign(Paint.Align.CENTER); float scalePosition = 10; RectF scaleRect = new RectF(); scaleRect.set(faceRect.left + scalePosition, faceRect.top + scalePosition, faceRect.right - scalePosition, faceRect.bottom - scalePosition); if (!Colors) scalePaint.setColor(Color.WHITE); scalePaint.setStrokeWidth(2); canvas.save(Canvas.MATRIX_SAVE_FLAG); for (int i = 0; i < Max; ++i) { if (Colors) { if (i > 20) scalePaint.setColor(getResources().getColor(R.color.WarningYellow)); if (i > 40) scalePaint.setColor(getResources().getColor(R.color.WarningOrange)); if (i > 60) scalePaint.setColor(getResources().getColor(R.color.WarningRed)); } canvas.drawLine(100, 20, 100, 18, scalePaint); int divisor = 5; if (Max > 100) divisor = 25; if (i % divisor == 0) { canvas.drawText(Integer.toString(i), 100, 16, scalePaint); } canvas.rotate((360.0f / Max), 100, 100); } canvas.restore(); }
From source file:com.cssweb.android.view.FinanceMini.java
public void drawPrice(Canvas canvas) { //canvas.restore(); Paint paint = this.mPaint; paint.setTypeface(Typeface.DEFAULT_BOLD); paint.setAntiAlias(true); if (quoteData != null) { try {/*from w w w .java2 s .c o m*/ JSONArray jArr = quoteData.getJSONArray("data"); JSONObject jo = jArr.getJSONObject(0); paint.setTextAlign(Paint.Align.LEFT); paint.setTextSize(mTextSize); paint.setColor(GlobalColor.colorLabelName); canvas.translate(0, DY); canvas.drawText("", x, y, paint); canvas.translate(0, DY); canvas.drawText("?", x, y, paint); canvas.translate(0, DY); canvas.drawText("", x, y, paint); canvas.translate(0, DY); canvas.drawText("?", x, y, paint); canvas.translate(0, DY); canvas.drawText("", x, y, paint); canvas.translate(0, DY); int syjd = jo.getInt("syjd"); switch (syjd) { case 1: canvas.drawText("()", x, y, paint); break; case 2: canvas.drawText("()", x, y, paint); break; case 3: canvas.drawText("()", x, y, paint); break; case 4: canvas.drawText("()", x, y, paint); break; default: canvas.drawText("", x, y, paint); break; } if (jo.getDouble("wb") < 0) paint.setColor(GlobalColor.colorPriceDown); else if (jo.getDouble("wb") > 0) paint.setColor(GlobalColor.colorpriceUp); else paint.setColor(GlobalColor.colorPriceEqual); paint.setTextAlign(Paint.Align.RIGHT); canvas.translate(width / 2, -DY * 5); if (jo.getInt("tp") == 1) canvas.drawText("", x - tips, y, paint); else canvas.drawText(Utils.dataFormation(jo.getDouble("wb") * 100, 1) + "%", x - tips, y, paint); paint.setColor(GlobalColor.colorStockName); canvas.translate(0, DY); canvas.drawText(Utils.getAmountFormat(jo.getInt("cjsl"), false), x - tips, y, paint); paint.setColor(GlobalColor.colorpriceUp); canvas.translate(0, DY); canvas.drawText(Utils.getAmountFormat(jo.getDouble("wp"), false), x - tips, y, paint); paint.setColor(GlobalColor.colorStockName); canvas.translate(0, DY); canvas.drawText(Utils.dataFormation(jo.getDouble("hs") * 100, 1) + "%", x - tips, y, paint); canvas.translate(0, DY); canvas.drawText(Utils.dataFormation(jo.getDouble("jz"), 1), x - tips, y, paint); canvas.translate(0, DY); canvas.drawText(Utils.dataFormation(jo.getDouble("mgsy"), 2), x - tips, y, paint); paint.setTextAlign(Paint.Align.LEFT); paint.setColor(GlobalColor.colorLabelName); canvas.translate(0, -DY * 5); canvas.drawText("", x, y, paint); canvas.translate(0, DY); canvas.drawText("?", x, y, paint); canvas.translate(0, DY); canvas.drawText("", x, y, paint); canvas.translate(0, DY); canvas.drawText("", x, y, paint); canvas.translate(0, DY); canvas.drawText("?", x, y, paint); canvas.translate(0, DY); if (NameRule.isBond(type)) canvas.drawText("", x, y, paint); else canvas.drawText("PE()", x, y, paint); paint.setTextAlign(Paint.Align.RIGHT); canvas.translate(width / 2, -DY * 5); if (jo.getDouble("wc") < 0) { paint.setColor(GlobalColor.colorPriceDown); canvas.drawText("-" + Utils.getAmountFormat(Math.abs(jo.getDouble("wc")), true), x - tips, y, paint); } else if (jo.getDouble("wc") > 0) { paint.setColor(GlobalColor.colorpriceUp); canvas.drawText(Utils.getAmountFormat(jo.getDouble("wc"), true), x - tips, y, paint); } else { paint.setColor(GlobalColor.colorPriceEqual); canvas.drawText(Utils.getAmountFormat(jo.getDouble("wc"), false), x - tips, y, paint); } paint.setColor(GlobalColor.colorStockName); canvas.translate(0, DY); canvas.drawText(Utils.dataFormation(jo.getDouble("lb"), 1, jo.getInt("tp")), x - tips, y, paint); paint.setColor(GlobalColor.colorPriceDown); canvas.translate(0, DY); canvas.drawText(Utils.getAmountFormat(jo.getDouble("np"), false), x - tips, y, paint); paint.setColor(GlobalColor.colorStockName); canvas.translate(0, DY); canvas.drawText(Utils.getAmountFormat(jo.getDouble("gb"), true), x - tips, y, paint); canvas.translate(0, DY); canvas.drawText(Utils.getAmountFormat(jo.getDouble("ltsl") * 100, true), x - tips, y, paint); canvas.translate(0, DY); if (NameRule.isBond(type)) { canvas.drawText(Utils.dataFormation(jo.getDouble("fullprice"), 1), x - tips, y, paint); } else { canvas.drawText(Utils.dataFormation(jo.getDouble("sy"), 1), x - tips, y, paint); } } catch (JSONException e) { Log.e(TAG, e.toString()); } } }
From source file:com.android.tabletcustomui.views.LeftCircleContainer.java
private void addCircle(int position, final int value, float diff, double ratio) { final int radius = value / 2; final RectF mOval = new RectF(); mOval.set(0 + diff, 0 + diff, value - diff, value - diff); final Paint mPaintClip = new Paint(); mPaintClip.setStyle(Paint.Style.FILL); mPaintClip.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.OVERLAY)); mPaintClip.setAntiAlias(true); final PointF pointF = new PointF(mOval.centerX(), mOval.centerY()); final Path clipPath = new Path(); clipPath.addCircle(pointF.x, pointF.y, (float) (radius * ratio), Path.Direction.CW); View circleView;// w w w. jav a 2 s . c o m if (position == 0) { mPaintClip.setColor(getContext().getResources().getColor(R.color.circle_light_blue)); circleView = new View(getContext()) { @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); canvas.clipPath(clipPath, Region.Op.DIFFERENCE); canvas.drawArc(mOval, 330, 10, true, mPaintClip); canvas.drawArc(mOval, 342, 20, true, mPaintClip); canvas.drawArc(mOval, 4, 10, true, mPaintClip); canvas.drawArc(mOval, 240, 10, true, mPaintClip); canvas.drawArc(mOval, 252, 20, true, mPaintClip); canvas.drawArc(mOval, 275, 10, true, mPaintClip); canvas.drawArc(mOval, 150, 10, true, mPaintClip); canvas.drawArc(mOval, 162, 20, true, mPaintClip); canvas.drawArc(mOval, 185, 10, true, mPaintClip); canvas.drawArc(mOval, 60, 10, true, mPaintClip); canvas.drawArc(mOval, 72, 20, true, mPaintClip); canvas.drawArc(mOval, 95, 10, true, mPaintClip); } }; FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(value, value); layoutParams.gravity = Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL; circleView.setLayoutParams(layoutParams); this.addView(circleView); animateClockWise(circleView); } else if (position == 1) { mPaintClip.setColor(getContext().getResources().getColor(R.color.circle_dark_blue)); circleView = new View(getContext()) { @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); canvas.clipPath(clipPath, Region.Op.DIFFERENCE); canvas.drawCircle(pointF.x, pointF.y, radius, mPaintClip); } }; FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(value, value); layoutParams.gravity = Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL; circleView.setLayoutParams(layoutParams); this.addView(circleView); animateClockWise(circleView); } else if (position == 2) { mPaintClip.setColor(getContext().getResources().getColor(R.color.circle_light_blue)); circleView = new View(getContext()) { @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); canvas.clipPath(clipPath, Region.Op.DIFFERENCE); canvas.drawArc(mOval, 55, 190, true, mPaintClip); } }; FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(value, value); layoutParams.gravity = Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL; circleView.setLayoutParams(layoutParams); this.addView(circleView); animateClockWise(circleView); } else if (position == 3) { mPaintClip.setColor(getContext().getResources().getColor(R.color.circle_light_blue)); circleView = new View(getContext()) { @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); canvas.clipPath(clipPath, Region.Op.DIFFERENCE); canvas.drawArc(mOval, 240, 190, true, mPaintClip); canvas.drawArc(mOval, 80, 150, true, mPaintClip); } }; FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(value, value); layoutParams.gravity = Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL; circleView.setLayoutParams(layoutParams); this.addView(circleView); animateClockWise(circleView); } else if (position == 4) { mPaintClip.setColor(getContext().getResources().getColor(R.color.circle_light_blue)); circleView = new View(getContext()) { @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); canvas.clipPath(clipPath, Region.Op.DIFFERENCE); canvas.drawArc(mOval, 335, 150, true, mPaintClip); canvas.drawArc(mOval, 140, 180, true, mPaintClip); } }; FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(value, value); layoutParams.gravity = Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL; circleView.setLayoutParams(layoutParams); this.addView(circleView); animateClockWise(circleView); } else if (position == 5) { mPaintClip.setColor(getContext().getResources().getColor(R.color.circle_light_grey)); circleView = new View(getContext()) { @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); canvas.clipPath(clipPath, Region.Op.DIFFERENCE); canvas.drawArc(mOval, 330, 150, true, mPaintClip); canvas.drawArc(mOval, 140, 150, true, mPaintClip); } }; FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(value, value); layoutParams.gravity = Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL; circleView.setLayoutParams(layoutParams); this.addView(circleView); animateClockWise(circleView); } else if (position == 6) { mPaintClip.setColor(getContext().getResources().getColor(R.color.circle_purple_color)); circleView = new View(getContext()) { @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); canvas.clipPath(clipPath, Region.Op.DIFFERENCE); canvas.drawArc(mOval, 290, 5, true, mPaintClip); canvas.drawArc(mOval, 297, 20, true, mPaintClip); canvas.drawArc(mOval, 319, 20, true, mPaintClip); canvas.drawArc(mOval, 60, 15, true, mPaintClip); canvas.drawArc(mOval, 77, 8, true, mPaintClip); } }; FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(value, value); layoutParams.gravity = Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL; circleView.setLayoutParams(layoutParams); this.addView(circleView); animateClockWise(circleView); } else if (position == 7) { mPaintClip.setColor(getContext().getResources().getColor(R.color.circle_dark_blue)); circleView = new View(getContext()) { @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); canvas.clipPath(clipPath, Region.Op.DIFFERENCE); canvas.drawArc(mOval, 160, 10, true, mPaintClip); canvas.drawArc(mOval, 172, 30, true, mPaintClip); canvas.drawArc(mOval, 204, 30, true, mPaintClip); canvas.drawArc(mOval, 236, 10, true, mPaintClip); canvas.drawArc(mOval, 20, 20, true, mPaintClip); canvas.drawArc(mOval, 42, 8, true, mPaintClip); } }; FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(value, value); layoutParams.gravity = Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL; circleView.setLayoutParams(layoutParams); this.addView(circleView); animateAntiClockWise(circleView); } }
From source file:com.lemon.lime.MainActivity.java
private void addBarGraphRenderers() { Paint paint = new Paint(); paint.setStrokeWidth(50f);/* w w w. jav a 2s . co m*/ paint.setAntiAlias(true); paint.setColor(Color.argb(200, 56, 138, 252)); BarGraphRenderer barGraphRendererBottom = new BarGraphRenderer(16, paint, false); mVisualizerView.addRenderer(barGraphRendererBottom); Paint paint2 = new Paint(); paint2.setStrokeWidth(12f); paint2.setAntiAlias(true); paint2.setColor(Color.argb(200, 181, 111, 233)); BarGraphRenderer barGraphRendererTop = new BarGraphRenderer(4, paint2, true); mVisualizerView.addRenderer(barGraphRendererTop); }
From source file:com.binu.LogarithmicGraph.DrawGraphAsyncTask.java
@Override protected Object doInBackground(Object[] params) { Bitmap bitmapBackground = Bitmap.createBitmap(mViewWidth, mViewHeight, Bitmap.Config.ARGB_8888); Canvas canvasBackground = new Canvas(bitmapBackground); Paint paint = new Paint(); paint.setStrokeWidth(1f);/*w w w.j ava 2s .com*/ int starty = 0; int endy = mViewHeight; canvasBackground.drawColor(Color.BLACK); double ratio = Math.pow(Math.E, Math.log(MAX_FREQUENCY / MIN_FREQUENCY) / mViewWidth); mLogScaledX_values = new double[mViewWidth]; for (int i = 0; i < mViewWidth; i++) { if (i == 0) { mLogScaledX_values[i] = 20; } else { mLogScaledX_values[i] = mLogScaledX_values[i - 1] * ratio; } } //Major lines for (int i = 0; i < MAJOR_GRIDLINE_POINTS.length; i++) { paint.setColor(ContextCompat.getColor(mContext, R.color.graph_grid_color)); float xStart = (float) findNearestNumberPosition(mLogScaledX_values, MAJOR_GRIDLINE_POINTS[i]); float textSize = (getPixelDensity(mContext) * mLabelTextSize) / 480; paint.setTextSize(textSize); Log.i("Density", "" + getPixelDensity(mContext)); if (Math.round(MAJOR_GRIDLINE_POINTS[i]) == 20) { if (isShowLabels()) canvasBackground.drawText(getFormattedLabel(MAJOR_GRIDLINE_POINTS[i]), xStart + (getPixelDensity(mContext) * 10) / 480, endy - (getPixelDensity(mContext) * 10) / 480, paint); } else if (Math.round(MAJOR_GRIDLINE_POINTS[i]) == 20000) { if (isShowLabels()) canvasBackground.drawText(getFormattedLabel(MAJOR_GRIDLINE_POINTS[i]), xStart - (getPixelDensity(mContext) * 70) / 480, endy - (getPixelDensity(mContext) * 10) / 480, paint); } else { if (isShowLabels()) canvasBackground.drawText(getFormattedLabel(MAJOR_GRIDLINE_POINTS[i]), xStart - (getPixelDensity(mContext) * 30) / 480, endy - (getPixelDensity(mContext) * 10) / 480, paint); canvasBackground.drawLine(xStart, starty, xStart + 1, endy, paint); } } //Minor lines for (int i = 0; i < MINOR_GRIDLINE_POINTS.length; i++) { paint.setColor(ContextCompat.getColor(mContext, R.color.graph_grid_color_dull)); float xStart = (float) findNearestNumberPosition(mLogScaledX_values, MINOR_GRIDLINE_POINTS[i]); canvasBackground.drawLine(xStart, starty, xStart + 1, endy, paint); if (isShowLabels()) { paint.setColor(ContextCompat.getColor(mContext, R.color.graph_grid_color)); if (MINOR_GRIDLINE_POINTS[i] == 50 || MINOR_GRIDLINE_POINTS[i] == 500 || MINOR_GRIDLINE_POINTS[i] == 5000) canvasBackground.drawText(getFormattedLabel(MINOR_GRIDLINE_POINTS[i]), xStart - (getPixelDensity(mContext) * 30) / 480, endy - (getPixelDensity(mContext) * 10) / 480, paint); } } float[] Y_points = calculateGraphYAxis(); float div = mViewHeight / (Y_points.length - 1); //Level lines for (int i = 0; i < Y_points.length - 1; i++) { paint.setColor(ContextCompat.getColor(mContext, R.color.graph_grid_color_dull)); canvasBackground.drawLine(0, div * (i + 1), mViewWidth, (div * (i + 1)) + 1, paint); } //Level labels if (isShowLabels()) { for (int i = 0; i < Y_points.length; i++) { paint.setColor(ContextCompat.getColor(mContext, R.color.graph_grid_color)); if (i == 0) canvasBackground.drawText("dB", 0, (div * i) + (getPixelDensity(mContext) * 50) / 480, paint); else if (i == Y_points.length - 1) canvasBackground.drawText("", 0, div * i, paint); else canvasBackground.drawText("" + Math.round(Y_points[i]), 0, div * i, paint); } } BitmapDrawable drawable = new BitmapDrawable(mContext.getResources(), bitmapBackground); mDrawableBackground = drawable; //Plotting the curve points Bitmap bitmapForeground = Bitmap.createBitmap(mViewWidth, mViewHeight, Bitmap.Config.ARGB_8888); Canvas canvasForeground = new Canvas(bitmapForeground); Paint plotPaint = new Paint(); plotPaint.setStyle(Paint.Style.STROKE); plotPaint.setStrokeCap(Paint.Cap.ROUND); plotPaint.setStrokeWidth(PLOT_THICKNESS); plotPaint.setAntiAlias(true); plotPaint.setColor(ContextCompat.getColor(mContext, R.color.graph_plot_color)); for (int i = 0; i < X_values.length; i++) { // canvasForeground.drawCircle(i, mViewHeight - mPlotPoint[i], 2f, plotPaint); /*float startX, float startY, float stopX, float stopY, @NonNull Paint paint*/ float startX = (float) getGetPixelValueForX(X_values[i]); float startY = mViewHeight - getPixelValueFromdB((int) GAIN_MAX, (int) GAIN_MIN, mViewHeight, Y_values[i]); float stopX; float stopY; if (i == X_values.length - 1) { stopX = (float) getGetPixelValueForX(X_values[i]); stopY = mViewHeight - getPixelValueFromdB((int) GAIN_MAX, (int) GAIN_MIN, mViewHeight, Y_values[i]); } else { stopX = (float) getGetPixelValueForX(X_values[i + 1]); stopY = mViewHeight - getPixelValueFromdB((int) GAIN_MAX, (int) GAIN_MIN, mViewHeight, Y_values[i + 1]); } canvasForeground.drawLine(startX, startY, stopX, stopY, plotPaint); } BitmapDrawable drawableFore = new BitmapDrawable(mContext.getResources(), bitmapForeground); mDrawableForeground = drawableFore; return null; }
From source file:com.yaozu.object.widget.PagerSlidingTabStrip.java
public PagerSlidingTabStrip(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); setFillViewport(true);/* w ww . j a va2 s .co m*/ setWillNotDraw(false); tabsContainer = new LinearLayout(context); tabsContainer.setOrientation(LinearLayout.HORIZONTAL); tabsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); tabsContainer.setGravity(Gravity.CENTER_VERTICAL); // ? addView(tabsContainer); DisplayMetrics dm = getResources().getDisplayMetrics(); //scrollOffset = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, scrollOffset, dm); mScrollOffset = dm.widthPixels / 2; indicatorHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, indicatorHeight, dm); underlineHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, underlineHeight, dm); dividerPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerPadding, dm); tabPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabPadding, dm); // add by hangl begin tabPaddingVertical = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabPaddingVertical, dm); // add by hangl end dividerWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerWidth, dm); tabTextSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabTextSize, dm); // change sp to dp // get system attrs (android:textSize and android:textColor) TypedArray a = context.obtainStyledAttributes(attrs, ATTRS); tabTextSize = a.getDimensionPixelSize(0, tabTextSize); a.recycle(); // get custom attrs a = context.obtainStyledAttributes(attrs, R.styleable.PagerSlidingTabStrip); tabTextColor = a.getColor(R.styleable.PagerSlidingTabStrip_tabTextColor, tabTextColor); indicatorColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsIndicatorColor, indicatorColor); underlineColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsUnderlineColor, underlineColor); dividerColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsDividerColor, dividerColor); tabTextSize = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_tabTextSize, tabTextSize); // add by hangl begin tabTextColorNormal = a.getColor(R.styleable.PagerSlidingTabStrip_pstsTextNormalColor, tabTextColorNormal); tabTextColorSelected = a.getColor(R.styleable.PagerSlidingTabStrip_pstsTextSelectedColor, tabTextColorSelected); tabPaddingVertical = a.getDimensionPixelOffset(R.styleable.PagerSlidingTabStrip_pstsTabPaddingVertical, tabPaddingVertical); expandViewWidth = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsExpandViewWidth, expandViewWidth); // add by hangl end indicatorHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsIndicatorHeight, indicatorHeight); underlineHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsUnderlineHeight, underlineHeight); dividerPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsDividerPadding, dividerPadding); tabPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsTabPaddingLeftRight, tabPadding); tabBackgroundResId = a.getResourceId(R.styleable.PagerSlidingTabStrip_pstsTabBackground, tabBackgroundResId); shouldExpand = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsShouldExpand, shouldExpand); mScrollOffset = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsScrollOffset, mScrollOffset); textAllCaps = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsTextAllCaps, textAllCaps); a.recycle(); rectPaint = new Paint(); rectPaint.setAntiAlias(true); rectPaint.setStyle(Style.FILL); Paint dividerPaint = new Paint(); dividerPaint.setAntiAlias(true); dividerPaint.setStrokeWidth(dividerWidth); defaultTabLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); expandedTabLayoutParams = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f); if (locale == null) { locale = getResources().getConfiguration().locale; } }
From source file:com.linhnv.apps.maxim.utils.ImageWorker.java
private BitmapDrawable roundCornered(BitmapDrawable scaledBitmap, int i) { Bitmap bitmap = scaledBitmap.getBitmap(); Bitmap result = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(result); int color = 0xff424242; Paint paint = new Paint(); Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()); RectF rectF = new RectF(rect); int roundPx = i; paint.setAntiAlias(true); canvas.drawARGB(0, 0, 0, 0);/*from ww w. j a v a 2s . c om*/ // paint.setColor(Color.BLUE); canvas.drawRoundRect(rectF, roundPx, roundPx, paint); paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN)); canvas.drawBitmap(bitmap, rect, rect, paint); BitmapDrawable finalresult = new BitmapDrawable(mResources, result); return finalresult; }
From source file:com.gmail.walles.johan.batterylogger.BatteryPlotFragment.java
private void addPlotData(final XYPlot plot) { LineAndPointFormatter medianFormatter = getMedianFormatter(); try {//from www .jav a 2 s .c o m // Add battery drain series to the plot History history = new History(getActivity()); if (history.isEmpty() && BuildConfig.DEBUG && isRunningOnEmulator()) { history = History.createFakeHistory(); } drainDots = history.getBatteryDrain(); enableDrainDots(plot); final List<XYSeries> medians = history.getDrainLines(); for (XYSeries median : medians) { plot.addSeries(median, medianFormatter); } // Add red restart lines to the plot Paint restartPaint = new Paint(); restartPaint.setAntiAlias(true); restartPaint.setColor(Color.RED); restartPaint.setStrokeWidth(dpToPixels(0.5f)); plot.addSeries(history.getEvents(), new RestartFormatter(restartPaint)); // Add events to the plot Paint labelPaint = new Paint(); labelPaint.setAntiAlias(true); labelPaint.setColor(Color.WHITE); labelPaint.setTextSize(spToPixels(IN_GRAPH_TEXT_SIZE_SP)); eventFormatter = new EventFormatter(labelPaint); plot.addSeries(history.getEvents(), eventFormatter); if (history.isEmpty()) { showAlertDialogOnce("No Battery History Recorded", "Come back in a few hours to get a graph, or in a week to be able to see patterns."); } else if (medians.size() < 5) { showAlertDialogOnce("Very Short Battery History Recorded", "If you come back in a week you'll be able to see patterns much better."); } } catch (IOException e) { Log.e(TAG, "Reading battery history failed", e); showAlertDialog("Reading Battery History Failed", e.getMessage()); } }
From source file:com.acceleratedio.pac_n_zoom.DrawSVG.java
public ArrayList<ImageView> DrawSVG(Context context, ImageView orgnlImageView, RelativeLayout rel_anm_lo) { paint.setColor(Color.WHITE);//from w w w . ja va2 s . c om paint.setStyle(Paint.Style.FILL); LoadSVG.SVGData data = AnimActivity.svg_data; ArrayList<ImageView> imgViews = new ArrayList<ImageView>(); imgViews.add(orgnlImageView); if (data.symbl != null) { ArrayList<String> sprt_ordr = data.svg.ordr; int sym_mbr = 0; Bitmap bitmap; Canvas canvas; // - Loop through the sprites int sprt_nmbr = sprt_ordr.size(); data.svg.initScl = new float[sprt_nmbr]; float[] initScl = data.svg.initScl; for (int sprt_mbr = 1; sprt_mbr < sprt_nmbr; sprt_mbr += 1) { String sprt_id = sprt_ordr.get(sprt_mbr); // e.g., id="g2_0" if (Integer.parseInt(sprt_id.substring(sprt_id.indexOf('_') + 1)) > 0) { // The symbol is already drawn; replicate the view String init_sprt = sprt_id.substring(0, sprt_id.indexOf('_') + 1) + '0'; String svg_ordr = data.svg.svg_ordr; String cnt_str = svg_ordr.substring(0, svg_ordr.indexOf(init_sprt)); ImageView init_vw = imgViews.get(StringUtils.countMatches(cnt_str, ",")); Bitmap initBmp = ((BitmapDrawable) init_vw.getDrawable()).getBitmap(); bitmap = Bitmap.createBitmap(initBmp.getWidth(), initBmp.getHeight(), initBmp.getConfig()); canvas = new Canvas(bitmap); canvas.save(Canvas.MATRIX_SAVE_FLAG); xfrmInit crt_sprt = getInitSpriteAttrib(sprt_id); canvas.scale(crt_sprt.scl, crt_sprt.scl); initScl[sprt_mbr] = crt_sprt.scl; canvas.translate(0, 0); } else { // The symbol needs to be drawn; a new view is used bitmap = getCreatBmp(rel_anm_lo); canvas = new Canvas(bitmap); canvas.save(Canvas.MATRIX_SAVE_FLAG); // - Set the init values xfrmInit crt_sprt = getInitSpriteAttrib(sprt_id); canvas.scale(crt_sprt.scl, crt_sprt.scl); initScl[sprt_mbr] = crt_sprt.scl; canvas.translate(0, 0); // - Draw the bitmap LoadSVG.symbol crt_sym = data.symbl.get(sym_mbr); ArrayList<LoadSVG.path> pths = crt_sym.pths; int pth_nmbr = pths.size(); // Loop through the paths for (int pth_mbr = 0; pth_mbr < pth_nmbr; pth_mbr += 1) { LoadSVG.path crt_pth = pths.get(pth_mbr); final Path path = new Path(); final Paint paint = new Paint(); /* Debug if (pth_mbr + 1 == pth_nmbr) { String log_str = "Paths: pth_mbr = " + String.valueOf(pth_mbr) + "; color = " + crt_pth.clr; Log.d("DrawSVG", log_str); } */ paint.setColor(Color.parseColor(crt_pth.clr)); paint.setAntiAlias(true); paint.setStyle(Paint.Style.FILL_AND_STROKE); ld_pth_pnts(crt_pth.pth, path); path.close(); path.setFillType(Path.FillType.EVEN_ODD); canvas.drawPath(path, paint); } canvas.restore(); sym_mbr += 1; } ImageView iv = new ImageView(context); iv.setImageBitmap(bitmap); RelativeLayout.LayoutParams rlp = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT); iv.draw(canvas); iv.setLayoutParams(rlp); iv.setBackgroundColor(Color.TRANSPARENT); imgViews.add(iv); } // sprites } // if symbol return imgViews; }
From source file:com.waz.zclient.pages.main.conversation.LocationFragment.java
private Bitmap getMarker() { if (marker != null) { return marker; }/*from w w w. j a v a 2 s . c om*/ int size = getResources().getDimensionPixelSize(R.dimen.share_location__current_location_marker__size); int outerCircleRadius = getResources() .getDimensionPixelSize(R.dimen.share_location__current_location_marker__outer_ring_radius); int midCircleRadius = getResources() .getDimensionPixelSize(R.dimen.share_location__current_location_marker__mid_ring_radius); int innerCircleRadius = getResources() .getDimensionPixelSize(R.dimen.share_location__current_location_marker__inner_ring_radius); Bitmap bitmap = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); Paint paint = new Paint(); paint.setColor(getControllerFactory().getAccentColorController().getColor()); paint.setAntiAlias(true); paint.setStyle(Paint.Style.FILL); paint.setAlpha( getResources().getInteger(R.integer.share_location__current_location_marker__outer_ring_alpha)); canvas.drawCircle(size / 2, size / 2, outerCircleRadius, paint); paint.setAlpha( getResources().getInteger(R.integer.share_location__current_location_marker__mid_ring_alpha)); canvas.drawCircle(size / 2, size / 2, midCircleRadius, paint); paint.setAlpha( getResources().getInteger(R.integer.share_location__current_location_marker__inner_ring_alpha)); canvas.drawCircle(size / 2, size / 2, innerCircleRadius, paint); marker = bitmap; return marker; }