Пример #1
0
 /**
  * Format the lat/lon labels with cardinal points (N,S,E,W).
  *
  * @param value the value
  * @param type (LATITUDE or LONGITUDE)
  * @return the formatted string
  */
 public String formatLatLonCardinal(double value, int type) {
   String retString;
   if (type == LATITUDE) {
     retString = Misc.format(Math.abs(value));
     if (value < 0) {
       retString += "S";
     } else if (value == 0.f) {
       retString = "EQ";
     } else {
       retString += "N";
     }
   } else { // LONGITUDE
     if (value > 180) {
       value -= 360;
     }
     retString = Misc.format(Math.abs(value));
     if (value < 0) {
       retString += "W";
     } else if (value == 0.f) {
       retString = "0";
     } else {
       retString += "E";
     }
   }
   return retString;
 }
Пример #2
0
  /**
   * Create the given ViewManager
   *
   * @param viewDescriptor Identifies the VM
   * @param properties Property string to pass
   * @return The new one
   */
  public ViewManager createViewManager(ViewDescriptor viewDescriptor, String properties) {
    synchronized (viewManagers) {
      try {
        ViewManager viewManager = null;
        if (viewDescriptor == null) {
          viewDescriptor = new ViewDescriptor();
        }
        if (viewDescriptor.getClassNames().size() > 0) {
          Class viewManagerClass = Misc.findClass((String) viewDescriptor.getClassNames().get(0));
          Constructor ctor =
              Misc.findConstructor(
                  viewManagerClass,
                  new Class[] {IntegratedDataViewer.class, ViewDescriptor.class, String.class});

          if (ctor == null) {
            throw new IllegalArgumentException(
                "cannot create ViewManager:" + viewManagerClass.getName());
          }

          viewManager =
              (ViewManager) ctor.newInstance(new Object[] {getIdv(), viewDescriptor, properties});
        } else {
          viewManager = new MapViewManager(getIdv(), viewDescriptor, properties);
        }

        addViewManager(viewManager);
        return viewManager;
      } catch (Throwable e) {
        logException("In getViewManager", e);
        return null;
      }
    }
  }
Пример #3
0
 /**
  * Check for equality
  *
  * @param object the object in question
  * @return true if they are equal
  */
 public boolean equals(Object object) {
   if (!object.getClass().equals(getClass())) {
     return false;
   }
   RaobDataSource that = (RaobDataSource) object;
   if (file != null) {
     return Misc.equals(this.file, that.file);
   }
   return Misc.equals(raobDataSet, that.raobDataSet);
 }
Пример #4
0
 /**
  * needed for XmlPersistable
  *
  * @param encoder encoder for encoding
  * @return this as an encoded Element
  */
 public Element createElement(XmlEncoder encoder) {
   List arguments =
       Misc.newList(
           ellipsoid, new Integer(onezone), new Boolean(onehemiflag), getDefaultMapArea());
   List types =
       Misc.newList(ellipsoid.getClass(), Integer.TYPE, Boolean.TYPE, Rectangle2D.Double.class);
   Element result = encoder.createObjectElement(getClass());
   Element ctorElement = encoder.createConstructorElement(arguments, types);
   result.appendChild(ctorElement);
   return result;
 }
Пример #5
0
  /**
   * Make the IdvWindow. Add event handlers for adding new data sources and closing the window.
   *
   * @return The window to put the gui in
   */
  public IdvWindow doMakeFrame() {
    if (frame == null) {
      JButton newBtn = new JButton("Add New Data Source");
      newBtn.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              idv.showChooser();
            }
          });
      JButton closeBtn = new JButton("Close");
      closeBtn.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              doClose();
            }
          });

      JComponent extra = getButtons();
      JComponent buttons;
      if (extra != null) {
        buttons =
            GuiUtils.wrap(
                GuiUtils.hflow(
                    Misc.newList(
                        /*newBtn,*/
                        extra, closeBtn),
                    4,
                    4));
      } else {
        buttons =
            GuiUtils.wrap(
                GuiUtils.hflow(
                    Misc.newList(
                        /*newBtn,*/
                        closeBtn),
                    4,
                    4));
      }

      JPanel contents = GuiUtils.centerBottom(getContents(), buttons);
      frame = new IdvWindow(getName(), idv, false);
      frame.getContentPane().add(contents);
      frame.addWindowListener(
          new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
              doClose();
            }
          });
      frame.pack();
      frame.show();
    }
    return frame;
  }
