Java 类com.google.gwt.core.client.JsArray 实例源码

项目:empiria.player    文件:AbstractConnectionView.java   
@Override
public void onTouchEvent(TouchEvent event) {
    NativeEvent nativeEvent = event.getNativeEvent();

    JsArray<Touch> touches = nativeEvent.getTouches();
    boolean isMouseClick = isMouseClick(touches); // method is also called
    // when MouseEvents
    // occur
    boolean isOneFingerTouch = isOneFingerTouch(touches);

    switch (event.getType()) {
        case TOUCH_START:
            if (isMouseClick || isOneFingerTouch) {
                onTouchStart(nativeEvent);
            } else {
                onTouchCancel(nativeEvent);
            }
            break;
        case TOUCH_CANCEL:
        case TOUCH_END:
            onTouchEnd(nativeEvent);
            break;
        case TOUCH_MOVE:
            if (isMouseClick || isOneFingerTouch) {
                onTouchMove(nativeEvent);
            } else {
                onTouchCancel(nativeEvent);
            }
            break;
        default:
            break;
    }

}
项目:empiria.player    文件:StyleSheet.java   
/**
 * Adds style properties to existing JSOModel. All style properties are converted to lowercase.
 */
public final Map<String, String> getDeclarationsForSelectors(List<String> selectors) {
    JsArray<JsCssRule> rules = getCssRules(styleSheet);
    Map<String, String> result = new HashMap<String, String>();
    int ln = rules.length();
    for (int i = 0; i < ln; i++) {
        JsCssRule rule = rules.get(i);
        if (rule.isStyleRule() && selectors.contains(rule.getSelector())) {
            JsArray<JsCssDeclaration> declarations = rule.getDeclarations();
            int dln = declarations.length();
            for (int j = 0; j < dln; j++) {
                JsCssDeclaration declaration = declarations.get(j);
                if (declaration.getProperty() != null && declaration.getValue() != null)
                    result.put(declaration.getProperty(), declaration.getValue());
            }
        }
    }
    return result;
}
项目:dangchat-sdk    文件:JsWebRTCProvider.java   
@NotNull
@Override
public Promise<WebRTCPeerConnection> createPeerConnection(final WebRTCIceServer[] webRTCIceServers, WebRTCSettings settings) {
    return new Promise<>(new PromiseFunc<WebRTCPeerConnection>() {
        @Override
        public void exec(@NotNull PromiseResolver<WebRTCPeerConnection> resolver) {
            JsArray<JsIceServer> servers = JsArray.createArray().cast();
            for (WebRTCIceServer s : webRTCIceServers) {
                if (s.getUsername() != null || s.getCredential() != null) {
                    servers.push(JsIceServer.create(s.getUrl(), s.getUsername(), s.getCredential()));
                } else {
                    servers.push(JsIceServer.create(s.getUrl()));
                }
            }
            resolver.result(new PeerConnection(JsPeerConnection.create(JsPeerConnectionConfig.create(servers))));
        }
    });
}
项目:dangchat-sdk    文件:JsFacade.java   
@UsedByApp
public JsPromise loadSessions() {
    return JsPromise.create(new JsPromiseExecutor() {
        @Override
        public void execute() {
            messenger.loadSessions().start(new CommandCallback<List<ApiAuthSession>>() {
                @Override
                public void onResult(List<ApiAuthSession> res) {
                    JsArray<JsAuthSession> jsSessions = JsArray.createArray().cast();

                    for (ApiAuthSession session : res) {
                        jsSessions.push(JsAuthSession.create(session));
                    }

                    resolve(jsSessions);
                }

                @Override
                public void onError(Exception e) {
                    Log.e(TAG, e);
                    reject(e.getMessage());
                }
            });
        }
    });
}
项目:dangchat-sdk    文件:JsFacade.java   
@UsedByApp
private JsPromise loadArchivedDialogs(final boolean init) {
    return JsPromise.create(new JsPromiseExecutor() {
        @Override
        public void execute() {
            messenger.loadArchivedDialogs(init, new RpcCallback<ResponseLoadArchived>() {
                @Override
                public void onResult(ResponseLoadArchived response) {
                    JsArray<JsDialogShort> res = JsArray.createArray().cast();
                    for (ApiDialog d : response.getDialogs()) {
                        res.push(JsDialogShort.create(messenger.buildPeerInfo(EntityConverter.convert(d.getPeer())), d.getUnreadCount()));
                    }
                    Log.d(TAG, "loadArchivedDialogs:result");
                    resolve(res);
                }

                @Override
                public void onError(RpcException e) {
                    Log.d(TAG, "loadArchivedDialogs:error");
                    reject(e.getMessage());
                }
            });
        }
    });
}
项目:dangchat-sdk    文件:JsFacade.java   
@UsedByApp
public JsPromise findUsers(final String query) {
    return JsPromise.create(new JsPromiseExecutor() {
        @Override
        public void execute() {
            messenger.findUsers(query).start(new CommandCallback<UserVM[]>() {
                @Override
                public void onResult(UserVM[] users) {
                    JsArray<JsUser> jsUsers = JsArray.createArray().cast();
                    for (UserVM user : users) {
                        jsUsers.push(messenger.getJsUser(user.getId()).get());
                    }
                    resolve(jsUsers);
                }

                @Override
                public void onError(Exception e) {
                    reject(e.getMessage());
                }
            });
        }
    });
}
项目:dangchat-sdk    文件:JsFacade.java   
/**
 * 批量注册用户
 * by Lining 2016/8/24
 * @param userIds
 * @param userNames
 * @return
 */
