Exemplo n.º 1
0
 public Object getPropertyValue(String propertyName) {
   Object result = null;
   if (propertySet.isPropertyDefined(propertyName)) {
     result = propertySet.getProperty(propertyName).getValue();
   }
   return result;
 }
Exemplo n.º 2
0
 private VectorDataLayer createLayerInternal(LayerContext ctx, VectorDataNode vectorDataNode) {
   final PropertySet configuration = createLayerConfig(ctx);
   // Save the name of the vectorDataNode, so that we can reconstruct the layer later (e.g. if
   // loaded from session file).
   configuration.setValue(PROPERTY_NAME_VECTOR_DATA, vectorDataNode.getName());
   return createLayer(vectorDataNode, configuration);
 }
  private void addParameters(
      final OperatorSpi operatorSpi, final AppContext appContext, final String helpID) {
    // OperatorMenu operatorMenu = new OperatorMenu(this.getJDialog(),
    //                                             operatorSpi.getOperatorClass(),
    //                                             parameterSupport,
    //                                             helpID);
    final PropertySet propertyContainer = parameterSupport.getPopertySet();
    final List<SourceProductSelector> sourceProductSelectorList =
        ioParametersPanel.getSourceProductSelectorList();

    sourceProductSelectorList
        .get(0)
        .addSelectionChangeListener(
            new AbstractSelectionChangeListener() {

              @Override
              public void selectionChanged(SelectionChangeEvent event) {
                final Product selectedProduct = (Product) event.getSelection().getSelectedValue();
                if (selectedProduct != null) {
                  final TargetProductSelectorModel targetProductSelectorModel =
                      getTargetProductSelector().getModel();
                  targetProductSelectorModel.setProductName(
                      selectedProduct.getName() + getTargetProductNameSuffix());
                  opUI.setSourceProducts(new Product[] {selectedProduct});
                }
              }
            });

    if (propertyContainer.getProperties().length > 0) {
      if (!sourceProductSelectorList.isEmpty()) {
        Property[] properties = propertyContainer.getProperties();
        List<PropertyDescriptor> rdnTypeProperties =
            new ArrayList<PropertyDescriptor>(properties.length);
        for (Property property : properties) {
          PropertyDescriptor parameterDescriptor = property.getDescriptor();
          if (parameterDescriptor.getAttribute(RasterDataNodeValues.ATTRIBUTE_NAME) != null) {
            rdnTypeProperties.add(parameterDescriptor);
          }
        }
        rasterDataNodeTypeProperties =
            rdnTypeProperties.toArray(new PropertyDescriptor[rdnTypeProperties.size()]);
      }

      final JComponent paremetersPanel =
          opUI.CreateOpTab(operatorName, parameterSupport.getParameterMap(), appContext);

      paremetersPanel.setBorder(new EmptyBorder(4, 4, 4, 4));
      this.form.add("Processing Parameters", new JScrollPane(paremetersPanel));

      // getJDialog().setJMenuBar(operatorMenu.createDefaultMenu());
    }
  }
Exemplo n.º 4
0
 private void updateTargetProductFields() {
   TargetProductSelectorModel model = targetProductSelector.getModel();
   Property property = propertySet.getProperty(ToolAdapterConstants.TOOL_TARGET_PRODUCT_FILE);
   if (!operatorDescriptor.isHandlingOutputName()) {
     Object value = property.getValue();
     if (value != null) {
       File file = operatorDescriptor.resolveVariables(new File(property.getValueAsText()));
       String productName = FileUtils.getFilenameWithoutExtension(file);
       if (fileExtension == null) {
         fileExtension = FileUtils.getExtension(file);
       }
       model.setProductName(productName);
     }
   } else {
     try {
       model.setProductName("Output Product");
       if (property != null) {
         property.setValue(null);
       }
     } catch (ValidationException e) {
       Logger.getLogger(ToolExecutionForm.class.getName()).severe(e.getMessage());
     }
   }
   model.setSaveToFileSelected(false);
   targetProductSelector.getProductDirTextField().setEnabled(false);
 }
  private synchronized void updateChildren() {

    // Collect all current mask layers
    LayerFilter layerFilter =
        layer -> {
          PropertySet conf = layer.getConfiguration();
          return conf.isPropertyDefined(MaskLayerType.PROPERTY_NAME_MASK)
              && conf.getValue(MaskLayerType.PROPERTY_NAME_MASK) != null;
        };
    List<Layer> maskLayers =
        LayerUtils.getChildLayers(
            LayerUtils.getRootLayer(this), LayerUtils.SEARCH_DEEP, layerFilter);
    HashMap<Mask, Layer> currentLayers = new HashMap<>();
    for (Layer maskLayer : maskLayers) {
      Mask mask = maskLayer.getConfiguration().getValue(MaskLayerType.PROPERTY_NAME_MASK);
      currentLayers.put(mask, maskLayer);
    }

    // Allign mask layers with available masks
    if (raster != null && getProduct() != null) {
      Mask[] availableMasks = getProduct().getMaskGroup().toArray(new Mask[0]);
      HashSet<Layer> unusedLayers = new HashSet<>(maskLayers);
      for (Mask availableMask : availableMasks) {
        // todo add all mask layers as soon as the masks have been scaled to fit the raster
        if (raster.getRasterSize().equals(availableMask.getRasterSize())) {
          Layer layer = currentLayers.get(availableMask);
          if (layer != null) {
            unusedLayers.remove(layer);
          } else {
            layer = createLayer(availableMask);
            getChildren().add(layer);
          }
          layer.setVisible(raster.getOverlayMaskGroup().contains(availableMask));
        }
      }

      // Remove unused layers
      for (Layer layer : unusedLayers) {
        layer.dispose();
        Layer layerParent = layer.getParent();
        if (layerParent != null) {
          layerParent.getChildren().remove(layer);
        }
      }
    }
  }