Пример #6
0
  /**
   * add to properties
   *
   * @param comps comps
   */
  public void getPropertiesComponents(List comps) {
    super.getPropertiesComponents(comps);
    binWidthField = new TimeLengthField("Bin Width", true);
    binRoundToField = new TimeLengthField("Bin Round To", true);
    binWidthField.setTime(binWidth);
    binRoundToField.setTime(binRoundTo);
    List roundToItems =
        Misc.toList(
            new Object[] {
              new TwoFacedObject("Change", new Double(0)),
              new TwoFacedObject("On the hour", new Double(60)),
              new TwoFacedObject("5 after", new Double(5)),
              new TwoFacedObject("10 after", new Double(10)),
              new TwoFacedObject("15 after", new Double(15)),
              new TwoFacedObject("20 after", new Double(20)),
              new TwoFacedObject("30 after", new Double(30)),
              new TwoFacedObject("45 after", new Double(45)),
              new TwoFacedObject("10 to", new Double(50)),
              new TwoFacedObject("5 to", new Double(55))
            });

    roundToCbx =
        GuiUtils.makeComboBox(
            roundToItems, roundToItems.get(0), false, this, "setRoundToFromComboBox");

    List widthItems =
        Misc.toList(
            new Object[] {
              new TwoFacedObject("Change", new Double(0)),
              new TwoFacedObject("5 minutes", new Double(5)),
              new TwoFacedObject("10 minutes", new Double(10)),
              new TwoFacedObject("15 minutes", new Double(15)),
              new TwoFacedObject("20 minutes", new Double(20)),
              new TwoFacedObject("30 minutes", new Double(30)),
              new TwoFacedObject("45 minutes", new Double(45)),
              new TwoFacedObject("1 hour", new Double(60)),
              new TwoFacedObject("6 hours", new Double(60 * 6)),
              new TwoFacedObject("12 hours", new Double(60 * 12)),
              new TwoFacedObject("1 day", new Double(60 * 24))
            });

    widthCbx =
        GuiUtils.makeComboBox(widthItems, widthItems.get(0), false, this, "setWidthFromComboBox");

    comps.add(GuiUtils.filler());
    comps.add(getPropertiesHeader("Time Binning"));

    comps.add(GuiUtils.rLabel("Bin Size:"));
    comps.add(GuiUtils.left(GuiUtils.hbox(binWidthField.getContents(), widthCbx, 5)));
    comps.add(GuiUtils.rLabel("Round To:"));
    comps.add(GuiUtils.left(GuiUtils.hbox(binRoundToField.getContents(), roundToCbx, 5)));
  }
Пример #7
0
  /**
   * _more_
   *
   * @param entry _more_
   * @param className _more_
   * @param properties _more_
   * @return _more_
   * @throws Exception _more_
   */
  private RecordFile doMakeRecordFile(Entry entry, String className, Hashtable properties)
      throws Exception {
    Class c = Misc.findClass(className);
    Constructor ctor = Misc.findConstructor(c, new Class[] {String.class, Hashtable.class});
    if (ctor != null) {
      return (RecordFile) ctor.newInstance(new Object[] {entry.getFile().toString(), properties});
    }
    ctor = Misc.findConstructor(c, new Class[] {String.class});

    if (ctor != null) {
      return (RecordFile) ctor.newInstance(new Object[] {entry.getResource().getPath()});
    }

    throw new IllegalArgumentException("Could not find constructor for " + className);
  }
