List of usage examples for android.graphics Path Path
public Path()
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);/* w ww . j av a 2 s.c o m*/ 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.cooltechworks.views.ScratchImageView.java
/** * Initialises the paint drawing elements. *//* ww w. j a va 2s .c o m*/ private void init() { mTouchPath = new Path(); mErasePaint = new Paint(); mErasePaint.setAntiAlias(true); mErasePaint.setDither(true); mErasePaint.setColor(0xFFFF0000); mErasePaint.setStyle(Paint.Style.STROKE); mErasePaint.setStrokeJoin(Paint.Join.BEVEL); mErasePaint.setStrokeCap(Paint.Cap.ROUND); setStrokeWidth(6); mGradientBgPaint = new Paint(); mErasePath = new Path(); mBitmapPaint = new Paint(Paint.DITHER_FLAG); Bitmap scratchBitmap; if (mCustomScrachView != null) { scratchBitmap = ((BitmapDrawable) mCustomScrachView).getBitmap(); } else { scratchBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_scratch_pattern); } mDrawable = new BitmapDrawable(getResources(), scratchBitmap); mDrawable.setTileModeXY(Shader.TileMode.REPEAT, Shader.TileMode.REPEAT); setEraserMode(); }
From source file:com.jaspersoft.android.jaspermobile.widget.AnnotationView.java
private void addPath() { Paint annotationPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG); annotationPaint.setColor(mColor);// w ww . j ava 2 s . co m annotationPaint.setStyle(Paint.Style.STROKE); annotationPaint.setStrokeJoin(Paint.Join.ROUND); annotationPaint.setStrokeCap(Paint.Cap.ROUND); DisplayMetrics metrics = getContext().getResources().getDisplayMetrics(); int strokeSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, mSize, metrics); annotationPaint.setStrokeWidth(strokeSize); Path annotationPath = new Path(); annotationPath.moveTo(mStartX, mStartY); mDrawingCache.add(new Pair<>(annotationPaint, annotationPath)); }
From source file:android.example.com.visualizerpreferences.AudioVisuals.VisualizerView.java
public VisualizerView(Context context, AttributeSet attrs) { super(context, attrs); mBytes = null;//from w w w.j ava 2s .c o m TrailedShape.setMinSize(MIN_SIZE_DEFAULT); // Create each of the shapes and define how they are drawn on screen // Make bass circle mBassCircle = new TrailedShape(BASS_MULTIPLIER) { @Override protected void drawThisShape(float shapeCenterX, float shapeCenterY, float currentSize, Canvas canvas, Paint paint) { canvas.drawCircle(shapeCenterX, shapeCenterY, currentSize, paint); } }; // Make midrange square mMidSquare = new TrailedShape(MID_MULTIPLIER) { @Override protected void drawThisShape(float shapeCenterX, float shapeCenterY, float currentSize, Canvas canvas, Paint paint) { canvas.drawRect(shapeCenterX - currentSize, shapeCenterY - currentSize, shapeCenterX + currentSize, shapeCenterY + currentSize, paint); } }; // Make treble triangle mTrebleTriangle = new TrailedShape(TREBLE_MULTIPLIER) { @Override protected void drawThisShape(float shapeCenterX, float shapeCenterY, float currentSize, Canvas canvas, Paint paint) { Path trianglePath = new Path(); trianglePath.moveTo(shapeCenterX, shapeCenterY - currentSize); trianglePath.lineTo(shapeCenterX + currentSize, shapeCenterY + currentSize / 2); trianglePath.lineTo(shapeCenterX - currentSize, shapeCenterY + currentSize / 2); trianglePath.lineTo(shapeCenterX, shapeCenterY - currentSize); canvas.drawPath(trianglePath, paint); } }; }
From source file:com.nextgis.maplibui.formcontrol.Sign.java
protected void init() { //1. get clean int[] attrs = new int[] { R.attr.ic_clear }; TypedArray ta = getContext().obtainStyledAttributes(attrs); mCleanImage = ta.getDrawable(0);// w w w . j av a 2 s . c om ta.recycle(); mClearBuff = (int) (getContext().getResources().getDisplayMetrics().density * CLEAR_BUFF_DP); mClearImageSize = (int) (getContext().getResources().getDisplayMetrics().density * CLEAR_IMAGE_SIZE_DP); mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mPaint.setStyle(Paint.Style.STROKE); mPaint.setStrokeWidth(3); mPaint.setDither(true); mPaint.setStrokeJoin(Paint.Join.ROUND); mPaint.setStrokeCap(Paint.Cap.ROUND); boolean bDark = PreferenceManager.getDefaultSharedPreferences(getContext()) .getString(SettingsConstantsUI.KEY_PREF_THEME, "light").equals("dark"); if (bDark) mPaint.setColor(Color.WHITE); else mPaint.setColor(Color.BLACK); mPath = new Path(); mPaths.add(mPath); }
From source file:com.rks.musicx.misc.widgets.DiagonalLayout.java
private Path createOutlinePath(float perpendicularHeight) { Path path = new Path(); if (settings.isBottom()) { if (settings.isGravityLeft()) { path.moveTo(getPaddingLeft(), getPaddingRight()); path.lineTo(width - getPaddingRight(), getPaddingTop()); path.lineTo(width - getPaddingRight(), height - perpendicularHeight - getPaddingBottom()); path.lineTo(getPaddingLeft(), height - getPaddingBottom()); path.close();/*from ww w .j a va2 s . c om*/ } else { path.moveTo(width - getPaddingRight(), height - getPaddingBottom()); path.lineTo(getPaddingLeft(), height - perpendicularHeight - getPaddingBottom()); path.lineTo(getPaddingLeft(), getPaddingTop()); path.lineTo(width - getPaddingRight(), getPaddingTop()); path.close(); } } else { if (settings.isGravityLeft()) { path.moveTo(width - getPaddingRight(), height - getPaddingBottom()); path.lineTo(width - getPaddingRight(), getPaddingTop() + perpendicularHeight); path.lineTo(getPaddingLeft(), getPaddingTop()); path.lineTo(getPaddingLeft(), height - getPaddingBottom()); path.close(); } else { path.moveTo(width - getPaddingRight(), height - getPaddingBottom()); path.lineTo(width - getPaddingRight(), getPaddingTop()); path.lineTo(getPaddingLeft(), getPaddingTop() + perpendicularHeight); path.lineTo(getPaddingLeft(), height - getPaddingBottom()); path.close(); } } return path; }
From source file:com.jjoe64.graphview.series.LineGraphSeries.java
/** * do the initialization/*from ww w . j a v a 2 s . c o m*/ * creates internal objects */ protected void init() { mStyles = new Styles(); mPaint = new Paint(); mPaint.setStrokeCap(Paint.Cap.ROUND); mPaint.setStyle(Paint.Style.STROKE); mPaintBackground = new Paint(); mPathBackground = new Path(); mPath = new Path(); mAnimationInterpolator = new AccelerateInterpolator(2f); }
From source file:org.connectbot.TerminalView.java
public TerminalView(Context context, TerminalBridge bridge) { super(context); this.context = context; this.bridge = bridge; paint = new Paint(); setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); setFocusable(true);/*from w w w . ja v a 2 s . c o m*/ setFocusableInTouchMode(true); cursorPaint = new Paint(); cursorPaint.setColor(bridge.color[bridge.defaultFg]); cursorPaint.setXfermode(new PixelXorXfermode(bridge.color[bridge.defaultBg])); cursorPaint.setAntiAlias(true); cursorStrokePaint = new Paint(cursorPaint); cursorStrokePaint.setStrokeWidth(0.1f); cursorStrokePaint.setStyle(Paint.Style.STROKE); /* * Set up our cursor indicators on a 1x1 Path object which we can later * transform to our character width and height */ // TODO make this into a resource somehow shiftCursor = new Path(); shiftCursor.lineTo(0.5f, 0.33f); shiftCursor.lineTo(1.0f, 0.0f); altCursor = new Path(); altCursor.moveTo(0.0f, 1.0f); altCursor.lineTo(0.5f, 0.66f); altCursor.lineTo(1.0f, 1.0f); ctrlCursor = new Path(); ctrlCursor.moveTo(0.0f, 0.25f); ctrlCursor.lineTo(1.0f, 0.5f); ctrlCursor.lineTo(0.0f, 0.75f); // For creating the transform when the terminal resizes tempSrc = new RectF(); tempSrc.set(0.0f, 0.0f, 1.0f, 1.0f); tempDst = new RectF(); scaleMatrix = new Matrix(); bridge.addFontSizeChangedListener(this); // connect our view up to the bridge setOnKeyListener(bridge.getKeyHandler()); mAccessibilityBuffer = new StringBuffer(); // Enable accessibility features if a screen reader is active. new AccessibilityStateTester().execute((Void) null); }
From source file:lollipop.iconics.IconicsDrawable.java
private void prepare() { mIconPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mBackgroundPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mContourPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mContourPaint.setStyle(Paint.Style.STROKE); mPath = new Path(); mPathBounds = new RectF(); mPaddingBounds = new Rect(); }
From source file:Main.java
@NonNull public static Path createBezierArcRadians(@NonNull PointF center, float radius, double startAngleRadians, double sweepAngleRadians, int pointsOnCircle, boolean overlapPoints, @Nullable Path addToPath) { final Path path = addToPath != null ? addToPath : new Path(); if (sweepAngleRadians == 0d) { return path; }// w w w .j a v a 2 s .com if (pointsOnCircle >= 1) { final double threshold = FULL_CIRCLE_RADIANS / pointsOnCircle; if (abs(sweepAngleRadians) > threshold) { double angle = normalizeRadians(startAngleRadians); PointF end, start = pointFromAngleRadians(center, radius, angle); path.moveTo(start.x, start.y); if (overlapPoints) { final boolean cw = sweepAngleRadians > 0; // clockwise? final double angleEnd = angle + sweepAngleRadians; while (true) { double next = (cw ? ceil(angle / threshold) : floor(angle / threshold)) * threshold; if (angle == next) { next += threshold * (cw ? 1d : -1d); } final boolean isEnd = cw ? angleEnd <= next : angleEnd >= next; end = pointFromAngleRadians(center, radius, isEnd ? angleEnd : next); addBezierArcToPath(path, center, start, end, false); if (isEnd) { break; } angle = next; start = end; } } else { final int n = abs((int) ceil(sweepAngleRadians / threshold)); final double sweep = sweepAngleRadians / n; for (int i = 0; i < n; i++, start = end) { angle += sweep; end = pointFromAngleRadians(center, radius, angle); addBezierArcToPath(path, center, start, end, false); } } return path; } } final PointF start = pointFromAngleRadians(center, radius, startAngleRadians); final PointF end = pointFromAngleRadians(center, radius, startAngleRadians + sweepAngleRadians); addBezierArcToPath(path, center, start, end, true); return path; }