Exemplo n.º 1
0
  private boolean checkReferencedRastersIncluded() {
    final Set<String> notIncludedNames = new TreeSet<String>();
    final List<String> includedNodeNames = Arrays.asList(productSubsetDef.getNodeNames());
    for (final String nodeName : includedNodeNames) {
      final RasterDataNode rasterDataNode = product.getRasterDataNode(nodeName);
      if (rasterDataNode != null) {
        collectNotIncludedReferences(rasterDataNode, notIncludedNames);
      }
    }

    boolean ok = true;
    if (!notIncludedNames.isEmpty()) {
      StringBuilder nameListText = new StringBuilder();
      for (String notIncludedName : notIncludedNames) {
        nameListText.append("  '").append(notIncludedName).append("'\n");
      }

      final String pattern =
          "The following dataset(s) are referenced but not included\n"
              + "in your current subset definition:\n"
              + "{0}\n"
              + "If you do not include these dataset(s) into your selection,\n"
              + "you might get unexpected results while working with the\n"
              + "resulting product.\n\n"
              + "Do you wish to include the referenced dataset(s) into your\n"
              + "subset definition?\n"; /*I18N*/
      final MessageFormat format = new MessageFormat(pattern);
      int status =
          JOptionPane.showConfirmDialog(
              getJDialog(),
              format.format(new Object[] {nameListText.toString()}),
              "Incomplete Subset Definition", /*I18N*/
              JOptionPane.YES_NO_CANCEL_OPTION);
      if (status == JOptionPane.YES_OPTION) {
        final String[] nodenames = notIncludedNames.toArray(new String[notIncludedNames.size()]);
        productSubsetDef.addNodeNames(nodenames);
        ok = true;
      } else if (status == JOptionPane.NO_OPTION) {
        ok = true;
      } else if (status == JOptionPane.CANCEL_OPTION) {
        ok = false;
      }
    }
    return ok;
  }
Exemplo n.º 2
0
  private boolean checkFlagDatasetIncluded() {
    final String[] nodeNames = productSubsetDef.getNodeNames();
    final List<String> flagDsNameList = new ArrayList<String>(10);
    boolean flagDsInSubset = false;
    for (int i = 0; i < product.getNumBands(); i++) {
      Band band = product.getBandAt(i);
      if (band.getFlagCoding() != null) {
        flagDsNameList.add(band.getName());
        if (StringUtils.contains(nodeNames, band.getName())) {
          flagDsInSubset = true;
        }
        break;
      }
    }

    final int numFlagDs = flagDsNameList.size();
    boolean ok = true;
    if (numFlagDs > 0 && !flagDsInSubset) {
      int status =
          JOptionPane.showConfirmDialog(
              getJDialog(),
              "No flag dataset selected.\n\n"
                  + "If you do not include a flag dataset in the subset,\n"
                  + "you will not be able to create bitmask overlays.\n\n"
                  + "Do you wish to include the available flag dataset(s)\n"
                  + "in the current subset?\n",
              "No Flag Dataset Selected",
              JOptionPane.YES_NO_CANCEL_OPTION);
      if (status == JOptionPane.YES_OPTION) {
        productSubsetDef.addNodeNames(flagDsNameList.toArray(new String[numFlagDs]));
        ok = true;
      } else if (status == JOptionPane.NO_OPTION) {
        /* OK, no flag datasets wanted */
        ok = true;
      } else if (status == JOptionPane.CANCEL_OPTION) {
        ok = false;
      }
    }

    return ok;
  }
Exemplo n.º 3
0
  private void updateDataSource() {
    if (!isInitialized) {
      return;
    }

    profileData = null;
    if (getRaster() != null) {
      try {
        if (dataSourceConfig.useCorrelativeData && dataSourceConfig.pointDataSource != null) {
          profileData =
              new TransectProfileDataBuilder()
                  .raster(getRaster())
                  .pointData(dataSourceConfig.pointDataSource)
                  .boxSize(dataSourceConfig.boxSize)
                  .connectVertices(dataSourceConfig.computeInBetweenPoints)
                  .useRoiMask(dataSourceConfig.useRoiMask)
                  .roiMask(dataSourceConfig.roiMask)
                  .build();
        } else {
          Shape shape = StatisticsUtils.TransectProfile.getTransectShape(getRaster().getProduct());
          if (shape != null) {
            profileData =
                new TransectProfileDataBuilder()
                    .raster(getRaster())
                    .path(shape)
                    .boxSize(dataSourceConfig.boxSize)
                    .connectVertices(dataSourceConfig.computeInBetweenPoints)
                    .useRoiMask(dataSourceConfig.useRoiMask)
                    .roiMask(dataSourceConfig.roiMask)
                    .build();
          }
        }
      } catch (IOException e) {
        JOptionPane.showMessageDialog(
            getParent(),
            "Failed to compute profile plot.\n" + "An I/O error occurred:" + e.getMessage(),
            "I/O error",
            JOptionPane.ERROR_MESSAGE); /*I18N*/
      }
    }
  }