@UsedByApp
public JsPromise registerUsers(final String[] userIds, final String[] userNames) {
    return JsPromise.create(new JsPromiseExecutor() {
        @Override
        public void execute() {
            messenger.registerUsers(userIds, userNames).start(new CommandCallback<RegisteredUserVM[]>() {
                @Override
                public void onResult(RegisteredUserVM[] users) {
                    JsArray<JsRegisteredUser> jsUsers = JsArray.createArray().cast();
                    for (RegisteredUserVM user : users) {
                        jsUsers.push(messenger.getJsUserRegistered(user.getId(), user.getOutId().get(), user.getIsNewUser()).get());
                    }
                    resolve(jsUsers);
                }

                @Override
                public void onError(Exception e) {
                    reject(e.getMessage());
                }
            });
        }
    });
}
项目:dangchat-sdk    文件:JsCall.java   
public static JsCall create(JsMessenger messenger, CallVM model) {
    JsArray<JsPeerInfo> members = JsArray.createArray().cast();
    for (CallMember member : model.getMembers().get()) {
        members.push(messenger.buildPeerInfo(Peer.user(member.getUid())));
    }
    String state;
    switch (model.getState().get()) {
        case RINGING:
            state = "calling";
            break;
        case CONNECTING:
            state = "connecting";
            break;
        case IN_PROGRESS:
            state = "in_progress";
            break;
        default:
        case ENDED:
            state = "ended";
            break;
    }
    return create(JsPeer.create(model.getPeer()), model.isOutgoing(), members, state, model.getIsMuted().get());
}
项目:dangchat-sdk    文件:JsMessage.java   
public native static JsMessage create(String rid,
                                      String sortKey,
                                      JsPeerInfo sender,
                                      boolean isOut,
                                      String date,
                                      JsDate fullDate,
                                      String state,
                                      boolean isOnServer,
                                      JsContent content,
                                      JsArray<JsReaction> reactions,
                                      double sortDate)/*-{
    return {
        rid: rid,
        sortKey: sortKey,
        sender: sender,
        isOut: isOut,
        date: date,
        fullDate: fullDate,
        state: state,
        isOnServer: isOnServer,
        content: content,
        reactions: reactions,
        sortDate: sortDate
    };
}-*/;
项目:dangchat-sdk    文件:JsBindingModule.java   
public JsBindedValue<JsArray<JsSticker>> getStickers() {
    if (stickers == null) {
        stickers = new JsBindedValue<>((JsArray<JsSticker>) JsArray.createArray());
        messenger.getAvailableStickersVM().getOwnStickerPacks().subscribe(new ValueChangedListener<ArrayList<StickerPack>>() {
            @Override
            public void onChanged(ArrayList<StickerPack> val, Value<ArrayList<StickerPack>> valueModel) {
                JsArray<JsSticker> stickerJsArray = JsArray.createArray().cast();
                stickerJsArray.setLength(0);
                for (StickerPack pack : val) {
                    for (Sticker sticker : pack.getStickers()) {
                        stickerJsArray.push(JsSticker.create(sticker));
                    }
                }
                stickers.changeValue(stickerJsArray);
            }
        });
    }
    return stickers;
}
项目:Wiab.pro    文件:DomHelper.java   
/**
 * Gets a list of descendants of e that match the given class name.
 *
 * If the browser has the native method, that will be called. Otherwise, it
 * traverses descendents of the given element and returns the list of elements
 * with matching classname.
 *
 * @param e
 * @param className
 */
