Changeset 529


Ignore:
Timestamp:
10/11/05 15:29:04 (15 years ago)
Author:
curtis
Message:

Report more information during initial dataset creation.

Location:
trunk/loci/visbio
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/loci/visbio/data/Dataset.java

    r465 r529  
    3131import java.util.Hashtable; 
    3232import javax.swing.JComponent; 
     33import loci.visbio.TaskEvent; 
     34import loci.visbio.TaskListener; 
    3335import loci.visbio.state.Dynamic; 
    3436import loci.visbio.state.SaveException; 
     
    7274  protected String[] ids; 
    7375 
     76  /** Optional listener for constructor progress. */ 
     77  protected TaskListener listener; 
     78 
    7479 
    7580  // -- Computed fields -- 
     
    121126    String[] ids, int[] lengths, String[] dims) 
    122127  { 
    123     this(name, pattern, ids, lengths, dims, Float.NaN, Float.NaN, Float.NaN); 
     128    this(name, pattern, ids, lengths, dims, 
     129      Float.NaN, Float.NaN, Float.NaN, null); 
     130  } 
     131 
     132  /** 
     133   * Constructs a multidimensional data object. 
     134   * See the complete constructor for more information. 
     135   */ 
     136  public Dataset(String name, String pattern, String[] ids, 
     137    int[] lengths, String[] dims, float width, float height, float step) 
     138  { 
     139    this(name, pattern, ids, lengths, dims, width, height, step, null); 
    124140  } 
    125141 
     
    147163   * @param height Physical height of each image, in microns. 
    148164   * @param step Physical distance between image slices, in microns. 
     165   * @param listener Listener object to be informed of construction progress. 
    149166   */ 
    150167  public Dataset(String name, String pattern, String[] ids, 
    151     int[] lengths, String[] dims, float width, float height, float step) 
     168    int[] lengths, String[] dims, float width, float height, float step, 
     169    TaskListener listener) 
    152170  { 
    153171    super(null, name, width, height, step); 
     
    156174    this.lengths = lengths; 
    157175    this.dims = dims; 
     176    this.listener = listener; 
    158177    initState(null); 
    159178  } 
     
    451470 
    452471    metadata = new Hashtable[ids.length]; 
     472    int numTasks = ids.length + 3; 
    453473 
    454474    // make sure each file exists 
     475    status(0, numTasks, "Reading files..."); 
    455476    for (int i=0; i<ids.length; i++) { 
    456477      File file = new File(ids[i]); 
     
    463484    // initialize data loaders 
    464485    loaders = new ImageFamily[ids.length]; 
    465     for (int i=0; i<ids.length; i++) loaders[i] = new ImageFamily(); 
     486    for (int i=0; i<ids.length; i++) { 
     487      loaders[i] = new ImageFamily(); 
     488    } 
    466489 
    467490    // determine number of images per source file 
     
    572595    // load metadata for each source file 
    573596    for (int i=0; i<ids.length; i++) { 
     597      status(i + 1, numTasks, "Reading metadata for " + ids[i] + "..."); 
    574598      String fname = new File(ids[i]).getName(); 
    575599      try { metadata[i] = loaders[i].getMetadata(ids[i]); } 
     
    584608 
    585609    // construct metadata controls 
     610    status(ids.length + 2, numTasks, "Finishing..."); 
    586611    controls = new DatasetWidget(this); 
    587612 
     
    591616    thumbs = new ThumbnailHandler(this, 
    592617      path + File.separator + name + ".visbio"); 
     618    status(ids.length + 3, numTasks, "Done"); 
    593619  } 
    594620 
     
    639665  } 
    640666 
     667  /** Notifies constructor task listener of a status update. */ 
     668  private void status(int current, int max, String message) { 
     669    if (listener == null) return; 
     670    listener.taskUpdated(new TaskEvent(current, max, message)); 
     671  } 
     672 
    641673} 
  • trunk/loci/visbio/data/DatasetPane.java

    r465 r529  
    3535import javax.swing.event.DocumentEvent; 
    3636import javax.swing.event.DocumentListener; 
     37import loci.visbio.TaskEvent; 
     38import loci.visbio.TaskListener; 
    3739import loci.visbio.util.*; 
    3840import visad.VisADException; 
     
    4345 * for importing a multidimensional data series into VisBio. 
    4446 */ 
    45 public class DatasetPane extends WizardPane implements DocumentListener { 
     47public class DatasetPane extends WizardPane 
     48  implements DocumentListener, TaskListener 
     49{ 
    4650 
    4751  // -- Constants -- 
     
    299303 
    300304 
     305  // -- TaskListener API methods -- 
     306 
     307  /** Updates progress bar to match status of dataset construction. */ 
     308  public void taskUpdated(TaskEvent e) { 
     309    final int value = e.getProgressValue(); 
     310    final int maximum = e.getProgressMaximum(); 
     311    final String message = e.getStatusMessage(); 
     312    Util.invoke(false, new Runnable() { 
     313      public void run() { 
     314        waitLabel.setText(message); 
     315        progress.setIndeterminate(false); 
     316        progress.setMaximum(maximum); 
     317        progress.setValue(value); 
     318      } 
     319    }); 
     320  } 
     321 
     322 
    301323  // -- Helper methods -- 
    302324 
     325  /** Helper method for DocumentListener methods. */ 
    303326  protected void checkText() { 
    304327    next.setEnabled(!groupField.getText().trim().equals("")); 
    305328  } 
     329 
     330  protected JLabel waitLabel = null; 
     331  protected JProgressBar progress = null; 
    306332 
    307333  /** Displays a "please wait" message on the dataset pane's second page. */ 
     
    309335    final JPanel wait = new JPanel(); 
    310336    wait.setLayout(new BorderLayout()); 
    311     wait.add(new JLabel(message), BorderLayout.NORTH); 
    312     JProgressBar progress = new JProgressBar(); 
     337    waitLabel = new JLabel(message); 
     338    wait.add(waitLabel, BorderLayout.NORTH); 
     339    progress = new JProgressBar(); 
    313340    progress.setIndeterminate(true); 
    314341    wait.add(progress, BorderLayout.CENTER); 
     
    320347      } 
    321348    }); 
     349  } 
     350 
     351  /** Updates the "please wait" message and progress bar. */ 
     352  protected void setWaitProgress() { 
    322353  } 
    323354 
     
    480511    // construct data object 
    481512    data = new Dataset(nameField.getText(), groupField.getText(), 
    482       files, lengths, dims, width, height, step); 
     513      files, lengths, dims, width, height, step, this); 
    483514 
    484515    Util.invoke(false, new Runnable() { 
  • trunk/loci/visbio/whatsnew.txt

    r526 r529  
     1v3.12 - Not yet released 
     2 
     3- TWEAK: Report more information during initial dataset creation 
     4 
     5 
    16v3.11 - Monday, October 10, 2005 
    27 
Note: See TracChangeset for help on using the changeset viewer.