private String getWindowTitle(VectorDataNode vectorDataNode, SimpleFeature feature) { final String titleText; if (vectorDataNode != null) { if (feature != null) { titleText = titleBase + " - " + vectorDataNode.getName() + " - " + feature.getID(); } else { titleText = titleBase + " - " + vectorDataNode.getName(); } } else { titleText = titleBase; } return titleText; }
public static String getCorrelativeDataLabel(VectorDataNode pointDataSource, AttributeDescriptor dataField1) { final String vdsName = pointDataSource.getName(); final String dataFieldName = dataField1.getLocalName(); return vdsName + "/" + dataFieldName; } }
@Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); if (value != null) { this.setText(((VectorDataNode) value).getName()); } return this; } });
@Override public void visit(VectorDataNode dataNode) { visitedList.add(dataNode.getName()); }
public PlacemarkGroup getPlacemarkGroup() { if (placemarkGroup == null) { synchronized (this) { if (placemarkGroup == null) { placemarkGroup = new PlacemarkGroup(getProduct(), getName(), this); } } } return placemarkGroup; }
private void writeVectorData(File vectorDataDir, VectorDataNode vectorDataNode) { try { VectorDataNodeWriter vectorDataNodeWriter = new VectorDataNodeWriter(); vectorDataNodeWriter.write(vectorDataNode, new File(vectorDataDir, vectorDataNode.getName() + VectorDataNodeIO.FILENAME_EXTENSION)); } catch (IOException e) { BeamLogManager.getSystemLogger().throwing("DimapProductWriter", "writeVectorData", e); } }
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); }
public VectorDataLayer(LayerContext ctx, VectorDataNode vectorDataNode) { this(TYPE, vectorDataNode, TYPE.createLayerConfig(ctx)); getConfiguration().setValue(VectorDataLayerType.PROPERTY_NAME_VECTOR_DATA, vectorDataNode.getName()); }
public static VectorDataNode[] getVectorDataNodes(VectorDataNode vectorDataNode, boolean individualShapes, String attributeName) { VectorDataNode[] vectorDataNodes; if (individualShapes) { FeatureCollection<SimpleFeatureType, SimpleFeature> featureCollection = vectorDataNode.getFeatureCollection(); SimpleFeature[] features = featureCollection.toArray(new SimpleFeature[0]); vectorDataNodes = new VectorDataNode[features.length]; for (int i = 0; i < features.length; i++) { SimpleFeature feature = features[i]; String newName; if (attributeName != null && feature.getAttribute(attributeName) != null && !feature.getAttribute(attributeName).toString().isEmpty()) { newName = feature.getAttribute(attributeName).toString().replace(" ", "_").replace("-", "_"); } else { newName = vectorDataNode.getName() + "_" + (i + 1); } vectorDataNodes[i] = new VectorDataNode(newName, new ListFeatureCollection(vectorDataNode.getFeatureType(), Arrays.asList(feature))); } } else { vectorDataNodes = new VectorDataNode[]{vectorDataNode}; } return vectorDataNodes; } }
private String getInfoText(VectorDataNode vectorDataNode, SimpleFeature feature) { final String infoText; if (vectorDataNode != null) { infoText = String.format("<html>" + "Vector data node: <b>%s</b> with %d feature(s)<br>" + "Feature type: <b>%s (%s)</b><br>" + "Geometry attribute: <b>%s</b><br>" + "<br>" + "%s<br>" + "</html>", vectorDataNode.getName(), vectorDataNode.getFeatureCollection().size(), vectorDataNode.getFeatureType().getTypeName(), vectorDataNode.getPlacemarkDescriptor().getClass().getSimpleName(), vectorDataNode.getFeatureType().getGeometryDescriptor().getLocalName(), feature != null ? String.format("Selected feature <b>%s</b>:", feature.getID()) : "No feature selected."); infoLabel.setText(infoText); } else { infoText = NO_SELECTION_TEXT; // infoText = getSelectionDebugText(selectionContext, selectedValue); } return infoText; }
@Override public void add(int index, VectorDataNode vectorDataNode) { Assert.notNull(vectorDataNode, "node"); VectorDataNode permanentNode = getPermanentNode(vectorDataNode.getName()); if (permanentNode != null) { permanentNode.getFeatureCollection().addAll(vectorDataNode.getFeatureCollection()); return; } super.add(index, vectorDataNode); }
@Override public boolean add(VectorDataNode vectorDataNode) { Assert.notNull(vectorDataNode, "node"); VectorDataNode permanentNode = getPermanentNode(vectorDataNode.getName()); if (permanentNode != null) { permanentNode.getFeatureCollection().addAll(vectorDataNode.getFeatureCollection()); return false; } return super.add(vectorDataNode); }
@Override public void figureChanged(FigureChangeEvent event) { final Figure sourceFigure = event.getSourceFigure(); if (sourceFigure instanceof SimpleFeatureFigure) { SimpleFeatureFigure featureFigure = (SimpleFeatureFigure) sourceFigure; try { final VectorDataNode vectorDataNode = getVectorDataNode(); final SimpleFeature simpleFeature = featureFigure.getSimpleFeature(); Debug.trace("VectorDataLayer$FigureChangeHandler: vectorDataNode=" + vectorDataNode.getName() + ", featureType=" + simpleFeature.getFeatureType().getTypeName()); reactingAgainstFigureChange = true; vectorDataNode.fireFeaturesChanged(simpleFeature); // todo - compute changed modelRegion instead of passing null (nf) fireLayerDataChanged(null); } finally { reactingAgainstFigureChange = false; } } } }
private static VectorDataNode createVectorDataNode(FeatureStatisticsWriter featureStatisticsWriter, VectorDataNode originalVDN) { final SimpleFeatureType updatedFeatureType = featureStatisticsWriter.getUpdatedFeatureType(); final List<SimpleFeature> features = featureStatisticsWriter.getFeatures(); final ListFeatureCollection featureCollection = new ListFeatureCollection(updatedFeatureType, features); final PlacemarkDescriptor placemarkDescriptor = originalVDN.getPlacemarkDescriptor(); final VectorDataNode vectorDataNode = new VectorDataNode(originalVDN.getName(), featureCollection, placemarkDescriptor); vectorDataNode.setPermanent(originalVDN.isPermanent()); vectorDataNode.setModified(true); vectorDataNode.setDescription(originalVDN.getDescription()); return vectorDataNode; }
protected VectorDataLayer(VectorDataLayerType vectorDataLayerType, VectorDataNode vectorDataNode, PropertySet configuration) { super(vectorDataLayerType, configuration); setUniqueId(); this.vectorDataNode = vectorDataNode; setName(vectorDataNode.getName()); figureFactory = new SimpleFeatureFigureFactory(vectorDataNode.getFeatureType()); figureCollection = new DefaultFigureCollection(); updateFigureCollection(); vectorDataChangeHandler = new VectorDataChangeHandler(); vectorDataNode.getProduct().addProductNodeListener(vectorDataChangeHandler); figureCollection.addChangeListener(new FigureChangeHandler()); }
/** * Performs the actual "Export Mask Pixels" command. */ private void exportVectorDataNode() { final VisatApp app = VisatApp.getApp(); final ProductNode productNode = app.getSelectedProductNode(); final VectorDataNode vectorDataNode = (VectorDataNode) productNode; if (vectorDataNode.getFeatureCollection().isEmpty()) { app.showInfoDialog(DLG_TITLE, "The selected geometry is empty. Nothing to export.", null); return; } final File file = promptForFile(app, vectorDataNode.getName()); if (file == null) { return; } final SwingWorker<Exception, Object> swingWorker = new ExportVectorNodeSwingWorker(app, vectorDataNode, file); UIUtils.setRootFrameWaitCursor(VisatApp.getApp().getMainFrame()); VisatApp.getApp().setStatusBarMessage("Exporting Geometry..."); swingWorker.execute(); }
@Test public void testGetVectorDataNodes() throws Exception { SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder(); builder.setName("sft"); builder.add("CAPITAL", String.class); SimpleFeatureType featureType = builder.buildFeatureType(); VectorDataNode vectorDataNode = new VectorDataNode("originalName", featureType); SimpleFeatureBuilder simpleFeatureBuilder = new SimpleFeatureBuilder(featureType); simpleFeatureBuilder.set("CAPITAL", "Moscow"); vectorDataNode.getFeatureCollection().add(simpleFeatureBuilder.buildFeature("0")); simpleFeatureBuilder.set("CAPITAL", "Coruscant"); vectorDataNode.getFeatureCollection().add(simpleFeatureBuilder.buildFeature("1")); VectorDataNode[] vectorDataNodes = VectorDataNodeIO.getVectorDataNodes(vectorDataNode, true, "CAPITAL"); assertEquals(2, vectorDataNodes.length); assertEquals("Moscow", vectorDataNodes[0].getName()); assertEquals("Coruscant", vectorDataNodes[1].getName()); vectorDataNodes = VectorDataNodeIO.getVectorDataNodes(vectorDataNode, false, "CAPITAL"); assertEquals(1, vectorDataNodes.length); assertEquals("originalName", vectorDataNodes[0].getName()); }
private static void testVectorData(VectorDataNode vectorDataNode, String expectedName, SimpleFeatureType expectedType) { assertNotNull(vectorDataNode.getPlacemarkDescriptor()); assertEquals(expectedName, vectorDataNode.getName()); assertNotNull(vectorDataNode.getFeatureCollection()); assertSame(expectedType, vectorDataNode.getFeatureType()); assertSame(expectedType, vectorDataNode.getFeatureCollection().getSchema()); }
@Test public void testGetVectorDataNodesWithEmptyAttribute() throws Exception { SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder(); builder.setName("sft"); builder.add("CAPITAL", String.class); SimpleFeatureType featureType = builder.buildFeatureType(); VectorDataNode vectorDataNode = new VectorDataNode("originalName", featureType); SimpleFeatureBuilder simpleFeatureBuilder = new SimpleFeatureBuilder(featureType); simpleFeatureBuilder.set("CAPITAL", ""); vectorDataNode.getFeatureCollection().add(simpleFeatureBuilder.buildFeature("0")); simpleFeatureBuilder.set("CAPITAL", "Coruscant"); vectorDataNode.getFeatureCollection().add(simpleFeatureBuilder.buildFeature("1")); VectorDataNode[] vectorDataNodes = VectorDataNodeIO.getVectorDataNodes(vectorDataNode, true, "CAPITAL"); assertEquals(2, vectorDataNodes.length); assertEquals("originalName_1", vectorDataNodes[0].getName()); assertEquals("Coruscant", vectorDataNodes[1].getName()); }