<commit_before>package br.com.insanitech.testapp

import android.app.Activity
import android.os.Bundle
import android.view.MotionEvent
import android.view.View
import br.com.insanitech.spritekit.*
import br.com.insanitech.spritekit.actions.SKAction
import br.com.insanitech.spritekit.graphics.SKColor
import br.com.insanitech.spritekit.graphics.SKRect
import br.com.insanitech.spritekit.graphics.SKSize
import kotlinx.android.synthetic.main.activity_main.*
import java.util.*

/**
 * Created by anderson on 24/06/15.
 */
class TestAppActivity : Activity(), View.OnTouchListener {
    private var view: SKView? = null
    private var texture: SKTexture? = null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
    }

    override fun onPause() {
        super.onPause()

        if (view != null) {
            view!!.onPause()
        }
    }

    override fun onResume() {
        super.onResume()

        if (view != null) {
            view!!.onResume()
        }
    }

    override fun onWindowFocusChanged(hasFocus: Boolean) {
        super.onWindowFocusChanged(hasFocus)

        // call this method here so the views are ready,
        // otherwise the width and height properties of all components will return 0;
        this.skview.queueEvent {
            this.initializeScene()
        }
    }

    private fun initializeScene() {
        if (view == null) {
            view = findViewById(R.id.skview) as SKView
            val scene = SKScene(SKSize(320f, 480f))
            scene.backgroundColor = SKColor.darkGray()

            texture = SKTexture(this, R.drawable.card_deck)

            val swordA = SKSpriteNode.spriteNode(SKColor.white(), SKSize(100f, 200f))
            swordA.texture = SKTexture(SKRect(0.0f, 0.0f, 1.0f / 14.0f, 1.0f / 4.0f), texture!!)
            swordA.colorBlendFactor = 0.5f

            //            SKSpriteNode heartA = SKSpriteNode.spriteNode(SKColor.white(), new SKSize(320, 480));
            //            heartA.setTexture(new SKTexture(new SKRect(0.0f, 2.0f / 4.0f, 1.0f / 14.0f, 1.0f / 4.0f), texture));
            //            heartA.setColorBlendFactor(0.5f);

            val nodeParent = SKNode.node()
            nodeParent.position.x = scene.size.width / 2.0f
            nodeParent.position.y = scene.size.height / 2.0f

            nodeParent.addChild(swordA)
            //            nodeParent.addChild(heartA);

            //            heartA.zPosition = -1;

            scene.addChild(nodeParent)

            view!!.presentScene(scene)

            view!!.setOnTouchListener(this)

            //            animateMovingCards(swordA);

            swordA.zRotation = 0.0f
            swordA.run(SKAction.sequence(Arrays.asList(SKAction.waitFor(1000), SKAction.rotateToAngle((Math.PI / 2).toFloat(), 500))))
            swordA.run(SKAction.sequence(Arrays.asList(SKAction.waitFor(2000), SKAction.rotateToAngle(Math.PI.toFloat(), 500))))
            swordA.run(SKAction.sequence(Arrays.asList(SKAction.waitFor(3000), SKAction.rotateToAngle((3 * Math.PI / 2).toFloat(), 500))))
            swordA.run(SKAction.sequence(Arrays.asList(SKAction.waitFor(4000), SKAction.rotateToAngle((Math.PI * 2).toFloat(), 500))))
        }
    }

    private fun rotate(nodeParent: SKNode) {
        nodeParent.run(SKAction.sequence(Arrays.asList(
                SKAction.rotateByAngle(1f, 50),
                SKAction.run {
                    rotate(nodeParent)
                })))
    }

    override fun onTouch(v: View, event: MotionEvent): Boolean {
        when (event.action) {
            MotionEvent.ACTION_MOVE ->

                return true

            else -> {
            }
        }
        return false<commit_msg>Modified tests Activity to test convert and atPoint functions;<commit_after>package br.com.insanitech.testapp

import android.app.Activity
import android.os.Bundle
import android.view.MotionEvent
import android.view.View
import br.com.insanitech.spritekit.*
import br.com.insanitech.spritekit.actions.SKAction
import br.com.insanitech.spritekit.graphics.SKColor
import br.com.insanitech.spritekit.graphics.SKPoint
import br.com.insanitech.spritekit.graphics.SKRect
import br.com.insanitech.spritekit.graphics.SKSize
import kotlinx.android.synthetic.main.activity_main.*
import java.util.*

/**
 * Created by anderson on 24/06/15.
 */
class TestAppActivity : Activity(), View.OnTouchListener {
    private var view: SKView? = null
    private var texture: SKTexture? = null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
    }

    override fun onPause() {
        super.onPause()

        if (view != null) {
            view!!.onPause()
        }
    }

    override fun onResume() {
        super.onResume()

        if (view != null) {
            view!!.onResume()
        }
    }

    override fun onWindowFocusChanged(hasFocus: Boolean) {
        super.onWindowFocusChanged(hasFocus)

        // call this method here so the views are ready,
        // otherwise the width and height properties of all components will return 0;
        this.skview.queueEvent {
            this.initializeScene()
        }
    }

    private fun initializeScene() {
        if (view == null) {
            view = findViewById(R.id.skview) as SKView
            val scene = SKScene(SKSize(320f, 480f))
            scene.backgroundColor = SKColor.darkGray()

            texture = SKTexture(this, R.drawable.card_deck)

            val swordA = SKSpriteNode.spriteNode(SKColor.white(), SKSize(100f, 200f))
            swordA.texture = SKTexture(SKRect(0.0f, 0.0f, 1.0f / 14.0f, 1.0f / 4.0f), texture!!)
            swordA.colorBlendFactor = 0.5f

            val heartA = SKSpriteNode.spriteNode(SKColor.white(), SKSize(100f, 200f))
            heartA.texture = SKTexture(SKRect(0.0f, 2.0f / 4.0f, 1.0f / 14.0f, 1.0f / 4.0f), texture!!)
            heartA.colorBlendFactor = 0.5f

            val nodeParent = SKNode.node()
            nodeParent.position.x = scene.size.width / 2.0f
            nodeParent.position.y = scene.size.height / 2.0f

            nodeParent.addChild(swordA)
            nodeParent.addChild(heartA)

            heartA.zPosition = -1f

            scene.addChild(nodeParent)

            view!!.presentScene(scene)

            view!!.setOnTouchListener(this)

            swordA.position.x -= 20f
            heartA.position.x += 20f
        }
    }

    private fun rotate(nodeParent: SKNode) {
        nodeParent.run(SKAction.sequence(Arrays.asList(
                SKAction.rotateByAngle(1f, 50),
                SKAction.run {
                    rotate(nodeParent)
                })))
    }

    override fun onTouch(v: View, event: MotionEvent): Boolean {
        System.out.println(event.toString())
        when (event.actionMasked) {
            MotionEvent.ACTION_UP -> {
                val touchLocation = SKPoint(event.x, event.y)
                val sceneLocation = this.view!!.scene!!.convertPoint(touchLocation)
                val touchNode = this.view!!.scene!!.atPoint(sceneLocation) as? SKSpriteNode
                System.out.println("Node position: ${touchNode?.position}, size: ${touchNode?.size}")
                System.out.println("Node's accumulated frame: ${touchNode?.calculateAccumulatedFrame()}")
            }
            else -> { }
        }
        return true
{'fraction_non_alphanumeric': 0.11312458361092605, 'fraction_numerical': 0.022385076615589607, 'mean_word_length': 2.1805084745762713, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '3140148', 'n_tokens_mistral': 2426, 'n_tokens_neox': 2259, 'n_words': 419}