Horus Doc || Java GUI Reference || Doxygen's quick Index  

KeyComponent Class Reference

List of all members.

Public Methods

 KeyComponent ()
void turnKey ()
void turnKey (boolean pos)
boolean isTurned ()
void paint (Graphics g)
void mouseClicked (MouseEvent e)
void mouseEntered (MouseEvent e)
void mouseExited (MouseEvent e)
void mousePressed (MouseEvent e)
void mouseReleased (MouseEvent e)
void startAnimation ()
void startAnimation (int t)
void joinAnimation ()
void run ()

Static Public Methods

Dimension componentSize ()

Constructor & Destructor Documentation

KeyComponent::KeyComponent   [inline]
 

00021 {
00022     setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
00023     setSize(componentSize());
00024     addMouseListener(this);
00025     _keyTurned = false;
00026 }


Member Function Documentation

Dimension KeyComponent::componentSize   [inline, static]
 

00029 {
00030     return new Dimension(61, 43);
00031 }

void KeyComponent::turnKey   [inline]
 

00034 {
00035     turnKey(!_keyTurned);
00036 }

void KeyComponent::turnKey boolean    pos [inline]
 

00039 {
00040     _keyTurned = pos;
00041     repaint();
00042 }

boolean KeyComponent::isTurned   [inline]
 

00045 {
00046     return _keyTurned;
00047 }

void KeyComponent::paint Graphics    g [inline]
 

00050 {
00051     g.drawImage((_keyTurned? Images.keyM: Images.key), 0, 0, this);
00052 }

void KeyComponent::mouseClicked MouseEvent    e [inline]
 

00055 {
00056     if(getParent() instanceof AnimatedMachine) {
00057         AnimatedMachine parent = (AnimatedMachine)getParent();
00058         parent.keyPressed();
00059     }
00060 }

void KeyComponent::mouseEntered MouseEvent    e [inline]
 

00062 {}

void KeyComponent::mouseExited MouseEvent    e [inline]
 

00063 {}

void KeyComponent::mousePressed MouseEvent    e [inline]
 

00064 {}

void KeyComponent::mouseReleased MouseEvent    e [inline]
 

00065 {}

void KeyComponent::startAnimation   [inline]
 

00069 {
00070     startAnimation(500);
00071 }

void KeyComponent::startAnimation int    t [inline]
 

00074 {
00075     _animDelay = t;
00076     _animThread = new Thread(this);
00077     _animThread.start();
00078 }

void KeyComponent::joinAnimation   [inline]
 

00081 {
00082     if(_animThread == null) return;
00083 
00084     try { _animThread.join(); }
00085     catch(InterruptedException e) {}
00086 }

void KeyComponent::run   [inline]
 

00089 {
00090     if(!(getParent() instanceof AnimatedMachine)) return;
00091 
00092     AnimatedMachine parent = (AnimatedMachine)getParent();
00093     boolean initialPos = _keyTurned;
00094 
00095     do {
00096         turnKey();
00097         parent.animationStep();
00098         try {
00099            _animThread.sleep(_animDelay);
00100         }catch(InterruptedException e) {}
00101     } while(parent.continueAnimation() || (initialPos != _keyTurned));
00102 }


The documentation for this class was generated from the following file:
Generated on Mon Jan 27 15:11:22 2003 for JavaReference by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001