import java.util.*; import java.awt.*; import java.applet.*; class RotateSlider extends Slider { protected Blackboard _bb; protected int _oldvalue; public RotateSlider( Blackboard black ) { _bb = black; SetMinimum( 0 ); SetMaximum( 360 ); _oldvalue = 0; SetValue( _oldvalue ); SetWidth( 100 ); } } // class RotateSlider class RotateXSlider extends RotateSlider { public RotateXSlider( Blackboard black ) { super( black ); } public void Motion() { _bb.projection.rotateX( GetValue()-_oldvalue ); _oldvalue = GetValue(); } public void Release() { _bb.projection.rotateX( GetValue()-_oldvalue ); _oldvalue = GetValue(); } } // class RotateXSlider class RotateYSlider extends RotateSlider { public RotateYSlider( Blackboard black ) { super( black ); } public void Motion() { _bb.projection.rotateY( GetValue()-_oldvalue ); _oldvalue = GetValue(); } public void Release() { _bb.projection.rotateY( GetValue()-_oldvalue ); _oldvalue = GetValue(); } } // class RotateYSlider class RotateZSlider extends RotateSlider { public RotateZSlider( Blackboard black ) { super( black ); } public void Motion() { _bb.projection.rotateZ( GetValue()-_oldvalue ); _oldvalue = GetValue(); } public void Release() { _bb.projection.rotateZ( GetValue()-_oldvalue ); _oldvalue = GetValue(); } } // class RotateZSlider public class RotateWindow extends Frame implements Runnable { protected Blackboard _bb; protected Slider _sliderX, _sliderY, _sliderZ; protected boolean _showing = false; public boolean showing() { return _showing; } public void showing( boolean s ) { _showing = s; } public void origo() { _sliderX.SetValue( 0 ); _sliderY.SetValue( 0 ); _sliderZ.SetValue( 0 ); } public RotateWindow( Blackboard black ) { super( "Rotation Controls" ); _bb = black; setLayout(new GridLayout( 0, 2, 4, 4 )); add( new Label("X Rotation:", Label.RIGHT) ); _sliderX = new RotateXSlider( _bb ); add( _sliderX ); add( new Label("Y Rotation:", Label.RIGHT) ); _sliderY = new RotateYSlider( _bb ); add( _sliderY ); add( new Label("Z Rotation:", Label.RIGHT) ); _sliderZ = new RotateZSlider( _bb ); add( _sliderZ ); } // Thread stuff // protected Thread _updater; public void run() { Thread.currentThread().setPriority(Thread.MIN_PRIORITY); while (true) { try { Thread.sleep(100); } catch (InterruptedException e) { break; } } } public void start() { _updater = new Thread(this); _updater.start(); } public void stop() { if( _updater != null ) _updater.stop(); _updater = null; } public boolean handleEvent(Event evt) { if (evt.id == Event.WINDOW_ICONIFY) { hide(); return true; } if (evt.id == Event.WINDOW_DESTROY) { dispose(); return true; } return super.handleEvent(evt); } } // class GraphWindow