Exemplo n.º 1
0
 private static void setSelectedVectorDataNode(
     ProductSceneView sceneView, final VectorDataNode vectorDataNode) {
   final LayerFilter layerFilter =
       new LayerFilter() {
         @Override
         public boolean accept(Layer layer) {
           return layer instanceof VectorDataLayer
               && ((VectorDataLayer) layer).getVectorDataNode() == vectorDataNode;
         }
       };
   Layer layer =
       LayerUtils.getChildLayer(sceneView.getRootLayer(), LayerUtils.SEARCH_DEEP, layerFilter);
   if (layer != null) {
     sceneView.setSelectedLayer(layer);
   }
 }
Exemplo n.º 2
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;
    }
  }