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

TrackingApp Class Reference

Tracking demo. More...

Inheritance diagram for TrackingApp::

CorbaSampleApp SampleApp List of all members.

Public Methods

void handleOpen ()
 This function is called by _bmenu if the associated menu item is selected. More...

void handleExit ()
 This function is called by _bmenu if the associated menu item is selected. More...

void actionPerformed (ActionEvent e)
void handleDisplayMode (String mode)
void handlePlayMode (String mode)
void handleUseMDC (boolean val)

Static Public Methods

void main (String[] args)
 main is called when this is used as an application. More...


Protected Methods

boolean buildSample (JFrame parent, JApplet applet, String[] args)

Detailed Description

Tracking demo.


Member Function Documentation

void TrackingApp::main String    args[] [inline, static]
 

main is called when this is used as an application.

This function has to be overloaded in the "leaf node" application itself.

Reimplemented from SampleApp.

00038 {
00039     TrackingApp app = new TrackingApp();
00040     app.doMain(args);
00041 
00042     // doMain will call buildSample
00043 }

void TrackingApp::handleOpen   [inline]
 

This function is called by _bmenu if the associated menu item is selected.

00049 {
00050     _director.stop();
00051 
00052     File file = askFilename(SEQ_FILTER, CorbaMediator.instance().hasLocalServer());
00053     if(file == null) return;
00054 
00055     HxCorba.Constructor cons =
00056         ServiceRepository.instance().getConstructor();
00057     if(cons == null) return;
00058 
00059     try {
00060         _seq = cons.constructBufferedImageSeq(file.getPath(), BUFF_SIZE+3);
00061         _seqPath = file.getPath();
00062         int nrFrames = _seq.nrFrames();
00063 
00064         _leftImCanvasSeq = new CanvasCorbaSequence(_seq);
00065         _leftViewer.doClear();
00066         _leftViewer.addObject(_leftImCanvasSeq);
00067 
00068         _rightImCanvas = new CanvasCorbaImage(_seq.getFrame(0), _displayMode);
00069         _rightViewer.doClear();
00070         _rightViewer.addObject(_rightImCanvas);
00071 
00072         handlePlayMode(_playMode);
00073 
00074         _director = new PlayingDirector(nrFrames);
00075 
00076         FrameNavigatorDisplayer disp = new FrameNavigatorDisplayer(_frameNav);
00077 
00078         _director.addPlayingObserver(new FrameDisplayer());
00079         _director.addPlayingObserver(new ResultDisplayer());
00080         _director.addPlayingObserver(new FrameStatusDisplayer());
00081         _director.addPlayingObserver(new TrackDisplayer());
00082         _director.addPlayingObserver(disp.makeObserver(_director));
00083 
00084         _butReset.setEnabled(true);
00085         _butPlay.setEnabled(true);
00086         _butStop.setEnabled(true);
00087         _butStep.setEnabled(true);
00088 
00089         _director.setCurrentFrame(0);
00090     }
00091     catch(org.omg.CORBA.OBJECT_NOT_EXIST ex) {
00092         ErrorStreamArea.println("Image sequence "+file.getName()+" doesn't exist");
00093     }
00094     catch(Exception ex) {
00095         ErrorStreamArea.println(" "+ex);
00096         ex.printStackTrace();
00097     }
00098 }

void TrackingApp::handleExit   [inline]
 

This function is called by _bmenu if the associated menu item is selected.

00104 {
00105     unregisterApp();
00106     quitSample();
00107 }

void TrackingApp::actionPerformed ActionEvent    e [inline]
 

00110 {
00111     if(e.getSource() == _butReset) _director.reset();
00112     if(e.getSource() == _butStop) _director.stop();
00113     if(e.getSource() == _butPlay) _director.play();
00114     if(e.getSource() == _butStep) _director.step();
00115 }

void TrackingApp::handleDisplayMode String    mode [inline]
 

00119 {
00120     _displayMode = mode;
00121     if(_rightImCanvas != null)
00122         _rightImCanvas.setDisplayMode(_displayMode);
00123 }

