| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161 |
- /*
- * $URL$
- * $Revision$
- * $LastChangedBy$
- * $LastChangedDate$
- *
- * Copyright (c) 2011 spherIC, Switzerland
- * All rights reserved.
- *
- * This software is the confidential and proprietary information
- * of spherIC. ("Confidential Information"). You shall not
- * disclose such Confidential Information and shall use it only
- * in accordance with the terms of the license agreement you
- * entered into with spherIC.
- */
- package ch.spherIC.recurvebowsight.components;
-
- import android.content.Context;
-
- import android.content.res.TypedArray;
-
- import android.graphics.Canvas;
- import android.graphics.Paint;
- import android.graphics.Rect;
-
- import android.util.AttributeSet;
-
- import ch.spherIC.recurvebowsight.R;
-
-
- /**
- * DOCUMENT ME!
- *
- * @author $author$
- * @version $Revision$, $Date$
- */
- public class XTextView extends FontTextView {
-
- private boolean drawborder;
- private int drawborderColor;
- private int drawborderWidth;
-
- /**
- * Creates a new XTextView object.
- *
- * @param context DOCUMENT ME!
- */
- public XTextView(final Context context) {
- super(context);
- }
-
- /**
- * Creates a new $class.name$ object.
- *
- * @param context DOCUMENT ME!
- * @param attrs DOCUMENT ME!
- * @param defStyle DOCUMENT ME!
- */
- public XTextView(final Context context, final AttributeSet attrs, final int defStyle) {
- super(context, attrs, defStyle);
- init(attrs);
- }
-
- /**
- * Creates a new $class.name$ object.
- *
- * @param context DOCUMENT ME!
- * @param attrs DOCUMENT ME!
- */
- public XTextView(final Context context, final AttributeSet attrs) {
- super(context, attrs);
- init(attrs);
- }
-
-
- /**
- * DOCUMENT ME!
- *
- * @param attrs DOCUMENT ME!
- */
- private void init(final AttributeSet attrs) {
-
- TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.XTextView);
- this.drawborder = a.getBoolean(R.styleable.XTextView_drawBorder, false);
- this.drawborderColor = a.getColor(R.styleable.XTextView_drawBorderColor, 0xffff0000);
- this.drawborderWidth = a.getDimensionPixelSize(R.styleable.XTextView_drawBorderWidth, 1);
-
- if (this.drawborder) {
- setPadding(getPaddingLeft() + this.drawborderWidth, getPaddingTop() + this.drawborderWidth, getPaddingRight() + this.drawborderWidth,
- getPaddingBottom() + this.drawborderWidth);
- }
- }
-
-
- /**
- * @see android.widget.TextView#onDraw(android.graphics.Canvas)
- */
- @Override
- protected void onDraw(final Canvas canvas) {
- super.onDraw(canvas);
-
- if (this.drawborder) {
- Rect rect = new Rect();
- Paint paint = new Paint();
- paint.setStyle(Paint.Style.STROKE);
- paint.setColor(this.drawborderColor);
- paint.setStrokeWidth(this.drawborderWidth);
- getLocalVisibleRect(rect);
- rect.bottom -= 1;
- rect.right -= 1;
- canvas.drawRect(rect, paint);
- }
- }
-
-
- /**
- * @param drawborderColor the drawborderColor to set
- */
- public void setDrawborderColor(final int drawborderColor) {
- this.drawborderColor = drawborderColor;
- invalidate();
- }
-
- /**
- * @return the drawborder
- */
- public boolean isDrawborder() {
- return this.drawborder;
- }
-
- /**
- * @param drawborder the drawborder to set
- */
- public void setDrawborder(final boolean drawborder) {
- this.drawborder = drawborder;
- invalidate();
- }
-
- /**
- * @return the drawborderWidth
- */
- public int getDrawborderWidth() {
- return this.drawborderWidth;
- }
-
- /**
- * @param drawborderWidth the drawborderWidth to set
- */
- public void setDrawborderWidth(final int drawborderWidth) {
- this.drawborderWidth = drawborderWidth;
- invalidate();
- }
-
- /**
- * @return the drawborderColor
- */
- public int getDrawborderColor() {
- return this.drawborderColor;
- }
-
- }
|