Пример #8
0
 /**
  * overwrite
  *
  * @param o object
  * @return equals
  */
 public boolean equals(Object o) {
   if (!super.equals(o)) {
     return false;
   }
   WmsDataSource that = (WmsDataSource) o;
   return Misc.equals(this.wmsSelections, that.wmsSelections);
 }
Пример #9
0
  /**
   * Adds the {@link ucar.unidata.data.DataChoice}s of the current input data via {@link
   * #addDataChoice(DataChoice)}.
   */
  protected void doMakeDataChoices() {
    int i = 0;
    List soundingObs = getRDS().getSoundingObs();
    List categories = new ArrayList();

    DataCategory cat = new DataCategory(DataCategory.CATEGORY_RAOBSOUNDING);
    cat.setForDisplay(false);
    categories.add(cat);

    List compCategories = new ArrayList();
    DataCategory compCat = new DataCategory("None");
    compCat.setForDisplay(false);
    compCategories.add(compCat);

    CompositeDataChoice composite =
        new CompositeDataChoice(this, soundingObs, getName(), "RAOB Data", categories);
    Hashtable props = Misc.newHashtable(DataChoice.PROP_ICON, "/auxdata/ui/icons/Balloon.gif");

    for (Iterator iter = soundingObs.iterator(); iter.hasNext(); ) {
      SoundingOb ob = (SoundingOb) iter.next();
      String name = ob.getLabel();
      DateTime obTime = ob.getTimestamp();
      DataSelection timeSelect = null;
      if (obTime != null) {
        ArrayList times = new ArrayList(1);
        times.add(obTime);
        timeSelect = new DataSelection(times);
      }
      DataChoice choice =
          new DirectDataChoice(this, ob, composite.getName(), name, categories, timeSelect, props);
      composite.addDataChoice(choice);
    }
    addDataChoice(composite);
  }
Пример #10
0
  /**
   * _more_
   *
   * @param soundingObs _more_
   * @return _more_
   */
  protected List<DataChoice> getTimeMatchingDataChoices(List<SoundingOb> soundingObs) {
    List<DataChoice> newChoices = new ArrayList<DataChoice>();
    List categories = new ArrayList();

    DataCategory cat = new DataCategory(DataCategory.CATEGORY_RAOBSOUNDING);
    cat.setForDisplay(false);
    categories.add(cat);

    List compCategories = new ArrayList();
    DataCategory compCat = new DataCategory("None");
    compCat.setForDisplay(false);
    compCategories.add(compCat);

    Hashtable props = Misc.newHashtable(DataChoice.PROP_ICON, "/auxdata/ui/icons/Balloon.gif");

    for (Iterator iter = soundingObs.iterator(); iter.hasNext(); ) {
      SoundingOb ob = (SoundingOb) iter.next();
      String name = ob.getLabel();
      DateTime obTime = ob.getTimestamp();
      DataSelection timeSelect = null;
      if (obTime != null) {
        ArrayList times = new ArrayList(1);
        times.add(obTime);
        timeSelect = new DataSelection(times);
      }

      DataChoice choice =
          new DirectDataChoice(this, ob, getName(), name, categories, timeSelect, props);
      newChoices.add(choice);
    }

    return newChoices;
  }
Пример #11
0
  public void getPropertyComponents(List comps, final ObjectListener listener) {
    visibleCbx = new JCheckBox(getName(), visible);
    float[] rgb = color.get().getRGBComponents(null);
    slider = new JSlider(0, 100, (int) (rgb[0] * 100));

    float[] xyz = new float[3];
    direction.get(xyz);
    directionXFld = makeField("" + xyz[0], listener, "X Direction");
    directionYFld = makeField("" + xyz[1], listener, "Y Direction");
    directionZFld = makeField("" + xyz[2], listener, "Z Direction");

    double[] pxyz = new double[3];
    location.get(pxyz);
    locationXFld = makeField("" + pxyz[0], listener, "");
    locationYFld = makeField("" + pxyz[1], listener, "");
    locationZFld = makeField("" + pxyz[2], listener, "");

    List fldComps =
        Misc.newList(GuiUtils.rLabel("Direction:"), directionXFld, directionYFld, directionZFld);
    //
    // fldComps.addAll(Misc.newList(GuiUtils.rLabel("Location:"),locationXFld,locationYFld,locationZFld));

    comps.add(visibleCbx);
    GuiUtils.tmpInsets = new Insets(0, 2, 0, 0);
    comps.add(
        GuiUtils.vbox(
            slider, GuiUtils.left(GuiUtils.doLayout(fldComps, 4, GuiUtils.WT_N, GuiUtils.WT_N))));

    if (listener != null) {
      visibleCbx.addActionListener(listener);
      slider.addChangeListener(listener);
    }
  }
