private Frame createFrame() { final Frame frame = new Frame(DEFAULT_TEMPLATE_PATH); frame.getElement().setId(DEFAULT_FRAME_NAME); frame.setTitle(UIMessages.INSTANCE.previewTitle()); frame.setWidth("500px"); frame.setHeight("500px"); frame.getElement().getStyle().setBackgroundColor("gray"); frame.setVisible(true); RootPanel.get().add(frame); frame.addLoadHandler(new LoadHandler() { @Override public void onLoad(LoadEvent event) { frame.getElement().getStyle().setBackgroundColor("white"); zoomPageComboBox.setValue(75); } }); return frame; }
public void setImageUrl(String src, int width, int height) { this.width = width; this.height = height; imageView = new Image(); imageView.setUrl(src); RootPanel.get().add(imageView); imageView.addLoadHandler(new LoadHandler() { @Override public void onLoad(final LoadEvent event) { imageView.removeFromParent(); createCanvasAndAddToView(imageView); if (loadHandler.isPresent()) { loadHandler.get().onLoad(event); } } }); }
@Test public void onAreaClick() throws Exception { // before ColorfillAreaClickListener colorfillAreaClickListener = mock(ColorfillAreaClickListener.class); instance.setAreaClickListener(colorfillAreaClickListener); when(canvasImageDataProvider.getCanvasImageData(canvasStubView)).thenReturn(imageData); ArgumentCaptor<LoadHandler> loadHandlerCaptor = ArgumentCaptor.forClass(LoadHandler.class); verify(canvasStubView).setImageLoadHandler(loadHandlerCaptor.capture()); loadHandlerCaptor.getValue() .onLoad(null); ArgumentCaptor<Command> commandCaptor = ArgumentCaptor.forClass(Command.class); verify(userInteractionHandlerFactory).applyUserClickHandler(commandCaptor.capture(), eq(canvas)); NativeEvent nativeEvent = mock(NativeEvent.class); commandCaptor.getValue() .execute(nativeEvent); ArgumentCaptor<Area> areaCaptor = ArgumentCaptor.forClass(Area.class); verify(colorfillAreaClickListener).onAreaClick(areaCaptor.capture()); verify(nativeEvent).preventDefault(); Area area = areaCaptor.getValue(); assertThat(area.getX()).isEqualTo(POSITION_X); assertThat(area.getY()).isEqualTo(POSITION_Y); }
@Test public void onAreaClickWrongCoordinates() throws Exception { ColorfillAreaClickListener colorfillAreaClickListener = mock(ColorfillAreaClickListener.class); instance.setAreaClickListener(colorfillAreaClickListener); when(canvasImageDataProvider.getCanvasImageData(canvasStubView)).thenReturn(imageData); doReturn(-10).when(positionHelper) .getXPositionRelativeToTarget(any(NativeEvent.class), Matchers.any(Element.class)); doReturn(-15).when(positionHelper) .getYPositionRelativeToTarget(any(NativeEvent.class), Matchers.any(Element.class)); ArgumentCaptor<LoadHandler> loadHandlerCaptor = ArgumentCaptor.forClass(LoadHandler.class); verify(canvasStubView).setImageLoadHandler(loadHandlerCaptor.capture()); loadHandlerCaptor.getValue() .onLoad(null); ArgumentCaptor<Command> commandCaptor = ArgumentCaptor.forClass(Command.class); verify(userInteractionHandlerFactory).applyUserClickHandler(commandCaptor.capture(), eq(canvas)); NativeEvent nativeEvent = mock(NativeEvent.class); commandCaptor.getValue() .execute(nativeEvent); verify(colorfillAreaClickListener, times(0)).onAreaClick(any(Area.class)); }
protected void handleDoubleClick(TableData.Row row) { VerticalPanel vp = new VerticalPanel(); final Image previewImage = new Image(getFullSizeUrl(row)); final HTML caption = new HTML(getPopUpCaption(row)); String title = getThumbnailDesc(row).replace("<em>", "").replace("</em>", ""); caption.setWidth("320px"); previewImage.addLoadHandler(new LoadHandler() { public void onLoad(LoadEvent ev) { caption.setWidth(previewImage.getWidth() + "px"); } }); GwtUtil.setStyle(vp, "margin", "8px"); vp.setCellHorizontalAlignment(previewImage, HasHorizontalAlignment.ALIGN_CENTER); vp.setCellVerticalAlignment(previewImage, HasVerticalAlignment.ALIGN_MIDDLE); vp.add(previewImage); vp.add(caption); PopupPane popupPane = new PopupPane(title, vp, PopupType.STANDARD, false, false); popupPane.show(); }
public void startDownloadRequest(String aUrlPrefix, final int aRequestType, Map<String, String> aParams, RequestBuilder.Method aMethod) throws Exception { final Frame frame = new Frame(); frame.setVisible(false); frame.addLoadHandler(new LoadHandler() { @Override public void onLoad(LoadEvent event) { Timer timer = new Timer() { @Override public void run() { frame.removeFromParent(); } }; timer.schedule(2000); } }); String query = ""; for (Map.Entry<String, String> ent : aParams.entrySet()) { query += param(ent.getKey(), ent.getValue()) + "&"; } query += param(PlatypusHttpRequestParams.TYPE, String.valueOf(aRequestType)); frame.setUrl(apiUrl + aUrlPrefix + "?" + query); RootPanel.get().add(frame); }
public TileSet(String path, int tileSize) { this.tileSize = tileSize; img = new Image(); // TODO add to a hidden block RootPanel.get("resourceLoader").add(img); img.addLoadHandler(new LoadHandler() { @Override public void onLoad(LoadEvent event) { imgElement = ImageElement.as(img.getElement()); initImageParameters(imgElement.getWidth(), imgElement.getHeight()); } }); img.setUrl(path); }
public void setHTML(final String html) { if (!isLoaded) { loadHandler = addLoadHandler(new LoadHandler() { @Override public void onLoad(LoadEvent event) { Scheduler.get().scheduleDeferred( new Scheduler.ScheduledCommand() { @Override public void execute() { _setHTML(html); } }); } }); } else { _setHTML(html); } }
private void createHiddenFrame(PrintFinishedInfo info) { final Frame frame = new Frame(); frame.setVisible(false); UrlBuilder builder = new UrlBuilder(info.getUrl()); for (String name : info.getParams().keySet()) { builder.addParameter(name, info.getParams().get(name)); } frame.setUrl(builder.toString()); frame.setPixelSize(0, 0); frame.getElement().getStyle().setPosition(Style.Position.ABSOLUTE); frame.getElement().getStyle().setBorderWidth(0, Style.Unit.PX); frame.addLoadHandler(new LoadHandler() { @Override public void onLoad(LoadEvent event) { frame.removeFromParent(); } }); RootPanel.get().add(frame); }
@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)); }
public SpritePlateAnimation(String imageUrl, double frameRate, int frameCount, int framesAcross) { m_frameRate = frameRate; m_frameCount = frameCount; m_framesAcross = framesAcross; Image img = new Image(); m_image = ImageElement.as(img.getElement()); img.addLoadHandler(new LoadHandler() { @Override public void onLoad(LoadEvent event) { m_loaded = true; m_frameWidth = m_image.getWidth() / m_framesAcross; int framesDown = m_frameCount / m_framesAcross; framesDown += (m_frameCount % m_framesAcross) > 0 ? 1 : 0; m_frameHeight = m_image.getHeight() / framesDown; } }); img.setVisible(false); RootPanel.get().add(img); img.setUrl(imageUrl); }
@Override public void add(final Widget child) { if(child instanceof GalleryImage) { ((GalleryImage) child).addLoadHandler(new LoadHandler() { @Override public void onLoad(LoadEvent event) { if(thumbnailWidth != null) { child.setWidth(thumbnailWidth); } if(thumbnailHeight != null) { child.setHeight(thumbnailHeight); } } }); super.add(child); } else { throw new IllegalArgumentException("Gallery can only contain GalleryImage's."); } }
public void init(final ExternalEmpiriaApi api, final ExternalFrameLoadHandler<T> onLoadHandler) { frame.addLoadHandler(new LoadHandler() { @Override public void onLoad(LoadEvent event) { T obj = init(frame.getElement(), api); onLoadHandler.onExternalModuleLoaded(obj); } }); }
@PostConstruct public void postConstruct() { canvasStubView.setPanelStyle(styleNameConstants.QP_COLORFILL_IMG()); canvasStubView.setImageLoadHandler(new LoadHandler() { @Override public void onLoad(LoadEvent event) { canvasStubViewLoded = true; bindView(); } }); }
@Test public void bindView() throws Exception { // before ColorfillAreaClickListener colorfillAreaClickListener = mock(ColorfillAreaClickListener.class); when(canvasImageDataProvider.getCanvasImageData(canvasStubView)).thenReturn(imageData); instance.setAreaClickListener(colorfillAreaClickListener); ArgumentCaptor<LoadHandler> argumentCaptor = ArgumentCaptor.forClass(LoadHandler.class); verify(canvasStubView).setImageLoadHandler(argumentCaptor.capture()); argumentCaptor.getValue() .onLoad(null); verify(userInteractionHandlerFactory).applyUserClickHandler(any(Command.class), eq(canvas)); verify(imageData).flush(); }
/** * Creates texture region from byte[]. * <p> * GWT platform requires additional step (as far as i know) to deal with Pixmap. It is need to load Image element * and wait until it is loaded. * * @param bytes Image byte[] representation, not null * @param consumer Consumer where you should deal with region, not null */ public static void createTextureFromBytes(byte[] bytes, final Consumer<TextureRegion> consumer) { String base64 = "data:image/png;base64," + new String(Base64Coder.encode(bytes)); final Image image = new Image(); image.setVisible(false); image.addLoadHandler(new LoadHandler() { @Override public void onLoad(LoadEvent event) { ImageElement imageElement = image.getElement().cast(); Pixmap pixmap = new Pixmap(imageElement); Gdx.app.log("ImageHelper", "pixmap: " + pixmap.getWidth() + "/" + pixmap.getHeight()); final int orgWidth = pixmap.getWidth(); final int orgHeight = pixmap.getHeight(); int width = MathUtils.nextPowerOfTwo(orgWidth); int height = MathUtils.nextPowerOfTwo(orgHeight); final Pixmap potPixmap = new Pixmap(width, height, pixmap.getFormat()); potPixmap.drawPixmap(pixmap, 0, 0, 0, 0, pixmap.getWidth(), pixmap.getHeight()); pixmap.dispose(); TextureRegion region = new TextureRegion(new Texture(potPixmap), 0, 0, orgWidth, orgHeight); potPixmap.dispose(); RootPanel.get().remove(image); consumer.accept(region); } }); image.setUrl(base64); RootPanel.get().add(image); }
/** * Enlarges image on page */ private static void createImageDialog(String img) { // Create the UI elements of the DialogBox final DialogBox dialogBox = new DialogBox(true, true); // DialogBox(autohide, modal) dialogBox.setStylePrimaryName("ode-DialogBox"); dialogBox.setGlassEnabled(true); dialogBox.setAnimationEnabled(true); VerticalPanel DialogBoxContents = new VerticalPanel(); FlowPanel holder = new FlowPanel(); Button ok = new Button("Close"); ok.addClickListener(new ClickListener() { public void onClick(Widget sender) { dialogBox.hide(); } }); ok.setStyleName("DialogBox-button"); // Adds Image Image image = new Image(img); image.addLoadHandler(new LoadHandler() { public void onLoad(LoadEvent evt) { dialogBox.center(); } }); image.setStyleName("DialogBox-image"); holder.add(ok); DialogBoxContents.add(image); DialogBoxContents.add(holder); dialogBox.setWidget(DialogBoxContents); dialogBox.center(); dialogBox.show(); }
private void initIFrame() { final Frame iframe = new Frame("javascript:\"\""); iframe.getElement().setAttribute("name", id); iframe.getElement().setAttribute("style", "position:absolute;width:0;height:0;border:0"); iframe.addLoadHandler(new LoadHandler() { @Override public void onLoad(LoadEvent arg0) { String content = IFrameElement.as(iframe.getElement()).getContentDocument().getBody().getInnerHTML(); if (content != null && !"".equals(content)) formPanel.fireEvent(new SubmitCompleteEvent(content) { }); } }); flowPanel.add(iframe); }
private void getMap() { // canvas size in px final int width = 1121; final int height = 2585; // get the 2D rendering context context = mapCanvas.getContext2d(); // initialize the canvas mapCanvas.setWidth(width + "px"); mapCanvas.setHeight(height + "px"); mapCanvas.setPixelSize(width, height); mapCanvas.setCoordinateSpaceWidth(width); mapCanvas.setCoordinateSpaceHeight(height); container.setWidth(width + "px"); final Image seattleImage = new Image(Resources.INSTANCE.seattleArea()); seattleImage.addLoadHandler(new LoadHandler() { @Override public void onLoad(LoadEvent event) { ImageElement imageElement = seattleImage.getElement().cast(); context.drawImage(imageElement, 0, 0); } }); seattleImage.setVisible(false); container.add(seattleImage); }
private void getMap() { // Tacoma map canvas size in px final int width = 1360; final int height = 1204; // get the 2D rendering context context = mapCanvas.getContext2d(); // initialize the canvas mapCanvas.setWidth(width + "px"); mapCanvas.setHeight(height + "px"); mapCanvas.setPixelSize(width, height); mapCanvas.setCoordinateSpaceWidth(width); mapCanvas.setCoordinateSpaceHeight(height); container.setWidth(width + "px"); final Image tacomaImage = new Image(Resources.INSTANCE.tacomaArea()); tacomaImage.addLoadHandler(new LoadHandler() { @Override public void onLoad(LoadEvent event) { ImageElement imageElement = tacomaImage.getElement().cast(); context.drawImage(imageElement, 0, 0); } }); tacomaImage.setVisible(false); container.add(tacomaImage); }
public QMap(String imageURL) { mapWidget = new MapWidget(); super.add(mapWidget); final Image image = new Image(imageURL); image.addLoadHandler(new LoadHandler() { @Override public void onLoad(LoadEvent event) { mapWidget.bindImage(image); } }); super.add(image); }
/** * Creates the general parameters panel. * * @return The general parameters panel. */ private ContentPanel createGeneralParametersPanel() { final ContentPanel panel = Panels.content(I18N.CONSTANTS.organizationManagementTitle(), CSS_ADMIN_PARAMETERS); generalForm = Forms.panel(150); generalOrganizationNameTextField = Forms.text(I18N.CONSTANTS.organizationManagementOrganizationName(), true); generalForm.add(generalOrganizationNameTextField); generalLogoFileField = Forms.upload(I18N.CONSTANTS.organizationManagementLogoUpload()); generalForm.add(generalLogoFileField); generalLogoPreview = new Image(); final SimplePanel previewWrapper = new SimplePanel(generalLogoPreview); previewWrapper.setStyleName(CSS_PREVIEW_WRAPPER); final AdapterField logoImageField = new AdapterField(previewWrapper); logoImageField.setFieldLabel(I18N.CONSTANTS.organizationManagementActualLogo()); logoImageField.setResizeWidget(false); generalForm.add(logoImageField); generalLogoPreview.addLoadHandler(new LoadHandler() { @Override public void onLoad(final LoadEvent event) { final Pair<Integer, Integer> ratio = ClientUtils.ratio(generalLogoPreview.getWidth(), generalLogoPreview.getHeight(), generalForm.getFieldWidth(), LOGO_IMAGE_HEIGHT); generalLogoPreview.setPixelSize(ratio.left, ratio.right); } }); generalSaveButton = Forms.button(I18N.CONSTANTS.organizationManagementSaveChanges(), IconImageBundle.ICONS.save()); generalForm.addButton(generalSaveButton); panel.add(generalForm); return panel; }
private void loadCustomUIFrame() { String htmlString = HTML_STRING; // String url = GADGET_SERVER_URL + "?url=" + gadgetUrl + "&up_id=divEditor&view=editor"; // url += "&source=" + URL.encodeQueryString(Window.Location.getHref()) + // "&parent=" + URL.encodeQueryString(Window.Location.getHref()) + //// "&container=open&view=home&lang=all&country=ALL&debug=0&nocache=0&sanitize=0" + // "&libs=core%3Acore.io#st=%25st%25" + // ""; htmlString = htmlString // .replace("%url%", url) .replace("\n", "") .replace("\r", ""); String params = gadgetSettings.getAdditionalParams() != null ? gadgetSettings.getAdditionalParams() : ""; params = params.replace("\"", "\\\""); htmlString = htmlString.replace("%s1%", params); this.addLoadHandler(new LoadHandler() { @Override public void onLoad(LoadEvent event) { loadEditorNative(getElement(), gadgetSettings.getGadgetHtml(true)); } }); HtmlUtils.writeHtml(getElement(), htmlString); // getElement().setInnerHTML(htmlString); // frame.setUrl("/GadgetCustomUI.html"); //frame.setUrl("/GadgetCustomUI.html?url="+gadgetUrl); }
public ESBGraphicalEditor() { editorFrame = new Frame("/esbeditor/index.html"); editorFrame.addLoadHandler(new LoadHandler() { @Override public void onLoad(LoadEvent event) { frameLoaded(); } }); editorFrame.setSize("100%", "100%"); }
private void loadModules() { BusyFeatureConsumer.get().call(true); ModuleServiceConsumer.get().getModules(new AsyncCallback<List<ModuleBean>>() { @Override public void onSuccess(List<ModuleBean> modules) { LOG.info("DynamicHost.onModuleLoad#getModules#onSuccess: modules=" + modules); final ModuleReadyFeatureProvider moduleReadyFeatureProvider = new ModuleReadyFeatureProvider(modules, LOAD_TIMEOUT); moduleReadyFeatureProvider.addLoadHandler(new LoadHandler() { @Override public void onLoad(LoadEvent event) { LOG.info("DynamicHost.onModuleLoad#ModuleReadyFeatureProvider.onLoad: unreadyModules=" + moduleReadyFeatureProvider.getUnreadyModules()); BusyFeatureConsumer.get().call(false); onModulesLoaded(moduleReadyFeatureProvider.getReadyModules()); } }); ModuleLoader.INSTANCE.load(modules); } @Override public void onFailure(Throwable caught) { LOG.log(Level.SEVERE, "DynamicHost.onModuleLoad#getModules#onFailure:", caught); BusyFeatureConsumer.get().call(false); onModulesLoaded(null); } }); }
/** * Tworzy obiekt html5/canvas * * @param element * @param moduleSocket */ private void fillCanvas(final Element element, final ModuleSocket moduleSocket) { styles = styleSocket.getStyles(element); Element titleNodes = XMLUtils.getFirstElementWithTagName(element, "title"); final String title = XMLUtils.getTextFromChilds(titleNodes); image.addLoadHandler(new LoadHandler() { @Override public void onLoad(LoadEvent event) { canvas.setWidth(image.getWidth() + "px"); canvas.setCoordinateSpaceWidth(image.getWidth()); canvas.setHeight(image.getHeight() + "px"); canvas.setCoordinateSpaceHeight(image.getHeight()); canvas.setTitle(title); mainPanel.setWidth(image.getWidth() + "px"); mainPanel.setHeight(image.getHeight() + "px"); textPanel.setWidth(image.getWidth() + "px"); textPanel.setHeight(image.getHeight() + "px"); // imgelement. Context2d context2d = canvas.getContext2d(); setContextStyle(context2d); NodeList labelList = element.getElementsByTagName("label"); for (int x = 0; x < labelList.getLength(); ++x) { Element label = (Element) labelList.item(x); // ustawiony czas nie obslugujemy w pictureplayer if (getAttributeAsInt(label, "start") != 0) { continue; } Element anchor = getFirstElementWithTagName(label, "anchor"); Element line = getFirstElementWithTagName(label, "line"); Element text = getFirstElementWithTagName(label, "text"); if (line != null) { parseLine(line, context2d); } if (text != null && anchor != null) { textPanel.add(parseText(text, anchor, moduleSocket)); } } mathJaxNative.renderMath(); } }); image.setUrl(element.getAttribute("src")); }
public void setImageLoadHandler(LoadHandler loadHandler) { this.loadHandler = Optional.fromNullable(loadHandler); }
public IESafeImage(LoadHandler loadHandler) { this(); setInitLoadHandlerReg(addLoadHandler(loadHandler)); }
public void load() { if (!loading && GWT.isClient()) { String mapParameter = Window.Location.getParameter("map"); if (mapParameter != null && !mapParameter.isEmpty()) { loading=true; mapName = mapParameter; mapFile = null; final Image img = new Image("img.php?mode=native&url=" + mapParameter); img.setVisible(false); RootPanel.get().add(img); img.addLoadHandler(new LoadHandler() { @Override public void onLoad(LoadEvent event) { Gdx.app.postRunnable(new Runnable() { @Override public void run() { ImageElement imgElement = ImageElement.as(img.getElement()); RootPanel.get().remove(img); Pixmap pixmap = new ScreenshotHelper().asPixmap(imgElement); if (pixmap != null) { Layer layer = layerManager.getLayer("RAW", RenderMask.Mask.BASIC); layer.drawPixmapToFit(pixmap); layer.invalidateTexture(); pixmap.dispose(); processed = true; world.getSystem(RefreshHandlerSystem.class).restart(); } } }); } }); } } if (!loading && mapFile != null) { loading = true; processed = true; layerManager.getLayer("RAW", RenderMask.Mask.BASIC).drawPixmapToFit(new Pixmap(Gdx.files.internal(mapFile))); } }
public UIObject render(ComponentGVO component, String uuid, String parent, String context) { Panel uiObject = null; if (component != null) { if (component instanceof MapGVO) { MapGVO gvo = (MapGVO) component; if (gvo.getMenu() != null) { final ComponentGVO finalComponentGVO = component; final String finalUuid = uuid; final String finalParent = parent; uiObject = new FlowPanel() { @Override public void onBrowserEvent(Event event) { if (event.getTypeInt() == Event.ONCONTEXTMENU) { DOM.eventPreventDefault(event); applyContextMenu(event, finalComponentGVO, finalUuid, finalParent); } super.onBrowserEvent(event); } @Override protected void setElement(Element elem) { super.setElement(elem); sinkEvents(Event.ONCONTEXTMENU); } }; } else { uiObject = new FlowPanel(); } AreaGVO[] areas = gvo.getAreas(); AreaWidget areasWidget[] = null; if (areas != null) { areasWidget = new AreaWidget[areas.length]; for (int i = 0; i < areas.length; i++) { if (areas[i] != null) { areasWidget[i] = new AreaWidget(areas[i].getShape(), areas[i].getCoords(), areas[i].getAlt(), null); } } } final Image image = new Image(); image.setUrl(gvo.getImageUrl()); uiObject.add(image); final MapWidget map = new MapWidget(areasWidget); for (int i = 0; i < areasWidget.length; i++) { String tempId = gvo.getId(); gvo.setId(gvo.getId() + "-" + i); RendererHelper.fillIn(gvo, areasWidget[i], uuid, parent, context); gvo.setId(tempId); } // Id is set by the RendererHelper RendererHelper.fillIn(component, map, uuid, parent, context); map.setName(map.getID()); image.addLoadHandler(new LoadHandler() { public void onLoad(LoadEvent event) { map.bindImage(image); } }); uiObject.add(map); } } return uiObject; }
public PublicImage(String url, LoadHandler loadHandler, ErrorHandler errorHandler) { addLoadHandler(loadHandler); addErrorHandler(errorHandler); setUrl(url); }
public HandlerRegistration addLoadHandler(LoadHandler handler) { return addHandler(handler, LoadEvent.getType()); }
@Override public HandlerRegistration addLoadHandler(final LoadHandler handler) { return super.addDomHandler(handler, LoadEvent.getType()); }
@Override public HandlerRegistration addLoadHandler(LoadHandler handler) { return image.addHandler(handler, LoadEvent.getType()); }
@Override public HandlerRegistration addLoadHandler(LoadHandler handler) { return handlerManager.addHandler(LoadEvent.getType(), handler); }