Search in sources :

Example 1 with ImageDataFilterChain

use of com.ait.lienzo.client.core.image.filter.ImageDataFilterChain in project lienzo-core by ahome-it.

the class Picture method toJSONObject.

/**
 * Serializes this shape as a {@link JSONObject}
 *
 * @return JSONObject
 */
@Override
public JSONObject toJSONObject() {
    JSONObject attr = new JSONObject(getAttributes().getJSO());
    if (getImageSerializationMode() == ImageSerializationMode.DATA_URL) {
        String url = getImageProxy().getImageElementURL();
        if (null == url) {
            url = getAttributes().getURL();
        }
        if (url.startsWith("data:")) {
            attr.put("url", new JSONString(url));
        } else {
            attr.put("url", new JSONString(toDataURL(false)));
        }
    }
    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);
    ImageDataFilterChain chain = getImageProxy().getFilterChain();
    if ((null != chain) && (chain.size() > 0)) {
        JSONArray filters = new JSONArray();
        JSONObject filter = new JSONObject();
        filter.put("active", JSONBoolean.getInstance(chain.isActive()));
        for (ImageDataFilter<?> ifilter : chain.getFilters()) {
            if (null != ifilter) {
                JSONObject make = ifilter.toJSONObject();
                if (null != make) {
                    filters.set(filters.size(), make);
                }
            }
        }
        filter.put("filters", filters);
        object.put("filter", filter);
    }
    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) JSONString(com.google.gwt.json.client.JSONString) ImageDataFilterChain(com.ait.lienzo.client.core.image.filter.ImageDataFilterChain)

Example 2 with ImageDataFilterChain

use of com.ait.lienzo.client.core.image.filter.ImageDataFilterChain in project lienzo-core by ahome-it.

the class Movie method toJSONObject.

@Override
public JSONObject toJSONObject() {
    JSONObject object = super.toJSONObject();
    ImageDataFilterChain chain = m_filters;
    if ((null != chain) && (chain.size() > 0)) {
        JSONArray filters = new JSONArray();
        JSONObject filter = new JSONObject();
        filter.put("active", JSONBoolean.getInstance(chain.isActive()));
        for (ImageDataFilter<?> ifilter : chain.getFilters()) {
            if (null != ifilter) {
                JSONObject make = ifilter.toJSONObject();
                if (null != make) {
                    filters.set(filters.size(), make);
                }
            }
        }
        filter.put("filters", filters);
        object.put("filter", filter);
    }
    return object;
}
Also used : JSONObject(com.google.gwt.json.client.JSONObject) JSONArray(com.google.gwt.json.client.JSONArray) ImageDataFilterChain(com.ait.lienzo.client.core.image.filter.ImageDataFilterChain)

Aggregations

ImageDataFilterChain (com.ait.lienzo.client.core.image.filter.ImageDataFilterChain)2 JSONArray (com.google.gwt.json.client.JSONArray)2 JSONObject (com.google.gwt.json.client.JSONObject)2 MetaData (com.ait.tooling.nativetools.client.collection.MetaData)1 JSONString (com.google.gwt.json.client.JSONString)1