<commit_before>import React, { PropTypes } from 'react';
import Canvas from '../../utils/Canvas';
import PreviewBase from './PreviewBase';
import fonts from '../../utils/fonts';
import units from '../../utils/units';

export default class Wind extends PreviewBase {
  static propTypes = {
    panel: PropTypes.number.isRequired,
    positionX: PropTypes.number.isRequired,
    positionY: PropTypes.number.isRequired,
    units: PropTypes.number.isRequired,
    visibleOn: PropTypes.number.isRequired,
    windDirection: PropTypes.number.isRequired,
    windSpeed: PropTypes.number.isRequired,
  }

  draw() {
    this.canvas.clear();
    const height = this.refs.canvas.height;
    const posY = height / 2;
    const font = fonts.getFont(0);

    if ((this.props.visibleOn & Math.pow(2, this.props.panel)) !== 0) {
      const windString = units.convertSpeed(this.props.windSpeed, this.props.units);
      const windPosition = Canvas.calculateStringPosition(windString, 20, posY, 0, 1, font);
      this.canvas.drawString(windString, windPosition.left, windPosition.top, font);

      context.save();
      context.translate(9, 9);
      context.rotate(this.props.windDirection * Math.PI / 180);
      context.translate(-9, -9);
      this.canvas.drawLine(6, 7, 9, 1);
      this.canvas.drawLine(9, 1, 12, 7);
      this.canvas.drawLine(9, 16, 9, 7, true);
      context.restore();
    }
  }

  render() {
    const { positionX, positionY } = this.props;
    const font = fonts.getFont(0);
    const windString = units.convertSpeed(this.props.windSpeed, this.props.units);
    const windPosition = Canvas.calculateStringPosition(windString, 0, 0, 0, 1, font);
    const width = windPosition.width + 20;
    const height = 18;
    const visible = (this.props.visibleOn & Math.pow(2, this.props.panel)) !== 0;

    return (<commit_msg>fix(preview): fix wind preview after canvas refactoring<commit_after>import React, { PropTypes } from 'react';
import Canvas from '../../utils/Canvas';
import PreviewBase from './PreviewBase';
import fonts from '../../utils/fonts';
import units from '../../utils/units';

export default class Wind extends PreviewBase {
  static propTypes = {
    panel: PropTypes.number.isRequired,
    positionX: PropTypes.number.isRequired,
    positionY: PropTypes.number.isRequired,
    units: PropTypes.number.isRequired,
    visibleOn: PropTypes.number.isRequired,
    windDirection: PropTypes.number.isRequired,
    windSpeed: PropTypes.number.isRequired,
  }

  draw() {
    this.canvas.clear();
    const height = this.refs.canvas.height;
    const posY = height / 2;
    const font = fonts.getFont(0);

    if ((this.props.visibleOn & Math.pow(2, this.props.panel)) !== 0) {
      const windString = units.convertSpeed(this.props.windSpeed, this.props.units);
      const windPosition = Canvas.calculateStringPosition(windString, 20, posY, 0, 1, font);
      this.canvas.drawString(windString, windPosition.left, windPosition.top, font);

      this.canvas.save();
      this.canvas.translate(9, 9);
      this.canvas.rotate(this.props.windDirection * Math.PI / 180);
      this.canvas.translate(-9, -9);
      this.canvas.drawLine(6, 7, 9, 1);
      this.canvas.drawLine(9, 1, 12, 7);
      this.canvas.drawLine(9, 16, 9, 7, true);
      this.canvas.restore();
    }
  }

  render() {
    const { positionX, positionY } = this.props;
    const font = fonts.getFont(0);
    const windString = units.convertSpeed(this.props.windSpeed, this.props.units);
    const windPosition = Canvas.calculateStringPosition(windString, 0, 0, 0, 1, font);
    const width = windPosition.width + 20;
    const height = 18;
    const visible = (this.props.visibleOn & Math.pow(2, this.props.panel)) !== 0;

    return (
{'fraction_non_alphanumeric': 0.1400214592274678, 'fraction_numerical': 0.02145922746781116, 'mean_word_length': 3.3665105386416863, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3077663', 'n_tokens_mistral': 1212, 'n_tokens_neox': 1152, 'n_words': 270}