public static NodeList<Element> getElementsByClassName(Element e, String className) {
  if (QuirksConstants.SUPPORTS_GET_ELEMENTS_BY_CLASSNAME) {
    return getElementsByClassNameNative(e, className);
  } else {
    NodeList<Element> all = e.getElementsByTagName("*");
    if (all == null) {
      return null;
    }
    JsArray<Element> ret = JavaScriptObject.createArray().cast();
    for (int i = 0; i < all.getLength(); ++i) {
      Element item = all.getItem(i);
      if (className.equals(item.getClassName())) {
        ret.push(item);
      }
    }
    return ret.cast();
  }
}
项目:playn    文件:HtmlInput.java   
private Touch.Event[] toTouchEvents (Touch.Event.Kind kind, NativeEvent nevent) {
  // Convert the JsArray<Native Touch> to an array of Touch.Events
  JsArray<com.google.gwt.dom.client.Touch> nativeTouches = nevent.getChangedTouches();
  int nativeTouchesLen = nativeTouches.length();
  Touch.Event[] touches = new Touch.Event[nativeTouchesLen];
  double time = plat.time();
  for (int t = 0; t < nativeTouchesLen; t++) {
    com.google.gwt.dom.client.Touch touch = nativeTouches.get(t);
    float x = touch.getRelativeX(rootElement);
    float y = touch.getRelativeY(rootElement);
    Point xy = plat.graphics().transformMouse(x, y);
    int id = getTouchIdentifier(nevent, t);
    touches[t] = new Touch.Event(0, time, xy.x, xy.y, kind, id);
  }
  return touches;
}
项目:gwt-chronoscope    文件:AbstractDataset.java   
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;
}
项目:dom-distiller    文件:FakeWebDocumentBuilder.java   
@Override
public void startElement(Element element) {
    elements.push(element);
    documentStringBuilder.append("<");
    documentStringBuilder.append(element.getTagName());
    JsArray<Node> attributes = DomUtil.getAttributes(element);
    for (int i = 0; i < attributes.length(); i++) {
        Node node = attributes.get(i);
        documentStringBuilder.append(" ");
        documentStringBuilder.append(node.getNodeName());
        documentStringBuilder.append("=\"");
        documentStringBuilder.append(node.getNodeValue());
        documentStringBuilder.append("\"");
    }
    documentStringBuilder.append(">");
}
项目:firefly    文件:WebPlotResultParser.java   
public static WebPlotResult[] convertAry(PlotResultOverlay res) {
    List<WebPlotResult> rList= new ArrayList<WebPlotResult>();
    if (res.isSuccess()) {
        if (res.isArrayResult()) {
            JsArray<PlotResultOverlay> ary= res.getResultAry();
            for(int i=0; (i<ary.length()); i++) {
                rList.add(convertItem(ary.get(i)));
            }

        }
        else {
           rList.add(convertItem(res));
        }
    }
    return rList.toArray(new WebPlotResult[rList.size()]);
}
项目:appformer    文件:PieChart.java   
@Override
public void reload() {
    if(provider == null)
        throw new NullPointerException("PieChartDataProvider not initialized before invoking update()");

    //TODO: show loading
    provider.reload(new AsyncCallback<JsArray<Series>>() {

        @Override
        public void onSuccess(JsArray<Series> result) {
               drawPie(provider.getData());
        }

        @Override
        public void onFailure(Throwable caught) {
            // TODO Auto-generated method stub

        }
    });
}
项目:dom-distiller    文件:DomUtil.java   
/**
 * Only keep some attributes for image elements.
 * @param imgElement The image element to strip in-place.
 */
