Example usage for com.google.gwt.core.client JsonUtils safeEval

List of usage examples for com.google.gwt.core.client JsonUtils safeEval

Introduction

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

Prototype

public static native <T extends JavaScriptObject> T safeEval(String json) ;

Source Link

Document

Evaluates a JSON expression safely.

Usage

From source file:org.bonitasoft.web.toolkit.client.data.model.OverlayFactory.java

License:Open Source License

public static JsArray<OverlayImpl> createArray(String json) {
    return JsonUtils.safeEval(json);
}

From source file:org.cleanlogic.cesiumjs4gwt.showcase.examples.Materials.java

License:Apache License

public void applyImageMaterial(Primitive primitive) {
    JSONObject uniforms = new JSONObject();
    uniforms.put("image", new JSONString(GWT.getModuleBaseURL() + "images/Cesium_Logo_Color.jpg"));

    JSONObject fabric = new JSONObject();
    fabric.put("type", new JSONString("Image"));
    fabric.put("uniforms", uniforms);

    MaterialOptions materialOptions = new MaterialOptions();
    materialOptions.fabric = JsonUtils.safeEval(fabric.toString());
    primitive.appearance.material = new Material(materialOptions);
}

From source file:org.cleanlogic.cesiumjs4gwt.showcase.examples.Materials.java

License:Apache License

public void applyAlphaMapMaterial(Primitive primitive) {
    JSONObject uniforms = new JSONObject();
    uniforms.put("image", new JSONString(GWT.getModuleBaseURL() + "images/Cesium_Logo_Color.jpg"));
    uniforms.put("channel", new JSONString("r"));

    JSONObject alphaMaterial = new JSONObject();
    alphaMaterial.put("type", new JSONString("AlphaMap"));
    alphaMaterial.put("uniforms", uniforms);

    JSONObject materials = new JSONObject();
    materials.put("alphaMaterial", alphaMaterial);

    JSONObject components = new JSONObject();
    components.put("diffuse", new JSONString("vec3(1.0)"));
    components.put("alpha", new JSONString("alphaMaterial.alpha"));

    JSONObject fabric = new JSONObject();
    fabric.put("materials", materials);
    fabric.put("components", components);

    MaterialOptions materialOptions = new MaterialOptions();
    materialOptions.fabric = JsonUtils.safeEval(fabric.toString());
    primitive.appearance.material = new Material(materialOptions);
}

From source file:org.cleanlogic.cesiumjs4gwt.showcase.examples.Materials.java

License:Apache License

public void applyBumpMapMaterial(Primitive primitive) {
    JSONObject uniforms = new JSONObject();
    uniforms.put("image", new JSONString(GWT.getModuleBaseURL() + "images/bumpmap.png"));

    JSONObject diffuseMaterial = new JSONObject();
    diffuseMaterial.put("type", new JSONString("DiffuseMap"));
    diffuseMaterial.put("uniforms", uniforms);

    uniforms = new JSONObject();
    uniforms.put("image", new JSONString(GWT.getModuleBaseURL() + "images/bumpmap.png"));
    uniforms.put("strength", new JSONNumber(0.8));

    JSONObject bumpMaterial = new JSONObject();
    bumpMaterial.put("type", new JSONString("BumpMap"));
    bumpMaterial.put("uniforms", uniforms);

    JSONObject materials = new JSONObject();
    materials.put("diffuseMaterial", diffuseMaterial);
    materials.put("bumpMaterial", bumpMaterial);

    JSONObject components = new JSONObject();
    components.put("diffuse", new JSONString("diffuseMaterial.diffuse"));
    components.put("specular", new JSONNumber(0.01));
    components.put("normal", new JSONString("bumpMaterial.normal"));

    JSONObject fabric = new JSONObject();
    fabric.put("materials", materials);
    fabric.put("components", components);

    MaterialOptions materialOptions = new MaterialOptions();
    materialOptions.fabric = JsonUtils.safeEval(fabric.toString());
    primitive.appearance.material = new Material(materialOptions);
}

