Example usage for com.google.gwt.core.client JavaScriptObject cast

List of usage examples for com.google.gwt.core.client JavaScriptObject cast

Introduction

In this page you can find the example usage for com.google.gwt.core.client JavaScriptObject cast.

Prototype

@Override
@SuppressWarnings("unchecked")
public <T extends JavascriptObjectEquivalent> T cast() 

Source Link

Document

A helper method to enable cross-casting from any JavaScriptObject type to any other JavaScriptObject type.

Usage

From source file:com.ait.tooling.nativetools.client.NArrayJSO.java

License:Open Source License

public static final NArrayJSO cast(final JavaScriptObject jso) {
    if (null != jso) {
        return jso.cast();
    }//from  w  w w . j av a 2s  . com
    return null;
}

From source file:com.ait.tooling.nativetools.client.NativeFunctionJSO.java

License:Open Source License

public static final NativeFunctionJSO make(final JavaScriptObject func) {
    if (NUtils.Native.isNativeFunction(func)) {
        return func.cast();
    }//w  w  w  .ja  v a2s.c o m
    return null;
}

From source file:com.ait.tooling.nativetools.client.NativeFunctionJSO.java

License:Open Source License

public final JavaScriptObject call(final JavaScriptObject args) {
    if (NUtils.Native.isArray(args)) {
        return call_0(this, args.cast());
    }// w ww  .  j  a  v  a  2 s .  co m
    final NArrayJSO list = NArrayJSO.make();

    list.push(args);

    return call_0(this, list);
}

From source file:com.ait.tooling.nativetools.client.NObject.java

License:Open Source License

public final <T extends JavaScriptObject> T getAsJSO(final String name) {
    final JavaScriptObject mjso = m_jso.getAsJSO(name);

    if (null != mjso) {
        return mjso.cast();
    }/*from   w w  w  .  ja  v  a 2s  . c o m*/
    return null;
}

From source file:com.ait.tooling.nativetools.client.NObjectJSO.java

License:Open Source License

public static final NObjectJSO cast(final JavaScriptObject jso) {
    if (null != jso) {
        return jso.cast();
    }//from   www  .  j  a va  2 s  .c om
    return null;
}

From source file:com.cgxlib.xq.client.js.JsCache.java

License:Apache License

public final void pushAll(JavaScriptObject prevElem) {
    checkNull();/*from w  w  w .j  ava  2  s. com*/
    JsCache c = prevElem.cast();
    for (int i = 0, ilen = c.length(); i < ilen; i++) {
        put(length(), c.get(i));
    }
}

From source file:com.cgxlib.xq.client.js.JsUtils.java

License:Apache License

/**
 * Returns a QueryString representation of a JavascriptObject.
 * <p/>// www  . j  ava  2  s  .c o m
 * TODO: jquery implementation accepts a second parameter (traditional)
 */
public static String param(JavaScriptObject js) {
    Properties prop = js.cast();
    String ret = "";
    for (String k : prop.keys()) {
        ret += ret.isEmpty() ? "" : "&";
        JsCache o = prop.getArray(k).cast();
        if (o != null) {
            for (int i = 0, l = o.length(); i < l; i++) {
                ret += i > 0 ? "&" : "";
                Properties p = o.<JsCache>cast().getJavaScriptObject(i);
                if (p != null) {
                    ret += k + "[]=" + p.toJsonString();
                } else {
                    ret += k + "[]=" + o.getString(i);
                }
            }
        } else {
            Properties p = prop.getJavaScriptObject(k);
            if (p != null) {
                ret += k + "=" + p.tostring();
            } else {
                String v = prop.getStr(k);
                if (v != null && !v.isEmpty() && !"null".equalsIgnoreCase(v)) {
                    ret += k + "=" + v;
                }
            }
        }
    }
    return ret;
}

From source file:com.emitrom.lienzo.client.core.shape.Node.java

License:Open Source License

/**
 * Constructor used by deserialization code.
 * //from w  w  w.j  ava  2s. com
 * @param type
 * @param node
 */
