<commit_before>package uk.co.pilllogger.views;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Point;
import android.util.AttributeSet;
import android.view.View;

import java.util.Map;

import uk.co.pilllogger.R;
import uk.co.pilllogger.state.State;

/**
 * Created by Alex on 17/03/14.
 */
public class HourOfDayView extends View
{
    Paint _fillPaint = new Paint();
    Paint _borderPaint = new Paint();
    Paint _textPaint = new Paint();
    Paint _indicatorPaint = new Paint();
    private Map<Integer, Integer> _data;
    private int _hour;
    private int _min = 0;
    private int _max = 0;
    private Context _context;
    private String _hourText = "";
    private int _desiredHeight = 0;
    private int _desiredWidth = 0;
    int _width;
    int _height;
    int _border;
    int _boxSize;
    private boolean _drawLegend = true;

    public HourOfDayView(Context context) {
        super(context);
        preInit(context);
    }

    public HourOfDayView(Context context, AttributeSet attrs) {
        super(context, attrs);
        preInit(context);
    }

    public HourOfDayView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        preInit(context);
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        int width = MeasureSpec.getSize(widthMeasureSpec);
        int border = 1;


        int boxSize = (width - (24*(border*2))) / 24;

        final int desiredHSpec = MeasureSpec.makeMeasureSpec(boxSize*5, MeasureSpec.EXACTLY);
        final int desiredWSpec = MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY);
        setMeasuredDimension(desiredWSpec, desiredHSpec);
    }

    private void preInit(Context context) {
        _context = context;
        _fillPaint.setColor(context.getResources().getColor(R.color.pill_colour6));
        _fillPaint.setStyle(Paint.Style.FILL);
        _borderPaint.setColor(Color.DKGRAY);
        _borderPaint.setStyle(Paint.Style.STROKE);
        _indicatorPaint.setColor(Color.WHITE);
        _indicatorPaint.setStyle(Paint.Style.FILL_AND_STROKE);
        _indicatorPaint.setStrokeWidth(2);
        _indicatorPaint.setAntiAlias(true);
        _textPaint.setTextSize(13 * getResources().getDisplayMetrics().density);
        _textPaint.setColor(Color.WHITE);
        _textPaint.setTypeface(State.getSingleton().getTypeface());
        _textPaint.setAntiAlias(true);
    }

    public void setData(Map<Integer, Integer> data, int hour, String hourText){
        _data = data;
        _hour = hour;
        _hourText = hourText;

        for(int key : _data.keySet()){
            int value = _data.get(key);

            if(value > _max)
                _max = value;

            if(value < _min)
                _min = value;<commit_msg>Added theme support for HourOfDayView<commit_after>package uk.co.pilllogger.views;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Point;
import android.util.AttributeSet;
import android.view.View;

import java.util.Map;

import uk.co.pilllogger.R;
import uk.co.pilllogger.state.State;

/**
 * Created by Alex on 17/03/14.
 */
public class HourOfDayView extends View
{
    Paint _fillPaint = new Paint();
    Paint _borderPaint = new Paint();
    Paint _textPaint = new Paint();
    Paint _indicatorPaint = new Paint();
    private Map<Integer, Integer> _data;
    private int _hour;
    private int _min = 0;
    private int _max = 0;
    private Context _context;
    private String _hourText = "";
    private int _desiredHeight = 0;
    private int _desiredWidth = 0;
    int _width;
    int _height;
    int _border;
    int _boxSize;
    private boolean _drawLegend = true;
    private int _textColour;

    public HourOfDayView(Context context) {
        super(context);
        preInit(context);
    }

    public HourOfDayView(Context context, AttributeSet attrs) {
        super(context, attrs);
        preInit(context);
    }

    public HourOfDayView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        preInit(context);
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        int width = MeasureSpec.getSize(widthMeasureSpec);
        int border = 1;


        int boxSize = (width - (24*(border*2))) / 24;

        final int desiredHSpec = MeasureSpec.makeMeasureSpec(boxSize*5, MeasureSpec.EXACTLY);
        final int desiredWSpec = MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY);
        setMeasuredDimension(desiredWSpec, desiredHSpec);
    }

    private void preInit(Context context) {
        _context = context;
        _textColour = context.getResources().getColor(State.getSingleton().getTheme().getDefaultTextColourResourceId());
        _fillPaint.setColor(context.getResources().getColor(State.getSingleton().getTheme().getDefaultChartColourResourceId()));
        _fillPaint.setStyle(Paint.Style.FILL);
        _borderPaint.setColor(Color.DKGRAY);
        _borderPaint.setStyle(Paint.Style.STROKE);
        _indicatorPaint.setColor(_textColour);
        _indicatorPaint.setStyle(Paint.Style.FILL_AND_STROKE);
        _indicatorPaint.setStrokeWidth(2);
        _indicatorPaint.setAntiAlias(true);
        _textPaint.setTextSize(13 * getResources().getDisplayMetrics().density);
        _textPaint.setColor(_textColour);
        _textPaint.setTypeface(State.getSingleton().getTypeface());
        _textPaint.setAntiAlias(true);
    }

    public void setData(Map<Integer, Integer> data, int hour, String hourText){
        _data = data;
        _hour = hour;
        _hourText = hourText;

        for(int key : _data.keySet()){
            int value = _data.get(key);

            if(value > _max)
                _max = value;

            if(value < _min)
                _min = value;
{'fraction_non_alphanumeric': 0.09972163091534304, 'fraction_numerical': 0.006713607335844114, 'mean_word_length': 3.053085600530856, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7485260', 'n_tokens_mistral': 1886, 'n_tokens_neox': 1800, 'n_words': 394}