public static void stripImageElement(ImageElement imgElement) {
    JsArray<Node> attrs = getAttributes(imgElement);
    for (int i = 0; i < attrs.length(); ) {
        String name = attrs.get(i).getNodeName();
        if (!"src".equals(name) &&
            !"alt".equals(name) &&
            !"srcset".equals(name) &&
            !"dir".equals(name) &&
            !"width".equals(name) &&
            !"height".equals(name) &&
            !"title".equals(name)) {
            imgElement.removeAttribute(name);
        } else {
            i++;
        }
    }
}
项目:gerrit    文件:ChangeInfo.java   
public static RevisionInfo findEditParentRevision(JsArray<RevisionInfo> list) {
  for (int i = 0; i < list.length(); i++) {
    // edit under revisions?
    RevisionInfo editInfo = list.get(i);
    if (editInfo.isEdit()) {
      String parentRevision = editInfo.editBase();
      // find parent
      for (int j = 0; j < list.length(); j++) {
        RevisionInfo parentInfo = list.get(j);
        String name = parentInfo.name();
        if (name.equals(parentRevision)) {
          // found parent pacth set number
          return parentInfo;
        }
      }
    }
  }
  return null;
}
项目:africhat-platform-0.1    文件:JsFacade.java   
public JsPromise findUsers(final String query) {
    return JsPromise.create(new JsPromiseExecutor() {
        @Override
        public void execute() {
            messenger.findUsers(query).start(new CommandCallback<UserVM[]>() {
                @Override
                public void onResult(UserVM[] users) {
                    JsArray<JsUser> jsUsers = JsArray.createArray().cast();

                    for (UserVM user : users) {
                        jsUsers.push(messenger.getJsUser(user.getId()).get());
                    }

                    resolve(jsUsers);
                }

                @Override
                public void onError(Exception e) {
                    reject(e.getMessage());
                }
            });
        }
    });
}
项目:gerrit    文件:ProjectBranchesScreen.java   
Query run() {
  // Retrieve one more branch than page size to determine if there are more
  // branches to display
  ProjectApi.getBranches(
      getProjectKey(),
      pageSize + 1,
      qStart,
      qMatch,
      new ScreenLoadCallback<JsArray<BranchInfo>>(ProjectBranchesScreen.this) {
        @Override
        public void preDisplay(JsArray<BranchInfo> result) {
          if (!isAttached()) {
            // View has been disposed.
          } else if (query == Query.this) {
            query = null;
            showList(result);
          } else {
            query.run();
          }
        }
      });
  return this;
}
项目:gerrit    文件:ChangeScreen.java   
/**
 * Resolve a revision or patch set id string to RevisionInfo. When this view is created from the
 * changes table, revision is passed as a real revision. When this view is created from side by
 * side (by closing it with 'u') patch set id is passed.
 *
 * @param info change info
 * @param revOrId revision or patch set id
 * @param defaultValue value returned when revOrId is null
 * @return resolved revision or default value
 */
