Beispiel #1
0
  private DivIcon createIcon(String label) {
    ImageResource markerImage = SiteFormResources.INSTANCE.blankMarker();

    DivIconOptions iconOptions = new DivIconOptions();
    iconOptions.setClassName(SiteFormResources.INSTANCE.style().locationMarker());
    iconOptions.setIconSize(new Point(markerImage.getWidth(), markerImage.getHeight()));
    iconOptions.setIconAnchor(new Point(markerImage.getWidth() / 2, markerImage.getHeight()));
    iconOptions.setHtml(label);

    DivIcon icon = new DivIcon(iconOptions);
    return icon;
  }
  @Test
  public void imageResource() {
    // Arrange
    ImageResource testImageResource = MyClientBundle.INSTANCE.testImageResource();

    // Act
    String name = testImageResource.getName();
    String url = testImageResource.getSafeUri().asString();
    int heigh = testImageResource.getHeight();
    int left = testImageResource.getLeft();
    int width = testImageResource.getWidth();
    int top = testImageResource.getTop();
    String toString = testImageResource.toString();

    // Assert
    assertEquals("testImageResource", name);
    assertEquals(
        "http://127.0.0.1:8888/gwt_test_utils_module/com/octo/gwt/test/resources/testImageResource.gif",
        url);
    assertEquals(0, heigh);
    assertEquals(0, left);
    assertEquals(0, width);
    assertEquals(0, top);
    assertEquals(
        "com.octo.gwt.test.internal.resources.ImageResourceCallback generated for 'com.octo.gwt.test.resources.MyClientBundle.testImageResource()'",
        toString);
    assertEquals(testImageResource, MyClientBundle.INSTANCE.testImageResource());
  }
Beispiel #3
0
 /**
  * Fails in all modes due to an HtmlUnit bug: offsetWidth always returns 1256. TODO(t.broyer):
  * file a new HtmlUnit bug. Similar to http://sourceforge.net/p/htmlunit/bugs/1447/
  */
 @DoNotRunWith(Platform.HtmlUnitBug)
 public void testCustomImageClass() {
   ImageResource resource = widgetUi.prettyImage;
   Image widget = widgetUi.fooImage;
   assertEquals(resource.getWidth(), widget.getOffsetWidth());
   assertEquals(resource.getHeight(), widget.getOffsetHeight());
   assertEquals(resource.getTop(), widget.getOriginTop());
   assertEquals(resource.getLeft(), widget.getOriginLeft());
 }
Beispiel #4
0
  /**
   * Fails in all modes due to an HtmlUnit bug: offsetWidth always returns 1256. TODO(t.broyer):
   * file a new HtmlUnit bug. Similar to http://sourceforge.net/p/htmlunit/bugs/1447/
   */
  @DoNotRunWith(Platform.HtmlUnitBug)
  public void testImageResourceInImageWidget() {
    ImageResource resource = widgetUi.prettyImage;
    Image widget = widgetUi.babyWidget;
    assertEquals(resource.getWidth(), widget.getOffsetWidth());
    assertEquals(resource.getHeight(), widget.getOffsetHeight());
    assertEquals(resource.getTop(), widget.getOriginTop());
    assertEquals(resource.getLeft(), widget.getOriginLeft());

    assertEquals("expected alt text", widget.getAltText());
    assertEquals("expected style name", widget.getStyleName());
  }
    @Override
    public Void apply(Element context, Value jsNode, int index) {
      Value propertyValue = jsNode.getProperty(TYPE);
      String kType = propertyValue.asString();
      ImageResource imageResource = getImage(KomodoType.getKomodoType(kType));

      /*
       * setAttribute will just set the attribute name to xlink:href and not
       * treat it as a ns prefix.
       */
      setElementAttributeNS(
          context, XLINK_NAMESPACE, HTML_HREF, imageResource.getSafeUri().asString());
      context.setAttribute(HTML_WIDTH, Integer.toString(imageResource.getWidth()));
      context.setAttribute(HTML_HEIGHT, Integer.toString(imageResource.getHeight()));
      return null;
    }
Beispiel #6
0
 @Override
 public void show(Detail detail) {
   ImageResource res = detail.imageResource();
   if (res.getWidth() > IMG_MAX_WIDTH || res.getHeight() > IMG_MAX_HEIGHT) {
     setInSlot(
         DetailsPresenter.IMAGE,
         new FitImage(res.getSafeUri().asString(), IMG_MAX_WIDTH, IMG_MAX_HEIGHT));
   } else {
     setInSlot(DetailsPresenter.IMAGE, new Image(res));
   }
   main.clear();
   main.add(detail.main());
   side.clear();
   side.add(detail.side());
   title.setText(detail.title());
 }
Beispiel #7
0
 protected ImageData getImageData(Object image) {
   ImageData imageData = new ImageData();
   if (image instanceof ImageResource) {
     ImageResource imageResource = (ImageResource) image;
     imageData.height = imageResource.getHeight();
     imageData.width = imageResource.getWidth();
   } else if (image instanceof ComposedImage) {
     ComposedImage composedImage = (ComposedImage) image;
     List<ComposedImage.Size> sizes = new ArrayList<ComposedImage.Size>();
     List<Object> images = new ArrayList<Object>(composedImage.getImages());
     List<ImageData> nestedImagesData = new ArrayList<ImageData>();
     for (Object nestedImage : images) {
       ImageData nestedImageData = getImageData(nestedImage);
       ComposedImage.Size size = new ComposedImage.Size();
       size.height = nestedImageData.height;
       size.width = nestedImageData.width;
       sizes.add(size);
       nestedImagesData.add(nestedImageData);
     }
   }
   return imageData;
 }
  @Test
  public void checkChildOverrideWithAnnotation() {
    // Setup
    ImageResource testImageResource = MyOverridedClientBundle.INSTANCE.testImageResource();

    // Test
    String name = testImageResource.getName();
    String url = testImageResource.getURL();
    int heigh = testImageResource.getHeight();
    int left = testImageResource.getLeft();
    int width = testImageResource.getWidth();
    int top = testImageResource.getTop();

    // Assert
    Assert.assertEquals("testImageResource", name);
    Assert.assertEquals(
        "http://127.0.0.1:8888/gwt_test_utils_module/com/octo/gwt/test/resources/override/override_testImageResource.gif",
        url);
    Assert.assertEquals(0, heigh);
    Assert.assertEquals(0, left);
    Assert.assertEquals(0, width);
    Assert.assertEquals(0, top);
  }
Beispiel #9
0
 public static AbstractImagePrototype getAbstractImagePrototype(ImageResource icon) {
   return IconHelper.createPath(icon.getURL(), icon.getWidth(), icon.getHeight());
 }