예제 #1
0
 private ProductNodeSubsetPane createBandSubsetPane() {
   Band[] bands = product.getBands();
   if (bands.length == 0) {
     return null;
   }
   return new ProductNodeSubsetPane(product.getBands(), true);
 }
예제 #2
0
 private ProductNodeSubsetPane createTiePointGridSubsetPane() {
   TiePointGrid[] tiePointGrids = product.getTiePointGrids();
   if (tiePointGrids.length == 0) {
     return null;
   }
   return new ProductNodeSubsetPane(
       product.getTiePointGrids(),
       new String[] {BeamConstants.LAT_DS_NAME, BeamConstants.LON_DS_NAME},
       true);
 }
예제 #3
0
  private static RasterDataNode[] getReferencedNodes(final RasterDataNode node) {
    final Product product = node.getProduct();
    if (product != null) {
      final List<String> expressions = new ArrayList<String>(10);
      if (node.getValidPixelExpression() != null) {
        expressions.add(node.getValidPixelExpression());
      }
      final ProductNodeGroup<Mask> overlayMaskGroup = node.getOverlayMaskGroup();
      if (overlayMaskGroup.getNodeCount() > 0) {
        final Mask[] overlayMasks =
            overlayMaskGroup.toArray(new Mask[overlayMaskGroup.getNodeCount()]);
        for (final Mask overlayMask : overlayMasks) {
          final String expression;
          if (overlayMask.getImageType() == Mask.BandMathsType.INSTANCE) {
            expression = Mask.BandMathsType.getExpression(overlayMask);
          } else if (overlayMask.getImageType() == Mask.RangeType.INSTANCE) {
            expression = Mask.RangeType.getExpression(overlayMask);
          } else {
            expression = null;
          }
          if (expression != null) {
            expressions.add(expression);
          }
        }
      }
      if (node instanceof VirtualBand) {
        final VirtualBand virtualBand = (VirtualBand) node;
        expressions.add(virtualBand.getExpression());
      }

      final ArrayList<Term> termList = new ArrayList<Term>(10);
      for (final String expression : expressions) {
        try {
          final Term term = product.parseExpression(expression);
          if (term != null) {
            termList.add(term);
          }
        } catch (ParseException e) {
          // @todo se handle parse exception
          Debug.trace(e);
        }
      }

      final Term[] terms = termList.toArray(new Term[termList.size()]);
      final RasterDataSymbol[] refRasterDataSymbols = BandArithmetic.getRefRasterDataSymbols(terms);
      return BandArithmetic.getRefRasters(refRasterDataSymbols);
    }
    return new RasterDataNode[0];
  }
예제 #4
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;
  }
예제 #5
0
 private void updateMemDisplay() {
   if (product != null) {
     long storageMem = product.getRawStorageSize(productSubsetDef);
     double factor = 1.0 / (1024 * 1024);
     double megas = MathUtils.round(factor * storageMem, 10);
     if (megas > memWarnLimit) {
       memLabel.setForeground(MEM_LABEL_WARN_COLOR);
     } else {
       memLabel.setForeground(MEM_LABEL_NORM_COLOR);
     }
     memLabel.setText(MEM_LABEL_TEXT + megas + "M");
   } else {
     memLabel.setText(" ");
   }
 }
예제 #6
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;
  }
예제 #7
0
 private ProductNodeSubsetPane createAnnotationSubsetPane() {
   final MetadataElement metadataRoot = product.getMetadataRoot();
   final MetadataElement[] metadataElements = metadataRoot.getElements();
   final String[] metaNodes;
   if (metadataElements.length == 0) {
     return null;
   }
   // metadata elements must be added to includeAlways list
   // to ensure that they are selected if isIgnoreMetada is set to false
   if (givenProductSubsetDef != null && !givenProductSubsetDef.isIgnoreMetadata()) {
     metaNodes = new String[metadataElements.length];
     for (int i = 0; i < metadataElements.length; i++) {
       final MetadataElement metadataElement = metadataElements[i];
       metaNodes[i] = metadataElement.getName();
     }
   } else {
     metaNodes = new String[0];
   }
   final String[] includeNodes = StringUtils.addToArray(metaNodes, Product.HISTORY_ROOT_NAME);
   return new ProductNodeSubsetPane(metadataElements, includeNodes, true);
 }
예제 #8
0
 private boolean canUseGeoCoordinates(Product product) {
   final GeoCoding geoCoding = product.getGeoCoding();
   return geoCoding != null && geoCoding.canGetPixelPos() && geoCoding.canGetGeoPos();
 }