package net.kc7.activityframe;

import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

import javax.swing.JPanel;
import javax.swing.Timer;

public class Activity extends JPanel implements ActionListener {

	private static final long serialVersionUID = 1L;
	
	private final int ACTIVITY_WIDTH;
	private final int ACTIVITY_HEIGHT;
	private final int ACTIVITY_FRAMERATE;
	
	private boolean active = false;
	
	protected static final int UP = KeyEvent.VK_UP;
	protected static final int DOWN = KeyEvent.VK_DOWN;
	protected static final int LEFT = KeyEvent.VK_LEFT;
	protected static final int RIGHT = KeyEvent.VK_RIGHT;
	
	public Activity(int width, int height, int framerate) {	
		ACTIVITY_WIDTH = width;
		ACTIVITY_HEIGHT = height;
		ACTIVITY_FRAMERATE = framerate;
		
		setFocusable(true);
		setPreferredSize(new Dimension(ACTIVITY_WIDTH, ACTIVITY_HEIGHT));
		addKeyListener(new KeyHandler());
		
		loadResources();
		startActivity();	
	}
	
	// OVERRIDE -- Loads images, audio, and other assets
	protected boolean loadResources() {
		return true;
	}
	
	// DEFAULT -- Kicks off the activity
	protected boolean startActivity() {
		active = true;
		Timer timer = new Timer(ACTIVITY_FRAMERATE, this);
		timer.start();
		
		return true;
	}
	
	// OVERRIDE -- Handle data and execute tasks every frame
	private boolean processInfo() {
		return true;
	}
	
	@Override
	public final void actionPerformed(ActionEvent e) {
		if (active) processInfo();
		repaint();
	}
	
	@Override
	public final void paintComponent(Graphics g) {
		super.paintComponent(g);
		
		if (active) drawView(g);
		else drawVoid(g);
	}
	
	// OVERRIDE -- Draws the View every active frame
	protected boolean drawView(Graphics g) {
		return true;
	}
	
	protected boolean drawVoid(Graphics g) {
		return true;
	}
	
	private boolean handleKey(int key) {
		return true;
	}
	
	private final class KeyHandler extends KeyAdapter {
		
		@Override
		public void keyPressed(KeyEvent e) {
			
			handleKey(e.getKeyCode());
			
		}
	}
}

@@ -291,16 +291,25 @@
 %0Apublic 
+abstract 
 class Ac
@@ -419,81 +419,8 @@
 %0A%09%0D%0A
-%09private final int ACTIVITY_WIDTH;%0D%0A%09private final int ACTIVITY_HEIGHT;%0D%0A
 %09pri
@@ -453,37 +453,39 @@
 AMERATE;%0D%0A%09%0D%0A%09pr
-iva
+otec
 te
+d
  boolean active 
@@ -494,16 +494,41 @@
 false;%0D%0A
+%09protected Timer timer;%0D%0A
 %09%0D%0A%09prot
@@ -802,64 +802,8 @@
 %7B%09%0D%0A
-%09%09ACTIVITY_WIDTH = width;%0D%0A%09%09ACTIVITY_HEIGHT = height;%0D%0A
 %09%09AC
@@ -897,39 +897,21 @@
 ion(
-ACTIVITY_WIDTH, ACTIVITY_HEIGHT
+width, height
 ));%0D
@@ -1003,28 +1003,16 @@
 %0D%0A%09%0D%0A%09//
- OVERRIDE --
  Loads i
@@ -1054,23 +1054,29 @@
 otected 
-boolean
+abstract void
  loadRes
@@ -1087,49 +1087,17 @@
 es()
- %7B%0D%0A%09%09return true;%0D%0A%09%7D%0D%0A%09%0D%0A%09// DEFAULT --
+;%0D%0A%09%0D%0A%09//
  Kic
@@ -1128,23 +1128,20 @@
 otected 
-boolean
+void
  startAc
@@ -1172,22 +1172,16 @@
 rue;%0D%0A%09%09
-Timer 
 timer = 
@@ -1241,49 +1241,17 @@
 ;%0D%0A%09
-%09%0D%0A%09%09return true;%0D%0A%09%7D%0D%0A%09%0D%0A%09// OVERRIDE --
+%7D%0D%0A%09%0D%0A%09//
  Han
@@ -1293,29 +1293,37 @@
 ame%0D%0A%09pr
-ivate boolean
+otected abstract void
  process
@@ -1328,38 +1328,273 @@
 ssInfo()
- %7B%0D%0A%09%09return true;%0D%0A%09%7D
+;%0D%0A%09%0D%0A%09// Draws the View every active frame%0D%0A%09protected abstract void drawView(Graphics g);%0D%0A%09%0D%0A%09// Draws the Void for an inactive frame%0D%0A%09protected abstract void drawVoid(Graphics g);%0D%0A%09%0D%0A%09// Handles key values%0D%0A%09protected abstract void handleKey(int key);
 %0D%0A%09%0D%0A%09@O
@@ -1712,37 +1712,40 @@
 %0D%0A%09@Override%0D%0A%09p
-ublic
+rotected
  final void pain
@@ -1862,253 +1862,8 @@
 %0A%09%0D%0A
-%09// OVERRIDE -- Draws the View every active frame%0D%0A%09protected boolean drawView(Graphics g) %7B%0D%0A%09%09return true;%0D%0A%09%7D%0D%0A%09%0D%0A%09protected boolean drawVoid(Graphics g) %7B%0D%0A%09%09return true;%0D%0A%09%7D%0D%0A%09%0D%0A%09private boolean handleKey(int key) %7B%0D%0A%09%09return true;%0D%0A%09%7D%0D%0A%09%0D%0A
 %09pri
@@ -1969,21 +1969,16 @@
 t e) %7B%0D%0A
-%09%09%09%0D%0A
 %09%09%09handl
@@ -2004,13 +2004,8 @@
 );%0D%0A
-%09%09%09%0D%0A
 %09%09%7D%0D

Revert "Revert "Major Update -- v0.9""