List of usage examples for android.graphics Paint setStyle
public void setStyle(Style style)
From source file:com.concavenp.artistrymuse.BaseAppCompatActivity.java
private BitmapImageViewTarget createBitmapImageViewTarget(final ImageView imageView) { return new BitmapImageViewTarget(imageView) { @Override//from w w w . jav a2 s .c o m protected void setResource(Bitmap bitmap) { int bitmapWidth = bitmap.getWidth(); int bitmapHeight = bitmap.getHeight(); int borderWidthHalf = 10; int bitmapSquareWidth = Math.min(bitmapWidth, bitmapHeight); int newBitmapSquare = bitmapSquareWidth + borderWidthHalf; Bitmap roundedBitmap = Bitmap.createBitmap(newBitmapSquare, newBitmapSquare, Bitmap.Config.ARGB_8888); // Initialize a new Canvas to draw empty bitmap Canvas canvas = new Canvas(roundedBitmap); // Calculation to draw bitmap at the circular bitmap center position int x = borderWidthHalf + bitmapSquareWidth - bitmapWidth; int y = borderWidthHalf + bitmapSquareWidth - bitmapHeight; canvas.drawBitmap(bitmap, x, y, null); // Initializing a new Paint instance to draw circular border Paint borderPaint = new Paint(); borderPaint.setStyle(Paint.Style.STROKE); borderPaint.setStrokeWidth(borderWidthHalf * 2); borderPaint.setColor(ResourcesCompat.getColor(getResources(), R.color.myApp_accent_700, null)); canvas.drawCircle(canvas.getWidth() / 2, canvas.getWidth() / 2, newBitmapSquare / 2, borderPaint); RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(getResources(), roundedBitmap); circularBitmapDrawable.setCircular(true); imageView.setImageDrawable(circularBitmapDrawable); } }; }
From source file:com.dgnt.dominionCardPicker.view.DynamicListView.java
/** Draws a black border over the screenshot of the view passed in. */ private Bitmap getBitmapWithBorder(View v) { Bitmap bitmap = getBitmapFromView(v); Canvas can = new Canvas(bitmap); Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()); Paint paint = new Paint(); paint.setStyle(Paint.Style.STROKE); paint.setStrokeWidth(LINE_THICKNESS); paint.setColor(ContextCompat.getColor(getContext(), R.color.colorAccent)); can.drawBitmap(bitmap, 0, 0, null);//from w w w . ja v a 2 s .co m can.drawRect(rect, paint); return bitmap; }
From source file:tw.jwzhuang.ipcamviewer.devices.CaptureActivity.java
/** * Superimpose a line for 1D or dots for 2D to highlight the key features of * the barcode.//from w w w.jav a 2 s .c o m * * @param barcode * A bitmap of the captured image. * @param rawResult * The decoded results which contains the points to draw. */ private void drawResultPoints(Bitmap barcode, Result rawResult) { ResultPoint[] points = rawResult.getResultPoints(); if (points != null && points.length > 0) { Canvas canvas = new Canvas(barcode); Paint paint = new Paint(); paint.setColor(getResources().getColor(R.color.result_image_border)); paint.setStrokeWidth(3.0f); paint.setStyle(Paint.Style.STROKE); Rect border = new Rect(2, 2, barcode.getWidth() - 2, barcode.getHeight() - 2); canvas.drawRect(border, paint); paint.setColor(getResources().getColor(R.color.result_points)); if (points.length == 2) { paint.setStrokeWidth(4.0f); drawLine(canvas, paint, points[0], points[1]); } else if (points.length == 4 && (rawResult.getBarcodeFormat() == BarcodeFormat.UPC_A || rawResult.getBarcodeFormat() == BarcodeFormat.EAN_13)) { // Hacky special case -- draw two lines, for the barcode and // metadata drawLine(canvas, paint, points[0], points[1]); drawLine(canvas, paint, points[2], points[3]); } else { paint.setStrokeWidth(10.0f); for (ResultPoint point : points) { canvas.drawPoint(point.getX(), point.getY(), paint); } } } }
From source file:com.forrestguice.suntimeswidget.LightMapView.java
private void drawPoint(Calendar calendar, int radius, Canvas c, Paint p) { if (calendar != null) { int w = c.getWidth(); int h = c.getHeight(); double minute = calendar.get(Calendar.HOUR_OF_DAY) * 60 + calendar.get(Calendar.MINUTE); int x = (int) Math.round((minute / MINUTES_IN_DAY) * w); int y = h / 2; p.setStyle(Paint.Style.FILL); p.setColor(colorPointFill);// w ww . j av a2s. c o m c.drawCircle(x, y, radius, p); p.setStyle(Paint.Style.STROKE); p.setStrokeWidth(pointStrokeWidth); p.setColor(colorPointStroke); c.drawCircle(x, y, radius, p); } }
From source file:sandra.examples.oneshot.voicelaunch.VoiceLaunch.java
/** * Writes a text in a drawable. We will use this method to show the similarity value in the seekbar * See stackoverflow http://stackoverflow.com/questions/6264543/draw-on-drawable?rq=1 *///from www . j a v a 2 s. c o m @SuppressWarnings("deprecation") private BitmapDrawable writeOnDrawable(int drawableId, String text) { Bitmap bm = BitmapFactory.decodeResource(getResources(), drawableId).copy(Bitmap.Config.ARGB_8888, true); Paint paint = new Paint(); paint.setStyle(Style.FILL); paint.setColor(Color.BLACK); paint.setTextSize(10); Canvas canvas = new Canvas(bm); canvas.drawText(text, bm.getWidth() / 4, bm.getHeight() / 2, paint); return new BitmapDrawable(bm); }
From source file:de.uni.stuttgart.informatik.ToureNPlaner.UI.Activities.MapScreen.MapScreen.java
private void setupWayOverlay() { Path p = new Path(); p.moveTo(4.f, 0.f);/*from w w w . ja v a 2 s. com*/ p.lineTo(0.f, -4.f); p.lineTo(8.f, -4.f); p.lineTo(12.f, 0.f); p.lineTo(8.f, 4.f); p.lineTo(0.f, 4.f); Paint fastWayOverlayColor = new Paint(Paint.ANTI_ALIAS_FLAG); fastWayOverlayColor.setStyle(Paint.Style.STROKE); fastWayOverlayColor.setColor(Color.BLUE); fastWayOverlayColor.setAlpha(160); fastWayOverlayColor.setStrokeWidth(5.f); fastWayOverlayColor.setStrokeJoin(Paint.Join.ROUND); fastWayOverlayColor.setPathEffect(new ComposePathEffect( new PathDashPathEffect(p, 12.f, 0.f, PathDashPathEffect.Style.ROTATE), new CornerPathEffect(30.f))); // create the WayOverlay and add the ways this.fastWayOverlay = new FastWayOverlay(session, fastWayOverlayColor); mapView.getOverlays().add(this.fastWayOverlay); Result result = session.getResult(); if (result != null) { addPathToMap(result.getWay()); } }
From source file:potboiler.client.PotsActivity.java
License:asdf
private void createDrawerMenu() { mMenuItems = getResources().getStringArray(R.array.menu_sections); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawer = (LinearLayout) findViewById(R.id.left_drawer); mCommandsList = (ListView) findViewById(R.id.commands); User user = PreferenceUtils.getUser(this); ((TextView) findViewById(R.id.name)).setText(user.username); Bitmap bitmap = ImageUtils.getImageFromFile(this, FileUtils.getImagesPath(this) + user.serverId); if (bitmap != null) { /*Bitmap circleBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888); //from w w w . j av a 2 s . c o m BitmapShader shader = new BitmapShader (bitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP); Paint paint = new Paint(); paint.setShader(shader); paint.setAntiAlias(true); Canvas c = new Canvas(circleBitmap); c.drawCircle(bitmap.getWidth() / 2, bitmap.getHeight() / 2, bitmap.getWidth() / 2, paint);*/ int w = bitmap.getWidth(); int h = bitmap.getHeight(); int radius = Math.min(h / 2, w / 2); Bitmap circleBitmap = Bitmap.createBitmap(w + 8, h + 8, Bitmap.Config.ARGB_8888); Paint paint = new Paint(); paint.setAntiAlias(true); Canvas c = new Canvas(circleBitmap); c.drawARGB(0, 0, 0, 0); paint.setStyle(Paint.Style.FILL); c.drawCircle((w / 2) + 4, (h / 2) + 4, radius, paint); paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN)); c.drawBitmap(bitmap, 4, 4, paint); paint.setXfermode(null); paint.setStyle(Paint.Style.STROKE); paint.setColor(Color.WHITE); paint.setStrokeWidth(3); c.drawCircle((w / 2) + 4, (h / 2) + 4, radius, paint); ((ImageView) findViewById(R.id.avatar)).setImageBitmap(circleBitmap); } mDrawerLayout.setScrimColor(getResources().getColor(android.R.color.transparent)); DrawerAdapter adapter = new DrawerAdapter(this, R.layout.item_drawer_list, R.id.title, mMenuItems); mCommandsList.setAdapter(adapter); mCommandsList.setOnItemClickListener(new DrawerItemClickListener()); mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.pots, R.string.pots) { public void onDrawerClosed(View view) { super.onDrawerClosed(view); syncActionBarArrowState(); // invalidateOptionsMenu(); // mDrawerToggle.syncState(); // setRefreshMenu(); } public void onDrawerOpened(View drawerView) { // super.onDrawerClosed(drawerView); super.onDrawerOpened(drawerView); mDrawerToggle.setDrawerIndicatorEnabled(true); // invalidateOptionsMenu(); // mDrawerToggle.syncState(); // setRefreshMenu(); } @Override public void onDrawerSlide(View drawerView, float slideOffset) { super.onDrawerSlide(drawerView, slideOffset); float xPositionOpenDrawer = mCommandsList.getWidth(); float xPositionWindowContent = (slideOffset * xPositionOpenDrawer); FrameLayout mHostFragment = (FrameLayout) findViewById(R.id.content_frame); mHostFragment.setX(xPositionWindowContent); getActionBarView().setX(xPositionWindowContent); } }; mDrawerLayout.setDrawerListener(mDrawerToggle); mDrawerToggle.syncState(); getSupportFragmentManager().addOnBackStackChangedListener(mOnBackStackChangedListener); findViewById(R.id.signout).setOnClickListener(this); }
From source file:ucsc.hci.rankit.DynamicListView.java
/** Draws a black border over the screenshot of the view passed in. */ private Bitmap getBitmapWithBorder(View v) { Bitmap bitmap = getBitmapFromView(v); Canvas can = new Canvas(bitmap); Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()); Paint paint = new Paint(); paint.setStyle(Paint.Style.STROKE); paint.setStrokeWidth(LINE_THICKNESS); paint.setColor(Color.WHITE);/*from ww w.ja v a 2s .c om*/ can.drawBitmap(bitmap, 0, 0, null); can.drawRect(rect, paint); return bitmap; }
From source file:com.spatialnetworks.fulcrum.widget.DynamicListView.java
/** * Draws a black border over the screenshot of the view passed in. *///from w w w . ja v a 2 s .c o m private Bitmap getBitmapWithBorder(View v) { Bitmap bitmap = getBitmapFromView(v); Canvas can = new Canvas(bitmap); Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()); Paint paint = new Paint(); paint.setStyle(Paint.Style.STROKE); paint.setStrokeWidth(LINE_THICKNESS); paint.setColor(ContextCompat.getColor(getContext(), R.color.gray_230)); can.drawBitmap(bitmap, 0, 0, null); can.drawRect(rect, paint); return bitmap; }