/** * Returns an array of elements contained in this element. * * @return an array of elements contained in this product. If this element has no elements a zero-length-array is * returned. */ public MetadataElement[] getElements() { if (elements == null) { return new MetadataElement[0]; } return elements.toArray(new MetadataElement[0]); }
@Override public void updateExpression(final String oldExternalName, final String newExternalName) { if (takingOverNodeOwnership) { for (final ProductNode node : toArray()) { node.updateExpression(oldExternalName, newExternalName); } } }
/** * Returns an array of attributes contained in this element. * * @return an array of attributes contained in this product. If this element has no attributes a zero-length-array * is returned. */ public MetadataAttribute[] getAttributes() { if (attributes == null) { return new MetadataAttribute[0]; } return attributes.toArray(new MetadataAttribute[attributes.getNodeCount()]); }
/** * Returns an array of bands contained in this product * * @return an array of bands contained in this product. If this product has no bands a zero-length-array is * returned. */ public Band[] getBands() { return bandGroup.toArray(new Band[getNumBands()]); }
/** * Removes all nodes from this group. */ public void removeAll() { final ProductNode[] nodes = toArray(); for (ProductNode node : nodes) { remove((T) node); } }
@Override public void acceptVisitor(ProductVisitor visitor) { if (takingOverNodeOwnership) { for (final ProductNode node : toArray()) { node.acceptVisitor(visitor); } } visitor.visit(this); }
protected void writeFlagCoding(int indent) { SampleCoding[] a = product.getFlagCodingGroup().toArray(new FlagCoding[0]); writeSampleCodings(indent, a, DimapProductConstants.TAG_FLAG_CODING, DimapProductConstants.TAG_FLAG, DimapProductConstants.TAG_FLAG_NAME, DimapProductConstants.TAG_FLAG_INDEX, DimapProductConstants.TAG_FLAG_DESCRIPTION); }
protected void writeIndexCoding(int indent) { SampleCoding[] a = product.getIndexCodingGroup().toArray(new IndexCoding[0]); writeSampleCodings(indent, a, DimapProductConstants.TAG_INDEX_CODING, DimapProductConstants.TAG_INDEX, DimapProductConstants.TAG_INDEX_NAME, DimapProductConstants.TAG_INDEX_VALUE, DimapProductConstants.TAG_INDEX_DESCRIPTION); }
@Override public PlacemarkGroup getPlacemarkGroup(Product product) { final VectorDataNode[] nodes = product.getVectorDataGroup().toArray(new VectorDataNode[0]); for (VectorDataNode node : nodes) { if (node.getPlacemarkDescriptor() == this) { return node.getPlacemarkGroup(); } } return null; }
@Override protected void computeRect(PlanarImage[] sourceImages, WritableRaster tile, Rectangle destRect) { final BufferedImage image = new BufferedImage(colorModel, RasterFactory.createWritableRaster(tile.getSampleModel(), tile.getDataBuffer(), new Point(0, 0)), false, null); final Graphics2D graphics2D = image.createGraphics(); graphics2D.translate(-tile.getMinX(), -tile.getMinY()); graphics2D.setColor(Color.WHITE); ProductNodeGroup<Placemark> placemarkGroup = getPlacemarkGroup(); Placemark[] placemarks = placemarkGroup.toArray(new Placemark[placemarkGroup.getNodeCount()]); for (Placemark placemark : placemarks) { final PixelPos pixelPos = placemark.getPixelPos(); if (pixelPos != null) { final int x = (int) pixelPos.x - placemarkSize / 2; final int y = (int) pixelPos.y - placemarkSize / 2; graphics2D.fillRect(x, y, placemarkSize, placemarkSize); } } graphics2D.dispose(); final byte[] data = ((DataBufferByte) tile.getDataBuffer()).getData(); for (int i = 0; i < data.length; i++) { data[i] = (data[i] != 0) ? TRUE : FALSE; } }
@Override public long getRawStorageSize(ProductSubsetDef subsetDef) { long size = 0; ProductNode[] nodes = toArray(); for (ProductNode node : nodes) { if (subsetDef.isNodeAccepted(node.getName())) { size += node.getRawStorageSize(subsetDef); } } return size; }
private Mask getMask(VectorDataNode sourceNode) { final Mask[] masks = maskGroup.toArray(new Mask[maskGroup.getNodeCount()]); for (final Mask mask : masks) { if (mask.getImageType() == Mask.VectorDataType.INSTANCE) { if (Mask.VectorDataType.getVectorData(mask) == sourceNode) { return mask; } } } return null; }
@Override public void setModified(boolean modified) { boolean oldState = isModified(); if (oldState != modified) { if (!modified) { for (ProductNode node : toArray()) { node.setModified(false); } clearRemovedList(); } super.setModified(modified); } }
private static List<RasterDataNode> getReferencedMasks(final RasterDataNode node) { final Product product = node.getProduct(); final List<RasterDataNode> rasterList = new ArrayList<RasterDataNode>(); if (product != null) { final ProductNodeGroup<Mask> maskGroup = product.getMaskGroup(); final Mask[] masks = maskGroup.toArray(new Mask[maskGroup.getNodeCount()]); for (final Mask mask : masks) { final String expression; if (mask.getImageType() == Mask.BandMathsType.INSTANCE) { expression = Mask.BandMathsType.getExpression(mask); } else if (mask.getImageType() == Mask.RangeType.INSTANCE) { expression = Mask.RangeType.getRasterName(mask); } else { expression = null; } if (isNodeReferencedByExpression(node, expression)) { rasterList.add(mask); } } } return rasterList; }
private synchronized Layer createVectorDataCollectionLayer() { final LayerType collectionLayerType = LayerTypeRegistry.getLayerType(VectorDataCollectionLayerType.class); final Layer collectionLayer = collectionLayerType.createLayer(this, collectionLayerType.createLayerConfig(this)); final ProductNodeGroup<VectorDataNode> vectorDataGroup = getRaster().getProduct().getVectorDataGroup(); final VectorDataNode[] vectorDataNodes = vectorDataGroup.toArray(new VectorDataNode[vectorDataGroup.getNodeCount()]); for (final VectorDataNode vectorDataNode : vectorDataNodes) { final Layer layer = VectorDataLayerType.createLayer(this, vectorDataNode); collectionLayer.getChildren().add(layer); } return collectionLayer; }
private void writeGcpGeoCoding(GcpGeoCoding gcpGeoCoding, String nodeType) { addEmptyRow(); addRow("The " + nodeType + " uses a geo-coding which is based on ground control points (GCPs)."); addEmptyRow(); ProductNodeGroup<Placemark> gcpGroup = getProduct().getGcpGroup(); addRow("Number Of GCPs", String.valueOf(gcpGroup.getNodeCount())); addRow("Function", String.valueOf(gcpGeoCoding.getMethod())); addRow("Datum", String.valueOf(gcpGeoCoding.getDatum().getName())); addRow("Latitude RMSE", String.valueOf(gcpGeoCoding.getRmseLat())); addRow("Longitude RMSE", String.valueOf(gcpGeoCoding.getRmseLon())); addEmptyRow(); addRow("Table of used GCPs"); Placemark[] gcps = gcpGroup.toArray(new Placemark[0]); addRow("Number", "Label", "X", "Y", "Latitude", "Longitude"); for (int i = 0; i < gcps.length; i++) { Placemark gcp = gcps[i]; PixelPos pixelPos = gcp.getPixelPos(); GeoPos geoPos = gcp.getGeoPos(); addRow(String.valueOf(i), gcp.getLabel(), String.valueOf(pixelPos.getX()), String.valueOf(pixelPos.getY()), geoPos.getLatString(), geoPos.getLonString()); } setFirstColumnWidth(40); }
Placemark[] getDisplayedPins() { if (isShowingSpectraForSelectedPins() && getCurrentView() != null) { return getCurrentView().getSelectedPins(); } else if (isShowingSpectraForAllPins() && getCurrentProduct() != null) { ProductNodeGroup<Placemark> pinGroup = getCurrentProduct().getPinGroup(); return pinGroup.toArray(new Placemark[pinGroup.getNodeCount()]); } else { return new Placemark[0]; } }
private void updateRoiMasks() { final Property property = bindingContext.getPropertySet().getProperty(PROPERTY_NAME_ROI_MASK); if (product != null) { property.getDescriptor().setValueSet(new ValueSet(product.getMaskGroup().toArray())); } else { property.getDescriptor().setValueSet(new ValueSet(new Mask[0])); } useRoiEnablement.apply(); roiMaskEnablement.apply(); }
protected void writeMasks(int indent) { final Mask[] masks = product.getMaskGroup().toArray(new Mask[product.getMaskGroup().getNodeCount()]); int persistableMaskCount = 0; for (final Mask mask : masks) { final DimapPersistable persistable = DimapPersistence.getPersistable(mask); if (persistable != null) { persistableMaskCount++; } } if (persistableMaskCount > 0) { final String[] bdTags = createTags(indent, DimapProductConstants.TAG_MASKS); println(bdTags[0]); for (final Mask mask : masks) { final DimapPersistable persistable = DimapPersistence.getPersistable(mask); if (persistable != null) { final Element element = persistable.createXmlFromObject(mask); printElement(indent + 1, element); } } println(bdTags[1]); } }
private void copyMasks(Product sourceProduct, boolean rename, String pattern) { ProductNodeGroup<Mask> maskGroup = sourceProduct.getMaskGroup(); final Mask[] masks = maskGroup.toArray(new Mask[maskGroup.getNodeCount()]); for (Mask mask : masks) { Mask.ImageType imageType = mask.getImageType(); final Mask newmask = new Mask(mask.getName(), targetProduct.getSceneRasterWidth(), targetProduct.getSceneRasterHeight(), imageType); newmask.setDescription(mask.getDescription()); for (Property property : mask.getImageConfig().getProperties()) { newmask.getImageConfig().setValue(property.getDescriptor().getName(), property.getValue()); } if (rename) { newmask.setName(pattern.replace(SOURCE_NAME_REFERENCE, mask.getName())); for (final Band targetBand : targetProduct.getBands()) { RasterDataNode srcRDN = sourceRasterMap.get(targetBand); if (srcRDN != null) { newmask.updateExpression( BandArithmetic.createExternalName(srcRDN.getName()), BandArithmetic.createExternalName(targetBand.getName())); } } } targetProduct.getMaskGroup().add(newmask); } }