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

IDBSurfApp Class Reference

A generic image database surfer application. More...

Inheritance diagram for IDBSurfApp::

CorbaSampleApp ViewerInspectionListener SampleApp List of all members.

Public Methods

void doArgs (String[] args)
void handleOpen ()
 This function is called by _bmenu if the associated menu item is selected. More...

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

void handleDisplayModeBinary ()
void handleDisplayModeStretch ()
void handleDisplayModeDirect ()
void handleViews (boolean showBlobs)
void handleRandom ()
void handleSearch (String dbName)
void handleSearch0 ()
 These functions are called by _bmenu if the associated menu item is selected. More...

void handleSearch1 ()
void handleSearch2 ()
void handleSearch3 ()
void handleSearch4 ()
void handleSearch5 ()
void handleSearch6 ()
void handleSearch7 ()
void handleSearch8 ()
void handleSearch9 ()
void handleResult (String type, String value)
void viewerEntered (ViewerEvent e)
 Implementation of ViewerInspectionListener. More...

void viewerExited (ViewerEvent e)
 Implementation of ViewerInspectionListener. More...

void viewerSelected (ViewerEvent e)
 Implementation of ViewerInspectionListener. More...

void objectEntered (ViewerEvent e)
 Implementation of ViewerInspectionListener. More...

void objectProbed (ViewerEvent e)
 Implementation of ViewerInspectionListener. More...

void objectSelected (ViewerEvent e)
 Implementation of ViewerInspectionListener. More...


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

A generic image database surfer application.


Member Function Documentation

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

00041 {
00042     IDBSurfApp app = new IDBSurfApp();
00043     app.doMain(args);
00044 
00045     // doMain will call buildSample
00046 }

void IDBSurfApp::doArgs String    args[] [inline]
 

00049 {
00050     int i, ndb = 0, names = 0;
00051     String[] dbFile = new String[10];
00052 
00053     for (i=0; i < 10; i++)
00054         _dbNames[i] = "";
00055 
00056     for (i=0; i < args.length; i++) {
00057         if (args[i].equals("-dir"))
00058             _dbDir = args[i+1];
00059         else if (args[i].equals("-blobdir"))
00060             _blobDir = args[i+1];
00061         else if (args[i].equals("-db")) {
00062             dbFile[ndb] = args[i+1];
00063             ndb++;
00064         }
00065         else if (args[i].equals("-name")) {
00066             _dbNames[names] = args[i+1];
00067             names++;
00068         }
00069         else if (args[i].equals("-rows"))
00070             _nrViewers = _nrColumns * Integer.valueOf(args[i+1]).intValue();
00071         else if (args[i].equals("-highlight"))
00072             _highlightFactor = Double.valueOf(args[i+1]).doubleValue();
00073     }
00074 
00075     for (i=0; i < ndb; i++) {
00076         OutputStreamArea.println("Reading Database "+dbFile[i]);
00077         if (_dbNames[i].equals(""))
00078             _dbNames[i] = "Database"+i;
00079         _ops.HxIDBOpen(_dbNames[i], dbFile[i]);
00080     }
00081 }

void IDBSurfApp::handleOpen   [inline]
 

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

00087 {
00088 }

void IDBSurfApp::handleNewImage int    index [inline]
 

00091 {
00092     String imname = _viewerNames[index];
00093 
00094     int strindex = imname.indexOf("#");
00095     if (strindex>=0)
00096         imname = imname.substring(0, strindex);
00097 
00098     _queryImage = _viewerImages[index];
00099     _queryName = imname;
00100     if (!_blobDir.equals(""))
00101         _queryBlobImage = _blobImages[index];
00102     _queryBlob = 0;
00103     
00104     if (_queryImage == null)
00105         return;
00106 
00107     // Clear viewer and add new image.
00108     CanvasObject cObj = new CanvasCorbaImage(_queryImage, _displayMode);
00109     _mainViewer.doClear();
00110     _mainViewer.addObject(cObj);
00111 
00112     OutputStreamArea.println("Search Image: " + _queryName);
00113 }

void IDBSurfApp::handleExit   [inline]
 

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

00118 {
00119     System.exit(0);
00120 }

void IDBSurfApp::handleDisplayModeBinary   [inline]
 

00123 { _displayMode = "Binary"; }

void IDBSurfApp::handleDisplayModeStretch   [inline]
 

00126 { _displayMode = "Stretch"; }

void IDBSurfApp::handleDisplayModeDirect   [inline]
 

00129 { _displayMode = "Direct"; }

void IDBSurfApp::handleViews boolean    showBlobs [inline]
 

