Version für alte Androidversionen der Visiereinstellung für Recurvebogen.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

XTextView.java 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. /*
  2. * $URL$
  3. * $Revision$
  4. * $LastChangedBy$
  5. * $LastChangedDate$
  6. *
  7. * Copyright (c) 2011 spherIC, Switzerland
  8. * All rights reserved.
  9. *
  10. * This software is the confidential and proprietary information
  11. * of spherIC. ("Confidential Information"). You shall not
  12. * disclose such Confidential Information and shall use it only
  13. * in accordance with the terms of the license agreement you
  14. * entered into with spherIC.
  15. */
  16. package ch.spherIC.recurvebowsight.components;
  17. import android.content.Context;
  18. import android.content.res.TypedArray;
  19. import android.graphics.Canvas;
  20. import android.graphics.Paint;
  21. import android.graphics.Rect;
  22. import android.util.AttributeSet;
  23. import ch.spherIC.recurvebowsight.R;
  24. /**
  25. * DOCUMENT ME!
  26. *
  27. * @author $author$
  28. * @version $Revision$, $Date$
  29. */
  30. public class XTextView extends FontTextView {
  31. private boolean drawborder;
  32. private int drawborderColor;
  33. private int drawborderWidth;
  34. /**
  35. * Creates a new XTextView object.
  36. *
  37. * @param context DOCUMENT ME!
  38. */
  39. public XTextView(final Context context) {
  40. super(context);
  41. }
  42. /**
  43. * Creates a new $class.name$ object.
  44. *
  45. * @param context DOCUMENT ME!
  46. * @param attrs DOCUMENT ME!
  47. * @param defStyle DOCUMENT ME!
  48. */
  49. public XTextView(final Context context, final AttributeSet attrs, final int defStyle) {
  50. super(context, attrs, defStyle);
  51. init(attrs);
  52. }
  53. /**
  54. * Creates a new $class.name$ object.
  55. *
  56. * @param context DOCUMENT ME!
  57. * @param attrs DOCUMENT ME!
  58. */
  59. public XTextView(final Context context, final AttributeSet attrs) {
  60. super(context, attrs);
  61. init(attrs);
  62. }
  63. /**
  64. * DOCUMENT ME!
  65. *
  66. * @param attrs DOCUMENT ME!
  67. */
  68. private void init(final AttributeSet attrs) {
  69. TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.XTextView);
  70. this.drawborder = a.getBoolean(R.styleable.XTextView_drawBorder, false);
  71. this.drawborderColor = a.getColor(R.styleable.XTextView_drawBorderColor, 0xffff0000);
  72. this.drawborderWidth = a.getDimensionPixelSize(R.styleable.XTextView_drawBorderWidth, 1);
  73. if (this.drawborder) {
  74. setPadding(getPaddingLeft() + this.drawborderWidth, getPaddingTop() + this.drawborderWidth, getPaddingRight() + this.drawborderWidth,
  75. getPaddingBottom() + this.drawborderWidth);
  76. }
  77. }
  78. /**
  79. * @see android.widget.TextView#onDraw(android.graphics.Canvas)
  80. */
  81. @Override
  82. protected void onDraw(final Canvas canvas) {
  83. super.onDraw(canvas);
  84. if (this.drawborder) {
  85. Rect rect = new Rect();
  86. Paint paint = new Paint();
  87. paint.setStyle(Paint.Style.STROKE);
  88. paint.setColor(this.drawborderColor);
  89. paint.setStrokeWidth(this.drawborderWidth);
  90. getLocalVisibleRect(rect);
  91. rect.bottom -= 1;
  92. rect.right -= 1;
  93. canvas.drawRect(rect, paint);
  94. }
  95. }
  96. /**
  97. * @param drawborderColor the drawborderColor to set
  98. */
  99. public void setDrawborderColor(final int drawborderColor) {
  100. this.drawborderColor = drawborderColor;
  101. invalidate();
  102. }
  103. /**
  104. * @return the drawborder
  105. */
  106. public boolean isDrawborder() {
  107. return this.drawborder;
  108. }
  109. /**
  110. * @param drawborder the drawborder to set
  111. */
  112. public void setDrawborder(final boolean drawborder) {
  113. this.drawborder = drawborder;
  114. invalidate();
  115. }
  116. /**
  117. * @return the drawborderWidth
  118. */
  119. public int getDrawborderWidth() {
  120. return this.drawborderWidth;
  121. }
  122. /**
  123. * @param drawborderWidth the drawborderWidth to set
  124. */
  125. public void setDrawborderWidth(final int drawborderWidth) {
  126. this.drawborderWidth = drawborderWidth;
  127. invalidate();
  128. }
  129. /**
  130. * @return the drawborderColor
  131. */
  132. public int getDrawborderColor() {
  133. return this.drawborderColor;
  134. }
  135. }