@Test public void checkSetSizeAttachesLoadHandler() { navigatorThumbnailItemView.setItemPxSize(100, 200); final ArgumentCaptor<LoadHandler> loadHandlerArgumentCaptor = ArgumentCaptor.forClass(LoadHandler.class); when(thumbImage.getWidth()).thenReturn(100); when(thumbImage.getHeight()).thenReturn(200); verify(thumbImage).addLoadHandler(loadHandlerArgumentCaptor.capture()); final LoadHandler loadHandler = loadHandlerArgumentCaptor.getValue(); assertNotNull(loadHandler); loadHandler.onLoad(mock(LoadEvent.class)); verify(body).setPixelSize(eq(100), eq(200)); }
@Override public NavigatorThumbnailItemView setItemPxSize(final int width, final int height) { thumbImage.addLoadHandler((e) -> { final int imgWidth = thumbImage.getWidth(); final int imgHeight = thumbImage.getHeight(); final float wfactor = imgWidth > width ? imgWidth / width : 1; final float hfactor = imgHeight > height ? imgHeight / height : 1; final float factor = wfactor >= hfactor ? wfactor : hfactor; int w = width; int h = height; if (factor > 1) { w = (int) Math.ceil(imgWidth / factor); h = (int) Math.ceil(imgHeight / factor); } thumbImage.setPixelSize(w, h); body.setPixelSize(width, height); }); return this; }
NavigatorThumbnailItemView extends Composite implements NavigatorItemView<NavigatorItem> { @Override public NavigatorThumbnailItemView setItemPxSize(final int width, final int height) { thumbImage.addLoadHandler((e) -> { final int imgWidth = thumbImage.getWidth(); final int imgHeight = thumbImage.getHeight(); final float wfactor = imgWidth > width ? imgWidth / width : 1; final float hfactor = imgHeight > height ? imgHeight / height : 1; final float factor = wfactor >= hfactor ? wfactor : hfactor; int w = width; int h = height; if (factor > 1) { w = (int) Math.ceil(imgWidth / factor); h = (int) Math.ceil(imgHeight / factor); } thumbImage.setPixelSize(w, h); body.setPixelSize(width, height); }); return this; } }
NavigatorThumbnailItemView extends Composite implements NavigatorItemView<NavigatorItem> { @Override public NavigatorThumbnailItemView setItemPxSize(final int width, final int height) { thumbImage.addLoadHandler((e) -> { final int imgWidth = thumbImage.getWidth(); final int imgHeight = thumbImage.getHeight(); final float wfactor = imgWidth > width ? imgWidth / width : 1; final float hfactor = imgHeight > height ? imgHeight / height : 1; final float factor = wfactor >= hfactor ? wfactor : hfactor; int w = width; int h = height; if (factor > 1) { w = (int) Math.ceil(imgWidth / factor); h = (int) Math.ceil(imgHeight / factor); } thumbImage.setPixelSize(w, h); body.setPixelSize(width, height); }); return this; }  }
NavigatorThumbnailItemView extends Composite implements NavigatorItemView<NavigatorItem> { @Override public NavigatorThumbnailItemView setItemPxSize(final int width, final int height) { thumbImage.addLoadHandler((e) -> { final int imgWidth = thumbImage.getWidth(); final int imgHeight = thumbImage.getHeight(); final float wfactor = imgWidth > width ? imgWidth / width : 1; final float hfactor = imgHeight > height ? imgHeight / height : 1; final float factor = wfactor >= hfactor ? wfactor : hfactor; int w = width; int h = height; if (factor > 1) { w = (int) Math.ceil(imgWidth / factor); h = (int) Math.ceil(imgHeight / factor); } thumbImage.setPixelSize(w, h); body.setPixelSize(width, height); }); return this; }  @Override void init(final NavigatorItem presenter); NavigatorThumbnailItemView select(); NavigatorThumbnailItemView deselect(); @Override NavigatorThumbnailItemView setUUID(final String uuid); @Override NavigatorThumbnailItemView setItemTitle(final String title); @Override NavigatorThumbnailItemView setThumbData(final String thumbData); @Override NavigatorThumbnailItemView setThumbUri(final SafeUri safeUri); @Override NavigatorThumbnailItemView setItemPxSize(final int width,
                                                    final int height); }
NavigatorThumbnailItemView extends Composite implements NavigatorItemView<NavigatorItem> { @Override public NavigatorThumbnailItemView setItemPxSize(final int width, final int height) { thumbImage.addLoadHandler((e) -> { final int imgWidth = thumbImage.getWidth(); final int imgHeight = thumbImage.getHeight(); final float wfactor = imgWidth > width ? imgWidth / width : 1; final float hfactor = imgHeight > height ? imgHeight / height : 1; final float factor = wfactor >= hfactor ? wfactor : hfactor; int w = width; int h = height; if (factor > 1) { w = (int) Math.ceil(imgWidth / factor); h = (int) Math.ceil(imgHeight / factor); } thumbImage.setPixelSize(w, h); body.setPixelSize(width, height); }); return this; }  @Override void init(final NavigatorItem presenter); NavigatorThumbnailItemView select(); NavigatorThumbnailItemView deselect(); @Override NavigatorThumbnailItemView setUUID(final String uuid); @Override NavigatorThumbnailItemView setItemTitle(final String title); @Override NavigatorThumbnailItemView setThumbData(final String thumbData); @Override NavigatorThumbnailItemView setThumbUri(final SafeUri safeUri); @Override NavigatorThumbnailItemView setItemPxSize(final int width,
                                                    final int height);  }