Search in sources :

Example 1 with Attribute

use of com.ait.lienzo.client.core.Attribute in project lienzo-core by ahome-it.

the class WiresLayoutContainer method remove.

@Override
public WiresLayoutContainer remove(final IPrimitive<?> child) {
    final ChildEntry entry = getChildEntry(child.getID());
    if (null != entry) {
        children.remove(entry);
        for (final Attribute attribute : child.getTransformingAttributes()) {
            final ObjectAttribute key = new ObjectAttribute(child, attribute);
            attrHandlerRegs.deregister(registrations.remove(key));
        }
    }
    group.remove(child);
    return this;
}
Also used : Attribute(com.ait.lienzo.client.core.Attribute)

Example 2 with Attribute

use of com.ait.lienzo.client.core.Attribute in project lienzo-core by ahome-it.

the class WiresLayoutContainer method add.

@Override
public WiresLayoutContainer add(final IPrimitive<?> child, final LayoutContainer.Layout layout) {
    if (null == child) {
        throw new NullPointerException("Child cannot be null.");
    }
    if (null == child.getID()) {
        child.setID(UUID.uuid());
    }
    addChild(child);
    if (null != layout) {
        final ChildEntry entry = new ChildEntry(child.getID(), layout);
        children.add(entry);
        for (final Attribute attribute : child.getTransformingAttributes()) {
            final HandlerRegistration reg = child.addAttributesChangedHandler(attribute, ShapeAttributesChangedHandler);
            registrations.put(new ObjectAttribute(child, attribute), reg);
            attrHandlerRegs.register(reg);
        }
        doPositionChild(child, true);
    }
    return this;
}
Also used : HandlerRegistration(com.google.gwt.event.shared.HandlerRegistration) Attribute(com.ait.lienzo.client.core.Attribute)

Example 3 with Attribute

use of com.ait.lienzo.client.core.Attribute in project lienzo-core by ahome-it.

the class JSONDeserializer method validateAttributes.

protected final void validateAttributes(final JSONObject json, final IFactory<?> factory, final String type, final ValidationContext ctx) throws ValidationException {
    final JSONValue aval = json.get("attributes");
    if (null == aval) {
        // OK - 'attributes' is optional
        return;
    }
    ctx.push("attributes");
    final JSONObject aobj = aval.isObject();
    if (aobj == null) {
        ctx.addBadTypeError("Object");
        return;
    } else {
        // Make sure all required attributes are defined (and not null)
        final Set<String> keys = aobj.keySet();
        for (final Attribute attr : factory.getRequiredAttributes()) {
            final String attrName = attr.getProperty();
            ctx.push(attrName);
            if (false == keys.contains(attrName)) {
                // value is missing
                ctx.addRequiredError();
            } else {
                final JSONValue jval = aobj.get(attrName);
                if (((jval == null) || (jval.isNull() != null))) {
                    // value is null
                    ctx.addRequiredError();
                }
            }
            // attrName
            ctx.pop();
        }
        for (final String attrName : keys) {
            ctx.push(attrName);
            final AttributeType atyp = factory.getAttributeType(attrName);
            if (atyp == null) {
                ctx.addInvalidAttributeError(type);
            } else {
                atyp.validate(aobj.get(attrName), ctx);
            }
            // attrName
            ctx.pop();
        }
    }
    // attributes
    ctx.pop();
}
Also used : JSONValue(com.google.gwt.json.client.JSONValue) JSONObject(com.google.gwt.json.client.JSONObject) Attribute(com.ait.lienzo.client.core.Attribute) AttributeType(com.ait.lienzo.client.core.AttributeType) JSONString(com.google.gwt.json.client.JSONString)

Example 4 with Attribute

use of com.ait.lienzo.client.core.Attribute in project lienzo-core by ahome-it.

the class AlignAndDistributeControlImpl method addHandlers.

public void addHandlers(final IDrawable<?> drawable, final ArrayList<Attribute> list) {
    for (final Attribute attribute : list) {
        m_attrHandlerRegs.register(drawable.addAttributesChangedHandler(attribute, ShapeAttributesChangedHandler));
    }
    m_attrHandlerRegs.register(drawable.addAttributesChangedHandler(Attribute.ROTATION, ShapeAttributesChangedHandler));
    m_attrHandlerRegs.register(drawable.addAttributesChangedHandler(Attribute.SCALE, ShapeAttributesChangedHandler));
    m_attrHandlerRegs.register(drawable.addAttributesChangedHandler(Attribute.SHEAR, ShapeAttributesChangedHandler));
}
Also used : Attribute(com.ait.lienzo.client.core.Attribute)

Example 5 with Attribute

use of com.ait.lienzo.client.core.Attribute in project lienzo-core by ahome-it.

the class AttributesChangedEvent method one.

public final boolean one(final List<Attribute> attributes) {
    int count = 0;
    final NFastStringSet seen = new NFastStringSet();
    for (final Attribute attribute : attributes) {
        final String name = attribute.getProperty();
        if (false == seen.contains(name)) {
            if (m_changed.contains(name)) {
                if (++count > 1) {
                    return false;
                }
                seen.add(name);
            }
        }
    }
    return (0 != count);
}
Also used : NFastStringSet(com.ait.tooling.nativetools.client.collection.NFastStringSet) Attribute(com.ait.lienzo.client.core.Attribute)

Aggregations

Attribute (com.ait.lienzo.client.core.Attribute)8 NFastStringSet (com.ait.tooling.nativetools.client.collection.NFastStringSet)4 AttributeType (com.ait.lienzo.client.core.AttributeType)1 HandlerRegistration (com.google.gwt.event.shared.HandlerRegistration)1 JSONObject (com.google.gwt.json.client.JSONObject)1 JSONString (com.google.gwt.json.client.JSONString)1 JSONValue (com.google.gwt.json.client.JSONValue)1