Пример #12
0
  /**
   * _more_
   *
   * @param stormTrack _more_
   * @param param _more_
   * @return _more_
   */
  protected LineState makeLine(StormTrack stormTrack, StormParam param) {
    List<Real> values = new ArrayList<Real>();
    List<DateTime> times = stormTrack.getTrackTimes();
    List<StormTrackPoint> trackPoints = stormTrack.getTrackPoints();
    double min = 0;
    double max = 0;
    Unit unit = null;
    for (int pointIdx = 0; pointIdx < times.size(); pointIdx++) {
      Real value = trackPoints.get(pointIdx).getAttribute(param);
      if (value == null) {
        continue;
      }
      if (unit == null) {
        unit = ((RealType) value.getType()).getDefaultUnit();
      }
      values.add(value);
      double dvalue = value.getValue();
      //            System.err.print(","+dvalue);
      if ((pointIdx == 0) || (dvalue > max)) {
        max = dvalue;
      }
      if ((pointIdx == 0) || (dvalue < min)) {
        min = dvalue;
      }
    }
    if (values.size() == 0) {
      return null;
    }
    //        System.err.println("");
    String paramLabel = param.toString();
    String label = stormTrack.getWay().toString(); // +":" + paramLabel;
    LineState lineState = new LineState();
    lineState.setRangeIncludesZero(true);
    if (stormTrack.getWay().isObservation()) {
      lineState.setWidth(2);
    } else {
      lineState.setWidth(1);
    }
    lineState.setRange(new Range(min, max));
    lineState.setChartName(paramLabel);
    lineState.setAxisLabel("[" + unit + "]");

    //        System.err.println (param + " " +  StormDataSource.TYPE_STORMCATEGORY);
    if (Misc.equals(param, StormDataSource.PARAM_STORMCATEGORY)) {
      //            lineState.setShape(LineState.LINETYPE_BAR);
      lineState.setLineType(LineState.LINETYPE_BAR);
      lineState.setLineType(LineState.LINETYPE_AREA);
    } else {
      lineState.setLineType(LineState.LINETYPE_SHAPES_AND_LINES);
      lineState.setShape(LineState.SHAPE_LARGEPOINT);
    }

    lineState.setColor(stormDisplayState.getWayDisplayState(stormTrack.getWay()).getColor());
    lineState.setName(label);
    lineState.setTrack(times, values);
    return lineState;
  }
Пример #13
0
 /**
  * Create the name label if needed.
  *
  * @return The component that holds the name label.
  */
 protected JComponent getLabelComponent() {
   if (nameLabel == null) {
     nameLabel = new JLabel();
     Font font = nameLabel.getFont();
     nameLabel.setFont(font.deriveFont(Font.ITALIC | Font.BOLD));
     labelComponent = GuiUtils.hflow(Misc.newList(new JLabel("Layout Model: "), nameLabel));
   }
   return labelComponent;
 }
Пример #14
0
 /**
  * Insert a new ui component into the panel.
  *
  * @param handler The handler associated with this component.
  */
 private void addToHistory(XmlHandler handler) {
   int howManyToRemove = handlers.size() - historyIdx - 1;
   for (int cnt = 0; cnt < howManyToRemove; cnt++) {
     Misc.removeLast(handlers);
   }
   handlers.add(handler);
   historyIdx = handlers.size() - 1;
   checkButtons();
 }