private RevisionInfo resolveRevisionOrPatchSetId(
    ChangeInfo info, String revOrId, String defaultValue) {
  int parentNum;
  if (revOrId == null) {
    revOrId = defaultValue;
  } else if ((parentNum = toParentNum(revOrId)) > 0) {
    CommitInfo commitInfo = info.revision(revision).commit();
    JsArray<CommitInfo> parents = commitInfo.parents();
    if (parents.length() >= parentNum) {
      return RevisionInfo.forParent(-parentNum, parents.get(parentNum - 1));
    }
  } else if (!info.revisions().containsKey(revOrId)) {
    JsArray<RevisionInfo> list = info.revisions().values();
    for (int i = 0; i < list.length(); i++) {
      RevisionInfo r = list.get(i);
      if (revOrId.equals(String.valueOf(r._number()))) {
        revOrId = r.name();
        break;
      }
    }
  }
  return revOrId != null ? info.revision(revOrId) : null;
}
项目:che    文件:OrionEditorWidget.java   
@Override
public List<HotKeyItem> getHotKeys() {
  OrionTextViewOverlay orionTextViewOverlay = editorOverlay.getTextView();
  List<HotKeyItem> hotKeyItems = new ArrayList<>();
  JsArray<OrionKeyBindingsRelationOverlay> keyBindings =
      OrionKeyModeOverlay.getKeyBindings_(orionTextViewOverlay);
  for (int i = 0; i < keyBindings.length(); i++) {
    OrionKeyBindingsRelationOverlay key = keyBindings.get(i);

    String actionId = key.getActionId();
    String actionDescription = orionTextViewOverlay.getActionDescription(actionId);
    String hotKey = UiUtilsOverlay.getUserKeyString(uiUtilsOverlay, key.getKeyBindings());

    if (actionDescription != null) {
      hotKeyItems.add(new HotKeyItem(actionDescription, hotKey));
    }
  }
  return hotKeyItems;
}
项目:gerrit    文件:AccountSuggestOracle.java   
@Override
public void _onRequestSuggestions(Request req, Callback cb) {
  AccountApi.suggest(
      req.getQuery(),
      req.getLimit(),
      new GerritCallback<JsArray<AccountInfo>>() {
        @Override
        public void onSuccess(JsArray<AccountInfo> in) {
          List<AccountSuggestion> r = new ArrayList<>(in.length());
          for (AccountInfo p : Natives.asList(in)) {
            r.add(new AccountSuggestion(p, req.getQuery()));
          }
          cb.onSuggestionsReady(req, new Response(r));
        }
      });
}
项目:appformer    文件:JSNativePerspective.java   
public PerspectiveDefinition buildPerspective() {
    final PerspectiveDefinition perspectiveDefinition = new PerspectiveDefinitionImpl(getDefaultPanelType());
    perspectiveDefinition.setName(getId());
    final String contextId = getContextId();
    if (contextId != null) {
        perspectiveDefinition.setContextDefinition(new ContextDefinitionImpl(new DefaultPlaceRequest(contextId)));
    }
    perspectiveDefinition.setContextDisplayMode(getContextDisplayMode());

    final JSPanelDefinition view = getView(obj);

    final JsArray<JSPartDefinition> parts = view.getParts();
    final JsArray<JSPanelDefinition> panels = view.getChildren();

    final PanelDefinition root = perspectiveDefinition.getRoot();

    buildParts(root,
               parts);
    buildPanels(root,
                panels);

    return perspectiveDefinition;
}
项目:gerrit    文件:UnifiedChunkManager.java   
private void markEdit(DisplaySide side, int startLine, JsArrayString lines, JsArray<Span> edits) {
  if (lines == null || edits == null) {
    return;
  }

  EditIterator iter = new EditIterator(lines, startLine);
  Configuration bg =
      Configuration.create().set("className", getIntralineBgFromSide(side)).set("readOnly", true);

  Configuration diff =
      Configuration.create().set("className", getDiffColorFromSide(side)).set("readOnly", true);

  Pos last = Pos.create(0, 0);
  for (Span span : Natives.asList(edits)) {
    Pos from = iter.advance(span.skip());
    Pos to = iter.advance(span.mark());
    if (from.line() == last.line()) {
      getMarkers().add(cm.markText(last, from, bg));
    } else {
      getMarkers().add(cm.markText(Pos.create(from.line(), 0), from, bg));
    }
    getMarkers().add(cm.markText(from, to, diff));
    last = to;
    colorLines(cm, LineClassWhere.BACKGROUND, getDiffColorFromSide(side), from.line(), to.line());
  }
}
项目:gerrit    文件:DashboardTable.java   
@Override
protected void onLoad() {
  super.onLoad();
  ChangeList.queryMultiple(
      new GerritCallback<JsArray<ChangeList>>() {
        @Override
        public void onSuccess(JsArray<ChangeList> result) {
          List<ChangeList> cls = Natives.asList(result);
          updateColumnsForLabels(cls.toArray(new ChangeList[cls.size()]));
          for (int i = 0; i < cls.size(); i++) {
            sections.get(i).display(cls.get(i));
          }
          finishDisplay();
        }
      },
      OPTIONS,
      queries.toArray(new String[queries.size()]));
}
项目:gerrit    文件:ProjectTagsScreen.java   
Query run() {
  // Retrieve one more tag than page size to determine if there are more
  // tags to display
  ProjectApi.getTags(
      getProjectKey(),
      pageSize + 1,
      qStart,
      qMatch,
      new ScreenLoadCallback<JsArray<TagInfo>>(ProjectTagsScreen.this) {
        @Override
        public void preDisplay(JsArray<TagInfo> result) {
          if (!isAttached()) {
            // View has been disposed.
          } else if (query == Query.this) {
            query = null;
            showList(result);
          } else {
            query.run();
          }
        }
      });
  return this;
}
项目:gerrit    文件:ConfigInfo.java   
final List<FindReplace> commentlinks() {
  JsArray<CommentLinkInfo> cls = commentlinks0().values();
  List<FindReplace> commentLinks = new ArrayList<>(cls.length());
  for (int i = 0; i < cls.length(); i++) {
    CommentLinkInfo cl = cls.get(i);
    if (!cl.enabled()) {
      continue;
    }
    if (cl.link() != null) {
      commentLinks.add(new LinkFindReplace(cl.match(), cl.link()));
    } else {
      try {
        FindReplace fr = new RawFindReplace(cl.match(), cl.html());
        commentLinks.add(fr);
      } catch (RuntimeException e) {
        int index = e.getMessage().indexOf("at Object");
        new ErrorDialog(
                "Invalid commentlink configuration: "
                    + (index == -1 ? e.getMessage() : e.getMessage().substring(0, index)))
            .center();
      }
    }
  }
  return commentLinks;
}
项目:empiria.player    文件:AbstractConnectionView.java   
private boolean isMouseClick(JsArray<Touch> touches) {
    return (touches == null) && pointerEventsCoordinates.isEmpty();
}
项目:empiria.player    文件:TutorConfig.java   
public List<TutorPersonaProperties> getPersonas() {
    JsArray<TutorJs> tutors = tutorConfigJs.getTutors();
    List<TutorPersonaProperties> personas = new ArrayList<TutorPersonaProperties>();
    for (int i = 0; i < tutors.length(); i++) {
        TutorPersonaProperties persona = fromJs(tutors.get(i), i);
        personas.add(persona);
    }
    return personas;
}
项目:empiria.player    文件:ProgressBonusConfig.java   
private static List<ProgressConfig> getProgresses(ProgressBonusConfigJs configJs) {
    List<ProgressConfig> progresses = Lists.newArrayList();
    JsArray<ProgressConfigJs> jsProgresses = configJs.getProgresses();

    for (int i = 0; i < jsProgresses.length(); i++) {
        ProgressConfigJs progressConfigJs = jsProgresses.get(i);
        ProgressConfig progress = ProgressConfig.fromJs(progressConfigJs);
        progresses.add(progress);
    }
    return progresses;
}
项目:empiria.player    文件:ProgressConfig.java   
private static List<ProgressAssetConfig> getAssets(JsArray<ProgressAssetConfigJs> progresses) {
    List<ProgressAssetConfig> assets = Lists.newArrayList();

    for (int i = 0; i < progresses.length(); i++) {
        ProgressAssetConfigJs configJs = progresses.get(i);
        ProgressAssetConfig asset = ProgressAssetConfig.fromJs(configJs);
        assets.add(asset);
    }
    return assets;
}
项目:empiria.player    文件:BonusConfig.java   
private static List<BonusAction> getActions(BonusConfigJs bonusConfigJs) {
    List<BonusAction> actions = Lists.newArrayList();
    JsArray<BonusActionJs> jsActions = bonusConfigJs.getActions();

    for (int i = 0; i < jsActions.length(); i++) {
        BonusActionJs jsAction = jsActions.get(i);
        BonusAction action = BonusAction.fromJs(jsAction);
        actions.add(action);
    }

    return actions;
}
项目:empiria.player    文件:BonusAction.java   
private static List<BonusResource> getBonuses(JsArray<BonusResourceJs> jsBonuses) {
    List<BonusResource> bonuses = Lists.newArrayList();

    for (int i = 0; i < jsBonuses.length(); i++) {
        BonusResourceJs jsBonus = jsBonuses.get(i);
        BonusResource bonus = BonusResource.fromJs(jsBonus);
        bonuses.add(bonus);
    }

    return bonuses;
}
项目:empiria.player    文件:ItemBody.java   
private JavaScriptObject getModuleJsSockets() {
    eu.ydp.empiria.player.client.controller.communication.sockets.ModuleInterferenceSocket[] moduleSockets = getModuleSockets();
    JsArray<JavaScriptObject> moduleSocketsJs = JSArrayUtils.createArray(0);
    for (int i = 0; i < moduleSockets.length; i++) {
        moduleSocketsJs.set(i, moduleSockets[i].getJsSocket());
    }
    return moduleSocketsJs;
}
项目:empiria.player    文件:PositionHelper.java   
private Touch getTouch(NativeEvent event) {
    JsArray<Touch> touches = event.getChangedTouches();
    Touch touch = null;
    if (touches != null && touches.length() == 1) {
        touch = touches.get(0);
    }
    return touch;
}
项目:LAS    文件:JsUtil.java   
static <T extends JavaScriptObject> JsArray<T> toArray(final Collection<T> collection) {
  JsArray<T> array = JavaScriptObject.createArray().cast();
  for (T t : collection) {
    array.push(t);
  }
  return array;
}
项目:social-analytics    文件:SentimentPieChart.java   
/**
 * Updates the pue chart with new data
 * @param sentimentSummary
 */
