@Override public void actionPerformed(ActionEvent e) { final String[] rasterNames = collectNamesOfRastersOfSameSize(); final RangeEditorDialog.Model model = new RangeEditorDialog.Model(rasterNames); model.setMinValue(0.0); RasterDataNode referencedRaster = getMaskForm().getProduct().getRasterDataNode(model.getRasterName()); if (referencedRaster == null) { Dialogs.showError(String.format("Raster '%s' not found.", model.getRasterName())); return; Dimension expectedSize = getMaskForm().getTargetMaskSize(); if (expectedSize != null && !ProductUtils.areRastersEqualInSize(expectedSize.width, expectedSize.height, referencedRaster)) { return; Mask mask = createNewMask(Mask.RangeType.INSTANCE); String externalName = Tokenizer.createExternalName(model.getRasterName()); mask.setDescription(model.getMinValue() + " <= " + externalName + " <= " + model.getMaxValue()); mask.setDescription(mask.getDescription().replace(oldText, newText)); }); getMaskForm().addMask(mask);
MaskFormActions(ToolTopComponent maskTopComponent, MaskForm maskForm) { maskActions = new MaskAction[]{ new NewBandMathsAction(maskForm), new NewRangeAction(maskForm), new NewVectorDataNodeAction(maskForm), new NullAction(maskForm), new NewUnionAction(maskForm), new NewIntersectionAction(maskForm), new NewDifferenceAction(maskForm), new NewInvDifferenceAction(maskForm), new NewComplementAction(maskForm), new NullAction(maskForm), new CopyAction(maskForm), new EditAction(maskForm), new RemoveAction(maskForm), new TransferAction(maskForm), new ImportAction(maskTopComponent, maskForm), new ExportAction(maskTopComponent, maskForm), new ZoomToVectorMaskAction(maskTopComponent, maskForm), new NullAction(maskForm), }; }
@Override void updateState() { setEnabled(getMaskForm().isInManagementMode()); }