Пример #15
0
  /**
   * Make the control widgets
   *
   * @param controlWidgets list of control widgets
   * @throws RemoteException Java RMI error
   * @throws VisADException VisAD Error
   */
  public void getControlWidgets(List controlWidgets) throws VisADException, RemoteException {
    super.getControlWidgets(controlWidgets);

    JComponent barbSizeBox =
        GuiUtils.wrap(
            GuiUtils.createValueBox(
                this, CMD_BARBSIZE, (int) flowScaleValue, Misc.createIntervalList(1, 10, 1), true));

    // make possible another component(s) to put on same line w barbSizeBox
    JComponent extra = doMakeExtraComponent();

    JComponent rightPanel =
        GuiUtils.leftCenter(
            ((extra != null)
                ? (JComponent) GuiUtils.hflow(Misc.newList(barbSizeBox, extra))
                : (JComponent) barbSizeBox),
            GuiUtils.filler());
    controlWidgets.add(new WrapperWidget(this, GuiUtils.rLabel("Windbarb size: "), rightPanel));
  }
Пример #16
0
 /**
  * Make a combo box to select vertical separation of wind barbs, in m
  *
  * @return component for vertical interval selection
  */
 protected JComponent doMakeVerticalIntervalComponent() {
   JComboBox intervalBox =
       GuiUtils.createValueBox(
           this,
           CMD_INTERVAL,
           (int) verticalIntervalValue,
           Misc.createIntervalList(250, 1000, 250),
           true);
   return GuiUtils.label("  Vertical interval (m): ", GuiUtils.wrap(intervalBox));
 }
Пример #17
0
 /**
  * Create a UrlDataChoice.
  *
  * @param url URL (choice ID)
  * @param desc DataChoice description
  */
 public UrlDataChoice(String url, String desc) {
   super(
       url,
       desc,
       desc,
       Misc.newList(
           new DataCategory("Documentation", true),
           new DataCategory(DataCategory.CATEGORY_HTML, false)));
   this.url = url;
 }
Пример #18
0
 /**
  * Override the superclass method for this.
  *
  * @return a unique composite of the times for all child choices.
  */
 public List getAllDateTimes() {
   Hashtable seen = new Hashtable();
   List mine = new ArrayList();
   for (int i = 0; i < dataChoices.size(); i++) {
     DataChoice child = (DataChoice) dataChoices.get(i);
     if (child != null) {
       Misc.addUnique(mine, child.getAllDateTimes(), seen);
     }
   }
   return mine;
 }
Пример #19
0
 /** Start/stop autoupdating if needed */
 private void checkAutoUpdate() {
   // bumping up the timestamp will stop any previous threads
   timestamp++;
   if (animationInfo.getAnimationSetInfo().usingCurrentTime()) {
     Misc.run(
         new Runnable() {
           public void run() {
             updateAnimationSet(++timestamp);
           }
         });
   }
 }
Пример #20
0
 /**
  * Get all the levels associated with this choice
  *
  * @param dataSelection data selection
  * @return List of levels
  */
 public List getAllLevels(DataSelection dataSelection) {
   Hashtable seen = new Hashtable();
   List mine = new ArrayList();
   dataSelection = DataSelection.merge(dataSelection, myDataSelection);
   for (int i = 0; i < dataChoices.size(); i++) {
     DataChoice child = (DataChoice) dataChoices.get(i);
     if (child != null) {
       Misc.addUnique(mine, child.getAllLevels(dataSelection), seen);
     }
   }
   return mine;
 }
