cid#1607171 Data race condition
[LibreOffice.git] / android / source / src / java / org / libreoffice / canvas / CalcHeaderCell.java
bloba285234bc8b09249bd7f771baaed8be06a71033a
1 package org.libreoffice.canvas;
3 import android.graphics.Canvas;
4 import android.graphics.Color;
5 import android.graphics.Paint;
6 import android.graphics.Paint.Style;
7 import android.graphics.Rect;
8 import android.graphics.RectF;
9 import android.text.TextPaint;
11 public class CalcHeaderCell extends CommonCanvasElement {
12 private final TextPaint mTextPaint = new TextPaint();
14 private final Paint mFramePaint = new Paint();
15 private final Paint mBgPaint = new Paint();
16 private final RectF mBounds;
17 private final Rect mTextBounds = new Rect();
18 private final String mText;
20 public CalcHeaderCell(float left, float top, float width, float height, String text, boolean selected) {
21 mBounds = new RectF(left, top, left + width, top + height);
23 mFramePaint.setStyle(Style.STROKE);
24 mFramePaint.setColor(Color.BLACK);
26 mBgPaint.setStyle(Style.FILL);
27 mBgPaint.setColor(Color.GRAY);
28 // draw background more intensely when cell is selected
29 if (selected) {
30 mBgPaint.setAlpha(100);
31 } else {
32 mBgPaint.setAlpha(25);
35 mTextPaint.setColor(Color.BLACK);
36 mTextPaint.setTextSize(24f); // hard coded for now
37 mTextPaint.setTextAlign(Paint.Align.CENTER);
38 mText = text;
40 mTextPaint.getTextBounds(mText, 0, mText.length(), mTextBounds);
43 /**
44 * Implement hit test here
46 * @param x - x coordinate of the
47 * @param y - y coordinate of the
49 @Override
50 public boolean onHitTest(float x, float y) {
51 return false;
54 /**
55 * Called inside draw if the element is visible. Override this method to
56 * draw the element on the canvas.
58 * @param canvas - the canvas
60 @Override
61 public void onDraw(Canvas canvas) {
62 canvas.drawRect(mBounds, mBgPaint);
63 canvas.drawRect(mBounds, mFramePaint);
64 canvas.drawText(mText, mBounds.centerX(), mBounds.centerY() - mTextBounds.centerY(), mTextPaint);