Exemplo n.º 1
0
  @Test
  public void deletePicture() {
    SBook book = SBooks.createBook("book1");
    SSheet sheet = book.createSheet("Picture");

    assertEquals(0, sheet.getPictures().size());

    try {
      AImage zklogo = new AImage(RangeTest.class.getResource("zklogo.png"));

      ViewAnchor anchor = new ViewAnchor(0, 1, zklogo.getWidth() / 2, zklogo.getHeight() / 2);
      SPicture picture =
          SRanges.range(sheet).addPicture(anchor, zklogo.getByteData(), SPicture.Format.PNG);

      assertEquals(1, sheet.getPictures().size());
      assertEquals(Format.PNG, picture.getFormat());
      assertEquals(zklogo.getWidth() / 2, picture.getAnchor().getWidth());

      SRanges.range(sheet).deletePicture(picture);
      assertEquals(0, sheet.getPictures().size());

      //			ImExpTestUtil.write(book, Type.XLSX); //human checking
    } catch (IOException e) {
      e.printStackTrace();
      fail();
    }
  }
Exemplo n.º 2
0
  private void show(int index, org.zkoss.util.media.Media media) {
    System.out.println("received: " + media.getName());

    Vbox box = new Vbox();
    box.setId("file" + index);
    box.setStyle("border: 1px solid black; padding: 3px;");
    box.setParent(results);

    createLabel(box, "name", media.getName());
    createLabel(box, "contentType", media.getContentType());
    createLabel(box, "format", media.getFormat());
    createLabel(
        box,
        "binary",
        media.isBinary()
            ? new java.math.BigInteger(1, media.getByteData()).toString(16).toUpperCase()
            : "");
    createLabel(box, "text", media.isBinary() ? "" : media.getStringData());
    if (media instanceof AImage) {
      AImage image = (AImage) media;
      createLabel(box, "width", image.getWidth() + "px");
      createLabel(box, "height", image.getHeight() + "px");
    } else {
      createLabel(box, "width", "");
      createLabel(box, "height", "");
    }
  }