Package com.google.gwt.json.client

Examples of com.google.gwt.json.client.JSONArray


    JSONObject n3 = new JSONObject();
    n3.put("id", new JSONNumber(3));
    n3.put("text", new JSONString("Node 3"));

    JSONArray nodes = new JSONArray();
    nodes.set(0, n1);
    nodes.set(1, n2);
    nodes.set(2, n3);


    JSONObject l1 = new JSONObject();
    l1.put("from", new JSONNumber(1));
    l1.put("to", new JSONNumber(2));

    JSONObject l2 = new JSONObject();
    l2.put("from", new JSONNumber(1));
    l2.put("to", new JSONNumber(3));

    JSONObject l3 = new JSONObject();
    l3.put("from", new JSONNumber(2));
    l3.put("to", new JSONNumber(3));

    JSONArray links = new JSONArray();
    links.set(0, l1);
    links.set(1, l2);
    links.set(2, l3);


    JSONObject p1 = new JSONObject();
    p1.put("from", new JSONNumber(1));
    p1.put("to", new JSONNumber(2));
    p1.put("duration", new JSONNumber(5));

    JSONObject p2 = new JSONObject();
    p2.put("from", new JSONNumber(1));
    p2.put("to", new JSONNumber(3));
    p2.put("duration", new JSONNumber(3));

    JSONObject p3 = new JSONObject();
    p3.put("from", new JSONNumber(2));
    p3.put("to", new JSONNumber(3));
    p3.put("duration", new JSONNumber(1));

    JSONArray packages = new JSONArray();
    packages.set(0, p1);
    packages.set(1, p2);
    packages.set(2, p3);


    // Create options
    Network.Options options = Network.Options.create();
    options.setWidth("300px");
    options.setHeight("300px");
    options.setStabilize(false);
    options.setBackgroundColor("#E4F3F8");
    options.setBorderWidth(0);
    options.setLinksLength(100);
    options.setLinksWidth(2);

    // create the visualization, with data and options
    network = new Network(nodes.getJavaScriptObject(),
        links.getJavaScriptObject(),
        packages.getJavaScriptObject(),
        options);
   
    network.addSelectHandler(createSelectHandler(network));
   
    RootPanel.get("mynetwork").add(network);
View Full Code Here


  void addPackageOffline() {
    JSONObject p = new JSONObject();
    p.put("from", new JSONNumber(1));
    p.put("to", new JSONNumber(2));

    JSONArray packages = new JSONArray();
    packages.set(0, p);
   
    network.addPackages(packages.getJavaScriptObject());
  }
View Full Code Here

    p.put("id", new JSONNumber(packageId));
    p.put("from", new JSONNumber(2));
    p.put("to", new JSONNumber(3));
    p.put("progress", new JSONNumber(packageProgress));

    JSONArray packages = new JSONArray();
    packages.set(0, p);
   
    network.addPackages(packages.getJavaScriptObject());
  }
View Full Code Here

    p.put("id", new JSONNumber(packageId));
    p.put("from", new JSONNumber(2));
    p.put("to", new JSONNumber(3));
    p.put("action", new JSONString("delete"));

    JSONArray packages = new JSONArray();
    packages.set(0, p);

    network.addPackages(packages.getJavaScriptObject());
  }
