org::scilab::modules::gui::events::AxesRotationTracker Class Reference

Inheritance diagram for org::scilab::modules::gui::events::AxesRotationTracker:

Inheritance graph
[legend]
Collaboration diagram for org::scilab::modules::gui::events::AxesRotationTracker:

Collaboration graph
[legend]

Public Member Functions

 AxesRotationTracker (SwingScilabCanvas canvas)
void waitForClick (int[] clickPosition)
boolean getDisplacement (int[] displacement)
void cancelRecording ()
void mouseClicked (MouseEvent event)
void mouseEntered (MouseEvent event)
void mouseExited (MouseEvent event)
void mousePressed (MouseEvent event)
void mouseReleased (MouseEvent event)
void focusGained (FocusEvent event)
void focusLost (FocusEvent event)

Protected Member Functions

void reinit ()
void startRecording (int initX, int initY)
void endRecording ()

Private Attributes

boolean recordStarted
boolean recordEnded
boolean isWaitingForClick
int clickPosX
int clickPosY

Detailed Description

Class used to retrieve displacement that must be used for interactive rotation.
Author:
Jean-Baptiste Silvy

Definition at line 30 of file AxesRotationTracker.java.


Constructor & Destructor Documentation

org::scilab::modules::gui::events::AxesRotationTracker::AxesRotationTracker ( SwingScilabCanvas  canvas  )  [inline]

default constructor

Parameters:
canvas canvas on which we want to recod mouse displacement

Definition at line 43 of file AxesRotationTracker.java.

References reinit().

00043                                                              {
00044                 super(canvas);
00045                 reinit();
00046         }

Here is the call graph for this function:


Member Function Documentation

void org::scilab::modules::gui::events::AxesRotationTracker::reinit (  )  [inline, protected]

Reinit mouse tracking

Reimplemented from org::scilab::modules::gui::events::MouseDisplacementTracker.

Definition at line 51 of file AxesRotationTracker.java.

References clickPosX, clickPosY, and org::scilab::modules::gui::events::MouseDisplacementTracker::getTrackedCanvas().

Referenced by AxesRotationTracker(), cancelRecording(), and getDisplacement().

00051                                 {
00052                 super.reinit();
00053                 this.recordStarted = false;
00054                 this.recordEnded = false;
00055                 this.isWaitingForClick = false;
00056                 clickPosX = -1;
00057                 clickPosY = -1;
00058                 // Back to default cursor
00059                 getTrackedCanvas().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
00060         }

Here is the call graph for this function:

Here is the caller graph for this function:

void org::scilab::modules::gui::events::AxesRotationTracker::waitForClick ( int[]  clickPosition  )  [inline]

Wait for a click in the graphic canvas.

Parameters:
clickPosition position of the click in pixel

Definition at line 66 of file AxesRotationTracker.java.

References clickPosX, clickPosY, org::scilab::modules::gui::events::MouseDisplacementTracker::getLock(), org::scilab::modules::gui::events::MouseDisplacementTracker::getTrackedCanvas(), and isWaitingForClick.

Referenced by getDisplacement().

00066                                                       {
00067                 getTrackedCanvas().addMouseListener(this);
00068                 getTrackedCanvas().addFocusListener(this);
00069                 synchronized (getLock()) {
00070                         isWaitingForClick = true;
00071                         // wait until the click occures
00072                         try {
00073                                 getLock().wait();
00074                         } catch (InterruptedException e) {
00075                                 e.printStackTrace();
00076                         }
00077                         clickPosition[0] = clickPosX;
00078                         clickPosition[1] = clickPosY;
00079                 }
00080                 getTrackedCanvas().removeMouseListener(this);
00081                 getTrackedCanvas().removeFocusListener(this);
00082         }

Here is the call graph for this function:

Here is the caller graph for this function:

boolean org::scilab::modules::gui::events::AxesRotationTracker::getDisplacement ( int[]  displacement  )  [inline]