Пример #21
0
    /**
     * Make the gui for the data subset panel
     *
     * @return gui for data subset panel
     */
    protected JComponent doMakeContents() {
      GuiUtils.tmpInsets = GuiUtils.INSETS_5;
      String prop = (String) pointDataSource.getProperty(PROP_STATIONMODELNAME);
      if (dataSelection != null) {
        prop = (String) dataSelection.getProperty(PROP_STATIONMODELNAME);
      }
      if (prop != null) {
        pmc.setPlotModelByName((String) prop);
      }

      return GuiUtils.top(GuiUtils.hflow(Misc.newList(new JLabel("Layout Model: "), pmc), 5, 5));
    }
Пример #22
0
 /**
  * Add the given object to the list of units
  *
  * @param selected Selected unit
  */
 public void addToUnitList(Object selected) {
   synchronized (UNIT_MUTEX) {
     if (unitList == null) {
       getDefaultUnitList();
     }
     if (!Misc.containsString(selected.toString(), unitList, true)
         && !unitList.contains(selected)) {
       unitList.add(selected);
       getStore().put(PREF_UNITLIST, unitList);
       getStore().save();
     }
   }
 }
Пример #23
0
 /**
  * Override the superclass method for this.
  *
  * @return a unique set of the selected times of all child choices
  */
 public List getSelectedDateTimes() {
   if (useDataSourceToFindTimes) {
     return dataSource.getSelectedDateTimes();
   }
   List mine = new ArrayList();
   Hashtable seen = new Hashtable();
   for (int i = 0; i < dataChoices.size(); i++) {
     DataChoice child = (DataChoice) dataChoices.get(i);
     if (child != null) {
       Misc.addUnique(mine, child.getSelectedDateTimes(), seen);
     }
   }
   return mine;
 }
Пример #24
0
 /**
  * autoupdate the set of synthetic times
  *
  * @param myTimestamp used to only have on thread active
  */
 private void updateAnimationSet(int myTimestamp) {
   try {
     while (true) {
       long seconds = (long) (animationInfo.getAnimationSetInfo().getPollMinutes() * 60);
       Misc.sleepSeconds(seconds);
       DisplayMaster displayMaster = getDisplayMaster();
       if ((displayMaster == null) || (anime == null) || (myTimestamp != timestamp)) {
         break;
       }
       displayMaster.dataChange();
     }
   } catch (Exception exc) {
     LogUtil.logException("Error updating animation set", exc);
   }
 }
Пример #25
0
 /**
  * Create a new PlotModelComponent
  *
  * @param idv the associated IDV
  * @param plotModelListener the listener
  * @param methodName method on listener to call
  * @param plotModel the plot model
  * @param addNone should we add the 'none' entry to the widget
  */
 public PlotModelComponent(
     IntegratedDataViewer idv,
     Object plotModelListener,
     String methodName,
     StationModel plotModel,
     boolean addNone) {
   this.idv = idv;
   this.addNone = addNone;
   setLayout(new BorderLayout());
   this.add(makeStationModelWidget());
   this.plotModelListener = plotModelListener;
   method =
       Misc.findMethod(plotModelListener.getClass(), methodName, new Class[] {StationModel.class});
   setPlotModel(plotModel);
 }
Пример #26
0
  /**
   * Add components to properties dialog
   *
   * @param comps List of components
   * @param tabIdx Which tab in properties dialog
   */
  protected void getPropertiesComponents(List comps, int tabIdx) {
    super.getPropertiesComponents(comps, tabIdx);
    if (tabIdx != 0) {
      return;
    }
    comps.add(GuiUtils.rLabel("Histogram: "));

    comps.add(
        GuiUtils.left(
            GuiUtils.hbox(
                Misc.newList(new JLabel("Number of Bins: "), binFld = new JTextField("" + bins, 6)),
                4)));
    //                                             new JLabel("      Stacked: "),
    // stackedCbx = new JCheckBox("",stacked)),4)));
  }