void TrackingApp::handlePlayMode String    mode [inline]
 

00126 {
00127     _playMode = mode;
00128     if(_seq == null) return;
00129 
00130     _leftImCanvasSeq = mode.equals(THREADED)?
00131     new CanvasCorbaSeqThread(_seq, BUFF_SIZE) :
00132     new CanvasCorbaSequence(_seq);
00133     _leftViewer.doClear();
00134     _leftViewer.addObject(_leftImCanvasSeq);
00135 }

void TrackingApp::handleUseMDC boolean    val [inline]
 

00138 {
00139     HxCorba.Constructor cons =
00140         ServiceRepository.instance().getConstructor();
00141     if(cons == null) return;
00142     int flag = (val) ? 1 : 0;
00143     cons.setUseMDC(flag);
00144 }

boolean TrackingApp::buildSample JFrame    parent,
JApplet    applet,
String    args[]
[inline, protected, virtual]
 

Reimplemented from SampleApp.

00153 {
00154     OutputStreamArea.println("Initializing CorbaMediator...");
00155     initCorbaMediator(args);
00156     setAdvancedLookupManager(parent);
00157 
00158     _ops = ServiceRepository.instance().getGlobalOps();
00159     if(_ops == null) return false;
00160 
00161     OutputStreamArea.println("Building "+getSampleName()+" GUI...");
00162 
00163     _leftViewer = ViewerFactory.makeBasicViewer();
00164     _rightViewer = ViewerFactory.makeBasicViewer();
00165 
00166     // set layout manager
00167 
00168     JPanel gui = new JPanel();
00169     gui.setLayout(new GridBagLayout());
00170 
00171     // Add splitpane with two viewers
00172 
00173     JPanel leftPanel = new JPanel(new GridBagLayout());
00174     _showLeft = new JCheckBox("Show original frame", true);
00175     HX.addGridComp(leftPanel, _showLeft, 0, 0, 1, 1,
00176                    GridBagConstraints.NONE, 0.0, 0.0, 1, 1);
00177     HX.addGridComp(leftPanel, _leftViewer, 0, 1, 1, 1,
00178                    GridBagConstraints.BOTH, 1.0, 1.0, 1, 1);
00179 
00180 
00181     JPanel rightPanel = new JPanel(new GridBagLayout());
00182     _showRight = new JCheckBox("Show processed frame", false);
00183     HX.addGridComp(rightPanel, _showRight, 0, 0, 1, 1,
00184                    GridBagConstraints.NONE, 0.0, 0.0, 1, 1);
00185     HX.addGridComp(rightPanel, _rightViewer, 0, 1, 1, 1,
00186                    GridBagConstraints.BOTH, 1.0, 1.0, 1, 1);
00187 
00188     JSplitPane viewSP = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
00189                                        leftPanel, rightPanel);
00190     viewSP.setOneTouchExpandable(true);
00191     viewSP.setDividerLocation(378);
00192     HX.addGridComp(gui, viewSP, 0, 0, 1, 1,
00193                    GridBagConstraints.BOTH, 1.0, 1.0, 0, 3);
00194 
00195 
00196     // Add frame navigator
00197 
00198     _frameNav = new SimpleFrameNavigator(null,
00199         0, 0, 720, SimpleFrameNavigator.SCROLL_BAR);
00200     HX.addGridComp(gui, _frameNav, 0, 1, 1, 1,
00201                    GridBagConstraints.HORIZONTAL, 1.0, 0.0, 0, 3);
00202 
00203     // Add button control panel
00204 
00205     JPanel butPanel = new JPanel();
00206 
00207     _butReset = new JButton("Reset");
00208     _butStop = new JButton("Stop");
00209     _butPlay = new JButton("Play");
00210     _butStep = new JButton("Step");
00211 
00212     JButton[] buttons = { _butReset, _butStop, _butPlay, _butStep };
00213     String[] butTips = {"Reset playing", "Stop playing", "Continue playing",
00214         "Step one frame"};
00215     for(int i=0; i<buttons.length; i++) {
00216         buttons[i].setToolTipText(butTips[i]);
00217         buttons[i].addActionListener(this);
00218         buttons[i].setEnabled(false);
00219         butPanel.add(buttons[i]);
00220     }
00221 
00222     _statField = new JTextField("idle", 8);
00223     _statField.setEditable(false);
00224     butPanel.add(_statField);
00225 
00226     _fpsField = new JTextField("fps", 8);
00227     _fpsField.setEditable(false);
00228     butPanel.add(_fpsField);
00229 
00230     HX.addGridComp(gui, butPanel, 0, 2, 1, 1,
00231                    GridBagConstraints.HORIZONTAL, 1.0, 0.0, 0, 3);
00232 
00233     JPanel opsPanel = new JPanel();
00234 
00235     _doProcess = new JCheckBox("Process frame", false);
00236     opsPanel.add(_doProcess);
00237 
00238     opsPanel.add(new JLabel("Operation: "));
00239     JTextField opName = new JTextField(_operationName, 10);
00240     opName.setEditable(false);
00241     opsPanel.add(opName);
00242 
00243     opsPanel.add(new JLabel("Argument: "));
00244     JTextField opArg = new JTextField(""+_operationArg, 5);
00245     opArg.setEditable(false);
00246     opsPanel.add(opArg);
00247 
00248     JButton changeBut = new JButton("Change operation");
00249     opsPanel.add(changeBut);
00250     changeBut.addActionListener(new OperationListener(changeBut, opName, opArg));
00251 
00252     HX.addGridComp(gui, opsPanel, 0, 3, 1, 1,
00253                    GridBagConstraints.HORIZONTAL, 1.0, 0.0, 0, 3);
00254 
00255     // Create ExtMenuBar:
00256 
00257     ExtMenuBar bmenu = new ExtMenuBar(this);
00258     bmenu.addMenu("File");
00259     bmenu.addMenuItem("File", "Open", "handleOpen");
00260     bmenu.addSeparator("File");
00261     bmenu.addMenuItem("File", "Exit", "handleExit");
00262 
00263     bmenu.addMenu("Preferences");
00264     //bmenu.addSubMenu("Preferences", "Play mode");
00265     //String[] modes = { NORMAL, THREADED, REAL_TIME,
00266     //  REAL_TIME_AUDIO, EXTERNAL};
00267     //bmenu.addGroupMenu("Play mode", modes, "handlePlayMode", modes[0]);
00268 
00269     bmenu.addSubMenu("Preferences", "Result Display Mode");
00270     bmenu.addGroupMenu("Result Display Mode", getRGBModes(), "handleDisplayMode", _displayMode);
00271     bmenu.addCheckBoxItem("Preferences", "useMDC", "handleUseMDC", false);
00272 
00273     //if(isStandalone()) {
00274     //    bmenu.addMenu("Tools");
00275     //    bmenu.addMenuItem("Tools", "App Browser", "handleAppBrowser");
00276     //    bmenu.addSeparator("Tools");
00277     //    bmenu.addMenuItem("Tools", "Register App", "handleRegisterApp");
00278     //}
00279 
00280     parent.setJMenuBar(bmenu);
00281     parent.getContentPane().add(gui, BorderLayout.CENTER);
00282     parent.setSize(771, 480);
00283     parent.setLocation(0, 0);
00284 
00285     if(_ops == null) {
00286         _showRight.setEnabled(false);
00287         _doProcess.setEnabled(false);
00288         changeBut.setEnabled(false);
00289         opName.setEnabled(false);
00290         opArg.setEnabled(false);
00291     }
00292 
00293     OutputStreamArea.println("Done.");
00294 
00295     OutDialog out = new OutDialog(parent, 10, 3, 80);
00296     out.setLocation(0, 480);
00297     out.show();
00298 
00299     return true;
00300 }


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