/* 	D.java	Title:			Virtual Control Surface	Author:			root	Description:	Copyright © 2001 Jason LamportAll Rights ReservedD is a class used only for debugging and testing.(see static method D.bug() )*/package com.strangelight.v4control;import com.strangelight.*;import com.strangelight.salsa.*;import com.strangelight.mactoolbox.*;import java.awt.*;import java.awt.event.*;import java.net.*;public class D extends J_Frame implements 	V4ControlLib_interface,		/* ***********		ActionListener, 	AdjustmentListener, 	AncestorListener, 	InputMethodListener,	InternalFrameListener, 	InvocationListener, 	ItemListener, 	TextListener,	ContainerListener, 	FocusListener, 	InputListener, 	PaintListener,	KeyListener, 	MouseListener, 		***** */			WindowListener, 	ActionListener ,	ComponentListener, 	MouseMotionListener{	private V_Knob test_knob;	private java.util.Random rand = new java.util.Random();	public void do_test1() {		int val, ch, cntrlr;		ch = 1 + (int)( 16 * rand.nextFloat() );		cntrlr = (int)( 256 * rand.nextFloat() );		val = (int)( 128 * rand.nextFloat() );				bug( test_knob + ":" + ch + ":" + cntrlr + ":" + val );		test_knob.set_value(val);		test_knob.set_controller(cntrlr);		test_knob.set_channel(ch);	}		public D() {						setLocation(new java.awt.Point(0, 0));		setTitle("DEBUG");		setLayout(null);		setSize(new java.awt.Dimension(350, 235));				test_knob = new V_Knob(1,2,3);		add( test_knob );				setVisible(true);				bug("instance of D created.");	}		public static void init() {		flusher = new DebuggerFlusher();	}			//______  native code debugger section _______________________	private static DebuggerFlusher flusher;		private static final class DebuggerFlusher extends Thread 		implements V4ControlLib_interface 	{		private native static void j_flush_debugger();		boolean keep_running = true;		int jvm_output_every =5000;			//	print a message every jvm_output_every millisec		int SLEEP_MS = 100;				public void run() {			int msec_since_last_msg = 0;						while ( keep_running ) {				j_flush_debugger();				msec_since_last_msg += SLEEP_MS;				try {					sleep(SLEEP_MS);				} catch ( InterruptedException x ) {					D.bug("DebuggerFlusher interrupted!");				}				if ( msec_since_last_msg >= jvm_output_every ) {					msec_since_last_msg = 0;					D.bug(						"<still flushing native-code debugger every "						+ SLEEP_MS + "ms>"					);				}			}		}				DebuggerFlusher() {			setDaemon(true);			start();		}	}	private native static void j_macsBug( byte[] msg );	private native static void j_debug( byte[] msg );		public static void macsBug(byte[] ba) {		macsBug( ASCII.toString(ba) );	}	public static void macsBug(Object[] objs) {		for( int i=0; i < objs.length; i++) {			macsBug( objs[i] );		}	}		public static void macsBug(Object obj) {		byte length_byte = (byte) obj.toString().length(); 		//	this ugly-looking expression just turns obj.toString() into a length-		//	prefixed (i.e. Pascal-style) array of 8-bit chars:		j_macsBug( 			(				( (char) length_byte )				+ obj.toString() 			).getBytes()		);	}	public static void bug_native(byte[] ba) {		bug_native( ASCII.toString(ba) );	}	public static void bug_native(Object[] objs) {		for( int i=0; i < objs.length; i++) {			bug_native( objs[i] );		}	}		public static void bug_native(Object obj) {		j_debug( ( obj.toString() + "\0").getBytes() );	}//____________________________________________________________	public static void bug(byte[] ba) {		System.out.println( ASCII.toString(ba) );	}	public static void bug(Object[] objs) {		for( int i=0; i < objs.length; i++) {			bug( objs[i] );		}	}		public static void bug(Object obj) {		System.out.println(obj);	}	public void actionPerformed(ActionEvent e) {		D.bug(e);		try {			if ( e.getSource() == ApplicationMBar.getItem(ApplicationMBar.TEST_1) ) {				do_test1();			} else if (  e.getSource() == ApplicationMBar.getItem(ApplicationMBar.TEST_2)  ) {				do_test2();			}		} catch (E_Exception err) {			err.printStackTrace();		}	}  		public void do_test2() throws E_OSErr {		J_OMSOutputNodes list = new J_OMSOutputNodes();		D.bug( list.get_infoRecs() );	}		//	WindowListener methods				public void windowActivated(WindowEvent e) {		//	D.bug( e.paramString() + e.getSource().toString() );	}	public void windowClosed(WindowEvent e) {		//	D.bug( e.paramString() + e.getSource().toString() );	}	public void windowClosing(WindowEvent e) {		//	D.bug( e.paramString() + e.getSource().toString() );	}	public void windowDeactivated(WindowEvent e) {		//	D.bug( e.paramString() + e.getSource().toString() );	}	public void windowDeiconified(WindowEvent e) {		//	D.bug( e.paramString() + e.getSource().toString() );	}	public void windowIconified(WindowEvent e) {		//	D.bug( e.paramString() + e.getSource().toString() );	}	public void windowOpened(WindowEvent e) {		//	D.bug( e.paramString() + e.getSource().toString() );	}		//	MouseMotionListener methods			public void mouseDragged(MouseEvent e) {		//	D.bug( e.paramString() + e.getSource().toString() );	}	public void mouseMoved(MouseEvent e) {		//	D.bug( e.paramString() + e.getSource().toString() );	}		//	ComponentListener methods			public void componentHidden(ComponentEvent e) {		//	D.bug( e.paramString() + e.getSource().toString() );	}	public void componentMoved(ComponentEvent e) {		//	D.bug( e.paramString() + e.getSource().toString() );	}	public void componentResized(ComponentEvent e) {		//	D.bug( e.paramString() + e.getSource().toString() );	}	public void componentShown(ComponentEvent e) {		//	D.bug( e.paramString() + e.getSource().toString() );	}	}