View Full Code Here

       
        //*
        DataTable data = new DataTable () {
          @Override
          public void onEvent(String event, JavaScriptObject items) {
            JSONArray jsonItems = new JSONArray(items);
            System.out.println("event=" + event +
                ", items=" + jsonItems.toString());
          }
        };

        for (int i = 0; i < 100; i++) {
          data.setField(i, "name", "Truck " + i);
View Full Code Here

    public void getChanges(int index, int num, JavaScriptObject items, 
        AsyncCallback<Response> callback) {
      Response response = Response.create();
      response.setTotalItems(this.trucks.size());

      JSONArray array = new JSONArray(items);
      for (int i = 0; i < array.size(); i++) {
        Truck truck = trucks.get(index + i);

        Truck checkTruck = null;
        JSONValue value = array.get(i);
        JSONObject item = null;
        if (value != null) {
          item = value.isObject();
        }
        if (item != null) {
View Full Code Here

      callback.onSuccess(response);
    }

    @Override
    public void onEvent(String event, JavaScriptObject items) {
      JSONArray trucks = new JSONArray(items);
      Truck truck = new Truck();
      truck.fromJSON(trucks.get(0).isObject());
      System.out.println("onEvent event=" + event +
          ", truck=" + truck.toJSON());
    }
View Full Code Here

   * This is the entry point method.
   */
  public void onModuleLoad() {
    DateTimeFormat dtf = DateTimeFormat.getFormat("yyyy-MM-dd");

    JSONArray dataA = new JSONArray();
    JSONArray dataB = new JSONArray();

    // create data
    Date d = dtf.parse("2012-08-23");
    int n = 200; // number of datapoints
    for (int i = 0; i < n; i++) {
      JSONObject pointA = new JSONObject();
      pointA.put("date", new JSONNumber(d.getTime()));
      pointA.put("value", new JSONNumber(customFunctionA(i)));
      dataA.set(i, pointA);

      JSONObject pointB = new JSONObject();
      pointB.put("date", new JSONNumber(d.getTime()));
      pointB.put("value", new JSONNumber(customFunctionB(i)));
      dataB.set(i, pointB);

      d.setTime(d.getTime() + 1000 * 60); // steps of one minute
    }
   
    JSONObject dataSetA = new JSONObject();
    dataSetA.put("label", new JSONString("Function A"));
    dataSetA.put("data", dataA);
   
    JSONObject dataSetB = new JSONObject();
    dataSetB.put("label", new JSONString("Function B"));
    dataSetB.put("data", dataB);

    Graph.Options options = Graph.Options.create();
    options.setHeight("400px");
    options.setLineStyle(Graph.Options.LINESTYLE.DOT, 1);
    options.setLineColor("blue", 1);
    options.setLineLegend(false, 0);

    JSONArray data = new JSONArray();
    data.set(0, dataSetA);
    data.set(1, dataSetB);
   
    // create the graph, with data and options
    chart = new Graph(data.getJavaScriptObject(), options);

    RootPanel.get("mygraph").add(chart);
  }
View Full Code Here

    JSONObject n3 = new JSONObject();
    n3.put("id", new JSONNumber(3));
    n3.put("text", new JSONString("Node 3"));

    JSONArray nodes = new JSONArray();
    nodes.set(0, n1);
    nodes.set(1, n2);
    nodes.set(2, n3);


    JSONObject l1 = new JSONObject();
    l1.put("from", new JSONNumber(1));
    l1.put("to", new JSONNumber(2));

    JSONObject l2 = new JSONObject();
    l2.put("from", new JSONNumber(1));
    l2.put("to", new JSONNumber(3));

    JSONObject l3 = new JSONObject();
    l3.put("from", new JSONNumber(2));
    l3.put("to", new JSONNumber(3));

    JSONArray links = new JSONArray();
    links.set(0, l1);
    links.set(1, l2);
    links.set(2, l3);


    JSONObject p1 = new JSONObject();
    p1.put("from", new JSONNumber(1));
    p1.put("to", new JSONNumber(2));
    p1.put("duration", new JSONNumber(5));

    JSONObject p2 = new JSONObject();
    p2.put("from", new JSONNumber(1));
    p2.put("to", new JSONNumber(3));
    p2.put("duration", new JSONNumber(3));

    JSONObject p3 = new JSONObject();
    p3.put("from", new JSONNumber(2));
    p3.put("to", new JSONNumber(3));
    p3.put("duration", new JSONNumber(1));

    JSONArray packages = new JSONArray();
    packages.set(0, p1);
    packages.set(1, p2);
    packages.set(2, p3);


    // Create options
    Network.Options options = Network.Options.create();
    options.setWidth("300px");
    options.setHeight("300px");
    options.setStabilize(false);
    options.setBackgroundColor("#E4F3F8");
    options.setBorderWidth(0);
    options.setLinksLength(100);
    options.setLinksWidth(2);

    // create the visualization, with data and options
    network = new Network(nodes.getJavaScriptObject(),
        links.getJavaScriptObject(), packages.getJavaScriptObject(),
        options);
   
    network.addSelectHandler(createSelectHandler(network));
   
    RootPanel.get("mynetwork").add(network);
View Full Code Here

  }

  public DataPoint[] getDatapoints() {
    List<DataPoint> list = new ArrayList<DataPoint>(size());
    for (int i = 0; i < size(); i++) {
      JSONArray array = getArray(i);
      if (array != null) {
        DataPoint datapoint = new DataPoint(array);
        list.add(datapoint);
      }
    }
View Full Code Here

TOP

Related Classes of com.google.gwt.json.client.JSONArray

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.