Guest User

Untitled

a guest
Jan 18th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. public class GraphPlotting extends View
  2. {
  3. public void onDraw(Canvas canvas)
  4. {
  5.  
  6. readPoints();
  7. Paint paint1 = new Paint();
  8. paint1.setColor(Color.rgb(0xFF,0xFF, 0xFF));
  9. paint1.setStrokeWidth(1.0f);
  10.  
  11. Paint paint2 = new Paint();
  12. paint2.setColor(Color.rgb(0xFF,0xFF, 0xFF));
  13. paint2.setStrokeWidth(10.0f);
  14.  
  15. Paint paint = new Paint();
  16. paint.setStyle(Paint.Style.FILL);
  17. paint.setColor(Color.RED);
  18. canvas.drawPaint(paint);
  19.  
  20. canvas.drawLines(p,paint1);
  21.  
  22.  
  23. }
  24. public void readPoints()
  25. {
  26. DisplayMetrics dm = new DisplayMetrics();
  27. getWindowManager().getDefaultDisplay().getMetrics(dm);
  28.  
  29. height = dm.heightPixels;
  30. width = dm.widthPixels;
  31.  
  32. // drawing graph based on above dimension which in my case is 480 by 800
  33.  
  34. }
  35.  
  36. <RelativeLayout
  37. android:layout_width="200dp"
  38. android:layout_height="200dp"
  39. android:orientation="vertical"
  40. android:layout_below="@+id/btn_analyze"
  41. android:layout_centerHorizontal="true"
  42. android:id="@+id/rlgraph"
  43. >
  44. <com.aventusoft.mylynel.GraphPlotting
  45.  
  46. android:id="@+id/view1"
  47. android:layout_width="match_parent"
  48. android:layout_height="match_parent"
  49.  
  50. />
  51. </RelativeLayout>
  52.  
  53. @Override
  54. protected void onSizeChanged(int w, int h, int oldw, int oldh) {
  55.  
  56. widgetHeight = h;
  57. widgetWidth = w;
  58.  
  59. if (sizeChangedObservers != null && sizeChangedObservers.size() > 0) {
  60. for (SizeChangedObserver observer : sizeChangedObservers) {
  61. observer.callback(w, h);
  62. }
  63. }
  64.  
  65. updateIncrements();
  66.  
  67. }
Add Comment
Please, Sign In to add comment