/*
Program to display coordinates of handwriting and their velocity
interactively. The XY coordinates are loaded via a URL.

Copyright, Lambert Schomaker/NICI, March 1996.

Please, refer to the author when using this code by:

Schomaker, L.R.B. (1993).
Using Stroke- or Character-based Self-organiZing Maps
in the Recognition of On-line, Connected Cursive Script.
{\em Pattern Recognition}, 26(3), 443-450.

Schomaker, L.R.B., & Teulings, H.-L. (1990).
A Handwriting Recognition System based on the Properties and Architectures 
of the Human Motor System.
{\em Proceedings of the International Workshop on Frontiers in Handwriting
Recognition (IWFHR)}. (pp. 195-211). Montreal: CENPARMI Concordia.
 */

import java.awt.*;
import java.applet.*;

/*
 * Can be run either as a standalone application by
 * typing "java hwrveloc" or as an applet in the AppletViewer.
 */

public class hwrveloc extends Applet {
    hwrFilterPanel pc;
    hwrVelocPanel pv;

    public void init() {

	pc = new hwrFilterPanel(false,false,false);
	pv = new hwrVelocPanel();

	setLayout(new GridLayout(0,1));
	add(pc);
	add(pv);

        pc.canvas.Hin = new hwrCoord(1);
        pc.canvas.Boxcarwidth = 11;
        pv.canvas.H = pc.canvas.Hout;

    } 

    public void start() {
	pc.controls.enable();
	pv.controls.enable();
    }

    public void stop() {
	pc.controls.disable();
	pv.controls.disable();
    }

    public boolean handleEvent(Event e) {
	if (e.id == Event.WINDOW_DESTROY) {
	    System.exit(0);
        } else {
              if(e.id == e.ACTION_EVENT ) {
                 // System.out.println(e.arg);
                 if(e.arg.equals("FilterEvent")) {
                   pv.canvas.H = pc.canvas.Hout;
                   pv.canvas.redraw();
                   // return true;
                 } else if(e.arg.equals("CursorEvent")) {
                        pc.canvas.Cursor = pv.canvas.Cursor;
                        pc.canvas.repaint();
                 } else if(e.arg.equals("MinimaEvent")) {
                        pc.canvas.repaint();
                 }
              }
        }
	return false;
    }

    public static void main(String args[]) {
	Frame f = new Frame("hwrveloc");
	hwrveloc hwrVeloc = new hwrveloc();

	hwrVeloc.init();           /* Read the ink data etc. */
	hwrVeloc.start();          /* Enable the control events */

	f.add("Center", hwrVeloc); /* Put the hwrVeloc object on the frame */
                                   /* In the middle, that is. */
        f.pack();
	f.resize(500, 600);        /* Size in pixels. Words are wider than high */
	f.show();                  /* Show it all */
    }
}
    
/* end hwrveloc.java */

