List of usage examples for com.google.gwt.core.client JsArrayInteger get
public final native int get(int index) ;
From source file:amdb.client.slider.Slider.java
License:Apache License
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); }// ww w . j a va 2s .co m return vals; }
From source file:com.alonsoruibal.chess.book.JSONBook.java
License:Open Source License
public void generateMoves(Board board) { String key2Find = "x" + Long.toHexString(board.getKey()); totalWeight = 0;/*from ww w.ja v a2 s . c o m*/ moves = new ArrayList<Integer>(); weights = new ArrayList<Integer>(); JsArray<JsArrayInteger> array = getData(key2Find); if (array != null) { JsArrayInteger moveArray = array.get(0); JsArrayInteger weightArray = array.get(1); for (int i = 0, size = moveArray.length(); i < size; i++) { int moveInt = moveArray.get(i); int weight = weightArray.get(i); int move = Move.getFromString(board, int2MoveString(moveInt), true); // Add only if it is legal if (board.isMoveLegal(move)) { //GWT.log("JSONBook addMove(" + move + ", " + weight + ")", null); moves.add(move); weights.add(weight); totalWeight += weight; } } } }
From source file:com.calclab.emite.core.client.xmpp.datetime.gwt.TimeZone.java
License:Open Source License
public static TimeZone createTimeZone(TimeZoneInfo timezoneData) { TimeZone tz = new TimeZone(); tz.timezoneID = timezoneData.getID(); tz.standardOffset = -timezoneData.getStandardOffset(); JsArrayString jsTimezoneNames = timezoneData.getNames(); tz.tzNames = new String[jsTimezoneNames.length()]; for (int i = 0; i < jsTimezoneNames.length(); i++) { tz.tzNames[i] = jsTimezoneNames.get(i); }/*from w ww.ja va 2s .c o m*/ JsArrayInteger transitions = timezoneData.getTransitions(); if (transitions == null || transitions.length() == 0) { tz.transitionPoints = null; tz.adjustments = null; } else { int transitionNum = transitions.length() / 2; tz.transitionPoints = new int[transitionNum]; tz.adjustments = new int[transitionNum]; for (int i = 0; i < transitionNum; ++i) { tz.transitionPoints[i] = transitions.get(i * 2); tz.adjustments[i] = transitions.get(i * 2 + 1); } } return tz; }
From source file:com.github.nmorel.gwtjackson.client.deser.array.cast.PrimitiveIntegerArrayJsonDeserializer.java
License:Apache License
@Override public int[] doDeserializeArray(JsonReader reader, JsonDeserializationContext ctx, JsonDeserializerParameters params) { JsArrayInteger jsArray = JsArrayInteger.createArray().cast(); reader.beginArray();/*from www . ja v a2s. c o m*/ while (JsonToken.END_ARRAY != reader.peek()) { if (JsonToken.NULL == reader.peek()) { reader.skipValue(); jsArray.push(DEFAULT); } else { jsArray.push(reader.nextInt()); } } reader.endArray(); if (GWT.isScript()) { return reinterpretCast(jsArray); } else { int length = jsArray.length(); int[] ret = new int[length]; for (int i = 0; i < length; i++) { ret[i] = jsArray.get(i); } return ret; } }
From source file:com.github.nmorel.gwtjackson.client.deser.array.cast.PrimitiveShortArrayJsonDeserializer.java
License:Apache License
@Override public short[] doDeserializeArray(JsonReader reader, JsonDeserializationContext ctx, JsonDeserializerParameters params) { JsArrayInteger jsArray = JsArrayInteger.createArray().cast(); reader.beginArray();/*from www . j a v a 2 s . co m*/ while (JsonToken.END_ARRAY != reader.peek()) { if (JsonToken.NULL == reader.peek()) { reader.skipValue(); jsArray.push(DEFAULT); } else { jsArray.push(reader.nextInt()); } } reader.endArray(); if (GWT.isScript()) { return reinterpretCast(jsArray); } else { int length = jsArray.length(); short[] ret = new short[length]; for (int i = 0; i < length; i++) { ret[i] = (short) jsArray.get(i); } return ret; } }
From source file:com.google.livingstories.client.lsp.Externs.java
License:Apache License
public static void bind() { currentParameters = Window.Location.getParameterMap(); Set<Integer> corePanelIds = new HashSet<Integer>(); JsArrayInteger corePanelIdsJs = getCorePanelIds(); if (corePanelIdsJs != null) { for (int i = 0; i < corePanelIdsJs.length(); i++) { corePanelIds.add(corePanelIdsJs.get(i)); }//from www . j a v a2 s . c o m } Dictionary itemTypes = Dictionary.getDictionary("ITEM_TYPES"); for (String key : itemTypes.keySet()) { String itemType = itemTypes.get(key); int panelId = Integer.valueOf(key); boolean isCurrentFilteredType = corePanelIds.contains(panelId); ContentItemType contentType = getContentTypeForFilters(itemType); if (contentType == null) { throw new IllegalArgumentException("No matching content type: " + itemType); } else if (contentType != ContentItemType.ASSET) { contentTypesToPanelIds.put(contentType, panelId); if (isCurrentFilteredType) { coreItemTypes.add(contentType); } } else { AssetType assetType = getAssetTypeForFilters(itemType); assetTypesToPanelIds.put(assetType, panelId); if (isCurrentFilteredType) { coreItemTypes.add(ContentItemType.ASSET); coreItemAssetTypes.add(assetType); } } } Dictionary themes = Dictionary.getDictionary("THEMES"); for (String key : themes.keySet()) { themesById.put(Integer.valueOf(key), themes.get(key)); } parseContentItems(getContentItemsJs()); }
From source file:com.googlecode.gwt.charts.client.ajaxloader.ArrayHelper.java
License:Apache License
/** * Takes an array of Integers to be interpreted as bytes and returns a Java * Array of the byte primitive type./*from w w w . j a v a 2 s .c o m*/ * * @param bytes a JavaScript array to return. */ public static byte[] toJavaArrayBytes(JsArrayInteger bytes) { int length = bytes.length(); byte[] ret = new byte[length]; for (int i = 0; i < length; i++) { ret[i] = (byte) bytes.get(i); } return ret; }
From source file:com.googlecode.gwtquake.client.GwtWebGLRenderer.java
License:Open Source License
public Image GL_LoadNewImage(final String name, int type) { final Image image = Images.GL_Find_free_image_t(name, type); int cut = name.lastIndexOf('.'); String normalizedName = cut == -1 ? name : name.substring(0, cut); JsArrayInteger d = getImageSize(normalizedName); if (d == null) { GlState.gl.log("Size not found for " + name); image.width = 128;/*from w w w . j a v a 2s.c o m*/ image.height = 128; } else { image.width = d.get(0); image.height = d.get(1); } if (type != com.googlecode.gwtquake.shared.common.QuakeImage.it_pic) { GlState.gl.glTexImage2D(TEXTURE_2D, 0, RGBA, HOLODECK_TEXTURE_SIZE, HOLODECK_TEXTURE_SIZE, 0, RGBA, UNSIGNED_BYTE, holoDeckTexture); GlState.gl.glTexParameterf(TEXTURE_2D, TEXTURE_MIN_FILTER, LINEAR); GlState.gl.glTexParameterf(TEXTURE_2D, TEXTURE_MAG_FILTER, LINEAR); } imageQueue.add(image); if (imageQueue.size() == 1) { new ImageLoader().schedule(); } return image; }
From source file:com.googlecode.gwtquake.client.GwtWireframeGLRenderer.java
License:Open Source License
public Image GL_LoadNewImage(final String name, int type) { final Image image = Images.GL_Find_free_image_t(name, type); JsArrayInteger d = getImageSize(name); if (d == null) { GlState.gl.log("Size not found for " + name); image.width = 128;//from w ww. j a v a 2 s . c om image.height = 128; } else { image.width = d.get(0); image.height = d.get(1); } return image; }
From source file:com.googlecode.mgwt.ui.client.util.impl.OperaCssUtilImpl.java
License:Apache License
@Override public int[] getPositionFromTransForm(Element element) { JsArrayInteger array = getPositionFromTransform(element); return new int[] { array.get(0), array.get(1) }; }