/** * Get the original value (if possible) or the regular value if the original value does not exist. * @param key the key to return * @return the value of the key */ public String getOriginalValue(final String key) { String value = get(Attributes.ORIGINAL_VALUE_MARKER + key); if (value != null) { return value; } return get(key); } }
public void setPost(@Nonnull final String post) { attributes.set("post", post); }
public ControlAttributes() { attributes = new Attributes(); }
@Nonnull public Attributes removeStandard() { Attributes attributes = new Attributes(controlAttributes); attributes.remove("id"); attributes.remove("height"); attributes.remove("width"); attributes.remove("x"); attributes.remove("y"); attributes.remove("align"); attributes.remove("valign"); attributes.remove("paddingLeft"); attributes.remove("paddingRight"); attributes.remove("paddingTop"); attributes.remove("paddingBottom"); attributes.remove("padding"); attributes.remove("marginLeft"); attributes.remove("marginRight"); attributes.remove("marginTop"); attributes.remove("marginBottom"); attributes.remove("margin"); attributes.remove("childClip"); attributes.remove("visible"); attributes.remove("visibleToMouse"); attributes.remove("childLayout"); attributes.remove("focusable"); attributes.remove("filename"); attributes.remove("filter"); attributes.remove("imageMode"); attributes.remove("inset"); attributes.remove("backgroundColor");
@SuppressWarnings("ConstantConditions") public void resolveParameters(@Nonnull final Attributes attributes) { List<Parameter> entrySet = getParameterSet(); for (Parameter entry : entrySet) { String key = entry.getKey(); String value = entry.getValue(); // first check the given attributes and then check our own if (attributes.isSet(key)) { set(value, controlParameter.applyParameter(entry.getOriginalValue(), entry.getKey(), attributes.get(key))); } else if (isSet(key) && !isParameterDefinition(get(key))) { set(value, get(key)); } else { remove(value); } } }
private void replaceAllIds( @Nonnull final ElementType type, @Nonnull final String oldId, @Nonnull final String newId) { final Collection<ElementType> children = type.getElements(); for (final ElementType child : children) { final String id = child.getAttributes().get("id"); if (id != null) { child.getAttributes().set("id", id.replace(oldId, newId)); } replaceAllIds(child, oldId, newId); } }
return; panelRenderer.setBackgroundColor(convert.color(attributes.get("backgroundColor"))); String backgroundImage = attributes.get("backgroundImage"); if (backgroundImage == null) { return; screen, backgroundImage, attributes.getAsBoolean("filter", Convert.DEFAULT_IMAGE_FILTER)); if (image == null) { return; String areaProviderProperty = ImageModeHelper.getAreaProviderProperty(attributes.getAttributes()); String renderStrategyProperty = ImageModeHelper.getRenderStrategyProperty(attributes.getAttributes()); ImageMode imageMode = convert.imageMode(areaProviderProperty, renderStrategyProperty);
@Nonnull final NiftyRenderEngine renderEngine) { BoxConstraints boxConstraints = layoutPart.getBoxConstraints(); boxConstraints.setHeight(convert.sizeValue(attributes.get("height"))); boxConstraints.setWidth(convert.sizeValue(attributes.get("width"))); boxConstraints.setX(convert.sizeValue(attributes.get("x"))); boxConstraints.setY(convert.sizeValue(attributes.get("y"))); boxConstraints.setHorizontalAlign(convert.horizontalAlign(attributes.get("align"))); boxConstraints.setVerticalAlign(convert.verticalAlign(attributes.get("valign"))); String paddingTop = Convert.DEFAULT_PADDING; String paddingBottom = Convert.DEFAULT_PADDING; if (attributes.isSet("padding")) { try { String padding = attributes.get("padding"); assert padding != null; // checked by isSet PaddingAttributeParser paddingParser = new PaddingAttributeParser(padding); boxConstraints.setPaddingLeft(convert.paddingSizeValue(attributes.get("paddingLeft"), paddingLeft)); boxConstraints.setPaddingRight(convert.paddingSizeValue(attributes.get("paddingRight"), paddingRight)); boxConstraints.setPaddingTop(convert.paddingSizeValue(attributes.get("paddingTop"), paddingTop)); boxConstraints.setPaddingBottom(convert.paddingSizeValue(attributes.get("paddingBottom"), paddingBottom)); String marginTop = Convert.DEFAULT_MARGIN; String marginBottom = Convert.DEFAULT_MARGIN; if (attributes.isSet("margin")) { try { String margin = attributes.get("margin"); assert margin != null; // checked by isSet PaddingAttributeParser marginParser = new PaddingAttributeParser(margin);
return; textRenderer.setFont(convert.font(renderEngine, attributes.get("font"))); textRenderer.setTextHAlign(convert.textHorizontalAlign(attributes.get("textHAlign"))); textRenderer.setTextVAlign(convert.textVerticalAlign(attributes.get("textVAlign"))); textRenderer.setColor(convert.color(attributes.get("color"), textRenderer.getColor())); textRenderer.setTextSelectionColor(convert.color(attributes.get("selectionColor"), textRenderer.getTextSelectionColor())); textRenderer.setText(attributes.getOriginalValue("text")); textRenderer.setTextLineHeight(convert.sizeValue(attributes.get("textLineHeight"))); textRenderer.setTextMinHeight(convert.sizeValue(attributes.get("textMinHeight"))); boolean wrap = attributes.getAsBoolean("wrap", false); textRenderer.setLineWrapping(wrap);
void resolveParameters(@Nonnull final Attributes parentAttributes) { getAttributes().resolveParameters(parentAttributes); Attributes newParent = new Attributes(parentAttributes); newParent.merge(getAttributes()); interact.resolveParameters(newParent); effects.resolveParameters(newParent); for (ElementType elementType : elements) { elementType.resolveParameters(newParent); } }
@Override public void activate( @Nonnull final Nifty nifty, @Nonnull final Element element, @Nonnull final EffectProperties parameter) { entries.clear(); for (Attributes entry : parameter.getEffectValues().getValues()) { SizeValue offset = new SizeValue(entry.get("offset")); Color color = entry.getAsColor("color"); if (color != null) { entries.add(new Entry(offset, color)); } } horizontal = "horizontal".equals(parameter.getProperty("direction", "vertical")); }
@Nonnull final Attributes effectsTypeAttributes, @Nonnull final List<Object> controllers) { Attributes effectAttributes = new Attributes(getAttributes()); effectAttributes.merge(effectsTypeAttributes); EffectProperties effectProperties = new EffectProperties(effectAttributes.createProperties()); applyEffectValues(effectProperties);
private boolean getInherit(@Nonnull final Attributes attributes) { return attributes.getAsBoolean("inherit", DEFAULT_INHERIT); }
public void bindControl( @Nonnull final Nifty nifty, @Nonnull final Screen screen, @Nonnull final Element element, @Nonnull final Attributes attributes) { controller.bind( nifty, screen, element, new Parameters(attributes.createProperties())); }
private int getHotspotY() { return getAttributes().getAsInteger("hotspotY", 0); } }
@Nonnull List<Parameter> getParameterSet() { return extractParameters(); }
@Nullable public LinearInterpolator toLinearInterpolator() { if (values.isEmpty()) { return null; } if (!containsTimeValues()) { return null; } LinearInterpolator interpolator = new LinearInterpolator(); for (Attributes p : values) { interpolator.addPoint(p.getAsFloat("time"), p.getAsFloat("value")); } return interpolator; }
private void replaceAllIds( @Nonnull final ElementType type, @Nonnull final String oldId, @Nonnull final String newId) { final Collection<ElementType> children = type.getElements(); for (final ElementType child : children) { final String id = child.getAttributes().get("id"); if (id != null) { child.getAttributes().set("id", id.replace(oldId, newId)); } replaceAllIds(child, oldId, newId); } }
String filename = attributes.get("filename"); if (filename == null) { return; screen, filename, attributes.getAsBoolean("filter", Convert.DEFAULT_IMAGE_FILTER)); if (image == null) { log.severe("Image for the filename \"" + filename + "\" couldn't be load."); image.setColor(convert.color(attributes.get("color"))); String areaProviderProperty = ImageModeHelper.getAreaProviderProperty(attributes.getAttributes()); String renderStrategyProperty = ImageModeHelper.getRenderStrategyProperty(attributes.getAttributes()); ImageMode imageMode = convert.imageMode(areaProviderProperty, renderStrategyProperty); imageRenderer.setImage(image); imageRenderer.setInset(convert.insetSizeValue(attributes.get("inset"), image.getHeight()));
private boolean getPost(@Nonnull final Attributes attributes) { return attributes.getAsBoolean("post", DEFAULT_POST); }