From source file:org.cleanlogic.cesiumjs4gwt.showcase.examples.Materials.java

License:Apache License

public void applyDiffuseMaterial(Primitive primitive) {
    JSONObject uniforms = new JSONObject();
    uniforms.put("image", new JSONString(GWT.getModuleBaseURL() + "images/Cesium_Logo_Color.jpg"));

    JSONObject fabric = new JSONObject();
    fabric.put("type", new JSONString("DiffuseMap"));
    fabric.put("uniforms", uniforms);

    MaterialOptions materialOptions = new MaterialOptions();
    materialOptions.fabric = JsonUtils.safeEval(fabric.toString());
    primitive.appearance.material = new Material(materialOptions);
}

From source file:org.cleanlogic.cesiumjs4gwt.showcase.examples.Materials.java

License:Apache License

public void applyEmissionMapMaterial(Primitive primitive) {
    JSONObject uniforms = new JSONObject();
    uniforms.put("image", new JSONString(GWT.getModuleBaseURL() + "images/Cesium_Logo_Color.jpg"));

    JSONObject diffuseMaterial = new JSONObject();
    diffuseMaterial.put("type", new JSONString("DiffuseMap"));
    diffuseMaterial.put("uniforms", uniforms);

    JSONObject repeat = new JSONObject();
    repeat.put("x", new JSONNumber(1));
    repeat.put("y", new JSONNumber(0.5));

    uniforms = new JSONObject();
    uniforms.put("image", new JSONString(GWT.getModuleBaseURL() + "images/checkerboard.png"));
    uniforms.put("repeat", repeat);

    JSONObject emissionMaterial = new JSONObject();
    emissionMaterial.put("type", new JSONString("EmissionMap"));
    emissionMaterial.put("uniforms", uniforms);

    JSONObject materials = new JSONObject();
    materials.put("diffuseMaterial", diffuseMaterial);
    materials.put("emissionMaterial", emissionMaterial);

    JSONObject components = new JSONObject();
    components.put("diffuse", new JSONString("diffuseMaterial.diffuse"));
    components.put("emission", new JSONString("emissionMaterial.emission * 0.2"));

    JSONObject fabric = new JSONObject();
    fabric.put("materials", materials);
    fabric.put("components", components);

    MaterialOptions materialOptions = new MaterialOptions();
    materialOptions.fabric = JsonUtils.safeEval(fabric.toString());
    primitive.appearance.material = new Material(materialOptions);
}

From source file:org.cleanlogic.cesiumjs4gwt.showcase.examples.Materials.java

License:Apache License

public void applyNormalMapMaterial(Primitive primitive) {
    JSONObject uniforms = new JSONObject();
    uniforms.put("image", new JSONString(GWT.getModuleBaseURL() + "images/bumpmap.png"));

    JSONObject diffuseMaterial = new JSONObject();
    diffuseMaterial.put("type", new JSONString("DiffuseMap"));
    diffuseMaterial.put("uniforms", uniforms);

    uniforms = new JSONObject();
    uniforms.put("image", new JSONString(GWT.getModuleBaseURL() + "images/normalmap.png"));
    uniforms.put("strength", new JSONNumber(0.6));

    JSONObject normalMap = new JSONObject();
    normalMap.put("type", new JSONString("NormalMap"));
    normalMap.put("uniforms", uniforms);

    JSONObject materials = new JSONObject();
    materials.put("diffuseMaterial", diffuseMaterial);
    materials.put("normalMap", normalMap);

    JSONObject components = new JSONObject();
    components.put("diffuse", new JSONString("diffuseMaterial.diffuse"));
    components.put("specular", new JSONNumber(0.01));
    components.put("normal", new JSONString("normalMap.normal"));

    JSONObject fabric = new JSONObject();
    fabric.put("materials", materials);
    fabric.put("components", components);

    MaterialOptions materialOptions = new MaterialOptions();
    materialOptions.fabric = JsonUtils.safeEval(fabric.toString());
    primitive.appearance.material = new Material(materialOptions);
}

