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;
}
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;
}
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();
}
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));
}
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);
}
Aggregations