public static Mask create(String name, String description, int width, int height, String expression, Color color, double transparency) { final Mask mask = new Mask(name, width, height, BandMathsType.INSTANCE); if (description != null) { mask.setDescription(description); } mask.setImageColor(color); mask.setImageTransparency(transparency); BandMathsType.setExpression(mask, expression); return mask; }
@Override public final Mask createObjectFromXml(Element element, Product product) { final String name = getChildAttributeValue(element, TAG_NAME, ATTRIB_VALUE); final int width = product.getSceneRasterWidth(); final int height = product.getSceneRasterHeight(); final Mask mask = new Mask(name, width, height, createImageType()); mask.setDescription(getChildAttributeValue(element, TAG_DESCRIPTION, ATTRIB_VALUE)); mask.setImageTransparency(Double.parseDouble(getChildAttributeValue(element, TAG_TRANSPARENCY, ATTRIB_VALUE))); final int r = Integer.parseInt(getChildAttributeValue(element, TAG_COLOR, ATTRIB_RED)); final int g = Integer.parseInt(getChildAttributeValue(element, TAG_COLOR, ATTRIB_GREEN)); final int b = Integer.parseInt(getChildAttributeValue(element, TAG_COLOR, ATTRIB_BLUE)); final int a = Integer.parseInt(getChildAttributeValue(element, TAG_COLOR, ATTRIB_ALPHA)); mask.setImageColor(new Color(r, g, b, a)); configureMask(mask, element); return mask; }
/** * Creates a new mask based on the geometries contained in a vector data node, * adds it to this product and returns it. * * @param maskName the new mask's name * @param vectorDataNode the vector data node * @param description the mask's description * @param color the display color * @param transparency the display transparency * * @return the new mask which has just been added * * @since BEAM 4.10 */ public Mask addMask(String maskName, VectorDataNode vectorDataNode, String description, Color color, double transparency) { final Mask mask = new Mask(maskName, getSceneRasterWidth(), getSceneRasterHeight(), Mask.VectorDataType.INSTANCE); Mask.VectorDataType.setVectorData(mask, vectorDataNode); mask.setDescription(description); mask.setImageColor(color); mask.setImageTransparency(transparency); getMaskGroup().add(mask); return mask; }
protected Mask createNewMask(Mask.ImageType type) { final Product product = maskForm.getProduct(); final ProductNodeGroup<Mask> productNodeGroup = product.getMaskGroup(); String maskName = getNewMaskName(productNodeGroup); final Mask mask = new Mask(maskName, product.getSceneRasterWidth(), product.getSceneRasterHeight(), type); final VisatApp visatApp = VisatApp.getApp(); if(visatApp != null) { final PropertyMap preferences = visatApp.getPreferences(); mask.setImageColor(preferences.getPropertyColor("mask.color", Mask.ImageType.DEFAULT_COLOR)); mask.setImageTransparency(preferences.getPropertyDouble("mask.transparency", Mask.ImageType.DEFAULT_TRANSPARENCY)); } return mask; }
if (colorAttribute != null && colorAttribute.getLength() >= 3 && colorAttribute.getLength() <= 4) { mask.setImageColor(createColor(colorAttribute));
@Test public void createXmlFromObject() { final Mask mask = new Mask("myRange", 10, 10, Mask.RangeType.INSTANCE); mask.setDescription("Carefully defined range"); mask.setImageColor(new Color(0, 255, 0, 128)); mask.setImageTransparency(0.78); final RangeTypeMaskPersistable maskPersistable = new RangeTypeMaskPersistable(); final Element element = maskPersistable.createXmlFromObject(mask); assertNotNull(element); assertEquals(TAG_MASK, element.getName()); assertEquals(Mask.RangeType.TYPE_NAME, getAttributeString(element, ATTRIB_TYPE)); final Element name = element.getChild(TAG_NAME); assertEquals("myRange", getAttributeString(name, ATTRIB_VALUE)); final Element description = element.getChild(TAG_DESCRIPTION); assertEquals("Carefully defined range", getAttributeString(description, ATTRIB_VALUE)); final Element color = element.getChild(TAG_COLOR); assertEquals(0, getAttributeInt(color, ATTRIB_RED)); assertEquals(255, getAttributeInt(color, ATTRIB_GREEN)); assertEquals(0, getAttributeInt(color, ATTRIB_BLUE)); assertEquals(128, getAttributeInt(color, ATTRIB_ALPHA)); final Element transparency = element.getChild(TAG_TRANSPARENCY); assertEquals(0.78, getAttributeDouble(transparency, ATTRIB_VALUE), 0.0); }
mask.setImageColor((Color) aValue); fireTableCellUpdated(rowIndex, columnIndex); } else if (column == IDX_TRANSPARENCY) {
final Mask mask = new Mask("myRange", 10, 10, Mask.RangeType.INSTANCE); mask.setDescription("Carefully defined range"); mask.setImageColor(new Color(0, 255, 0, 128)); mask.setImageTransparency(0.78); final PropertyContainer config = mask.getImageConfig();