@Override public boolean validatePage() { String imageFilePath = (String) getContext().getPropertyValue(ImageFileLayerSource.PROPERTY_NAME_IMAGE_FILE_PATH); String worldFilePath = (String) getContext().getPropertyValue(ImageFileLayerSource.PROPERTY_NAME_WORLD_FILE_PATH); if (imageFilePath == null) { return false; } return new File(imageFilePath).exists() && (worldFilePath == null || new File(worldFilePath).exists()); }
private Style getSelectedStyle(Style[] styles) { Style selectedStyle = (Style) context.getPropertyValue(ShapefileLayerSource.PROPERTY_NAME_SELECTED_STYLE); if (selectedStyle == null) { selectedStyle = styles[0]; context.setPropertyValue(ShapefileLayerSource.PROPERTY_NAME_SELECTED_STYLE, styles[0]); } return selectedStyle; }
@Override public boolean hasNextPage() { return getContext().getPropertyValue(ImageFileLayerSource.PROPERTY_NAME_IMAGE_FILE_PATH) != null; }
@Override public boolean validatePage() { return getContext().getPropertyValue(WmsLayerSource.PROPERTY_NAME_SELECTED_LAYER) != null; }
@Override public boolean canFinish() { return getContext().getPropertyValue(ImageFileLayerSource.PROPERTY_NAME_IMAGE_FILE_PATH) != null; }
private FeatureCollection<SimpleFeatureType, SimpleFeature> getFeatureCollection(File file) throws IOException { Object featureCollectionValue = context.getPropertyValue(ShapefileLayerSource.PROPERTY_NAME_FEATURE_COLLECTION); FeatureCollection<SimpleFeatureType, SimpleFeature> featureCollection; if (featureCollectionValue == null) { featureCollection = FeatureUtils.getFeatureSource(file.toURI().toURL()).getFeatures(); } else { featureCollection = (FeatureCollection<SimpleFeatureType, SimpleFeature>) featureCollectionValue; } return featureCollection; }
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); }
String filePath = (String) context.getPropertyValue(ShapefileLayerSource.PROPERTY_NAME_FILE_PATH); String fileName = new File(filePath).getName();
@Override public Component createPageComponent() { final LayerSourcePageContext context = getContext(); Layer selectedLayer = (Layer) context.getPropertyValue(WmsLayerSource.PROPERTY_NAME_SELECTED_LAYER); JLabel infoLabel = new JLabel(WmsAssistantPage2.getLatLonBoundingBoxText(selectedLayer.getLatLonBoundingBox())); styleList.setSelectedItem(context.getPropertyValue(WmsLayerSource.PROPERTY_NAME_SELECTED_STYLE)); styleList.setRenderer(new StyleListCellRenderer()); styleList.addItemListener(new StyleItemListener());
private Style[] getStyles(File file, FeatureCollection<SimpleFeatureType, SimpleFeature> featureCollection) { Style[] styles = (Style[]) context.getPropertyValue(ShapefileLayerSource.PROPERTY_NAME_STYLES); if (styles == null || styles.length == 0) { styles = createStyle(file, featureCollection.getSchema()); context.setPropertyValue(ShapefileLayerSource.PROPERTY_NAME_STYLES, styles); } return styles; }
AffineTransform transform = (AffineTransform) getContext().getPropertyValue( ImageFileLayerSource.PROPERTY_NAME_WORLD_TRANSFORM); transform.getMatrix(flatmatrix);
@Override public Component createPageComponent() { JPanel panel = new JPanel(new BorderLayout(4, 4)); panel.setBorder(new EmptyBorder(4, 4, 4, 4)); panel.add(new JLabel("Available layers:"), BorderLayout.NORTH); LayerSourcePageContext context = getContext(); modelCRS = (CoordinateReferenceSystem) context.getLayerContext().getCoordinateReferenceSystem(); WMSCapabilities wmsCapabilities = (WMSCapabilities) context.getPropertyValue( WmsLayerSource.PROPERTY_NAME_WMS_CAPABILITIES); layerTree = new JTree(new WmsTreeModel(wmsCapabilities.getLayer())); layerTree.setRootVisible(false); layerTree.setShowsRootHandles(true); layerTree.setExpandsSelectedPaths(true); layerTree.setCellRenderer(new MyDefaultTreeCellRenderer()); layerTree.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); layerTree.getSelectionModel().addTreeSelectionListener(new LayerTreeSelectionListener()); panel.add(new JScrollPane(layerTree), BorderLayout.CENTER); infoLabel = new JLabel(" "); panel.add(infoLabel, BorderLayout.SOUTH); getContext().setPropertyValue(WmsLayerSource.PROPERTY_NAME_SELECTED_LAYER, null); return panel; }
bounds.getMaxX(), bounds.getMaxY())); Style[] styles = (Style[]) context.getPropertyValue(ShapefileLayerSource.PROPERTY_NAME_STYLES); Style selectedStyle = (Style) context.getPropertyValue(ShapefileLayerSource.PROPERTY_NAME_SELECTED_STYLE); styleList.setModel(new DefaultComboBoxModel(styles)); styleList.setSelectedItem(selectedStyle);
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; } } }
if (path != null && !path.trim().isEmpty()) { try { final String oldPath = (String) context.getPropertyValue(ShapefileLayerSource.PROPERTY_NAME_FILE_PATH); if (!path.equals(oldPath)) { context.setPropertyValue(ShapefileLayerSource.PROPERTY_NAME_FILE_PATH, path); context.setPropertyValue(ShapefileLayerSource.PROPERTY_NAME_FEATURE_COLLECTION_CRS, null); FeatureCollection fc = (FeatureCollection) context.getPropertyValue(ShapefileLayerSource.PROPERTY_NAME_FEATURE_COLLECTION); final CoordinateReferenceSystem featureCrs = fc.getSchema().getCoordinateReferenceSystem(); if (featureCrs == null) {
template.setValue(WmsLayerType.PROPERTY_NAME_RASTER, raster); template.setValue(WmsLayerType.PROPERTY_NAME_IMAGE_SIZE, mapImageSize); URL wmsUrl = (URL) context.getPropertyValue(WmsLayerSource.PROPERTY_NAME_WMS_URL); template.setValue(WmsLayerType.PROPERTY_NAME_URL, wmsUrl); StyleImpl selectedStyle = (StyleImpl) context.getPropertyValue(WmsLayerSource.PROPERTY_NAME_SELECTED_STYLE); String styleName = null; if (selectedStyle != null) { WebMapServer wms = (WebMapServer) context.getPropertyValue(WmsLayerSource.PROPERTY_NAME_WMS); final List<Layer> layerList = wms.getCapabilities().getLayerList(); Layer selectedLayer = (Layer) context.getPropertyValue(WmsLayerSource.PROPERTY_NAME_SELECTED_LAYER); template.setValue(WmsLayerType.PROPERTY_NAME_LAYER_INDEX, layerList.indexOf(selectedLayer)); CRSEnvelope crsEnvelope = (CRSEnvelope) context.getPropertyValue(WmsLayerSource.PROPERTY_NAME_CRS_ENVELOPE); template.setValue(WmsLayerType.PROPERTY_NAME_CRS_ENVELOPE, crsEnvelope); final com.bc.ceres.glayer.Layer layer = wmsType.createLayer(getContext().getLayerContext(), template);
private void updatePreview() { cancelPreviewWorker(); showMessage("<html><i>Loading map...</i></html>"); CRSEnvelope crsEnvelope = (CRSEnvelope) getContext().getPropertyValue(WmsLayerSource.PROPERTY_NAME_CRS_ENVELOPE); previewWorker = new WmsPreviewWorker(getContext(), getPreviewSize(crsEnvelope)); previewWorker.execute(); // todo - AppContext.addWorker(previewWorker); (nf) }
@Override protected Layer doInBackground(ProgressMonitor pm) throws Exception { try { pm.beginTask("Reading shapes", ProgressMonitor.UNKNOWN); final ProductSceneView sceneView = context.getAppContext().getSelectedProductSceneView(); final Geometry clipGeometry = FeatureUtils.createGeoBoundaryPolygon(sceneView.getProduct()); File file = new File((String) context.getPropertyValue(ShapefileLayerSource.PROPERTY_NAME_FILE_PATH)); FeatureCollection<SimpleFeatureType, SimpleFeature> featureCollection = getFeatureCollection(file); CoordinateReferenceSystem featureCrs = (CoordinateReferenceSystem) context.getPropertyValue( ShapefileLayerSource.PROPERTY_NAME_FEATURE_COLLECTION_CRS); Style[] styles = getStyles(file, featureCollection); Style selectedStyle = getSelectedStyle(styles); final LayerType type = LayerTypeRegistry.getLayerType(FeatureLayerType.class.getName()); final PropertySet configuration = type.createLayerConfig(sceneView); configuration.setValue(FeatureLayerType.PROPERTY_NAME_FEATURE_COLLECTION_URL, file.toURI().toURL()); configuration.setValue(FeatureLayerType.PROPERTY_NAME_FEATURE_COLLECTION, featureCollection); configuration.setValue(FeatureLayerType.PROPERTY_NAME_FEATURE_COLLECTION_CRS, featureCrs); configuration.setValue(FeatureLayerType.PROPERTY_NAME_FEATURE_COLLECTION_CLIP_GEOMETRY, clipGeometry); configuration.setValue(FeatureLayerType.PROPERTY_NAME_SLD_STYLE, selectedStyle); Layer featureLayer = type.createLayer(sceneView, configuration); featureLayer.setName(file.getName()); featureLayer.setVisible(true); return featureLayer; } finally { pm.done(); } }