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

VideoApp Class Reference

A video application. More...

Inheritance diagram for VideoApp::

VideoSampleApp 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 handleDisplayMode (String mode)
void handlePlayMode (String mode)
void handlePlayMode (PlayMode mode)
void handleUseMDC (boolean val)
void handleAppBrowser ()
void handleRegisterApp ()

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)
String getSamplePath ()

Detailed Description

A video application.


Member Function Documentation

void VideoApp::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.

00036 {
00037     VideoApp app = new VideoApp();
00038     app.doMain(args);
00039 
00040     // doMain will call buildSample
00041 }

void VideoApp::handleOpen   [inline]
 

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

00047 {
00048     _director.stop();
00049 
00050     File file = askFilename(SEQ_FILTER, CorbaMediator.instance().hasLocalServer());
00051     if(file == null) return;
00052 
00053     HxCorba.Constructor cons =
00054         ServiceRepository.instance().getConstructor();
00055     if(cons == null) return;
00056 
00057     try {
00058         _seq = cons.constructBufferedImageSeq(file.getPath(), BUFF_SIZE+3);
00059         if(_seq == null) {
00060             ErrorStreamArea.println("Image sequence "+file.getName()+" doesn't exist");
00061             return;
00062         }
00063 
00064         _seqDisplayer.setSequence(_seq);
00065         _externalPlayer.setSequencePath(file.getPath());
00066 
00067         _director = new PlayingDirector(_seq.nrFrames());
00068 
00069         FrameNavigatorDisplayer disp = new FrameNavigatorDisplayer(_frameNav);
00070 
00071         _director.addPlayingObserver(_seqDisplayer);
00072         _director.addPlayingObserver(new ResultDisplayer());
00073         _director.addPlayingObserver(makeFrameStatusDisplayer());
00074         _director.addPlayingObserver(disp.makeObserver(_director));
00075         _director.addPlayingObserver(_externalPlayer);
00076 
00077         //_director.addPlayingObserver(PlayingObserverFactory.makeDebugObserver());
00078 
00079         handlePlayMode(_playMode);
00080 
00081         //Set Director to enable buttons
00082         setDirector(_director);
00083 
00084         _director.setCurrentFrame(0);
00085     }
00086     catch(Exception ex) {
00087         ErrorStreamArea.println(" "+ex);
00088         ex.printStackTrace();
00089     }
00090 }

void VideoApp::handleExit   [inline]
 

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

00096 {
00097     _externalPlayer.close();
00098 
00099     unregisterApp();
00100     quitSample();
00101 }

void VideoApp::handleDisplayMode String    mode [inline]
 

00104 {
00105     _displayMode = mode;
00106     if(_rightImCanvas != null)
00107         _rightImCanvas.setDisplayMode(_displayMode);
00108 }

void VideoApp::handlePlayMode String    mode [inline]
 

00111 {
00112     PlayMode playMode = PlayMode.getMode(mode);
00113     if(playMode == null)
00114         OutputStreamArea.println("Unknown PlayMode: "+mode);
00115     else
00116         handlePlayMode(playMode);
00117 }

void VideoApp::handlePlayMode PlayMode    mode [inline]
 

00120 {
00121     _playMode = mode;
00122     if(_seq == null) return;
00123 
00124     _externalPlayer.setMode(externalPlayerMode(mode));
00125     _director.setRealTime(isRealTimeMode(mode));
00126 
00127     _seqDisplayer.setThreadedMode(mode == PlayMode.THREADED);
00128     _seqDisplayer.setEnabled(_showLeft.isSelected() &&
00129         mode != PlayMode.EXTERNAL);
00130 
00131     _director.showCurrentFrame();
00132 }

void VideoApp::handleUseMDC boolean    val [inline]
 

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

void VideoApp::handleAppBrowser   [inline]
 

00144 {
00145     AppBrowser app = new AppBrowser(/*CorbaMediator.appMgr()*/);
00146     JDialog dlg = new JDialog(getParentFrame(), "App Browser", false);
00147     dlg.getContentPane().add(app);
00148     dlg.pack();
00149     dlg.setVisible(true);
00150 }

void VideoApp::handleRegisterApp   [inline]
 

00153 {
00154     registerApp(new CorbaVideoServant());
00155 }

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

Reimplemented from SampleApp.

