XAxis.java 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. package com.github.mikephil.charting.components;
  2. import com.github.mikephil.charting.utils.Utils;
  3. /**
  4. * Class representing the x-axis labels settings. Only use the setter methods to
  5. * modify it. Do not access public variables directly. Be aware that not all
  6. * features the XLabels class provides are suitable for the RadarChart.
  7. *
  8. * @author Philipp Jahoda
  9. */
  10. public class XAxis extends AxisBase {
  11. /**
  12. * width of the x-axis labels in pixels - this is automatically
  13. * calculated by the computeSize() methods in the renderers
  14. */
  15. public int mLabelWidth = 1;
  16. /**
  17. * height of the x-axis labels in pixels - this is automatically
  18. * calculated by the computeSize() methods in the renderers
  19. */
  20. public int mLabelHeight = 1;
  21. /**
  22. * width of the (rotated) x-axis labels in pixels - this is automatically
  23. * calculated by the computeSize() methods in the renderers
  24. */
  25. public int mLabelRotatedWidth = 1;
  26. /**
  27. * height of the (rotated) x-axis labels in pixels - this is automatically
  28. * calculated by the computeSize() methods in the renderers
  29. */
  30. public int mLabelRotatedHeight = 1;
  31. /**
  32. * This is the angle for drawing the X axis labels (in degrees)
  33. */
  34. protected float mLabelRotationAngle = 0f;
  35. /**
  36. * if set to true, the chart will avoid that the first and last label entry
  37. * in the chart "clip" off the edge of the chart
  38. */
  39. private boolean mAvoidFirstLastClipping = false;
  40. /**
  41. * the position of the x-labels relative to the chart
  42. */
  43. private XAxisPosition mPosition = XAxisPosition.TOP;
  44. /**
  45. * enum for the position of the x-labels relative to the chart
  46. */
  47. public enum XAxisPosition {
  48. TOP, BOTTOM, BOTH_SIDED, TOP_INSIDE, BOTTOM_INSIDE
  49. }
  50. public XAxis() {
  51. super();
  52. mYOffset = Utils.convertDpToPixel(4.f); // -3
  53. }
  54. /**
  55. * returns the position of the x-labels
  56. */
  57. public XAxisPosition getPosition() {
  58. return mPosition;
  59. }
  60. /**
  61. * sets the position of the x-labels
  62. *
  63. * @param pos
  64. */
  65. public void setPosition(XAxisPosition pos) {
  66. mPosition = pos;
  67. }
  68. /**
  69. * returns the angle for drawing the X axis labels (in degrees)
  70. */
  71. public float getLabelRotationAngle() {
  72. return mLabelRotationAngle;
  73. }
  74. /**
  75. * sets the angle for drawing the X axis labels (in degrees)
  76. *
  77. * @param angle the angle in degrees
  78. */
  79. public void setLabelRotationAngle(float angle) {
  80. mLabelRotationAngle = angle;
  81. }
  82. /**
  83. * if set to true, the chart will avoid that the first and last label entry
  84. * in the chart "clip" off the edge of the chart or the screen
  85. *
  86. * @param enabled
  87. */
  88. public void setAvoidFirstLastClipping(boolean enabled) {
  89. mAvoidFirstLastClipping = enabled;
  90. }
  91. /**
  92. * returns true if avoid-first-lastclipping is enabled, false if not
  93. *
  94. * @return
  95. */
  96. public boolean isAvoidFirstLastClippingEnabled() {
  97. return mAvoidFirstLastClipping;
  98. }
  99. }