Пример #27
0
 /**
  * Get the name for the projection in question. A little better than <code>
  * MapProjection.toString()</code>
  *
  * @param projection MapProjection in question
  * @return name for projection
  */
 public String getMapProjectionName(MapProjection projection) {
   Object op = projection;
   if (projection instanceof ProjectionCoordinateSystem) {
     ProjectionImpl pi = ((ProjectionCoordinateSystem) projection).getProjection();
     String name = pi.getName();
     if ((name != null) && (name.length() > 0)) {
       return name;
     }
     // make a default
     op = pi;
   } else if (projection instanceof visad.data.mcidas.AREACoordinateSystem) {
     return projection.toString();
   }
   return Misc.getClassName(op.getClass());
 }
Пример #28
0
  /**
   * Respond to <code>ControlEvent</code>s.
   *
   * @param e <code>ControlEvent</code> to respond to
   */
  protected void handleControlChanged(ControlEvent e) {
    checkHistoryMatrix();

    NavigatedDisplay navDisplay = getNavigatedDisplay();

    if ((lastVerticalRangeUnit != null) && (lastVerticalRange != null)) {
      if (!(Misc.equals(lastVerticalRangeUnit, navDisplay.getVerticalRangeUnit())
          && Arrays.equals(lastVerticalRange, navDisplay.getVerticalRange()))) {
        verticalRangeChanged();
      }
    }

    lastVerticalRangeUnit = navDisplay.getVerticalRangeUnit();
    lastVerticalRange = navDisplay.getVerticalRange();
    super.handleControlChanged(e);
  }
Пример #29
0
 /** Called by the parent class after all initialization has been done. */
 public void initDone() {
   try {
     // communicate the probe's initial position
     // Run this in a thread to get around possible deadlock issues.
     Misc.runInABit(
         10,
         new Runnable() {
           public void run() {
             lineProbeWasMoved();
           }
         });
   } catch (Exception ex) {
     logException(ex);
   }
   super.initDone();
 }
Пример #30
0
  /**
   * A utility method that will wait until all displays are finished being created. This looks at
   * the DisplayControls, data sources, global wait cursor count, the visad thread pool and looks at
   * any active java3d threads
   *
   * @param uiManager The ui manager. We use this to access the wait cursor count
   * @param timeToWait (milliseconds) elapsed time to wait for nothing to be active
   */
  public static void waitUntilDisplaysAreDone(IdvUIManager uiManager, long timeToWait) {
    Trace.call1("Waiting on displays");
    int successiveTimesWithNoActive = 0;
    int sleepTime = 10;
    long firstTime = System.currentTimeMillis();
    int cnt = 0;
    while (true) {
      boolean cursorCount = (uiManager.getWaitCursorCount() > 0);
      boolean actionCount = ActionImpl.getTaskCount() > 0;
      boolean dataActive = DataSourceImpl.getOutstandingGetDataCalls() > 0;
      boolean anyJ3dActive = anyJava3dThreadsActive();
      boolean allDisplaysInitialized = uiManager.getIdv().getAllDisplaysIntialized();

      //            System.err.println ("\tAll displays init:" + allDisplaysInitialized +" cursor
      // cnt:" + uiManager.getWaitCursorCount() + " action cnt:" +actionCount + " data active: " +
      // dataActive);
      //            if ((cnt++) % 30 == 0) {
      //                System.err.println ("\tcnt:" + uiManager.getWaitCursorCount() + " "
      // +actionCount + " " + dataActive);
      //            }
      boolean anyActive =
          actionCount || cursorCount || dataActive || !allDisplaysInitialized || anyJ3dActive;
      if (dataActive) {
        firstTime = System.currentTimeMillis();
      }

      if (anyActive) {
        successiveTimesWithNoActive = 0;
      } else {
        successiveTimesWithNoActive++;
      }
      if ((timeToWait == 0) && !anyActive) {
        break;
      }
      if (successiveTimesWithNoActive * sleepTime > timeToWait) {
        break;
      }
      Misc.sleep(sleepTime);
      // At most wait 120 seconds
      if (System.currentTimeMillis() - firstTime > 120000) {
        System.err.println("Error waiting for to be done:" + LogUtil.getStackDump(false));
        return;
      }
    }
    Trace.call2("Waiting on displays");
  }