/** * Sets the transparency value. The valid value range is <code>0.0F</code> to <code>1.0F</code>. * * @param transparency the transparency value * @throws IllegalArgumentException if the given transparency value is out of range. */ public void setTransparency(float transparency) { if (transparency < 0.0F || transparency > 1.0F) { throw new IllegalArgumentException("transparency must be >= 0 and <= 1"); } if (_transparency != transparency) { _transparency = transparency; fireProductNodeChanged(PROPERTY_NAME_TRANSPARENCY); setModified(true); } }
/** * Sets the boolean flag expression code of this <code>BitmaskDef</code> instance. Also sets the <code>term</code> * property if the given string representation of the expression can be compiled. * * @param expr the string representation of the expression * @throws IllegalArgumentException if the expression is invalid (and not parsable) */ public void setExpr(String expr) { if (!ObjectUtils.equalObjects(expr, _expr)) { _expr = (expr != null) ? expr : ""; fireProductNodeChanged(PROPERTY_NAME_EXPR); setModified(true); } }
/** * Replaces in the expression that this class contains * all occurences of the oldExternalName with the given newExternalName. * * @param oldExternalName * @param newExternalName */ @Override public void updateExpression(final String oldExternalName, final String newExternalName) { if (_expr == null) { return; } final String expression = StringUtils.replaceWord(_expr, oldExternalName, newExternalName); if (!_expr.equals(expression)) { _expr = expression; setModified(true); } super.updateExpression(oldExternalName, newExternalName); }
/** * Sets the color of this bitmask definition. A bitmask definition must allways have a color. If the given color is * <code>null</code> the default color is set to this bitmask definition. * * @param color the color to be set */ public void setColor(Color color) { if (!ObjectUtils.equalObjects(_color, color)) { if (color != null) { _color = color; } else { _color = _DEFAULT_COLOR; } fireProductNodeChanged(PROPERTY_NAME_COLOR); setModified(true); } }
public void testFail() { final BitmaskDef bitmaskDef = new BitmaskDef("name", "desc", "abc def ghi", Color.red, 0.5f); bitmaskDef.setModified(false); assertFalse(bitmaskDef.isModified()); assertEquals("abc def ghi", bitmaskDef.getExpr()); bitmaskDef.updateExpression("def", "BBBBBB"); assertEquals("abc BBBBBB ghi", bitmaskDef.getExpr()); assertTrue(bitmaskDef.isModified()); } }