void setIncrementalData(JsArrayNumber domain, JsArray<JsArrayNumber> rangeArray) { int len = domain.length(); // using this length for both double d[] = new double[len]; for(int i=0; i<d.length; i++) { d[i] = domain.get(i); } int rangeArrayLength = rangeArray.length(); Array1D[] ranges = new Array1DImpl[rangeArray.length()]; for (int dimension = 0; dimension < rangeArrayLength; dimension++) { double[] r = new double[len]; for(int j=0; j < r.length; j++) { r[j] = rangeArray.get(dimension).get(j); } ranges[dimension] = new Array1DImpl(r); } incremental = new MipMap(new Array1DImpl(d), ranges, -1, getMipMapChain().getMipMap(0)); Interval region = new Interval(d[0], d[d.length - 1]); incrementalInterval = region; outgoingRequest = System.currentTimeMillis(); firing = true; datasets.fireChanged(this, region); firing = false; }
public String compareJsArrayNumber(JsArrayNumber objectA,JsArrayNumber objectB){ if(objectA==null){ if(objectB==null){ return "";//no need check }else{ return "A is null,B's length is "+objectB.length(); } } if(objectB==null){ return "A is"+objectA.length()+",but B is Empty"; } if(objectA.length()!=objectB.length()){ return "A's length"+objectA.length()+",B's length is "+objectB.length(); } for(int i=0;i<objectA.length();i++){ if(objectA.get(i)!=objectB.get(i)){ return "difference value at:"+i; } } return ""; }
public void flipV(JSONModelFile model){ JsArray<JsArrayNumber> uvs= model.getUvs(); if(uvs==null){ return; } for(int i=0;i<uvs.length();i++){ JsArrayNumber array=uvs.get(i); for(int j=0;j<array.length();j++){ if(j%2==1){//v only double old=array.get(j); array.set(j, 1-old); } } } }
/** {@inheritDoc} */ @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; } }
private List<Double> getNumberArrayAttribute(SliderOption option, List<Double> defaultValue) { // Get array attribute JsArrayNumber array = null; if (isAttached()) { array = getNumberArrayAttribute(getElement(), option.getName()); } else { String value = attributeMixin.getAttribute(option.getDataAttribute()); if (value != null && !value.isEmpty()) { array = JsonUtils.safeEval(value); } } // Attribute not set if (array == null) { return defaultValue; } // Put array to list List<Double> list = new ArrayList<Double>(array.length()); for (int i = 0; i < array.length(); i++) { list.add(array.get(i)); } return list; }
/** * Internal constructor used to load a JSArray already in another object. * @param array JS array instance */ JsIntegerArrayList(JsArrayIntegerImpl array) { // if null, creates a new JS array if (array == null){ this.array = (JsArrayIntegerImpl)JsArrayNumber.createArray().cast(); } else { // uses an existing array this.array = array; } }
/** * Internal constructor used to load a JSArray already in another object. * @param array JS array instance */ JsDoubleArrayList(JsArrayDoubleImpl array) { // if null, creates a new JS array if (array == null){ this.array = (JsArrayDoubleImpl)JsArrayNumber.createArray().cast(); } else { // uses an existing array this.array = array; } }
public static JsArrayNumber toJsArray(double[] data) { JsArrayNumber jsan = (JsArrayNumber) JsArrayNumber.createArray(); int len = data.length; for (int i = len - 1; i >= 0; i--) { jsan.set(i, data[i]); } return jsan; }
public static JsArrayNumber toJsArray(float[] data) { JsArrayNumber jsan = (JsArrayNumber) JsArrayNumber.createArray(); int len = data.length; for (int i = len - 1; i >= 0; i--) { jsan.set(i, data[i]); } return jsan; }
public void setValue(int row, int col, double val) { JsArrayNumber arr = data.get(col); if (arr == null) { arr = JsArrayNumber.createArray().cast(); data.set(col, arr); } arr.set(row, val); }
public JsonArray<JsonArrayNumber> getTupleRange() { JsArray<JsArrayNumber> tupleRange = jso.getTupleRange(); if (tupleRange != null) { return new GwtJsonArrayOverlay<JsonArrayNumber>(tupleRange, JsonArrayNumber.class); } return null; }
public T get(int i) { T wrapper = null; if (parameterType == JsonArrayNumber.class) { wrapper = (T) new GwtJsonArrayNumber((JsArrayNumber) jso.get(i)); } else if(parameterType == JsonArrayString.class) { wrapper = (T) new GwtJsonArrayString((JsArrayString) jso.get(i)); } return wrapper; }
public static JsArrayInteger toJsArray(int[] data) { JsArrayInteger jsan = (JsArrayInteger) JsArrayNumber.createArray(); int len = data.length; for (int i = len - 1; i >= 0; i--) { jsan.set(i, data[i]); } return jsan; }
public static JsArrayNumber fromDoubles(Collection<Double> collection) { JsArrayNumber array = JsArrayNumber.createArray().cast(); for(Double item : collection) { array.push(item); } return array; }
public static List<Double> toList(JsArrayNumber array) { List<Double> list = new ArrayList<>(); if(array != null) { for (int i = 0; i < array.length(); i++) { list.add(array.get(i)); } } return list; }
private static void checkForDoubleAryResult(String key, WebPlotResult wpRes,PlotResultOverlay res) { JsArrayNumber jsAry= res.getDoubleArrayResult(key); if (jsAry!=null) { double ary[]= new double[jsAry.length()]; for(int i= 0; (i<ary.length); i++) ary[i]= jsAry.get(i); wpRes.putResult(key,new DataEntry.DoubleArray(ary)); } }
public final native JsArrayNumber getDoubleArrayResult(String key) /*-{ if (key in this) { return this[key]; } else { return null; } }-*/;
private String iterateConnectionProxies(SearchResultProxy res) { List<ConnectionProxy> c = res.getConnections(); Iterator<ConnectionProxy> cp_it = c.iterator(); String total = ""; while(cp_it.hasNext()) { ConnectionProxy cp = cp_it.next(); String s = "Total distance: " + cp.getDistance() + "m: " + cp.getTime() + "min\n"; Iterator<LineProxy> i = cp.getLines().iterator(); while(i.hasNext()) { LineProxy lp = i.next(); s += lp.toString(); if(lp.getStartStreet() != null && lp.getDestStreet() != null) { s += " desde " + lp.getStartStreet() + " hasta " + lp.getDestStreet(); } s += " /distance: " + lp.getDistance() + "m: " + lp.getTime() + "min\n"; if(lp.getAlternativeLines().size() > 0) { s += "Alternatives: "; for(String ss : lp.getAlternativeLines()) { s += ss + ", "; } s = s.substring(0, s.length() - 2); s += "\n"; } JsArrayNumber jsnums = getNativeArray(); for(int j = 0; j < lp.getAllPoints().size(); j++) { jsnums.push(lp.getAllPoints().get(j)); } drawPoly(jsnums, false, "#000000"); jsnums = getNativeArray(); for(int j = 0; j < lp.getRelevantPoints().size(); j++) { jsnums.push(lp.getRelevantPoints().get(j)); } drawPoly(jsnums, false, "#ff0000"); } s += "\n"; total += s; } return total; }
/** Values stored in JSON strings are accessible through the JSO. */ public void testDynamicJso_getters() { DynamicJso jso = JsonUtils.safeEval("{\"a\":\"b\"}"); assertEquals("b", jso.getString("a")); assertEquals(JsType.STRING, jso.typeofKey("a")); jso = JsonUtils.safeEval("{\"a\":42}"); assertEquals(42, jso.getInteger("a")); assertEquals(JsType.INTEGER, jso.typeofKey("a")); jso = JsonUtils.safeEval("{\"a\":1.2}"); assertEquals(1.2, jso.getDouble("a")); assertEquals(JsType.NUMBER, jso.typeofKey("a")); 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")); }
public String compare(String label,JsArray<JsArrayNumber> objectA,JsArray<JsArrayNumber> objectB){ String result=""; if(objectA==null){ if(objectB==null){ result="";//no need check }else{ result= "A is null,B's length is "+objectB.length(); } } else if(objectB==null){ result= "A is "+objectA.length()+",but B is Empty"; }else{ if(objectA.length()!=objectB.length()){ return "A's length "+objectA.length()+",B's length is "+objectB.length(); } for(int i=0;i<objectA.length();i++){ JsArrayNumber numberA=objectA.get(i); JsArrayNumber numberB=objectB.get(i); String numberResult=compareJsArrayNumber(numberA,numberB); if(!numberResult.isEmpty()){ result="difference array at:"+i; break; } } } if(!result.isEmpty()){ return label+":"+result; } return null;//return null for predicate }
public String compare(String label,JsArrayNumber objectA,JsArrayNumber objectB){ String result=compareJsArrayNumber(objectA,objectB); if(!result.isEmpty()){ return label+":"+result; } return null; }
public void setVisibleRange(double... values) { JsArrayNumber array = JsArrayNumber.createArray().cast(); for (double value : values) { array.push(value); } _setVisibleRange(array); }
public static JsArrayNumber fromArray(double... values) { if (GWT.isScript()) { return reinterpretCast(values); } else { JsArrayNumber ret = JavaScriptObject.createArray().cast(); for (int i = 0, l = values.length; i < l; i++) { ret.set(i, values[i]); } return ret; } }
public static double[] toArray(JsArrayNumber values) { if (GWT.isScript()) { return reinterpretCast(values); } else { int length = values.length(); double[] ret = new double[length]; for (int i = 0, l = length; i < l; i++) { ret[i] = values.get(i); } return ret; } }
static native TessResult tessellate2(JsArrayNumber points, int pOffset, int pLength, JsArrayInteger bounds, int bOffset, int bLength) /*-{ return $wnd.tessellate(points, pOffset, pOffset + pLength, bounds, bOffset, bOffset + bLength, true); }-*/;
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); } }
/** * Converts the range to a JavaScript number array. * * @return a JavaScript number array */ public JsArrayNumber toJsArray() { JsArrayNumber array = JavaScriptObject.createArray().cast(); array.push(minValue); array.push(maxValue); return array; }
/** * Wraps a Java float Array to a JsArrayNumber for dev mode. * * @param srcArray the array to wrap * @return the wrapped array */ public static JsArrayNumber wrapArray(float[] srcArray) { JsArrayNumber result = JavaScriptObject.createArray().cast(); for (int i = 0; i < srcArray.length; i++) { result.set(i, srcArray[i]); } return result; }
/** * Wraps a Java double Array to a JsArrayNumber for dev mode. * * @param srcArray the array to wrap * @return the wrapped array */ public static JsArrayNumber wrapArray(double[] srcArray) { JsArrayNumber result = JavaScriptObject.createArray().cast(); for (int i = 0; i < srcArray.length; i++) { result.set(i, srcArray[i]); } return result; }
/** * Wraps a Java double Array to a JsArrayNumber. * * @param srcArray the array to wrap * @return the wrapped array */ public static JsArrayNumber wrapArray(double[] srcArray) { if (GWT.isScript()) { return arrayAsJsArrayForProdMode(srcArray); } JsArrayNumber result = JavaScriptObject.createArray().cast(); for (int i = 0; i < srcArray.length; i++) { result.set(i, srcArray[i]); } return result; }
/** * Wraps a Java float Array to a JsArrayNumber. * * @param srcArray the array to wrap * @return the wrapped array */ public static JsArrayNumber wrapArray(float[] srcArray) { if (GWT.isScript()) { return arrayAsJsArrayForProdMode(srcArray); } JsArrayNumber result = JavaScriptObject.createArray().cast(); for (int i = 0; i < srcArray.length; i++) { result.set(i, srcArray[i]); } return result; }
public native IIRFilterNode createIIRFilter(JsArrayNumber feedforward, JsArrayNumber feedback) /*-{ return this.createIIRFilter(feedforward, feedback); }-*/;