Package org.waveprotocol.wave.model.document

Examples of org.waveprotocol.wave.model.document.AnnotationBehaviour


        return next != null;
      }

      @Override
      public AnnotationBehaviour next() {
        AnnotationBehaviour ret = next;
        getNext();
        return ret;
      }

      private void getNext() {
        while ((fromIndex = parts.indexOf('/', fromIndex + 1)) != -1) {
          AnnotationBehaviour behaviour = behaviours.get(parts.substring(0, fromIndex));
          if (behaviour != null) {
            next = behaviour;
            return;
          }
        }
View Full Code Here


  }

  @Override
  public AnnotationBehaviour getClosestBehaviour(String key) {
    // TODO(patcoleman): optimise?
    AnnotationBehaviour closest = null;
    Iterator<AnnotationBehaviour> behaviours = getBehaviours(key);
    while (behaviours.hasNext()) {
      closest = behaviours.next();
    }
    return closest;
View Full Code Here

     *   - link-like (bias away, with priority overriding containers).
     *   - spell-like (metadata, never inherits)
     */
    AnnotationRegistry registry = root.createExtension();
    registry.registerBehaviour(STYLE_KEY, new DefaultAnnotationBehaviour(AnnotationFamily.CONTENT));
    registry.registerBehaviour(LINK_KEY, new AnnotationBehaviour() {
      public BiasDirection getBias(StringMap<Object> left, StringMap<Object> right,
          CursorDirection cursor) {
        assert left.containsKey(LINK_KEY) && right.containsKey(LINK_KEY);
        return left.get(LINK_KEY) == null ? BiasDirection.LEFT : BiasDirection.RIGHT; // away
      }
View Full Code Here

     *   - style-like (no bias change, inherits inside)
     *   - link-like (bias away, with priority overriding containers).
     */
    REGISTRY = AnnotationRegistryImpl.ROOT;
    REGISTRY.registerBehaviour(STYLE_KEY, new DefaultAnnotationBehaviour(AnnotationFamily.CONTENT));
    REGISTRY.registerBehaviour(LINK_KEY, new AnnotationBehaviour() {
      public BiasDirection getBias(StringMap<Object> left, StringMap<Object> right,
          CursorDirection cursor) {
        assert left.containsKey(LINK_KEY) && right.containsKey(LINK_KEY);
        return left.get(LINK_KEY) == null ? BiasDirection.LEFT : BiasDirection.RIGHT; // away
      }
View Full Code Here

  /** Interpret a replacement based on the annotation behaviour, return true if it was set. */
  private boolean interpretReplace(String key, ContentType type, Builder builder,
      StringMap<Object> inside, StringMap<Object> outside, StringMap<Object> current,
      StringMap<String> changeCollector) {
    AnnotationBehaviour logic = annotationLogic.getClosestBehaviour(key);
    if (logic != null) {
      switch (logic.replace(inside, outside, type)) {
        case INSIDE :
          return safeSet(builder, key, inside.get(key), current.get(key), changeCollector);
        case OUTSIDE :
          return safeSet(builder, key, outside.get(key), current.get(key), changeCollector);
        case NEITHER :
View Full Code Here

  private ReadableStringSet filterContentAnnotations(ReadableStringSet known) {
    final StringSet interested = CollectionUtils.createStringSet();
    known.each(new Proc() {
      @Override
      public void apply(final String key) {
        AnnotationBehaviour behaviour = annotationLogic.getClosestBehaviour(key);
        if (behaviour != null && behaviour.getAnnotationFamily() == AnnotationFamily.CONTENT) {
          interested.add(key);
        }
      }
    });
    return interested;
View Full Code Here

    leftSide.each( new ProcV<Object>() {
      public void apply(String key, Object value) {
        Iterator<AnnotationBehaviour> behaviours = registry.getBehaviours(key);

        while (behaviours.hasNext()) {
          AnnotationBehaviour behaviour = behaviours.next();
          double priority = behaviour.getPriority();
          if (priority > bestPriority.boxed) {
            bestPriority.boxed = priority;
            bias.boxed = behaviour.getBias(leftSide, rightSide, lastMovement);
          }
        }
      }
    });
    return bias.boxed;
View Full Code Here

    leftSide.each( new ProcV<Object>() {
      public void apply(String key, Object value) {
        Iterator<AnnotationBehaviour> behaviours = registry.getBehaviours(key);

        while (behaviours.hasNext()) {
          AnnotationBehaviour behaviour = behaviours.next();
          double priority = behaviour.getPriority();
          if (priority > bestPriority.boxed) {
            bestPriority.boxed = priority;
            bias.boxed = behaviour.getBias(leftSide, rightSide, lastMovement);
          }
        }
      }
    });
    return bias.boxed;
View Full Code Here

        return next != null;
      }

      @Override
      public AnnotationBehaviour next() {
        AnnotationBehaviour ret = next;
        getNext();
        return ret;
      }

      private void getNext() {
        while ((fromIndex = parts.indexOf('/', fromIndex + 1)) != -1) {
          AnnotationBehaviour behaviour = behaviours.get(parts.substring(0, fromIndex));
          if (behaviour != null) {
            next = behaviour;
            return;
          }
        }
View Full Code Here

  }

  @Override
  public AnnotationBehaviour getClosestBehaviour(String key) {
    // TODO(patcoleman): optimise?
    AnnotationBehaviour closest = null;
    Iterator<AnnotationBehaviour> behaviours = getBehaviours(key);
    while (behaviours.hasNext()) {
      closest = behaviours.next();
    }
    return closest;
View Full Code Here

TOP

Related Classes of org.waveprotocol.wave.model.document.AnnotationBehaviour

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.