From source file:org.cleanlogic.cesiumjs4gwt.showcase.examples.Materials.java

License:Apache License

public void applySpecularMapMaterial(Primitive primitive) {
    JSONObject uniforms = new JSONObject();
    uniforms.put("image", new JSONString(GWT.getModuleBaseURL() + "images/Cesium_Logo_Color.jpg"));
    uniforms.put("channel", new JSONString("r"));

    JSONObject fabric = new JSONObject();
    fabric.put("type", new JSONString("SpecularMap"));
    fabric.put("uniforms", uniforms);

    MaterialOptions materialOptions = new MaterialOptions();
    materialOptions.fabric = JsonUtils.safeEval(fabric.toString());
    primitive.appearance.material = new Material(materialOptions);
}

From source file:org.cleanlogic.cesiumjs4gwt.showcase.examples.Materials.java

License:Apache License

public void applyWaterMaterial(Primitive primitive) {
    JSONObject uniforms = new JSONObject();
    uniforms.put("specularMap", new JSONString(GWT.getModuleBaseURL() + "images/earthspec1k.jpg"));
    uniforms.put("normalMap", new JSONString(GWT.getModuleBaseURL() + "images/waterNormals.jpg"));
    uniforms.put("frequency", new JSONNumber(10000.0));
    uniforms.put("animationSpeed", new JSONNumber(0.01));
    uniforms.put("amplitude", new JSONNumber(1.0));

    JSONObject fabric = new JSONObject();
    fabric.put("type", new JSONString("Water"));
    fabric.put("uniforms", uniforms);

    MaterialOptions materialOptions = new MaterialOptions();
    materialOptions.fabric = JsonUtils.safeEval(fabric.toString());
    primitive.appearance.material = new Material(materialOptions);
}

From source file:org.cleanlogic.cesiumjs4gwt.showcase.examples.Materials.java

License:Apache License

public void applyCompositeMaterial(Primitive primitive) {
    JSONObject fabric = new JSONObject();

    JSONObject uniforms = new JSONObject();
    uniforms.put("image", new JSONString(GWT.getModuleBaseURL() + "images/earthspec1k.jpg"));
    uniforms.put("heightField", new JSONString(GWT.getModuleBaseURL() + "images/earthbump1k.jpg"));
    fabric.put("uniforms", uniforms);

    uniforms = new JSONObject();
    uniforms.put("image", new JSONString(GWT.getModuleBaseURL() + "images/earthbump1k.jpg"));

    JSONObject bumpMap = new JSONObject();
    bumpMap.put("type", new JSONString("BumpMap"));
    bumpMap.put("uniforms", uniforms);

    JSONObject materials = new JSONObject();
    materials.put("bumpMap", bumpMap);

    fabric.put("materials", materials);
    fabric.put("source",
            new JSONString("czm_material czm_getMaterial(czm_materialInput materialInput) {"
                    + "czm_material material = czm_getDefaultMaterial(materialInput);"
                    + "float heightValue = texture2D(heightField, materialInput.st).r;"
                    + "material.diffuse = mix(vec3(0.2, 0.6, 0.2), vec3(1.0, 0.5, 0.2), heightValue);"
                    + "material.alpha = (1.0 - texture2D(image, materialInput.st).r) * 0.7;"
                    + "material.normal = bumpMap.normal;" + "material.specular = step(0.1, heightValue);" + // Specular mountain tops
                    "material.shininess = 8.0;" + // Sharpen highlight
                    "return material;" + "}"));

    MaterialOptions materialOptions = new MaterialOptions();
    materialOptions.fabric = JsonUtils.safeEval(fabric.toString());
    primitive.appearance.material = new Material(materialOptions);
}