/** * Gets the contents of the given {@link JsArrayMixed} as a double array. * * @param o {@link JsArrayMixed} * @return double[] if the array is not null, else null */ private static double[] getDoubleArray(JsArrayMixed o) { if (o != null) { double[] a = new double[o.length()]; for (int i = 0; i < o.length(); i++) { a[i] = o.getNumber(i); } return a; } else { return null; } }
/** * Execute a function around each object. */ public static void each(JsArrayMixed objects, Function f) { for (int i = 0, l = objects.length(); i < l; i++) { f.f(i, objects.getObject(i)); } }
/** * Get the maximum zoomlevel for this layer. * * @return maximum zoomlevel */ public int getMaxZoomLevel() { return getMinZoomLevel() + LayerImpl.getResolutions(this.getJSObject()).length() - 1; }
/** * Wrap a GQuery around an existing javascript element, event, node, nodelist, function or array. */ public static GQuery $(JavaScriptObject jso) { if (jso == null) { return $(); } // Execute a native javascript function like jquery does if (JsUtils.isFunction(jso)) { new JsUtils.JsFunction(jso).fe(); return $(); } // Wraps a native array like jquery does if (!JsUtils.isWindow(jso) && !JsUtils.isElement(jso) && JsUtils.isArray(jso)) { JsArrayMixed c = jso.cast(); JsNodeArray elms = JsNodeArray.create(); for (int i = 0; i < c.length(); i++) { Object obj = c.getObject(i); if (obj instanceof Node) { elms.addNode((Node) obj); } } return $(elms); } return JsUtils.isWindow(jso) ? $(jso.<Element> cast()) : JsUtils.isElement(jso) ? $(jso.<Element> cast()) : JsUtils.isEvent(jso) ? $(jso.<Event> cast()) : JsUtils.isNodeList(jso) ? $(jso.<NodeList<Element>> cast()) : $(jso.<Element> cast()); }