private MaskAction getMaskAction(Class<?> type) { for (MaskAction maskAction : maskActions) { if (type.getName().equals(maskAction.getValue(Action.ACTION_COMMAND_KEY))) { return maskAction; } } return null; }
MaskAction(MaskForm maskForm, String iconPath, String buttonName, String description) { this.maskForm = maskForm; putValue(ACTION_COMMAND_KEY, getClass().getName()); if (!iconPath.isEmpty()) { putValue(LARGE_ICON_KEY, loadIcon(iconPath)); } putValue(SHORT_DESCRIPTION, description); putValue("componentName", buttonName); }
@Override public final void updateState() { for (MaskAction maskAction : actions.getAllActions()) { maskAction.updateState(); } }
protected Mask createNewMask(Mask.ImageType type) { String maskName = getNewMaskName(getMaskForm().getProduct().getMaskGroup()); Dimension maskSize = getMaskForm().getTargetMaskSize(); Mask mask = new Mask(maskName, maskSize.width, maskSize.height, type); Preferences preferences = SnapApp.getDefault().getPreferences(); mask.setImageColor( StringUtils.parseColor(preferences.get("mask.color", StringUtils.formatColor(Mask.ImageType.DEFAULT_COLOR)))); mask.setImageTransparency(preferences.getDouble("mask.transparency", Mask.ImageType.DEFAULT_TRANSPARENCY)); return mask; }
final MaskAction[] allActions = actions.getAllActions(); for (int i = 0; i < allActions.length; i += 2) { buttonPanel.add(allActions[i].createComponent(), gbc); buttonPanel.add(allActions[i + 1].createComponent(), gbc); gbc.gridy++;
protected String[] collectNamesOfRastersOfSameSize() { final Product product = getMaskForm().getProduct(); //todo [multisize_products] do not compare raster sizes final RasterDataNode referenceRaster = getMaskForm().getRaster(); final List<String> rangeRasterNames = new ArrayList<>(); final Band[] bands = product.getBands(); for (Band band : bands) { if (band.getRasterHeight() == referenceRaster.getRasterHeight() && band.getRasterWidth() == referenceRaster.getRasterWidth()) { rangeRasterNames.add(band.getName()); } } final TiePointGrid[] tiePointGrids = product.getTiePointGrids(); for (TiePointGrid tiePointGrid : tiePointGrids) { if (tiePointGrid.getRasterHeight() == referenceRaster.getRasterHeight() && tiePointGrid.getRasterWidth() == referenceRaster.getRasterWidth()) { rangeRasterNames.add(tiePointGrid.getName()); } } return rangeRasterNames.toArray(new String[rangeRasterNames.size()]); } }
JComponent createComponent() { AbstractButton button = ToolButtonFactory.createButton(this, false); button.setName((String) getValue("componentName")); return button; }