protected Node(NodeType type, JSONObject node) {
    m_type = type;

    if (null == node) {
        m_attr = Attributes.make();

        return;
    }
    JSONValue aval = node.get("attributes");

    if (null == aval) {
        m_attr = Attributes.make();

        return;
    }
    JSONObject aobj = aval.isObject();

    if (null == aobj) {
        m_attr = Attributes.make();

        return;
    }
    JavaScriptObject ajso = aobj.getJavaScriptObject();

    if (null == ajso) {
        m_attr = Attributes.make();

        return;
    }
    m_attr = ajso.cast();

    if (NativeInternalType.BOOLEAN != m_attr.typeOf(Attribute.VISIBLE)) {
        setVisible(true);
    }
    if (NativeInternalType.BOOLEAN != m_attr.typeOf(Attribute.LISTENING)) {
        setListening(true);
    }
}

From source file:com.emitrom.lienzo.client.core.shape.Shape.java

License:Open Source License

/**
 * Fills the Shape using the passed attributes.
 * This method will silently also fill the Shape to its unique rgb color if the context is a buffer.
 * /*from ww w  .j a  v a 2  s  .  c o m*/
 * @param context
 * @param attr
 */
protected void fill(Context2D context, Attributes attr, double alpha) {
    boolean filled = attr.isDefined(Attribute.FILL);

    if ((filled) || (attr.isFillShapeForSelection())) {
        if (context.isSelection()) {
            context.save();

            context.setGlobalAlpha(1);

            context.setFillColor(getColorKey());

            context.fill();

            context.restore();

            setWasFilledFlag(true);

            return;
        }
        if (false == filled) {
            return;
        }
        context.save();

        doApplyShadow(context, attr);

        context.setGlobalAlpha(alpha);

        String fill = attr.getFillColor();

        if (null != fill) {
            context.setFillColor(fill);

            context.fill();

            setWasFilledFlag(true);
        } else {
            JavaScriptObject grad = attr.getObject(Attribute.FILL.getProperty());

            if (null != grad) {
                GradientJSO base = grad.cast();

                if (LinearGradient.TYPE.equals(base.getType())) {
                    context.setFillGradient(new LinearGradient((LinearGradientJSO) base));

                    context.fill();

                    setWasFilledFlag(true);
                } else if (RadialGradient.TYPE.equals(base.getType())) {
                    context.setFillGradient(new RadialGradient((RadialGradientJSO) base));

                    context.fill();

                    setWasFilledFlag(true);
                } else if (PatternGradient.TYPE.equals(base.getType())) {
                    context.setFillGradient(new PatternGradient((PatternGradientJSO) base));

                    context.fill();

                    setWasFilledFlag(true);
                }
            }
        }
        context.restore();
    }
}

From source file:com.emitrom.lienzo.client.core.shape.Text.java

License:Open Source License

protected void fill(Context2D context, Attributes attr, double alpha) {
    boolean filled = attr.isDefined(Attribute.FILL);

    if ((filled) || (attr.isFillShapeForSelection())) {
        if (context.isSelection()) {
            context.save();//w w  w. j  a v a 2  s  . com

            context.setGlobalAlpha(1);

            Layer layer = getLayer();

            context.getJSO().fillTextWithGradient(getText(), 0, 0, 0, 0, layer.getWidth(), layer.getHeight(),
                    getColorKey());

            context.restore();

            setWasFilledFlag(true);

            return;
        }
        if (false == filled) {
            return;
        }
        context.save();

        doApplyShadow(context, attr);

        context.setGlobalAlpha(alpha);

        String fill = attr.getFillColor();

        if (null != fill) {
            context.setFillColor(fill);

            context.fillText(getText(), 0, 0);

            setWasFilledFlag(true);
        } else {
            JavaScriptObject grad = attr.getObject(Attribute.FILL.getProperty());

            if (null != grad) {
                GradientJSO base = grad.cast();

                if (LinearGradient.TYPE.equals(base.getType())) {
                    context.setFillGradient(new LinearGradient((LinearGradientJSO) base));

                    context.fillText(getText(), 0, 0);

                    setWasFilledFlag(true);
                } else if (RadialGradient.TYPE.equals(base.getType())) {
                    context.setFillGradient(new RadialGradient((RadialGradientJSO) base));

                    context.fillText(getText(), 0, 0);

                    setWasFilledFlag(true);
                } else if (PatternGradient.TYPE.equals(base.getType())) {
                    context.setFillGradient(new PatternGradient((PatternGradientJSO) base));

                    context.fillText(getText(), 0, 0);

                    setWasFilledFlag(true);
                }
            }
        }
        context.restore();
    }
}