private void makeMaskVisible(Mask mask) { if (visibleBand != null) { visibleBand.getOverlayMaskGroup().add(mask); } }
private boolean _add(Placemark placemark) { synchronized (placemarkMap) { final boolean added = super.add(placemark); if (added) { placemarkMap.put(placemark.getFeature(), placemark); } return added; } }
private static void addMasksToGroup(ProductNodeGroup<Mask> maskGroup, ProductNodeGroup<Mask> usageMaskGroup, String[] maskNames) { if (maskNames == null) { return; } for (String name : maskNames) { Mask mask = maskGroup.get(name); if (mask != null) { usageMaskGroup.add(mask); } } }
private void addMaskToProductIfPossible(Mask mask, Product product) throws Exception { if (mask.getImageType().canTransferMask(mask, product)) { product.getMaskGroup().add(mask); } else { throw new Exception(String.format("Cannot add mask '%s' to selected product.", mask.getName())); } } }
private static void addMask(Product mod35Product, ProductNodeGroup<Mask> maskGroup, String bandName, String flagName, String description, Color color, float transparency) { int width = mod35Product.getSceneRasterWidth(); int height = mod35Product.getSceneRasterHeight(); String maskPrefix = ""; Mask mask = Mask.BandMathsType.create(maskPrefix + flagName, description, width, height, bandName + "." + flagName, color, transparency); maskGroup.add(mask); }
/** * Adds the given tie-point grid to this product. * * @param tiePointGrid the tie-point grid to added, ignored if <code>null</code> */ public void addTiePointGrid(final TiePointGrid tiePointGrid) { if (containsRasterDataNode(tiePointGrid.getName())) { throw new IllegalArgumentException("The Product '" + getName() + "' already contains " + "a tie-point grid with the name '" + tiePointGrid.getName() + "'."); } tiePointGridGroup.add(tiePointGrid); }
public void addMask(Mask mask, int index) { getProduct().getMaskGroup().add(index, mask); makeMaskVisible(mask); fireTableDataChanged(); }
private synchronized PlacemarkGroup createPinGroup() { final VectorDataNode vectorDataNode = new VectorDataNode(PIN_GROUP_NAME, Placemark.createPinFeatureType()); vectorDataNode.setDefaultStyleCss( "symbol:pin; fill:#0000ff; fill-opacity:0.7; stroke:#ffffff; stroke-opacity:1.0; stroke-width:0.5"); vectorDataNode.setPermanent(true); this.vectorDataGroup.add(vectorDataNode); return vectorDataNode.getPlacemarkGroup(); }
private synchronized PlacemarkGroup createGcpGroup() { final VectorDataNode vectorDataNode = new VectorDataNode(GCP_GROUP_NAME, Placemark.createGcpFeatureType()); vectorDataNode.setDefaultStyleCss("symbol:plus; stroke:#ff8800; stroke-opacity:0.8; stroke-width:1.0"); vectorDataNode.setPermanent(true); this.vectorDataGroup.add(vectorDataNode); return vectorDataNode.getPlacemarkGroup(); }
private static void addFlagCoding(Product product, FlagCoding flagCoding, String flagCodingName) { final FlagCoding targetFlagCoding = new FlagCoding(flagCodingName); targetFlagCoding.setDescription(flagCoding.getDescription()); ProductUtils.copyMetadata(flagCoding, targetFlagCoding); product.getFlagCodingGroup().add(targetFlagCoding); }
private static void addFlagCoding(Product product) { final FlagCoding flagCoding = new FlagCoding("Flags"); flagCoding.addFlag("land", 1, "Land Flag"); flagCoding.addFlag("bright", 2, "Bright Flag"); product.getFlagCodingGroup().add(flagCoding); }
private static void addIndexCoding(Product product) { final IndexCoding indexCoding = new IndexCoding("Indexes"); indexCoding.addIndex("land", 12, "Land Index"); indexCoding.addIndex("bright", 13, "Bright Index"); product.getIndexCodingGroup().add(indexCoding); }
protected void addFlagCodingsToProduct(Product product) { final ProductNodeGroup<FlagCoding> flagCodingGroup = getSourceProduct().getFlagCodingGroup(); for (int i = 0; i < flagCodingGroup.getNodeCount(); i++) { FlagCoding sourceFlagCoding = flagCodingGroup.get(i); FlagCoding destFlagCoding = new FlagCoding(sourceFlagCoding.getName()); destFlagCoding.setDescription(sourceFlagCoding.getDescription()); cloneFlags(sourceFlagCoding, destFlagCoding); product.getFlagCodingGroup().add(destFlagCoding); } }
private void addTiePointGrids(Product product) { final int sceneRasterWidth = product.getSceneRasterWidth(); final int sceneRasterHeight = product.getSceneRasterHeight(); final TiePointGrid tiePointGrid = createTiePointGrid("tpg1", sceneRasterWidth, sceneRasterHeight, 21.1f, 14.2f, 16.3f, 32.004f, false); product.addTiePointGrid(tiePointGrid); tiePointGrid.getOverlayMaskGroup().add(product.getMaskGroup().get("name2")); tiePointGrid.getOverlayMaskGroup().add(product.getMaskGroup().get("name3")); product.addTiePointGrid( createTiePointGrid("tpg2", sceneRasterWidth, sceneRasterHeight, 21.1f, 14.2f, 16.3f, 32.004f, true)); }
@Before public void setup() { product = new Product("P", "T", 11, 11); pyramids = new VectorDataNode("pyramids", Placemark.createGeometryFeatureType()); product.getVectorDataGroup().add(pyramids); image = new VectorDataMultiLevelImage(VectorDataMultiLevelImage.createMaskMultiLevelSource(pyramids), pyramids); }
@Test public void testMaskIsAddedWhenFeatureIsAddedForTheFirstTime() throws Exception { final Product p = new Product("P", "T", 1, 1); final SimpleFeatureType featureType = new GeometryDescriptor().getBaseFeatureType(); final VectorDataNode node = new VectorDataNode("V", featureType); p.getVectorDataGroup().add(node); node.getFeatureCollection().add(new SimpleFeatureBuilder(featureType).buildFeature("id")); assertEquals(1, p.getMaskGroup().getNodeCount()); assertNotNull(p.getMaskGroup().get("V")); }
@Test public void testMaskIsRemovedWhenVdnIsRemoved() throws Exception { final Product p = new Product("P", "T", 1, 1); final SimpleFeatureType featureType = new GeometryDescriptor().getBaseFeatureType(); final VectorDataNode node = new VectorDataNode("V", featureType); p.getVectorDataGroup().add(node); node.getFeatureCollection().add(new SimpleFeatureBuilder(featureType).buildFeature("id1")); assertEquals(1, p.getMaskGroup().getNodeCount()); p.getVectorDataGroup().remove(node); assertEquals(0, p.getMaskGroup().getNodeCount()); } }
@Test public void testMaskIsNotAddedWhenFeatureIsAddedForTheSecondTime() throws Exception { final Product p = new Product("P", "T", 1, 1); final SimpleFeatureType featureType = new GeometryDescriptor().getBaseFeatureType(); final VectorDataNode node = new VectorDataNode("V", featureType); p.getVectorDataGroup().add(node); node.getFeatureCollection().add(new SimpleFeatureBuilder(featureType).buildFeature("id1")); node.getFeatureCollection().add(new SimpleFeatureBuilder(featureType).buildFeature("id2")); assertEquals(1, p.getMaskGroup().getNodeCount()); assertNotNull(p.getMaskGroup().get("V")); }
public void testNodeChangeIsObservable() { final Product p = new Product("p", "t", 10, 10); final ProductNodeGroup<Placemark> pinGroup = p.getPinGroup(); final Placemark placemark = Placemark.createPointPlacemark(PinDescriptor.getInstance(), "p1", "l1", "", new PixelPos(0, 0), null, null); pinGroup.add(placemark); final PNL listener = new PNL(Placemark.class); p.addProductNodeListener(listener); placemark.setLabel("new label"); assertEquals(true, p.isModified()); assertEquals("c:p1.label;", listener.trace); }
private Product createProduct(FlagCoding fc, int i) { Product p3 = new Product("p" + i, "t" + i, 16, 16); p3.setRefNo(i); p3.getFlagCodingGroup().add(fc); p3.addBand("f", ProductData.TYPE_UINT8).setSampleCoding(fc); p3.addBand("q", ProductData.TYPE_UINT32); p3.addBand("l", ProductData.TYPE_UINT32).setValidPixelExpression("f.LAND && !f.INVALID"); p3.addBand("w", ProductData.TYPE_UINT32).setValidPixelExpression("f.WATER && !f.INVALID"); p3.addBand("c", ProductData.TYPE_UINT32).setValidPixelExpression("f.CLOUD && !f.INVALID"); return p3; }