00133 {
00134     if (_blobDir.equals(""))
00135         showBlobs = false;
00136 
00137     for (int i=0 ; i<_viewerNames.length ; i++) {
00138         HxCorba.ImageRep showIm;
00139         String imname = _viewerNames[i];
00140         int    blobnr = 0;
00141 
00142         int index = imname.indexOf("#");
00143         if (index>=0) {
00144             blobnr = Integer.valueOf(imname.substring(index+1)).intValue();
00145             imname = imname.substring(0, index);
00146         }
00147 
00148         _viewerImages[i] = _fac.fromFile(_dbDir+"/"+imname);
00149         _blobImages[i] = _fac.fromFile(_blobDir+"/"+imname);
00150         showIm = _viewerImages[i];
00151 
00152         if (showBlobs)
00153             showIm = _ops.HxHighlightRegion(_viewerImages[i], _blobImages[i],
00154                 blobnr, _highlightFactor);
00155 
00156         CanvasObject cObj = new CanvasCorbaImage(showIm, _displayMode);
00157         _viewer[i].doClear();
00158         _viewer[i].addObject(cObj);
00159         _caption[i].setText(imname);
00160     }
00161 }

void IDBSurfApp::handleRandom   [inline]
 

00164 {
00165     _viewerNames = _ops.HxIDBRandom(_dbNames[0], _nrViewers);
00166     handleViews(false);
00167 }

void IDBSurfApp::handleSearch String    dbName [inline]
 

00170 {
00171     String theQuery = _queryName;
00172 
00173     if (dbName == "") {
00174         ErrorStreamArea.println("Database not loaded.");
00175         return;
00176     }
00177     if (_queryImage == null) {
00178         ErrorStreamArea.println("No query image.");
00179         return;
00180     }
00181 
00182     if (!_blobDir.equals("") && (_queryBlob == 0)) {
00183         ErrorStreamArea.println("No blob specified (point with mouse).");
00184         return;
00185     }
00186     
00187     if (!_blobDir.equals(""))
00188         theQuery = _queryName+"#"+(_queryBlob-1);
00189 
00190     _viewerNames = _ops.HxIDBSearch(theQuery, dbName, _nrViewers);
00191     handleViews(true);
00192 }

void IDBSurfApp::handleSearch0   [inline]
 

These functions are called by _bmenu if the associated menu item is selected.

00198 { handleSearch(_dbNames[0]); }

void IDBSurfApp::handleSearch1   [inline]
 

00199 { handleSearch(_dbNames[1]); }

void IDBSurfApp::handleSearch2   [inline]
 

00200 { handleSearch(_dbNames[2]); }

void IDBSurfApp::handleSearch3   [inline]
 

00201 { handleSearch(_dbNames[3]); }

void IDBSurfApp::handleSearch4   [inline]
 

00202 { handleSearch(_dbNames[4]); }

void IDBSurfApp::handleSearch5   [inline]
 

00203 { handleSearch(_dbNames[5]); }

void IDBSurfApp::handleSearch6   [inline]
 

00204 { handleSearch(_dbNames[6]); }

void IDBSurfApp::handleSearch7   [inline]
 

00205 { handleSearch(_dbNames[7]); }

void IDBSurfApp::handleSearch8   [inline]
 

00206 { handleSearch(_dbNames[8]); }

void IDBSurfApp::handleSearch9   [inline]
 

00207 { handleSearch(_dbNames[9]); }

void IDBSurfApp::handleResult String    type,
String    value
[inline]
 

00211 {
00212     /*if(type.equals("interface ImageRep")) {
00213         HxCorba.ImageRep image = (HxCorba.ImageRep)CorbaMediator.getStub(
00214             HxCorba.ImageRepHelper.id(), value);
00215 
00216         showImage(image, _rightViewer);
00217     }
00218     else*/ if(type.equals("void"))
00219         OutputStreamArea.println("void");
00220     else if(type.equals("error"))
00221         ErrorStreamArea.println(value);
00222     else
00223         OutputStreamArea.println("Result: "+value+", type: "+type);
00224 }

void IDBSurfApp::viewerEntered ViewerEvent    e [inline]
 

Implementation of ViewerInspectionListener.

Reimplemented from ViewerInspectionListener.

00230 {
00231 }

void IDBSurfApp::viewerExited ViewerEvent    e [inline]
 

Implementation of ViewerInspectionListener.

Reimplemented from ViewerInspectionListener.

00237 {
00238 }

void IDBSurfApp::viewerSelected ViewerEvent    e [inline]
 

Implementation of ViewerInspectionListener.

Reimplemented from ViewerInspectionListener.

00244 {
00245 }

void IDBSurfApp::objectEntered ViewerEvent    e [inline]
 

Implementation of ViewerInspectionListener.

Reimplemented from ViewerInspectionListener.

00251 {
00252 }

void IDBSurfApp::objectProbed ViewerEvent    e [inline]
 

Implementation of ViewerInspectionListener.

Reimplemented from ViewerInspectionListener.

00258 {
00259 }

void IDBSurfApp::objectSelected ViewerEvent    e [inline]
 

Implementation of ViewerInspectionListener.

Reimplemented from ViewerInspectionListener.

