Search in sources :

Example 1 with MetaData

use of com.ait.tooling.nativetools.client.collection.MetaData in project lienzo-core by ahome-it.

the class Layer method toJSONObject.

/**
 * Serializes this Layer as a {@link com.google.gwt.json.client.JSONObject}
 *
 * @return JSONObject
 */
@Override
public JSONObject toJSONObject() {
    final JSONObject object = new JSONObject();
    object.put("type", new JSONString(getNodeType().getValue()));
    if (hasMetaData()) {
        final MetaData meta = getMetaData();
        if (false == meta.isEmpty()) {
            object.put("meta", new JSONObject(meta.getJSO()));
        }
    }
    object.put("attributes", new JSONObject(getAttributes().getJSO()));
    final NFastArrayList<IPrimitive<?>> list = getChildNodes();
    final JSONArray children = new JSONArray();
    if (null != list) {
        final int size = list.size();
        for (int i = 0; i < size; i++) {
            final IPrimitive<?> prim = list.get(i);
            if (null != prim) {
                JSONObject make = prim.toJSONObject();
                if (null != make) {
                    children.set(children.size(), make);
                }
            }
        }
    }
    object.put("children", children);
    object.put("storage", getStorageEngine().toJSONObject());
    return object;
}
Also used : JSONObject(com.google.gwt.json.client.JSONObject) MetaData(com.ait.tooling.nativetools.client.collection.MetaData) JSONArray(com.google.gwt.json.client.JSONArray) JSONString(com.google.gwt.json.client.JSONString)

Example 2 with MetaData

use of com.ait.tooling.nativetools.client.collection.MetaData in project lienzo-core by ahome-it.

the class Scene method toJSONObject.

/**
 * Returns a {@link JSONObject} representation containing the object type, attributes and its respective children.
 *
 * @return JSONObject
 */
@Override
public final JSONObject toJSONObject() {
    final JSONObject object = new JSONObject();
    object.put("type", new JSONString(getNodeType().getValue()));
    if (hasMetaData()) {
        final MetaData meta = getMetaData();
        if (false == meta.isEmpty()) {
            object.put("meta", new JSONObject(meta.getJSO()));
        }
    }
    object.put("attributes", new JSONObject(getAttributes().getJSO()));
    final NFastArrayList<Layer> list = getChildNodes();
    final JSONArray children = new JSONArray();
    if (list != null) {
        final int size = list.size();
        for (int i = 0; i < size; i++) {
            final Layer layer = list.get(i);
            if (null != layer) {
                final JSONObject make = layer.toJSONObject();
                if (null != make) {
                    children.set(children.size(), make);
                }
            }
        }
    }
    object.put("children", children);
    object.put("storage", getStorageEngine().toJSONObject());
    return object;
}
Also used : JSONObject(com.google.gwt.json.client.JSONObject) MetaData(com.ait.tooling.nativetools.client.collection.MetaData) JSONArray(com.google.gwt.json.client.JSONArray) JSONString(com.google.gwt.json.client.JSONString)

Example 3 with MetaData

use of com.ait.tooling.nativetools.client.collection.MetaData in project lienzo-core by ahome-it.

the class Sprite method toJSONObject.

@Override
public JSONObject toJSONObject() {
    JSONObject attr = new JSONObject(getAttributes().getJSO());
    if (getSerializationMode() == ImageSerializationMode.DATA_URL) {
        String url = getURL();
        if (false == url.startsWith("data:")) {
            attr.put("url", new JSONString(ScratchPad.toDataURL(m_sprite)));
        }
    }
    JSONObject object = new JSONObject();
    object.put("type", new JSONString(getShapeType().getValue()));
    if (hasMetaData()) {
        final MetaData meta = getMetaData();
        if (false == meta.isEmpty()) {
            object.put("meta", new JSONObject(meta.getJSO()));
        }
    }
    object.put("attributes", attr);
    return object;
}
Also used : JSONObject(com.google.gwt.json.client.JSONObject) MetaData(com.ait.tooling.nativetools.client.collection.MetaData) JSONString(com.google.gwt.json.client.JSONString) JSONString(com.google.gwt.json.client.JSONString)

Example 4 with MetaData

use of com.ait.tooling.nativetools.client.collection.MetaData in project lienzo-core by ahome-it.

the class Viewport method toJSONObject.

/**
 * Returns a {@link JSONObject} representation of the {@link Viewport} with its {@link Attributes} as well as its children.
 *
 * @return {@link JSONObject}
 */
@Override
public final JSONObject toJSONObject() {
    final JSONObject object = new JSONObject();
    object.put("type", new JSONString(getNodeType().getValue()));
    if (hasMetaData()) {
        final MetaData meta = getMetaData();
        if (false == meta.isEmpty()) {
            object.put("meta", new JSONObject(meta.getJSO()));
        }
    }
    object.put("attributes", new JSONObject(getAttributes().getJSO()));
    final JSONArray children = new JSONArray();
    children.set(0, getScene().toJSONObject());
    object.put("children", children);
    object.put("storage", getStorageEngine().toJSONObject());
    return object;
}
Also used : JSONObject(com.google.gwt.json.client.JSONObject) MetaData(com.ait.tooling.nativetools.client.collection.MetaData) JSONArray(com.google.gwt.json.client.JSONArray) JSONString(com.google.gwt.json.client.JSONString)

Example 5 with MetaData

use of com.ait.tooling.nativetools.client.collection.MetaData in project lienzo-core by ahome-it.

the class Shape method toJSONObject.

/**
 * Serializes this shape as a {@link JSONObject}
 *
 * @return JSONObject
 */
@Override
public JSONObject toJSONObject() {
    final JSONObject object = new JSONObject();
    object.put("type", new JSONString(getShapeType().getValue()));
    if (hasMetaData()) {
        final MetaData meta = getMetaData();
        if (false == meta.isEmpty()) {
            object.put("meta", new JSONObject(meta.getJSO()));
        }
    }
    object.put("attributes", new JSONObject(getAttributes().getJSO()));
    return object;
}
Also used : JSONObject(com.google.gwt.json.client.JSONObject) MetaData(com.ait.tooling.nativetools.client.collection.MetaData) JSONString(com.google.gwt.json.client.JSONString)

Aggregations

MetaData (com.ait.tooling.nativetools.client.collection.MetaData)7 JSONObject (com.google.gwt.json.client.JSONObject)7 JSONString (com.google.gwt.json.client.JSONString)7 JSONArray (com.google.gwt.json.client.JSONArray)5 ImageDataFilterChain (com.ait.lienzo.client.core.image.filter.ImageDataFilterChain)1 DragConstraint (com.ait.lienzo.shared.core.types.DragConstraint)1