private static void createTransform(LayerSourcePageContext pageContext) { AffineTransform transform = new AffineTransform(); String worldFilePath = (String) pageContext.getPropertyValue(ImageFileLayerSource.PROPERTY_NAME_WORLD_FILE_PATH); if (worldFilePath != null && !worldFilePath.isEmpty()) { try { transform = Tools.loadWorldFile(worldFilePath); } catch (IOException e) { e.printStackTrace(); pageContext.showErrorDialog(e.getMessage()); } } pageContext.setPropertyValue(ImageFileLayerSource.PROPERTY_NAME_WORLD_TRANSFORM, transform); }
@Override protected void done() { try { Layer layer = get(); try { final AppContext appContext = getContext().getAppContext(); ProductSceneView sceneView = appContext.getSelectedProductSceneView(); rootLayer.getChildren().add(sceneView.getFirstImageLayerIndex(), layer); } catch (Exception e) { getContext().showErrorDialog(e.getMessage()); } } catch (ExecutionException e) { getContext().showErrorDialog( String.format("Error while expecting WMS response:\n%s", e.getCause().getMessage())); } catch (InterruptedException ignored) { // ok } }
@Override protected void done() { try { final Layer layer = get(); ProductSceneView sceneView = getContext().getAppContext().getSelectedProductSceneView(); final Layer rootLayer = getContext().getLayerContext().getRootLayer(); rootLayer.getChildren().add(sceneView.getFirstImageLayerIndex(), layer); } catch (InterruptedException ignored) { } catch (ExecutionException e) { getContext().showErrorDialog("Could not load shape file: \n" + e.getMessage()); e.printStackTrace(); } } }
@Override public AbstractLayerSourceAssistantPage getNextPage() { LayerSourcePageContext pageContext = getContext(); WebMapServer wms = null; WMSCapabilities wmsCapabilities = null; String wmsUrl = wmsUrlBox.getSelectedItem().toString(); if (wmsUrl != null && !wmsUrl.isEmpty()) { try { wms = getWms(pageContext.getWindow(), wmsUrl); wmsCapabilities = wms.getCapabilities(); } catch (Exception e) { e.printStackTrace(); pageContext.showErrorDialog("Failed to access WMS:\n" + e.getMessage()); } } history.copyInto(getContext().getAppContext().getPreferences()); if (wms != null && wmsCapabilities != null) { pageContext.setPropertyValue(WmsLayerSource.PROPERTY_NAME_WMS, wms); pageContext.setPropertyValue(WmsLayerSource.PROPERTY_NAME_WMS_CAPABILITIES, wmsCapabilities); return new WmsAssistantPage2(); } else { return null; } }
context.showErrorDialog("Failed to load ESRI shapefile:\n" + e.getMessage());
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 = pageContext.getAppContext().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; } } }
@Override public AbstractLayerSourceAssistantPage getNextPage() { final LayerSourcePageContext context = getContext(); try { final Product product = context.getAppContext().getSelectedProduct(); final GeoPos referencePos = ProductUtils.getCenterGeoPos(product); final CoordinateReferenceSystem crs = crsSelectionPanel.getCrs(referencePos); context.setPropertyValue(ShapefileLayerSource.PROPERTY_NAME_FEATURE_COLLECTION_CRS, crs); return new ShapefileAssistantPage3(); } catch (FactoryException e) { e.printStackTrace(); context.showErrorDialog("Could not create CRS:\n" + e.getMessage()); } return null; }