Package com.google.wave.api

Examples of com.google.wave.api.Image


    if (FormElement.getFormElementTypes().contains(type)) {
      result = new FormElement(type, properties);
    } else if (type == ElementType.GADGET) {
      result = new Gadget(properties);
    } else if (type == ElementType.IMAGE) {
      result = new Image(properties);
    } else if (type == ElementType.ATTACHMENT) {
      byte[] data = null;
      String encodedData = properties.get(Attachment.DATA);
      if (encodedData != null) {
        try {
View Full Code Here


  public void testShift() {
    Document document =
        BasicFactories.documentProvider().parse(LineContainers.debugContainerWrap(""));
    ApiView api = new ApiView(document, mock(Wavelet.class));
    api.insert(1, "0123456789");
    api.insert(4, new Image("id1", "caption"));
    api.insert(8, new Image("id1", "caption"));
    assertInSync(document, api);
    api.delete(2, 3);
    List<ElementInfo> elements = api.getElements();
    assertEquals(3, elements.size());
    api.delete(elements.get(1).apiPosition, elements.get(0).apiPosition + 1);
View Full Code Here

  public void testComposeDocUsingAppend() {
    Document document =
        BasicFactories.documentProvider().parse(LineContainers.debugContainerWrap(""));
    ApiView api = new ApiView(document, mock(Wavelet.class));
    api.insert(1, "hello");
    api.insert(1, new Image("id", "caption"));
    assertEquals(2, api.getElements().size());
    assertEquals("\n hello", api.apiContents());
    assertInSync(document, api);
    api.insert(api.apiContents().length(), " world");
    assertEquals("\n hello world", api.apiContents());
    assertInSync(document, api);
    api.insert(api.apiContents().length(), new Image("id", "caption"));
    assertInSync(document, api);
    api.insert(api.apiContents().length(), "!");
    assertEquals("\n hello world !", api.apiContents());
    assertInSync(document, api);
  }
View Full Code Here

  public void testInsertAndDeleteElementInString() {
    Document document =
        BasicFactories.documentProvider().parse(LineContainers.debugContainerWrap(""));
    ApiView api = new ApiView(document, mock(Wavelet.class));
    api.insert(1, "hello");
    api.insert(3, new Image("id", "caption"));
    assertEquals("\nhe llo", api.apiContents());
    assertInSync(document, api);
    api.delete(3, 5);
    assertEquals("\nhelo", api.apiContents());
    assertInSync(document, api);
View Full Code Here

  public void testInsertBeforeElementThenDeleteElement() {
    Document document =
        BasicFactories.documentProvider().parse(LineContainers.debugContainerWrap(""));
    ApiView api = new ApiView(document, mock(Wavelet.class));
    api.insert(1, "0123456789");
    api.insert(4, new Image("id1", "caption"));
    api.insert(4, "4");
    assertInSync(document, api);
    api.delete(5, 6);
    assertEquals(1, api.getElements().size());
    assertEquals("\n01243456789", api.apiContents());
View Full Code Here

  public void testTransformToXmlOffset() {
    Document document = BasicFactories.documentProvider().parse(
        LineContainers.debugContainerWrap("some text<gadget></gadget>"));
    ApiView api = new ApiView(document, mock(Wavelet.class));
    api.insert(3, new Image("id", "caption"));
    List<ElementInfo> apiElements = api.getElements();
    for (int i = 0; i < apiElements.size(); i++) {
      ElementInfo info = apiElements.get(i);
      assertEquals(info.xmlPosition, api.transformToXmlOffset(info.apiPosition));
    }
View Full Code Here

    textView.appendStyledText(new StyledText("Results", StyleType.HEADING2));

    textView.append("\n\n");
   
    textView.appendElement(new Image(getParticipationChartUrl(),
        PARTICIPATION_WIDTH, PARTICIPATION_HEIGHT, ""));
   
    textView.appendElement(new Image(getDistrtibutionChartUrl(),
        DISTRIBUTION_WIDTH, DISTRIBUTION_HEIGHT, ""));

    textView.append("\n");
  }
View Full Code Here

  /**
   * Updates the results charts by recalculating the Chart API urls and
   * replacing the images.
   */
  public void update() {
    Image distributionChart = new Image(getDistrtibutionChartUrl(),
        DISTRIBUTION_WIDTH, DISTRIBUTION_HEIGHT, "");
    Image participationChart = new Image(getParticipationChartUrl(),
        PARTICIPATION_WIDTH, PARTICIPATION_HEIGHT, "");
   
    TextView textView = blip.getDocument();
    for (Element element : textView.getElements(ElementType.IMAGE)) {
      Image image = (Image)element;
      if (image.getUrl().contains("Poll%20Distribution")) {
        textView.replaceElement(textView.getPosition(image), distributionChart);
      } else if (image.getUrl().contains("Poll%20Participation")) {
        textView.replaceElement(textView.getPosition(image), participationChart);
      }
    }
  }
View Full Code Here

    if (FormElement.getFormElementTypes().contains(type)) {
      result = new FormElement(type, properties);
    } else if (type == ElementType.GADGET) {
      result = new Gadget(properties);
    } else if (type == ElementType.IMAGE) {
      result = new Image(properties);
    } else if (type == ElementType.LINE) {
      result = new Line(properties);
    } else {
      result = new Element(type, properties);
    }
View Full Code Here

    // Test setting wavelet title.
    wavelet.setTitle("A wavelet title");

    // Test inserting image.
    blip.append(new Image("http://www.google.com/logos/clickortreat1.gif", 320, 118,
        "Click or treat"));

    // Test inserting list.
    Line line = new Line();
    line.setLineType("li");
    line.setIndent("2");
    blip.append(line);
    blip.append("bulleted!");

    // Test inserting extension installer.
    String installerUrl = "http://wave-skynet.appspot.com/public/extensions/areyouin/manifest.xml";
    blip.append(new Installer(installerUrl));

    // Test adding a proxied reply. The reply will be posted by
    // jkitchensinky+proxy@appspot.com. Note that as a side effect this will
    // also add this participant to the wave.
    wavelet.proxyFor("proxy").reply("\n").append("Douwe says Java rocks!");

    // Test inserting inline blip.
    Blip inlineBlip = blip.insertInlineBlip(5);
    inlineBlip.append("Hello again!");

    // Test creating a new wave. The new wave will have its own operation queue.
    // {@link AbstractRobot#newWave(String, Set, String, String)} takes a
    // {@code message} parameter which can be set to an arbitrary string. By
    // setting it to the serialized version of the current wave, we can
    // reconstruct the current wave when the other wave is constructed and
    // update the current wave.
    JsonElement waveletJson = SERIALIZER.toJsonTree(wavelet.serialize());
    JsonElement blipJson = SERIALIZER.toJsonTree(blip.serialize());
    JsonObject json = new JsonObject();
    json.add("wavelet", waveletJson);
    json.add("blip", blipJson);
    Wavelet newWave = this.newWave(wavelet.getDomain(), wavelet.getParticipants(),
        SERIALIZER.toJson(json), null);
    newWave.getParticipants().setParticipantRole(wavelet.getCreator(), Participants.Role.READ_ONLY);
   
    newWave.getRootBlip().append("A new day and a new wave");
    newWave.getRootBlip().appendMarkup("<p>Some stuff!</p><p>Not the <b>beautiful</b></p>");

    // Since the new wave has its own operation queue, we need to submit it
    // explicitly through the active gateway, or, as in this case, submit it
    // together with wavelet, which will handle the submit automatically.
    newWave.submitWith(wavelet);

    // Test inserting a form element.
    blip.append(new FormElement(ElementType.CHECK, "My Label", "true", "false"));

    // Test inserting replies with image.
    String imgUrl = "http://upload.wikimedia.org/wikipedia/en/thumb/c/cc/Googlewave.svg/" +
        "200px-Googlewave.svg.png";
    Blip replyBlip = blip.reply();
    replyBlip.append("Hello");
    replyBlip.append(new Image(imgUrl, 50, 50, "caption"));
    replyBlip.append("\nHello");
    replyBlip.append(new Image(imgUrl, 50, 50, "caption"));
    replyBlip.append("\nHello");
    replyBlip.append(new Image(imgUrl, 50, 50, "caption"));
  }
View Full Code Here

TOP

Related Classes of com.google.wave.api.Image

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.