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 () |
|
00021 { 00022 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); 00023 setSize(componentSize()); 00024 addMouseListener(this); 00025 _keyTurned = false; 00026 } |
|
00029 { 00030 return new Dimension(61, 43); 00031 } |
|
00034 { 00035 turnKey(!_keyTurned); 00036 } |
|
00039 { 00040 _keyTurned = pos; 00041 repaint(); 00042 } |
|
00045 { 00046 return _keyTurned; 00047 } |
|
|
|
00055 { 00056 if(getParent() instanceof AnimatedMachine) { 00057 AnimatedMachine parent = (AnimatedMachine)getParent(); 00058 parent.keyPressed(); 00059 } 00060 } |
|
00062 {} |
|
00063 {} |
|
00064 {} |
|
00065 {} |
|
00069 { 00070 startAnimation(500); 00071 } |
|
00074 { 00075 _animDelay = t; 00076 _animThread = new Thread(this); 00077 _animThread.start(); 00078 } |
|
00081 { 00082 if(_animThread == null) return; 00083 00084 try { _animThread.join(); } 00085 catch(InterruptedException e) {} 00086 } |
|
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 } |