private static void drawPieChart(JsArray<SentimentSummary> sentimentSummary) {

    DataTable data = DataTable.create();
    data.addColumn(ColumnType.STRING, "Sentiment");
    data.addColumn(ColumnType.NUMBER, "Count");

    data.addRows(sentimentSummary.length());
    int j = sentimentSummary.length();

    for (int i = 0; i < j; i++) {
        data.setValue(i, 0, sentimentSummary.get(i).getId());
        data.setValue(i, 1, sentimentSummary.get(i).getValue());
    }

    Legend legend = Legend.create();
    legend.setPosition(LegendPosition.NONE);

    PieChartOptions options = PieChartOptions.create();
    options.setWidth(500);
    options.setHeight(400);
    ChartArea area = ChartArea.create();
    area.setTop(50);
    area.setLeft(25);
    options.setChartArea(area);
    options.setLegend(legend);
    options.setColors("BDBDBD", "26A69A", "FF6E40");

    pieChart.draw(data, options);
}
项目:social-analytics    文件:SourcesPieChart.java   
/**
 * Updates the pue chart with new data
 * @param sourcesSummary
 */
private static void drawPieChart(JsArray<SourceSummary> sourcesSummary) {

    DataTable data = DataTable.create();
    data.addColumn(ColumnType.STRING, "Client");
    data.addColumn(ColumnType.NUMBER, "Count");

    data.addRows(sourcesSummary.length());
    int j = sourcesSummary.length();

    for (int i = 0; i < j; i++) {
        data.setValue(i, 0, sourcesSummary.get(i).getId());
        data.setValue(i, 1, sourcesSummary.get(i).getValue());
    }

    Legend legend = Legend.create();
    legend.setPosition(LegendPosition.NONE);

    PieChartOptions options = PieChartOptions.create();
    options.setWidth(500);
    options.setHeight(400);
    ChartArea area = ChartArea.create();
    area.setTop(50);
    area.setLeft(25);
    options.setChartArea(area);
    options.setLegend(legend);
    options.setColors("00796b", "00897b", "009688", "26a69a", "4db6ac", "80cbc4", "b2dfdb");

    pieChart.draw(data, options);
}
项目:dangchat-sdk    文件:JsFacade.java   
@UsedByApp
public JsArray<JsMentionFilterResult> findMentions(int gid, String query) {
    List<MentionFilterResult> res = messenger.findMentions(gid, query);
    JsArray<JsMentionFilterResult> mentions = JsArray.createArray().cast();
    for (MentionFilterResult m : res) {
        mentions.push(JsMentionFilterResult.create(m));
    }
    return mentions;
}