Пример #1
0
  /**
   * Constructs and returns a worker thread which can perform a match as specified by the current
   * state of this component.
   *
   * @return new worker thread
   * @throws RuntimeException if the current state does not fully specify a multi query job; such
   *     exceptions will have comprehensible messages
   */
  private MatchWorker createMatchWorker() {

    /* Acquire state from this panel's GUI components. */
    String sUrl = urlField_.getText();
    if (sUrl == null || sUrl.trim().length() == 0) {
      throw new IllegalArgumentException("No " + service_.getName() + " URL given");
    }
    URL serviceUrl;
    try {
      serviceUrl = new URL(sUrl);
    } catch (MalformedURLException e) {
      throw (IllegalArgumentException)
          new IllegalArgumentException("Bad " + service_.getName() + " URL syntax: " + sUrl)
              .initCause(e);
    }
    ConeErrorPolicy erract = (ConeErrorPolicy) erractSelector_.getSelectedItem();
    TopcatModel tcModel = tcModel_;
    if (tcModel == null) {
      throw new NullPointerException("No table selected");
    }
    final StarTable inTable = tcModel.getApparentStarTable();
    int[] rowMap = tcModel.getViewModel().getRowMap();
    ColumnData raData = raSelector_.getColumnData();
    ColumnData decData = decSelector_.getColumnData();
    ColumnData srData = srSelector_.getColumnData();
    if (raData == null) {
      throw new NullPointerException("No RA column given");
    }
    if (decData == null) {
      throw new NullPointerException("No Dec column given");
    }
    Number parNum = parallelModel_.getNumber();
    int parallelism = parNum == null ? 1 : parNum.intValue();
    MulticoneMode mcMode = (MulticoneMode) modeSelector_.getSelectedItem();
    StarTableFactory tfact = ControlWindow.getInstance().getTableFactory();

    /* Assemble objects based on this information. */
    ConeSearcher searcher = service_.createSearcher(serviceUrl, tfact);
    Coverage coverage = coverageModel_.isSelected() ? service_.getCoverage(serviceUrl) : null;
    DatasQuerySequenceFactory qsf = new DatasQuerySequenceFactory(raData, decData, srData, rowMap);
    ConeMatcher matcher =
        mcMode.createConeMatcher(searcher, erract, inTable, qsf, coverage, parallelism);
    ResultHandler resultHandler =
        mcMode.createResultHandler(this, tfact.getStoragePolicy(), tcModel, inTable);

    /* Create MatchWorker encapsulating all of this. */
    MatchWorker worker = new MatchWorker(matcher, resultHandler, tcModel, inTable);

    /* Perform post-construction configuration of constituent objects
     * as required. */
    qsf.setMatchWorker(worker);
    resultHandler.setMatchWorker(worker);

    /* Return worker thread. */
    return worker;
  }
Пример #2
0
 /** Update the service coverage component if the currently selected service URL has changed. */
 private void updateServiceCoverage() {
   if (hasCoverage_) {
     if (coverageModel_.isSelected()) {
       URL url = toUrl(urlField_.getText());
       if ((url == null && lastCoverageUrl_ != null)
           || (url != null && !url.equals(lastCoverageUrl_))) {
         Coverage cov = url == null ? null : service_.getCoverage(url);
         serviceCoverageView_.setCoverage(cov);
         lastCoverageUrl_ = url;
         updateOverlapCoverage();
       }
     } else {
       serviceCoverageView_.setCoverage(null);
       lastCoverageUrl_ = null;
     }
   }
 }