Package com.google.gwt.core.client

Examples of com.google.gwt.core.client.JsArrayNumber


    jso = JsonUtils.safeEval("{\"a\":false}");
    assertFalse(jso.getBoolean("a"));
    assertEquals(JsType.BOOLEAN, jso.typeofKey("a"));

    jso = JsonUtils.safeEval("{\"a\":[1,2,3]}");
    JsArrayNumber arr = jso.get("a");
    assertEquals(1.0, arr.get(0));
    assertEquals(2.0, arr.get(1));
    assertEquals(3.0, arr.get(2));
    assertEquals(JsType.ARRAY, jso.typeofKey("a"));

    jso = JsonUtils.safeEval("{\"a\":{\"foo\":\"bar\"}}");
    assertEquals("bar", jso.<DynamicJso>get("a").getString("foo"));
    assertEquals(JsType.OBJECT, jso.typeofKey("a"));
View Full Code Here


    }

    private JsArrayGeneric<JsArrayNumber> generateData(int n, int m) {
        JsArrayGeneric<JsArrayNumber> result = JsUtils.createJsArrayGeneric();
        for (int i = 0; i < n; i++) {
            JsArrayNumber a = JsUtils.createJsArrayNumber();
            for (int j = 0; j < m; j++) {
                a.set(j, 0);
            }
            for (int j = 0; j < 5; j++) {
                bump(a, m);
            }
            result.push(a);
View Full Code Here

    private PrimitiveDoubleArrayJsonDeserializer() { }

    @Override
    public double[] doDeserializeArray( JsonReader reader, JsonDeserializationContext ctx, JsonDeserializerParameters params ) {
        JsArrayNumber jsArray = JsArrayNumber.createArray().cast();
        reader.beginArray();
        while ( JsonToken.END_ARRAY != reader.peek() ) {
            if ( JsonToken.NULL == reader.peek() ) {
                reader.skipValue();
                jsArray.push( DEFAULT );
            } else {
                jsArray.push( reader.nextDouble() );
            }
        }
        reader.endArray();

        if ( GWT.isScript() ) {
            return reinterpretCast( jsArray );
        } else {
            int length = jsArray.length();
            double[] ret = new double[length];
            for ( int i = 0; i < length; i++ ) {
                ret[i] = jsArray.get( i );
            }
            return ret;
        }
    }
View Full Code Here

        }
        if (pieUIDL.hasAttribute("centerY")) {
            centerY = pieUIDL.getIntAttribute("centerY");
        }
        if (centerX != null || centerY != null) {
            JsArrayNumber center = JavaScriptObject.createArray().cast();
            center.push((centerX == null ? 0 : centerX));
            center.push((centerY == null ? 0 : centerY));
            pieOptions.setCenter(center);
        }
        if (pieUIDL.hasAttribute("borderColor")) {
            pieOptions
                    .setBorderColor(pieUIDL.getStringAttribute("borderColor"));
View Full Code Here

        }
        if (pieUIDL.hasAttribute("centerY")) {
            centerY = pieUIDL.getIntAttribute("centerY");
        }
        if (centerX != null || centerY != null) {
            JsArrayNumber center = JavaScriptObject.createArray().cast();
            center.push((centerX == null ? 0 : centerX));
            center.push((centerY == null ? 0 : centerY));
            pieOptions.setCenter(center);
        }
        if (pieUIDL.hasAttribute("borderColor")) {
            pieOptions
                    .setBorderColor(pieUIDL.getStringAttribute("borderColor"));
View Full Code Here

     * Add a new well known graphic.
     * @param wellKnownPoints The poins of the new well known graphic
     * @param name The name of the new well known graphic
     */
    public static void addWellKnownGraphic(int[] wellKnownPoints, String name) {
        JsArrayNumber jsArray = (JsArrayNumber) JsArrayNumber.createArray();
        for (int wellKnownPoint : wellKnownPoints) {
            jsArray.push(wellKnownPoint);
        }
        addWellKnownGraphic(jsArray, name);
    }
View Full Code Here

        }
        return array;
    }

    public final static JsArrayNumber toJsArrayNumber(double... values) {
        JsArrayNumber array = createJsArrayNumber();
        for (double value : values) {
            array.push(value);
        }
        return array;
    }
View Full Code Here

  public void onGamepadUpdated(int index) {
    Gamepad gamepad = Gamepad.getGamepad(index);
    GwtController controller = controllerMap.get(index);
    if (gamepad != null && controller != null) {
      // Determine what changed
      JsArrayNumber axes = gamepad.getAxes();
      JsArrayNumber buttons = gamepad.getButtons();
      synchronized(eventQueue) {
        for (int i = 0, j = axes.length(); i < j; i++) {
          float oldAxis = controller.getAxis(i);
          float newAxis = (float) axes.get(i);
          if (oldAxis != newAxis) {
            GwtControllerEvent event = eventPool.obtain();
            event.type = GwtControllerEvent.AXIS;
            event.controller = controller;
            event.code = i;           
            event.amount = newAxis;
            eventQueue.add(event);
          }
        }     
        for (int i = 0, j = buttons.length(); i < j; i++) {
          float oldButton = controller.getButtonAmount(i);
          float newButton = (float) buttons.get(i);
          if (oldButton != newButton) {
            if ((oldButton < 0.5f && newButton < 0.5f) || (oldButton >= 0.5f && newButton >= 0.5f)) {
              controller.buttons.put(i, newButton);
              continue;
            }
View Full Code Here

        }
        if (pieUIDL.hasAttribute("centerY")) {
            centerY = pieUIDL.getIntAttribute("centerY");
        }
        if (centerX != null || centerY != null) {
            JsArrayNumber center = JavaScriptObject.createArray().cast();
            center.push((centerX == null ? 0 : centerX));
            center.push((centerY == null ? 0 : centerY));
            pieOptions.setCenter(center);
        }
        if (pieUIDL.hasAttribute("borderColor")) {
            pieOptions
                    .setBorderColor(pieUIDL.getStringAttribute("borderColor"));
View Full Code Here

        }
        if (pieUIDL.hasAttribute("centerY")) {
            centerY = pieUIDL.getIntAttribute("centerY");
        }
        if (centerX != null || centerY != null) {
            JsArrayNumber center = JavaScriptObject.createArray().cast();
            center.push((centerX == null ? 0 : centerX));
            center.push((centerY == null ? 0 : centerY));
            pieOptions.setCenter(center);
        }
        if (pieUIDL.hasAttribute("borderColor")) {
            pieOptions
                    .setBorderColor(pieUIDL.getStringAttribute("borderColor"));
View Full Code Here

TOP

Related Classes of com.google.gwt.core.client.JsArrayNumber

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.