List of usage examples for android.graphics Paint setStrokeWidth
public void setStrokeWidth(float width)
From source file:foam.jellyfish.StarwispCanvas.java
@Override public void onDraw(Canvas canvas) { float sx = getWidth() / 320.0f; float sy = getHeight() / 200.0f; Paint myPaint = new Paint(); myPaint.setStrokeWidth(0); myPaint.setColor(Color.rgb(127, 127, 127)); canvas.drawRect(0, 0, getWidth(), getHeight(), myPaint); try {/*w ww .ja v a 2s .c om*/ for (int i = 0; i < m_Drawlist.length(); i++) { JSONArray prim = m_Drawlist.getJSONArray(i); if (prim.getString(0).equals("line")) { DrawLine(canvas, prim, sx, sy); } if (prim.getString(0).equals("text")) { DrawText(canvas, prim, sx, sy); } } } catch (JSONException e) { Log.e("starwisp", "Error parsing data " + e.toString()); } }
From source file:com.blogspot.ksoichiro.viewIndicator.ViewIndicator.java
@SuppressLint("DrawAllocation") @Override//from w ww . ja v a 2s . co m protected void onDraw(Canvas canvas) { super.onDraw(canvas); Paint paint = new Paint(); paint.setStrokeWidth(1); paint.setStrokeCap(Paint.Cap.ROUND); paint.setColor(Color.BLACK); paint.setAntiAlias(true); for (int i = 0; i < mNumOfViews; i++) { float cx = (getWidth() - (mNumOfViews - 1) * DISTANCE) / 2 + i * DISTANCE; float cy = getHeight() / 2.0f; if (mPosition == i) { paint.setStyle(Paint.Style.FILL_AND_STROKE); } else { paint.setStyle(Paint.Style.STROKE); } canvas.drawCircle(cx, cy, RADIUS, paint); } }
From source file:com.snippet.widget.ViewIndicator.java
@SuppressLint("DrawAllocation") @Override//from w w w . j a v a 2 s.co m protected void onDraw(Canvas canvas) { super.onDraw(canvas); Paint paint = new Paint(); paint.setStrokeWidth(1); paint.setStrokeCap(Paint.Cap.ROUND); paint.setColor(Color.BLACK); paint.setAntiAlias(true); for (int i = 0; i < mNumOfViews; i++) { float cx = (getWidth() - (mNumOfViews - 1) * mDistance) / 2 + i * mDistance; float cy = getHeight() / 2.0f; if (mPosition == i) { paint.setStyle(Paint.Style.FILL_AND_STROKE); } else { paint.setStyle(Paint.Style.STROKE); } canvas.drawCircle(cx, cy, mRadius, paint); } }
From source file:de.chrthms.chess.board.markers.SourceFieldView.java
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); Paint paint = new Paint(); paint.setColor(ContextCompat.getColor(getContext(), R.color.basicFieldPossibleColor)); paint.setStrokeWidth((getWidth() * 1f) / 100 * STROKE_WIDTH); float[] points = { getLeft(), getTop(), getRight(), getTop(), getRight(), getTop(), getRight(), getBottom(), getRight(), getBottom(), getLeft(), getBottom(), getLeft(), getBottom(), getLeft(), getTop() }; canvas.drawLines(points, paint);//from w ww .j a v a2 s . c o m }
From source file:com.jjoe64.graphview_demos.fragments.PointsGraph.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main, container, false); GraphView graph = (GraphView) rootView.findViewById(R.id.graph); PointsGraphSeries<DataPoint> series = new PointsGraphSeries<DataPoint>( new DataPoint[] { new DataPoint(0, -2), new DataPoint(1, 5), new DataPoint(2, 3), new DataPoint(3, 2), new DataPoint(4, 6) }); graph.addSeries(series);/*from w w w . j a v a 2s.c o m*/ series.setShape(PointsGraphSeries.Shape.POINT); PointsGraphSeries<DataPoint> series2 = new PointsGraphSeries<DataPoint>( new DataPoint[] { new DataPoint(0, -1), new DataPoint(1, 4), new DataPoint(2, 2), new DataPoint(3, 1), new DataPoint(4, 5) }); graph.addSeries(series2); series2.setShape(PointsGraphSeries.Shape.RECTANGLE); series2.setColor(Color.RED); PointsGraphSeries<DataPoint> series3 = new PointsGraphSeries<DataPoint>( new DataPoint[] { new DataPoint(0, 0), new DataPoint(1, 3), new DataPoint(2, 1), new DataPoint(3, 0), new DataPoint(4, 4) }); graph.addSeries(series3); series3.setShape(PointsGraphSeries.Shape.TRIANGLE); series3.setColor(Color.YELLOW); PointsGraphSeries<DataPoint> series4 = new PointsGraphSeries<DataPoint>( new DataPoint[] { new DataPoint(0, 1), new DataPoint(1, 2), new DataPoint(2, 0), new DataPoint(3, -1), new DataPoint(4, 3) }); graph.addSeries(series4); series4.setColor(Color.GREEN); series4.setCustomShape(new PointsGraphSeries.CustomShape() { @Override public void draw(Canvas canvas, Paint paint, float x, float y, DataPointInterface dataPoint) { paint.setStrokeWidth(10); canvas.drawLine(x - 20, y - 20, x + 20, y + 20, paint); canvas.drawLine(x + 20, y - 20, x - 20, y + 20, paint); } }); return rootView; }
From source file:de.chrthms.chess.board.markers.PossibleFieldView.java
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); Paint paint = new Paint(); paint.setColor(ContextCompat.getColor(getContext(), R.color.basicFieldPossibleColor)); paint.setStrokeWidth((getWidth() * 1f) / 100 * STROKE_WIDTH); // transform int (width) to float! float space = (getWidth() * 1f) / 100 * MARKER_SPACE; float size = (getWidth() * 1f) / 100 * MARKER_SIZE; Log.i("MARKER POINTS", "space = " + space + " size = " + size + " width = " + getWidth()); float[] points = { getLeft() + space, getTop() + space, getLeft() + space + size, getTop() + space, getLeft() + space, getTop() + space, getLeft() + space, getTop() + space + size, getRight() - space - size, getTop() + space, getRight() - space, getTop() + space, getRight() - space, getTop() + space, getRight() - space, getTop() + space + size, getLeft() + space, getBottom() - space, getLeft() + space + size, getBottom() - space, getLeft() + space, getBottom() - space, getLeft() + space, getBottom() - space - size, getRight() - space - size, getBottom() - space, getRight() - space, getBottom() - space, getRight() - space, getBottom() - space, getRight() - space, getBottom() - space - size, };/*from ww w .j a v a2 s .c om*/ Log.i("MARKER POINTS", "points array = " + Arrays.toString(points)); canvas.drawLines(points, paint); }
From source file:com.jjoe64.graphview_demos.fragments.Styling.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_main, container, false); GraphView graph = (GraphView) rootView.findViewById(R.id.graph); DataPoint[] points = new DataPoint[30]; for (int i = 0; i < 30; i++) { points[i] = new DataPoint(i, Math.sin(i * 0.5) * 20 * (Math.random() * 10 + 1)); }//from ww w. jav a2s . c o m LineGraphSeries<DataPoint> series = new LineGraphSeries<DataPoint>(points); points = new DataPoint[15]; for (int i = 0; i < 15; i++) { points[i] = new DataPoint(i * 2, Math.sin(i * 0.5) * 20 * (Math.random() * 10 + 1)); } LineGraphSeries<DataPoint> series2 = new LineGraphSeries<DataPoint>(points); // styling grid/labels graph.getGridLabelRenderer().setGridColor(Color.RED); graph.getGridLabelRenderer().setHighlightZeroLines(false); graph.getGridLabelRenderer().setHorizontalLabelsColor(Color.GREEN); graph.getGridLabelRenderer().setVerticalLabelsColor(Color.RED); graph.getGridLabelRenderer().setVerticalLabelsAlign(Paint.Align.LEFT); graph.getGridLabelRenderer().setLabelVerticalWidth(150); graph.getGridLabelRenderer().setTextSize(40); graph.getGridLabelRenderer().setGridStyle(GridLabelRenderer.GridStyle.HORIZONTAL); graph.getGridLabelRenderer().reloadStyles(); // styling viewport graph.getViewport().setBackgroundColor(Color.argb(255, 222, 222, 222)); // styling series series.setTitle("Random Curve 1"); series.setColor(Color.GREEN); series.setDrawDataPoints(true); series.setDataPointsRadius(10); series.setThickness(8); series2.setTitle("Random Curve 2"); series2.setDrawBackground(true); series2.setBackgroundColor(Color.argb(100, 255, 255, 0)); Paint paint = new Paint(); paint.setStyle(Paint.Style.STROKE); paint.setStrokeWidth(10); paint.setPathEffect(new DashPathEffect(new float[] { 8, 5 }, 0)); series2.setCustomPaint(paint); // styling legend graph.getLegendRenderer().setVisible(true); graph.getLegendRenderer().setTextSize(25); graph.getLegendRenderer().setBackgroundColor(Color.argb(150, 50, 0, 0)); graph.getLegendRenderer().setTextColor(Color.WHITE); //graph.getLegendRenderer().setAlign(LegendRenderer.LegendAlign.TOP); //graph.getLegendRenderer().setMargin(30); graph.getLegendRenderer().setFixedPosition(150, 0); graph.addSeries(series); graph.addSeries(series2); return rootView; }
From source file:com.sebible.cordova.videosnapshot.VideoSnapshot.java
private void drawTimestamp(Bitmap bm, String prefix, long timeMs, int textSize) { float w = bm.getWidth(), h = bm.getHeight(); float size = (float) (textSize * bm.getWidth()) / 1280; float margin = (float) (w < h ? w : h) * 0.05f; Canvas c = new Canvas(bm); Paint p = new Paint(); p.setColor(Color.WHITE);/* w w w . ja va2 s . c o m*/ p.setStrokeWidth((int) (size / 10)); p.setTextSize((int) size); // Text Size p.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_OVER)); // Text Overlapping Pattern long second = (timeMs / 1000) % 60; long minute = (timeMs / (1000 * 60)) % 60; long hour = (timeMs / (1000 * 60 * 60)) % 24; String text = String.format("%s %02d:%02d:%02d", prefix, hour, minute, second); Rect r = new Rect(); p.getTextBounds(text, 0, text.length(), r); //c.drawBitmap(originalBitmap, 0, 0, paint); c.drawText(text, bm.getWidth() - r.width() - margin, bm.getHeight() - r.height() - margin, p); }
From source file:com.eugene.fithealthmaingit.UI.NavFragments.FragmentWeight.java
private void chart() { mLineChart = (LineChartView) v.findViewById(R.id.linechart); mLineChart.reset();/* w ww . ja v a 2 s. c om*/ dataSet = new LineSet(); simpleArray = new float[weightLogAdapter.getCount()]; dates = new String[weightLogAdapter.getCount()]; for (int i = 0; i < weightLogAdapter.getCount(); i++) { WeightLog weightLogWeight = weightLogAdapter.getItem(i); simpleArray[i] = (float) weightLogWeight.getCurrentWeight(); dates[i] = String.valueOf(DateFormat.format("MMM dd", weightLogWeight.getDate())); } dataSet.addPoints(dates, simpleArray); mLineGridPaint = new Paint(); mLineGridPaint.setColor(this.getResources().getColor(R.color.accent)); mLineGridPaint.setStyle(Paint.Style.FILL); mLineGridPaint.setAntiAlias(true); /** * Controlling the data set and setting it to the chart. */ dataSet.setDots(true).setDotsColor(this.getResources().getColor(R.color.primary)) .setDotsRadius(Tools.fromDpToPx(3)).setDotsStrokeThickness(Tools.fromDpToPx(1)) .setDotsStrokeColor(this.getResources().getColor(R.color.primary)) .setLineColor(this.getResources().getColor(R.color.primary_dark)) .setLineThickness(Tools.fromDpToPx(1)).beginAt(0).endAt(weightLogAdapter.getCount()); mLineChart.addData(dataSet); mLineChart.setBorderSpacing(Tools.fromDpToPx(0)).setGrid(LineChartView.GridType.HORIZONTAL, mLineGridPaint) .setXAxis(false).setXLabels(XController.LabelPosition.OUTSIDE).setYAxis(false) .setYLabels(YController.LabelPosition.OUTSIDE).setAxisBorderValues(min, max, 5) .setLabelColor(this.getResources().getColor(R.color.text_color)) .setLabelsFormat(new DecimalFormat("##' lbs'")).show(); Paint paint = new Paint(); paint.setStrokeWidth((float) Equations.dpToPx(getActivity(), 2)); paint.setColor(getActivity().getResources().getColor(R.color.green)); mLineChart.setThresholdLine(goalWeightLine, paint); }
From source file:com.nextgis.maplib.display.SimpleMarkerStyle.java
protected void onDraw(GeoPoint pt, GISDisplay display) { if (null == pt) return;//from ww w . j ava2 s.com switch (mType) { case MarkerStylePoint: Paint ptPaint = new Paint(); ptPaint.setColor(mColor); ptPaint.setStrokeWidth((float) (mSize / display.getScale())); ptPaint.setStrokeCap(Paint.Cap.ROUND); ptPaint.setAntiAlias(true); display.drawPoint((float) pt.getX(), (float) pt.getY(), ptPaint); break; case MarkerStyleCircle: Paint fillCirclePaint = new Paint(); fillCirclePaint.setColor(mColor); fillCirclePaint.setStrokeCap(Paint.Cap.ROUND); display.drawCircle((float) pt.getX(), (float) pt.getY(), mSize, fillCirclePaint); Paint outCirclePaint = new Paint(); outCirclePaint.setColor(mOutColor); outCirclePaint.setStrokeWidth((float) (mWidth / display.getScale())); outCirclePaint.setStyle(Paint.Style.STROKE); outCirclePaint.setAntiAlias(true); display.drawCircle((float) pt.getX(), (float) pt.getY(), mSize, outCirclePaint); break; case MarkerStyleDiamond: break; case MarkerStyleCross: break; case MarkerStyleTriangle: break; case MarkerStyleBox: break; } }