Retrieve the displacement performed since last call to the function. First call to the function waits for clivk to initialize

Parameters:
displacement array [dx, dy] displacement in pixels since last call
Returns:
true if it is still needed to retrieve displacement, false otherwise

Definition at line 90 of file AxesRotationTracker.java.

References clickPosX, clickPosY, org::scilab::modules::gui::events::MouseDisplacementTracker::getImmediateMouseDisplacement(), org::scilab::modules::gui::events::MouseDisplacementTracker::getMouseDisplacement(), org::scilab::modules::gui::events::MouseDisplacementTracker::getTrackedCanvas(), recordEnded, recordStarted, reinit(), startRecording(), and waitForClick().

Referenced by org::scilab::modules::gui::bridge::canvas::SwingScilabCanvas::getRotationDisplacement().

00090                                                            {
00091                 // Change cursor
00092                 
00093                 if (!recordStarted) {
00094                         // first call
00095                         Image icon = Toolkit.getDefaultToolkit().getImage(System.getenv("SCI") + "/modules/gui/images/icons/rotate.png");
00096                         getTrackedCanvas().setCursor(Toolkit.getDefaultToolkit().createCustomCursor(icon, new Point(0, 0), "rotate"));
00097                         waitForClick(displacement);
00098                         startRecording(clickPosX, clickPosY);
00099                         return true;
00100                 } else if (!recordEnded) {
00101                         // inside tracking loop
00102                         // get mouse displacement since last call
00103                         getMouseDisplacement(displacement);
00104                         return true;
00105                 } else {
00106                         // last call get current displacement and return
00107                         getImmediateMouseDisplacement(displacement);
00108                         
00109                         // reinit for a next call
00110                         reinit();
00111 
00112                         return false;
00113                 }
00114         }

Here is the call graph for this function:

Here is the caller graph for this function:

void org::scilab::modules::gui::events::AxesRotationTracker::cancelRecording (  )  [inline]

Manual disactivation of recording

Definition at line 119 of file AxesRotationTracker.java.

References endRecording(), and reinit().

Referenced by org::scilab::modules::gui::bridge::canvas::SwingScilabCanvas::stopRotationRecording().

00119                                       {
00120                 endRecording();
00121                 reinit();
00122         }

Here is the call graph for this function:

Here is the caller graph for this function:

void org::scilab::modules::gui::events::AxesRotationTracker::startRecording ( int  initX,
int  initY 
) [inline, protected]

Start mouse tarcking.

Parameters:
initX initial X coordinate
initY initial Y coordinate

Definition at line 129 of file AxesRotationTracker.java.

References org::scilab::modules::gui::events::MouseDisplacementTracker::activateTracking(), org::scilab::modules::gui::events::MouseDisplacementTracker::getTrackedCanvas(), and recordStarted.

Referenced by getDisplacement().

00129                                                             {
00130                 activateTracking(initX, initY);
00131                 // for final click
00132                 getTrackedCanvas().addMouseListener(this);
00133                 getTrackedCanvas().addFocusListener(this);
00134                 recordStarted = true;
00135         }

Here is the call graph for this function:

Here is the caller graph for this function:

void org::scilab::modules::gui::events::AxesRotationTracker::endRecording (  )  [inline, protected]

End mouse tracking.

Definition at line 140 of file AxesRotationTracker.java.

References org::scilab::modules::gui::events::MouseDisplacementTracker::desactivateTracking(), org::scilab::modules::gui::events::MouseDisplacementTracker::getTrackedCanvas(), recordEnded, and recordStarted.

Referenced by cancelRecording(), focusLost(), and mousePressed().

00140                                       {
00141                 if (recordStarted) {
00142                         desactivateTracking();
00143                 }
00144                 getTrackedCanvas().removeMouseListener(this);
00145                 getTrackedCanvas().removeFocusListener(this);
00146                 recordEnded = true;
00147         }

Here is the call graph for this function:

Here is the caller graph for this function:

void org::scilab::modules::gui::events::AxesRotationTracker::mouseClicked ( MouseEvent  event  )  [inline]

Parameters:
event clieck event

Definition at line 152 of file AxesRotationTracker.java.

00152                                                    {
00153                 // everything si done in mouse pressed
00154         }

void org::scilab::modules::gui::events::AxesRotationTracker::mouseEntered ( MouseEvent  event  )  [inline]

Parameters:
event entering event

Definition at line 159 of file AxesRotationTracker.java.

00159                                                    {
00160                 // not used
00161 
00162         }

void org::scilab::modules::gui::events::AxesRotationTracker::mouseExited ( MouseEvent  event  )  [inline]

Parameters:
event exiting event

Definition at line 167 of file AxesRotationTracker.java.

00167                                                   {
00168                 // not used
00169 
00170         }

void org::scilab::modules::gui::events::AxesRotationTracker::mousePressed ( MouseEvent  event  )  [inline]

Parameters:
event press event

Definition at line 175 of file AxesRotationTracker.java.

References clickPosX, clickPosY, endRecording(), org::scilab::modules::gui::events::MouseDisplacementTracker::getLock(), isWaitingForClick, recordEnded, recordStarted, and org::scilab::modules::gui::events::MouseDisplacementTracker::updateDisplacement().

00175                                                    {
00176                 if (isWaitingForClick) {
00177                         clickPosX = event.getX();
00178                         clickPosY = event.getY();
00179                         isWaitingForClick = false;
00180                         
00181                         // wake the click waiter
00182                         synchronized (getLock()) {
00183                                 getLock().notifyAll();
00184                         }
00185                         
00186                         return;
00187                 } else if (recordStarted && !recordEnded) {
00188                         // tracking loop
00189                         
00190                         // update position
00191                         // so next call to getDisplacement will get it
00192                         updateDisplacement(event.getX(), event.getY());
00193                         
00194                         // we finish record loop
00195                         endRecording();
00196                 }
00197         }

Here is the call graph for this function:

void org::scilab::modules::gui::events::AxesRotationTracker::mouseReleased ( MouseEvent  event  )  [inline]

Parameters:
event release event

Definition at line 202 of file AxesRotationTracker.java.

00202                                                     {
00203                 // nothing to do
00204 
00205         }

void org::scilab::modules::gui::events::AxesRotationTracker::focusGained ( FocusEvent  event  )  [inline]

Parameters:
event focus gained event

Definition at line 210 of file AxesRotationTracker.java.

00210                                                   {
00211                 // nothing to do here
00212                 // canvas must always have focus
00213         }

void org::scilab::modules::gui::events::AxesRotationTracker::focusLost ( FocusEvent  event  )  [inline]

This event occures when the canvas lost focus but also when the windows is closed. We then need to wake up every one.

Parameters:
event focus lost event

Definition at line 220 of file AxesRotationTracker.java.

References endRecording(), and org::scilab::modules::gui::events::MouseDisplacementTracker::getLock().

00220                                                 {
00221                 // focus lost so stop recording
00222                 endRecording();
00223                 synchronized (getLock()) {
00224                         getLock().notifyAll();
00225                 }
00226         }

Here is the call graph for this function:


Field Documentation

Definition at line 33 of file AxesRotationTracker.java.

Referenced by endRecording(), getDisplacement(), and mousePressed().

Definition at line 34 of file AxesRotationTracker.java.

Referenced by mousePressed(), and waitForClick().

Definition at line 36 of file AxesRotationTracker.java.

Referenced by getDisplacement(), mousePressed(), reinit(), and waitForClick().

Definition at line 37 of file AxesRotationTracker.java.

Referenced by getDisplacement(), mousePressed(), reinit(), and waitForClick().


The documentation for this class was generated from the following file:

Generated on Tue Sep 9 18:25:29 2008 for Scilab [trunk] by  doxygen 1.5.5