@Override public void cancel(LayerSourcePageContext pageContext) { pageContext.setPropertyValue(PROPERTY_NAME_IMAGE_FILE_PATH, null); }
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 void itemStateChanged(ItemEvent e) { LayerSourcePageContext context = getContext(); context.setPropertyValue(ShapefileLayerSource.PROPERTY_NAME_SELECTED_STYLE, styleList.getSelectedItem()); context.updateState(); updateMap(); } }
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 public void insertUpdate(DocumentEvent e) { getContext().setPropertyValue(ImageFileLayerSource.PROPERTY_NAME_WORLD_FILE_PATH, worldFileField.getText()); getContext().updateState(); }
@Override public void removeUpdate(DocumentEvent e) { getContext().setPropertyValue(ImageFileLayerSource.PROPERTY_NAME_WORLD_FILE_PATH, worldFileField.getText()); getContext().updateState(); }
@Override public void changedUpdate(DocumentEvent e) { getContext().setPropertyValue(ImageFileLayerSource.PROPERTY_NAME_WORLD_FILE_PATH, worldFileField.getText()); getContext().updateState(); } }
@Override public void itemStateChanged(ItemEvent e) { getContext().setPropertyValue(WmsLayerSource.PROPERTY_NAME_SELECTED_STYLE, styleList.getSelectedItem()); getContext().updateState(); updatePreview(); } }
@Override public void actionPerformed(ActionEvent e) { String imageFilePath = (String) imageFileBox.getSelectedItem(); if (imageFilePath == null || !new File(imageFilePath).isFile()) { return; } ImagePreviewWorker worker = new ImagePreviewWorker(imageFilePath, imagePreviewLabel); worker.execute(); getContext().setPropertyValue(ImageFileLayerSource.PROPERTY_NAME_IMAGE_FILE_PATH, imageFilePath); String worldFilePath = createWorldFilePath(imageFilePath); if (new File(worldFilePath).isFile()) { worldFileField.setText(worldFilePath); } else { worldFileField.setText(null); } getContext().updateState(); }
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; }
@Override public boolean performFinish() { AffineTransform transform = createTransform(); final LayerSourcePageContext context = getContext(); context.setPropertyValue(ImageFileLayerSource.PROPERTY_NAME_WORLD_TRANSFORM, transform); return ImageFileLayerSource.insertImageLayer(context); }
bounds.getMaxX(), bounds.getMaxY()); context.setPropertyValue(WmsLayerSource.PROPERTY_NAME_CRS_ENVELOPE, crsEnvelope); List<StyleImpl> styles = selectedLayer.getStyles(); if (!styles.isEmpty()) { context.setPropertyValue(WmsLayerSource.PROPERTY_NAME_SELECTED_STYLE, styles.get(0)); } else { context.setPropertyValue(WmsLayerSource.PROPERTY_NAME_SELECTED_STYLE, null); context.setPropertyValue(WmsLayerSource.PROPERTY_NAME_SELECTED_LAYER, selectedLayer); infoLabel.setForeground(Color.DARK_GRAY); infoLabel.setText(getLatLonBoundingBoxText(selectedLayer.getLatLonBoundingBox()));
@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; }
private WebMapServer getWms(Window window, String wmsUrl) throws Exception { WebMapServer wms; try { window.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); URL url = new URL(wmsUrl); wms = new WebMapServer(url); getContext().setPropertyValue(WmsLayerSource.PROPERTY_NAME_WMS_URL, url); } finally { window.setCursor(Cursor.getDefaultCursor()); } return wms; }
final String oldPath = (String) context.getPropertyValue(ShapefileLayerSource.PROPERTY_NAME_FILE_PATH); if (!path.equals(oldPath)) { context.setPropertyValue(ShapefileLayerSource.PROPERTY_NAME_FILE_PATH, path); final URL fileUrl = new File(path).toURI().toURL(); final FeatureSource<SimpleFeatureType, SimpleFeature> featureSource = FeatureUtils.getFeatureSource(fileUrl); context.setPropertyValue(ShapefileLayerSource.PROPERTY_NAME_FEATURE_COLLECTION, featureSource.getFeatures()); context.setPropertyValue(ShapefileLayerSource.PROPERTY_NAME_SELECTED_STYLE, null); context.setPropertyValue(ShapefileLayerSource.PROPERTY_NAME_STYLES, null); context.setPropertyValue(ShapefileLayerSource.PROPERTY_NAME_FEATURE_COLLECTION_CRS, null); return new ShapefileAssistantPage2(); } else { context.setPropertyValue(ShapefileLayerSource.PROPERTY_NAME_FEATURE_COLLECTION_CRS, featureCrs); return new ShapefileAssistantPage3();
@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; } }
imagePreviewLabel.setPreferredSize(new Dimension(200, 200)); panel.add(imagePreviewLabel, gbc); getContext().setPropertyValue(ImageFileLayerSource.PROPERTY_NAME_IMAGE_FILE_PATH, null); getContext().setPropertyValue(ImageFileLayerSource.PROPERTY_NAME_WORLD_FILE_PATH, null); getContext().setPropertyValue(ImageFileLayerSource.PROPERTY_NAME_WORLD_TRANSFORM, null);
@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; }