/** * Take a Java array, and produce a JS array that is only used for reading. As * this is actually a reference to the original array in prod mode, the source * must not be modified while this copy is in use or you will get different * behavior between DevMode and prod mode. * * @param array source array * @return JS array, which may be a copy or an alias of the input array */ public static JsArrayNumber readOnlyJsArray(float[] array) { if (GWT.isScript()) { return arrayAsJsArrayForProdMode(array).cast(); } JsArrayNumber dest = JsArrayNumber.createArray().cast(); for (int i = 0; i < array.length; ++i) { dest.push(array[i]); } return dest; }
/** * Take a Java array, and produce a JS array that is only used for reading. As * this is actually a reference to the original array in prod mode, the source * must not be modified while this copy is in use or you will get different * behavior between DevMode and prod mode. * * @param array source array * @return JS array, which may be a copy or an alias of the input array */ public static JsArrayNumber readOnlyJsArray(double[] array) { if (GWT.isScript()) { return arrayAsJsArrayForProdMode(array).cast(); } JsArrayNumber dest = JsArrayNumber.createArray().cast(); for (int i = 0; i < array.length; ++i) { dest.push(array[i]); } return dest; }
/** * Take a Java array, and produce a JS array that is only used for reading. As * this is actually a reference to the original array in prod mode, the source * must not be modified while this copy is in use or you will get different * behavior between DevMode and prod mode. * <p> * <b>NOTE: long values are not supported in JS, so long emulation is slow * and this method assumes that all the values can be safely stored in a * double.</b> * * @param array source array - its values are assumed to be in the valid range * for doubles -- if the values exceed 2^53, low-order bits will be lost * @return JS array, which may be a copy or an alias of the input array */ public static JsArrayNumber readOnlyJsArray(long[] array) { if (GWT.isScript()) { return arrayAsJsArrayForProdMode(array).cast(); } JsArrayNumber dest = JsArrayNumber.createArray().cast(); for (int i = 0; i < array.length; ++i) { dest.push(array[i]); } return dest; }
@Override public Path close() { list.push(CMD_CLOSE); return this; }
@Override public Path close() { list.push(CMD_CLOSE); return this; }
@Override public Path close() { list.push(CMD_CLOSE); return this; }
public void push(double value) { if(GWT.isScript()) { stackNative.push(value); } else { stackJava.add(value); } }
/** * Sets the property of ZoomRange, the interval which zooming can happen, receives as parameters the min and max * values */ public final T setZoomRange( double min, double max ) { JsArrayNumber array = JavaScriptObject.createArray().cast(); array.push( min ); array.push( max ); return setZoomRange( array ); }
private void updateSliderForNumberArray(SliderOption option, List<Double> value) { JsArrayNumber array = JavaScriptObject.createArray().cast(); for (Double val : value) { array.push(val); } if (isAttached()) { setAttribute(getElement(), option.getName(), array); refresh(); } else { String arrayStr = JsonUtils.stringify(array); attributeMixin.setAttribute(option.getDataAttribute(), arrayStr); } }