Exemplo n.º 6
0
 @Override
 public Layer createLayer(LayerContext ctx, PropertySet configuration) {
   Assert.notNull(ctx, "ctx");
   final ProductLayerContext plc = (ProductLayerContext) ctx;
   final String vectorDataName = (String) configuration.getValue(PROPERTY_NAME_VECTOR_DATA);
   final VectorDataNode vectorDataNode = plc.getProduct().getVectorDataGroup().get(vectorDataName);
   return createLayer(vectorDataNode, configuration);
 }
Exemplo n.º 7
0
  static boolean insertImageLayer(LayerSourcePageContext pageContext) {
    AffineTransform transform =
        (AffineTransform) pageContext.getPropertyValue(PROPERTY_NAME_WORLD_TRANSFORM);
    String imageFilePath = (String) pageContext.getPropertyValue(PROPERTY_NAME_IMAGE_FILE_PATH);

    try {
      ProductSceneView sceneView = SnapApp.getDefault().getSelectedProductSceneView();
      final ImageFileLayerType type = LayerTypeRegistry.getLayerType(ImageFileLayerType.class);
      final PropertySet configuration = type.createLayerConfig(sceneView);
      configuration.setValue(ImageFileLayerType.PROPERTY_NAME_IMAGE_FILE, new File(imageFilePath));
      configuration.setValue(ImageFileLayerType.PROPERTY_NAME_WORLD_TRANSFORM, transform);
      Layer layer = type.createLayer(sceneView, configuration);
      layer.setName(FileUtils.getFileNameFromPath(imageFilePath));
      Layer rootLayer = sceneView.getRootLayer();
      rootLayer.getChildren().add(sceneView.getFirstImageLayerIndex(), layer);
      return true;
    } catch (Exception e) {
      pageContext.showErrorDialog(e.getMessage());
      return false;
    }
  }
Exemplo n.º 8
0
  @Override
  public Layer createLayer(LayerContext ctx, PropertySet configuration) {
    CoordinateReferenceSystem targetCrs = null;
    if (ctx != null) {
      targetCrs = (CoordinateReferenceSystem) ctx.getCoordinateReferenceSystem();
    }
    FeatureCollection<SimpleFeatureType, SimpleFeature> fc;
    fc =
        (FeatureCollection<SimpleFeatureType, SimpleFeature>)
            configuration.getValue(FeatureLayerType.PROPERTY_NAME_FEATURE_COLLECTION);
    if (fc == null) {
      try {
        final URL url =
            (URL) configuration.getValue(FeatureLayerType.PROPERTY_NAME_FEATURE_COLLECTION_URL);
        FeatureSource<SimpleFeatureType, SimpleFeature> featureSource =
            FeatureUtils.getFeatureSource(url);
        fc = featureSource.getFeatures();
      } catch (IOException e) {
        throw new IllegalArgumentException(e);
      }
    }
    final CoordinateReferenceSystem featureCrs =
        (CoordinateReferenceSystem)
            configuration.getValue(FeatureLayerType.PROPERTY_NAME_FEATURE_COLLECTION_CRS);
    final Geometry clipGeometry =
        (Geometry)
            configuration.getValue(FeatureLayerType.PROPERTY_NAME_FEATURE_COLLECTION_CLIP_GEOMETRY);

    fc =
        FeatureUtils.clipCollection(
            fc,
            featureCrs,
            clipGeometry,
            DefaultGeographicCRS.WGS84,
            null,
            targetCrs,
            ProgressMonitor.NULL);

    return new FeatureLayer(this, fc, configuration);
  }
Exemplo n.º 9
0
 public static TOPSBurstsLayer createLayer(final RasterDataNode raster) {
   final LayerType type = LayerTypeRegistry.getLayerType(TOPSBurstLayerType.class);
   final PropertySet template = type.createLayerConfig(null);
   template.setValue("raster", raster);
   return new TOPSBurstsLayer(type, template);
 }