00264 {
00265     CanvasViewer v = (CanvasViewer) e.getViewer();
00266     int index = -1;
00267     for (int i=0 ; i<_nrViewers ; i++) {
00268         if (_viewer[i] == v)
00269             index = i;
00270     }
00271     if (index != -1) {
00272         OutputStreamArea.println("Image thumbnail selected: " + index);
00273         handleNewImage(index);
00274     }
00275     if ((_mainViewer == v) && !_blobDir.equals("")) {
00276         _queryBlob = _queryBlobImage.getAt(e.getXPosPcs(),
00277             e.getYPosPcs(),0).scalarInt()+1;
00278         OutputStreamArea.println("Image blob selected: " + (_queryBlob-1));
00279 
00280         HxCorba.ImageRep showIm;
00281         showIm = _ops.HxHighlightRegion(_queryImage, _queryBlobImage,
00282             _queryBlob-1, _highlightFactor);
00283 
00284         CanvasObject cObj = new CanvasCorbaImage(showIm, _displayMode);
00285         _mainViewer.doClear();
00286         _mainViewer.addObject(cObj);
00287     }
00288 }

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

Reimplemented from SampleApp.

00298 {
00299     OutputStreamArea out = new OutputStreamArea(10, 80, false);
00300     ErrorStreamArea err = new ErrorStreamArea(parent, 3, 80);
00301 
00302     OutputStreamArea.println("Initializing CorbaMediator...");
00303     initCorbaMediator(args);
00304     setAdvancedLookupManager(parent);
00305 
00306     _ops = ServiceRepository.instance().getGlobalOps();
00307     if(_ops == null) return false;
00308     _fac = ServiceRepository.instance().getConstructor();
00309     if(_fac == null) return false;
00310     _conf = ServiceRepository.instance().getConfigure();
00311     if(_conf == null) return false;
00312 
00313     _conf.getObjectUsage("IDL:HxCorba/ImageRep:1.0").setTotalLimit("Images",50);
00314 
00315     doArgs(args);
00316 
00317     OutputStreamArea.println("Building "+getSampleName()+" GUI...");
00318 
00319     // Create FileChooser, for loading images into viewer
00320 
00321     _fc = new JFileChooser("\\images");
00322     _horusFilter = new HorusImageFilter();
00323     _fc.addChoosableFileFilter(_horusFilter);
00324 
00325     // Main panel
00326 
00327     JPanel gui = new JPanel(new GridBagLayout());
00328 
00329     // Setup splitpanes
00330 
00331     JSplitPane lowerLeft = new JSplitPane(JSplitPane.VERTICAL_SPLIT, out, err);
00332     lowerLeft.setOneTouchExpandable(true);
00333     lowerLeft.setDividerLocation(170);
00334 
00335     _mainViewer = ViewerFactory.makeBasicViewer();
00336     _mainViewer.addViewerInspectionListener(this);
00337     JSplitPane left = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
00338                                      _mainViewer, lowerLeft);
00339     left.setOneTouchExpandable(true);
00340     left.setDividerLocation(512);
00341 
00342     JSplitPane viewSP = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
00343                                        left, makeViewers());
00344     viewSP.setOneTouchExpandable(true);
00345     viewSP.setDividerLocation(512);
00346     HX.addGridComp(gui, viewSP, 0, 0, 1, 1,
00347                    GridBagConstraints.BOTH, 1.0, 1.0, 1, 1);
00348 
00349 
00350     // Create ExtMenuBar:
00351 
00352     _bmenu = new ExtMenuBar(this);
00353     _bmenu.addMenu("File");
00354     _bmenu.addMenuItem("File", "Open", "handleOpen");
00355     _bmenu.addSeparator("File");
00356     _bmenu.addMenuItem("File", "Exit", "handleExit");
00357 
00358     _bmenu.addMenu("Surf");
00359 
00360     for (int i=0; i<10; i++) {
00361         if (_dbNames[i].equals("")) {
00362         }
00363         else
00364             _bmenu.addMenuItem("Surf", _dbNames[i], "handleSearch"+i);
00365     }
00366     _bmenu.addSeparator("Surf");
00367     _bmenu.addMenuItem("Surf", "Random", "handleRandom");
00368     _bmenu.addSeparator("Surf");
00369     _bmenu.addSubMenu("Surf", "Default Display Mode");
00370     _bmenu.addMenuItem("Default Display Mode", "Stretch",
00371         "handleDisplayModeStretch");
00372     _bmenu.addMenuItem("Default Display Mode", "Binary",
00373         "handleDisplayModeBinary");
00374     _bmenu.addMenuItem("Default Display Mode", "Direct",
00375         "handleDisplayModeDirect");
00376 
00377     parent.setJMenuBar(_bmenu);
00378     parent.getContentPane().add(gui, BorderLayout.CENTER);
00379     parent.setSize(1100, 840);
00380     parent.setLocation(0, 0);
00381 
00382     OutputStreamArea.println("Done.");
00383     out.capture();
00384 
00385     return true;
00386 }


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