00195 {
00196     OutputStreamArea.println("Initializing CorbaMediator...");
00197     initCorbaMediator(args);
00198     setAdvancedLookupManager(parent);
00199 
00200     _ops = ServiceRepository.instance().getGlobalOps();
00201 
00202     OutputStreamArea.println("Building "+getSampleName()+" GUI...");
00203     if(isStandalone())
00204         parent.setTitle(getSampleName()+" (unregistered)");
00205 
00206     _seqDisplayer = new SequenceDisplayer(BUFF_SIZE);
00207     //_leftViewer = ViewerFactory.makeBasicViewer();
00208     _rightViewer = ViewerFactory.makeBasicViewer();
00209 
00210 
00211     // set layout manager
00212 
00213     JPanel gui = new JPanel();
00214     gui.setLayout(new GridBagLayout());
00215 
00216     // Add splitpane with two viewers
00217 
00218     JPanel leftPanel = new JPanel(new GridBagLayout());
00219     _showLeft = new JCheckBox("Show original frame", true);
00220     HX.addGridComp(leftPanel, _showLeft, 0, 0, 1, 1,
00221                    GridBagConstraints.NONE, 0.0, 0.0, 1, 1);
00222     HX.addGridComp(leftPanel, _seqDisplayer.getViewer(), 0, 1, 1, 1,
00223                    GridBagConstraints.BOTH, 1.0, 1.0, 1, 1);
00224 
00225 
00226     JPanel rightPanel = new JPanel(new GridBagLayout());
00227     _showRight = new JCheckBox("Show processed frame", false);
00228     HX.addGridComp(rightPanel, _showRight, 0, 0, 1, 1,
00229                    GridBagConstraints.NONE, 0.0, 0.0, 1, 1);
00230     HX.addGridComp(rightPanel, _rightViewer, 0, 1, 1, 1,
00231                    GridBagConstraints.BOTH, 1.0, 1.0, 1, 1);
00232 
00233     JSplitPane viewSP = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
00234                                        leftPanel, rightPanel);
00235     viewSP.setOneTouchExpandable(true);
00236     viewSP.setDividerLocation(378);
00237     HX.addGridComp(gui, viewSP, 0, 0, 1, 1,
00238                    GridBagConstraints.BOTH, 1.0, 1.0, 0, 3);
00239 
00240     _showLeft.addItemListener(new ShowFrameListener());
00241 
00242     // Add frame navigator
00243 
00244     _frameNav = new SimpleFrameNavigator(null,
00245         0, 0, 720, SimpleFrameNavigator.SCROLL_BAR);
00246     HX.addGridComp(gui, _frameNav, 0, 1, 1, 1,
00247                    GridBagConstraints.HORIZONTAL, 1.0, 0.0, 0, 3);
00248 
00249     // Add button control panel
00250 
00251     JPanel ctrlPanel = getPlayingControlsPanel();
00252 
00253     HX.addGridComp(gui, ctrlPanel, 0, 2, 1, 1,
00254                    GridBagConstraints.HORIZONTAL, 1.0, 0.0, 0, 3);
00255 
00256     JPanel opsPanel = new JPanel();
00257 
00258     _doProcess = new JCheckBox("Process frame", false);
00259     opsPanel.add(_doProcess);
00260 
00261     opsPanel.add(new JLabel("Operation: "));
00262     JTextField opName = new JTextField(_operationName, 10);
00263     opName.setEditable(false);
00264     opsPanel.add(opName);
00265 
00266     opsPanel.add(new JLabel("Argument: "));
00267     JTextField opArg = new JTextField(""+_operationArg, 5);
00268     opArg.setEditable(false);
00269     opsPanel.add(opArg);
00270 
00271     JButton changeBut = new JButton("Change operation");
00272     opsPanel.add(changeBut);
00273     changeBut.addActionListener(new OperationListener(changeBut, opName, opArg));
00274 
00275     HX.addGridComp(gui, opsPanel, 0, 3, 1, 1,
00276                    GridBagConstraints.HORIZONTAL, 1.0, 0.0, 0, 3);
00277 
00278     // Create ExtMenuBar:
00279 
00280     ExtMenuBar bmenu = new ExtMenuBar(this);
00281     bmenu.addMenu("File");
00282     bmenu.addMenuItem("File", "Open", "handleOpen");
00283     bmenu.addSeparator("File");
00284     bmenu.addMenuItem("File", "Exit", "handleExit");
00285 
00286     bmenu.addMenu("Preferences");
00287     bmenu.addSubMenu("Preferences", "Play mode");
00288     bmenu.addGroupMenu("Play mode", PlayMode.getNames(), "handlePlayMode",
00289         _playMode.toString());
00290 
00291     bmenu.addSubMenu("Preferences", "Result Display Mode");
00292     bmenu.addGroupMenu("Result Display Mode", getRGBModes(), "handleDisplayMode", _displayMode);
00293     bmenu.addCheckBoxItem("Preferences", "useMDC", "handleUseMDC", false);
00294 
00295     if(isStandalone()) {
00296         bmenu.addMenu("Tools");
00297         bmenu.addMenuItem("Tools", "App Browser", "handleAppBrowser");
00298         bmenu.addSeparator("Tools");
00299         bmenu.addMenuItem("Tools", "Register App", "handleRegisterApp");
00300     }
00301 
00302     parent.setJMenuBar(bmenu);
00303     parent.getContentPane().add(gui, BorderLayout.CENTER);
00304     parent.setSize(771, 480);
00305     parent.setLocation(0, 0);
00306 
00307     if(_ops == null) {
00308         _showRight.setEnabled(false);
00309         _doProcess.setEnabled(false);
00310         changeBut.setEnabled(false);
00311         opName.setEnabled(false);
00312         opArg.setEnabled(false);
00313     }
00314 
00315     OutputStreamArea.println("Done.");
00316 
00317     OutDialog out = new OutDialog(parent, 10, 3, 80);
00318     out.setLocation(0, 480);
00319     out.show();
00320 
00321     return true;
00322 }

String VideoApp::getSamplePath   [inline, protected]
 

Reimplemented from CorbaSampleApp.

00325 {
00326     return getSampleProperty("VideoDir", ".");
00327 }


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