private native JsArrayInteger getAbsolutePosition(Element elem) /*-{ var curr = elem; var left = 0; var top = 0; if ($doc.getElementById) { do { left += elem.offsetLeft - elem.scrollLeft; top += elem.offsetTop - elem.scrollTop; elem = elem.offsetParent; curr = curr.parentNode; while (curr != elem) { left -= curr.scrollLeft; top -= curr.scrollTop; curr = curr.parentNode; } } while (elem.offsetParent); } return [left, top]; }-*/;
@Override public void setTerminalSize(int x, int y) { if (!connected) { return; } if (width == x && height == y) { return; } terminal.resize(x, y); width = x; height = y; Jso jso = Jso.create(); JsArrayInteger arr = Jso.createArray().cast(); arr.set(0, x); arr.set(1, y); jso.addField("type", "resize"); jso.addField("data", arr); socket.send(jso.serialize()); }
private String getColorAtPixel(int x, int y) { x = Math.max(Math.min(x, 179), 0); y = Math.max(Math.min(y, 179), 0); RenderingContext ctx = canvas.getContext(); ImageData imageData = ctx.getImageData(x, y, 1, 1); JsArrayInteger data = imageData.getData(); return ColorUtils.rgb2hex(data.get(0), data.get(1), data.get(2)); }
public void init() { // try to get the serialized representation of the SQLite DB from the // local storage String serializedDb = storage.getItem(LOCALSTORAGE_KEY_DB); if (serializedDb == null || serializedDb.isEmpty()) { // if nothing is found, we create the database from scratch sqlDb = SQLite.create(); // and inject the SQL file which creates the tables structure DbSchema dbSchema = (DbSchema) GWT.create(DbSchema.class); sqlDb.execute(dbSchema.sqlForSchema().getText()); } else { // if the local storage already contains some data, parse it as a // JSON integer array JSONValue dbContent = JSONParser.parseStrict(serializedDb); // and initialize SQLite with this "file" sqlDb = SQLite.create(dbContent.isArray().getJavaScriptObject() .<JsArrayInteger> cast()); } persistDB(); getMinIdPasswd(); getMinIdField(); }
public final static SQLite create(JsArrayInteger data) { // Loads the SQLite.js script if not done already if (bundle == null) { bundle = (SQLiteBundle) GWT.create(SQLiteBundle.class); Document doc = Document.get(); ScriptElement sqljs = doc.createScriptElement(); sqljs.setAttribute("type", "text/javascript"); sqljs.setInnerText(bundle.SqlJs().getText()); doc.getDocumentElement().getFirstChildElement().appendChild(sqljs); } if (data != null) return createWithDataJsni(data); return createJsni(); }
private <M> void loadCategoryElements(final CategoryTypeJS categoryTypeJS, final CategoryTypeDTO categoryTypeDTO, final RequestManager<M> requestManager, final Transaction transaction) { if(categoryTypeJS.getCategoryElements() != null) { categoryTypeDTO.setCategoryElementsDTO(new ArrayList<CategoryElementDTO>()); final JsArrayInteger categoryElements = categoryTypeJS.getCategoryElements(); final int size = categoryElements.length(); for(int index = 0; index < size; index++) { categoryElementAsyncDAO.get(categoryElements.get(index), new RequestManagerCallback<M, CategoryElementDTO>(requestManager) { @Override public void onRequestSuccess(CategoryElementDTO result) { result.setParentCategoryDTO(categoryTypeDTO); categoryTypeDTO.getCategoryElementsDTO().add(result); } }, transaction); } } }
public final static SQLite create( JsArrayInteger data ) { if( bundle == null ) { bundle = (SQLiteBundle) GWT.create( SQLiteBundle.class ); Document doc = Document.get(); ScriptElement sqljs = doc.createScriptElement(); sqljs.setAttribute( "type", "text/javascript" ); sqljs.setInnerText( bundle.SqlJs().getText() ); doc.getDocumentElement().getFirstChildElement().appendChild( sqljs ); } if( data != null ) return createWithDataJsni( data ); return createJsni(); }
public DragObject(TopologyView<TopologyViewRenderer> svgTopologyMap, Element draggableElement, Element containerElement, D3 selection) { m_svgTopologyMap = svgTopologyMap; m_draggableElement = draggableElement; m_containerElement = containerElement; m_selection = selection; m_selection.each(new Handler<GWTVertex>() { @Override public void call(GWTVertex vertex, int index) { Point p = new Point(vertex.getX(), vertex.getY()); m_startPosition.put(vertex.getId(), p); } }); //User m_vertexgroup because this is what we scale instead of every vertex element m_transform = D3.getTransform(D3.d3().select(getTopologyView().getVertexGroup()).attr("transform")); JsArrayInteger position = D3.getMouse(containerElement); m_startX = (int) (position.get(0) / m_transform.getScale().get(0)); m_startY = (int) (position.get(1) / m_transform.getScale().get(1)); }
public static JSObject getStyle(VectorStyleDef def) { String fillColor = def.getFill().getNormalColor(); Double fillOpacity = def.getFill().getOpacity(); String strokeColor = def.getLine().getNormalColor(); Double strokeWidth = new Double(def.getLine().getThickness()); JSObject styleObject = JSObject.createJSObject(); styleObject.setProperty(FILL_NAME, true); styleObject.setProperty(FILL_COLOR_NAME, fillColor); styleObject.setProperty(FILL_OPACITY_NAME, fillOpacity); styleObject.setProperty(STROKE_COLOR_NAME, strokeColor); styleObject.setProperty(STROKE_WIDTH_NAME, strokeWidth); styleObject.setProperty(RADIUS_NAME, RADIUS_VALUE); //icon String iconUrl = def.getPoint().getExternalGraphic(); if (iconUrl != null) { JSObject iconObject = JSObject.createJSObject(); iconObject.setProperty(ICON_URL_NAME, iconUrl); JsArrayInteger iconSize = JSObject.createArray().cast(); iconSize.push(def.getPoint().getGraphicWidth()); iconSize.push(def.getPoint().getGraphicHeight()); JSObject iconSizeObject = iconSize.cast(); iconObject.setProperty(ICON_SIZE_NAME, iconSizeObject); styleObject.setProperty(ICON_NAME, iconObject); } return styleObject; }
static JsArrayInteger toIntegerArray(int... javaArray) { JsArrayInteger jsArray = JavaScriptObject.createArray().cast(); for (int integer : javaArray) { jsArray.push(integer); } return jsArray; }
static JsArrayInteger toIntegerArray(final Collection<Integer> collection) { JsArrayInteger array = JavaScriptObject.createArray().cast(); for (Integer integer : collection) { array.push(integer); } return array; }
@Override public JsMessage convert(Message value) { JsMessenger messenger = JsMessenger.getInstance(); String rid = value.getRid() + ""; String sortKey = value.getSortDate() + ""; JsPeerInfo sender = messenger.buildPeerInfo(Peer.user(value.getSenderId())); boolean isOut = value.getSenderId() == messenger.myUid(); boolean isOnServer = value.isOnServer(); String date = messenger.getFormatter().formatTime(value.getDate()); JsDate fullDate = JsDate.create(value.getDate()); JsContent content = JsContent.createContent(value.getContent(), value.getSenderId()); JsArray<JsReaction> reactions = JsArray.createArray().cast(); for (Reaction r : value.getReactions()) { JsArrayInteger uids = (JsArrayInteger) JsArrayInteger.createArray(); boolean isOwnSet = false; for (Integer i : r.getUids()) { uids.push(i); if (i == messenger.myUid()) { isOwnSet = true; } } reactions.push(JsReaction.create(r.getCode(), uids, isOwnSet)); } double sortDate = value.getDate() / 1000.0; return create(rid, sortKey, sender, isOut, date, fullDate, Enums.convert(value.getMessageState()), isOnServer, content, reactions, sortDate); }
private void fireOnStartEvent(Event evt, JsArrayInteger values) { int[] vals = jsArrayIntegerToIntArray(values); SliderEvent e = new SliderEvent(evt, this, vals); for (SliderListener l : m_listeners) { l.onStart(e); } }
private void fireOnChangeEvent(Event evt, JsArrayInteger values, boolean hasOriginalEvent) { int[] vals = jsArrayIntegerToIntArray(values); SliderEvent e = new SliderEvent(evt, this, vals, hasOriginalEvent); for (SliderListener l : m_listeners) { l.onChange(e); } }
private void fireOnStopEvent(Event evt, JsArrayInteger values) { int[] vals = jsArrayIntegerToIntArray(values); SliderEvent e = new SliderEvent(evt, this, vals); for (SliderListener l : m_listeners) { l.onStop(e); } }
private int[] jsArrayIntegerToIntArray(JsArrayInteger values) { int len = values.length(); int[] vals = new int[len]; for (int i = 0; i < len; i++) { vals[i] = values.get(i); } return vals; }
public static JsArrayInteger toJsArray(byte[] data) { JsArrayInteger jsan = (JsArrayInteger) JsArrayInteger.createArray(); int len = data.length; for (int i = len - 1; i >= 0; i--) { jsan.set(i, data[i]); } return jsan; }
public static JsArrayInteger toJsArray(int[] data) { JsArrayInteger jsan = (JsArrayInteger) JsArrayInteger.createArray(); int len = data.length; for (int i = len - 1; i >= 0; i--) { jsan.set(i, data[i]); } return jsan; }
public static JsArrayInteger toJsArray(short[] data) { JsArrayInteger jsan = (JsArrayInteger) JsArrayInteger.createArray(); int len = data.length; for (int i = len - 1; i >= 0; i--) { jsan.set(i, data[i]); } return jsan; }
public static JsArrayInteger toJsArrayUnsigned(byte[] data) { JsArrayInteger jsan = (JsArrayInteger) JsArrayInteger.createArray(); int len = data.length; for (int i = len - 1; i >= 0; i--) { jsan.set(i, data[i] & 255); } return jsan; }
public static JsArrayInteger toJsArrayUnsigned(short[] data) { JsArrayInteger jsan = (JsArrayInteger) JsArrayInteger.createArray(); int len = data.length; for (int i = len - 1; i >= 0; i--) { jsan.set(i, data[i] & 65535); } return jsan; }
public static void glDrawBuffersWEBGL(int... buffers) { JsArrayInteger array = JsArrayInteger.createArray(buffers.length).cast(); for (int buffer : buffers) array.push(buffer); glDrawBuffersWEBGL(array); }
public static void glDrawBuffersWEBGL(Int32Array buffers) { JsArrayInteger array = JsArrayInteger.createArray(buffers.length()).cast(); for (int i = 0; i < buffers.length(); i++) array.push(buffers.get(i)); glDrawBuffersWEBGL(array); }
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; }
void play() { int i; JsArrayInteger arr = (JsArrayInteger)JsArrayInteger.createArray(); int ct = dataPtr; int base = 0; if (dataFull) { ct = dataCount; base = dataPtr; } if (ct * sampleStep < .05) { Window.alert("Audio data is not ready yet. Increase simulation speed to make data ready sooner."); return; } // rescale data to maximize double max = -1e8; double min = 1e8; for (i = 0; i != ct; i++) { if (data[i] > max) max = data[i]; if (data[i] < min) min = data[i]; } double adj = -(max+min)/2; double mult = 32766/(max+adj); for (i = 0; i != ct; i++) { int s = (int)((data[(i+base)%dataCount]+adj)*mult); arr.push(s); } playJS(arr, samplingRate); }
public static JsArrayInteger fromIntegers(Collection<Integer> collection) { JsArrayInteger array = JsArrayInteger.createArray().cast(); for(Integer item : collection) { array.push(item); } return array; }
public static List<Integer> toList(JsArrayInteger array) { List<Integer> list = new ArrayList<>(); if(array != null) { for (int i = 0; i < array.length(); i++) { list.add(array.get(i)); } } return list; }
public JsPoint(int x, int y) { JsArrayInteger jsX = (JsArrayInteger)JsArrayInteger.createArray(); jsX.push(x); array.set(0, jsX); JsArrayInteger jsY = (JsArrayInteger)JsArrayInteger.createArray(); jsY.push(y); array.set(1, jsY); }
private static void checkForIntAryResult(String key, WebPlotResult wpRes,PlotResultOverlay res) { JsArrayInteger jsAry= res.getIntArrayResult(key); if (jsAry!=null) { int ary[]= new int[jsAry.length()]; for(int i= 0; (i<ary.length); i++) ary[i]= jsAry.get(i); wpRes.putResult(key,new DataEntry.IntArray(ary)); } }
public final native JsArrayInteger getIntArrayResult(String key) /*-{ if (key in this) { return this[key]; } else { return null; } }-*/;