示例#1
0
  public void appendMessages(List<AnalyzedMessage> newMessages) {
    if (newMessages.size() == 0) return;

    List<AnalyzedMessage> oldMessages = new ArrayList<>(messages);

    if (messageFilter != null) newMessages = CUtils.filter(newMessages, messageFilter);

    messages.addAll(newMessages);

    List<StyleNode> msgNodes =
        CUtils.map(
            newMessages,
            m -> {
              StyleNode n = builder.buildMessage(m);
              n.updateTree(NStyleUtils.getTemplateManager());
              return n;
            });
    rootMessageStyleNodes.addAll(msgNodes);

    List<StyleNode> appendNodes = new ArrayList<>();
    List<StyleNode> removeNodes = new ArrayList<>();

    if (oldMessages.size() > 0) {
      appendNodes.add(builder.buildTemplate("message_separator"));

      if (newMessages.size() > 0) {
        if (newMessageSeparatorNode != null) removeNodes.add(newMessageSeparatorNode);
        newMessageSeparatorNode = builder.buildTemplate("new_message_separator");
        if (newMessageSeparatorNode != null) appendNodes.add(newMessageSeparatorNode);
      }
    }

    for (int i = 0; i < msgNodes.size(); i++) {
      StyleNode n = msgNodes.get(i);
      appendNodes.add(n);

      if (i < msgNodes.size() - 1) appendNodes.add(builder.buildTemplate("message_separator"));
    }

    if (endMarginTemplateId != null) {
      if (endMarginNode != null) removeNodes.add(endMarginNode);
      endMarginNode = builder.buildTemplate(endMarginTemplateId);
      appendNodes.add(endMarginNode);
    }

    runWithNoRedraw(
        () -> {
          CUtils.forEach(removeNodes, node -> node.getParent().removeChild(node));

          getRootStyleNode().addChildAll(appendNodes);

          try {
            getRootStyleNode().updateTree(NStyleUtils.getTemplateManager());
          } catch (RuntimeException e) {
            DialogUtils.openError(null, "Script error", e.toString());
          }
        });
  }
示例#2
0
 public List<AnalyzedMessage> getMessages(int offset, int length) {
   List<AnalyzedMessage> list = new ArrayList<>();
   for (int i = 0; i < rootMessageStyleNodes.size(); i++) {
     StyleNode node = rootMessageStyleNodes.get(i);
     if (JUtils.intersects(offset, length, node.getOffset(), node.getLength())) {
       list.add(messages.get(i));
     }
   }
   return list;
 }
示例#3
0
文件: Octree.java 项目: vlitomsk/fit
  public void add(Tp obj, int maxDepth) {
    if (!in(0, 0, 0, 2, obj)) throw new RuntimeException("Object is out of octree");

    if (maxDepth != 0) {
      for (int i = 0; i < 2; ++i)
        for (int j = 0; j < 2; ++j)
          for (int k = 0; k < 2; ++k)
            if (in(i, j, k, 1, obj)) {
              if (subtree[i][j][k] == null)
                subtree[i][j][k] = new Octree(xc[i], xc[i + 1], yc[j], yc[j + 1], zc[k], zc[k + 1]);
              subtree[i][j][k].add(obj, maxDepth - 1);
              return;
            }
    }
    // Gstate.counter++;
    container.add(obj);
    //        System.out.println("gstate counter:" + Gstate.counter);
  }
示例#4
0
 public List<Answer> classicFind(Predicate<Answer> pred) {
   List<Answer> results = new ArrayList<Answer>();
   for (Answer answer : answers.values()) if (pred.test(answer)) results.add(answer);
   return results;
 }