@Test public void checkURL() { Image i = new Image("http://my-url"); Assert.assertEquals("http://my-url", i.getUrl()); i.setUrl("newURL"); Assert.assertEquals("newURL", i.getUrl()); }
public static String getImageURL(int mode, AppW app) { // String modeText = app.getKernel().getModeText(mode); // // bugfix for Turkish locale added Locale.US // String iconName = "mode_" +StringUtil.toLowerCase(modeText) // + "_32"; // // macro if (mode >= EuclidianConstants.MACRO_MODE_ID_OFFSET) { int macroID = mode - EuclidianConstants.MACRO_MODE_ID_OFFSET; try { Macro macro = app.getKernel().getMacro(macroID); String iconName = macro.getIconFileName(); if (iconName == null || iconName.length() == 0) { // default icon return safeURI(myIconResourceBundle.mode_tool_32()); } // use image as icon Image img = new NoDragImage(app.getImageManager().getExternalImageSrc(iconName), 32); return img.getUrl(); } catch (Exception e) { App.debug("macro does not exist: ID = " + macroID); return ""; } } return safeURI(getImageURLNotMacro(mode)); }
/** * Utility method to create anchor tags * * @param image Image * @param relValue anchor "rel" attribute value * @return anchorElement Element */ private Element createAnchor(Image image, String relValue) { Element anchorElement = DOM.createAnchor(); DOM.setAttribute(anchorElement, "rel", relValue); DOM.setAttribute(anchorElement, "href", image.getUrl()); DOM.setAttribute(anchorElement, "title", image.getTitle()); DOM.appendChild(anchorElement, image.getElement()); return anchorElement; }
/** Share the data by using FB. */ private void onFbShareEvent() { MixpanelUtil.Click_On_FaceBook(); if (AppClientFactory.getCurrentPlaceToken().equals(PlaceTokens.PROFILE_PAGE)) { if (socialDo.getIsSearchShare()) { triggerShareDataEvent(PlayerDataLogEvents.FACEBOOK, false); SocialShareView.postOnFacebook( socialDo.getTitle(), socialDo.getRawUrl(), description, categoryImage.getUrl()); // Window.open( // "http://www.facebook.com/sharer/sharer.php?s=100&p[url]=" // + socialDo.getRawUrl() + "&p[images][0]=" // + socialDo.getThumbnailurl() + "&p[title]=" // + socialDo.getTitle().replaceAll("\\+", "%2B") + "&p[summary]=" + description, // "_blank", "width=626,height=436"); } else { triggerShareDataEvent(PlayerDataLogEvents.FACEBOOK, false); String title = i18n.GL1995() + " " + i18n.GL1433(); String token = Window.Location.getHref(); SocialShareView.postOnFacebook( title, socialDo.getRawUrl(), getAsHtml(description) + " " + token, categoryImage.getUrl()); // Window.open( // "http://www.facebook.com/sharer/sharer.php?s=100&p[url]=" // +socialDo.getRawUrl() + "&p[images][0]=" // + socialDo.getThumbnailurl() + "&p[title]=" // + "Check out "+socialDo.getTitle().replaceAll("\\+", "%2B")+" on Gooru" + // "&p[summary]=" + description, // "_blank", "width=626,height=436"); } } else { triggerShareDataEvent(PlayerDataLogEvents.FACEBOOK, false); SocialShareView.postOnFacebook( socialDo.getTitle(), socialDo.getRawUrl(), description, categoryImage.getUrl()); // Window.open( // "http://www.facebook.com/sharer/sharer.php?s=100&p[url]=" // + socialDo.getRawUrl() + "&p[images][0]=" // + socialDo.getThumbnailurl() + "&p[title]=" // + socialDo.getTitle().replaceAll("\\+", "%2B") + "&p[summary]=" + description, // "_blank", "width=626,height=436"); } }
public void testGwtImage() { final BeanFactory factory = (BeanFactory) GWT.create(HasGwtImageBeanFactory.class); assertNotNull(factory); final HasGwtImage bean = (HasGwtImage) factory.getBean(BEAN); assertNotNull(bean); final com.google.gwt.user.client.ui.Image image = bean.getImage(); assertNotNull(bean); final String url = image.getUrl(); assertTrue(url, url.length() > 0); }
public String getImageUrl() { return image.getUrl(); }
/** Initializes the Graphics */ public Graphics( FBCore fbCore, String userToken, String userEmail, String nickName, String playerRating, String playerRD) { initWidget(uiBinder.createAndBindUi(this)); treasureGridN = new Grid(1, 1); treasureGridN.setHeight(TREASURE_CHEST_HEIGHT + PADDING * 2 + "px"); treasureGridN.setCellPadding(PADDING); treasureGridS = new Grid(1, 1); treasureGridS.setHeight(TREASURE_CHEST_HEIGHT + PADDING * 2 + "px"); treasureGridS.setCellPadding(PADDING); AbsolutePanel treasurePanelN = new AbsolutePanel(); treasurePanelN.setSize(TREASURE_CHEST_WIDTH + "px", TREASURE_CHEST_HEIGHT + "px"); treasureGridN.setWidget(0, 0, treasurePanelN); AbsolutePanel treasurePanelS = new AbsolutePanel(); treasurePanelS.setSize(TREASURE_CHEST_WIDTH + "px", TREASURE_CHEST_HEIGHT + "px"); treasureGridS.setWidget(0, 0, treasurePanelS); gameGrid = new Grid(2, 6); gameGrid.resize(2, 6); for (int row = 0; row < 2; row++) { for (int col = 0; col < 6; col++) { AbsolutePanel pitPanel = new AbsolutePanel(); pitPanel.setSize(PIT_WIDTH + "px", PIT_HEIGHT + "px"); addSeeds(pitPanel, 0); if (row == 0) { handlerRegs[row][col] = pitPanel.addDomHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { // presenter.makeMove(colB); } }, ClickEvent.getType()); gameGrid.setWidget(row, 5 - col, pitPanel); // setPitEnabled(PlayerColor.NORTH, col, false); } else { handlerRegs[row][col] = pitPanel.addDomHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { // presenter.makeMove(colB); } }, ClickEvent.getType()); gameGrid.setWidget(row, col, pitPanel); // setPitEnabled(PlayerColor.SOUTH, col, true); } } } gameGrid.setCellPadding(20); gameAbsolutePanel.add(treasureGridN); gameAbsolutePanel.add(gameGrid, TREASURE_CHEST_WIDTH + 2 * PADDING, 0); gameAbsolutePanel.add( treasureGridS, TREASURE_CHEST_WIDTH + 14 * PADDING + PIT_WIDTH * 6 + 6 * 2, 0); gameAbsolutePanel.setSize( 12 + TREASURE_CHEST_WIDTH * 2 + 16 * PADDING + PIT_WIDTH * 6 + "px", 4 + 4 * PADDING + 2 * PIT_HEIGHT + "px"); gameAbsolutePanel.getElement().getStyle().setProperty("margin", "auto"); DOM.setStyleAttribute(gameAbsolutePanel.getElement(), "backgroundColor", "#b0c4de"); Image bgImg = new Image(); bgImg.setResource(gameImages.board()); DOM.setStyleAttribute( gameAbsolutePanel.getElement(), "backgroundImage", "url(" + bgImg.getUrl() + ")"); // Create a CellList. ContactCell contactCell = new ContactCell(); // Set a key provider that provides a unique key for each contact. If key is used to identify // contacts when fields (such as // the name and address) change. cellList = new CellList<ContactInfo>(contactCell, ContactInfo.KEY_PROVIDER); cellList.setPageSize(30); cellList.setKeyboardPagingPolicy(KeyboardPagingPolicy.INCREASE_RANGE); cellList.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.BOUND_TO_SELECTION); // Add a selection model so we can select cells. final SingleSelectionModel<ContactInfo> selectionModel = new SingleSelectionModel<ContactInfo>(ContactInfo.KEY_PROVIDER); cellList.setSelectionModel(selectionModel); selectionModel.addSelectionChangeHandler( new SelectionChangeEvent.Handler() { public void onSelectionChange(SelectionChangeEvent event) { showPlayGameElements(selectionModel.getSelectedObject()); } }); // Set the cellList as the display of the pagers. This example has two pagers. pagerPanel is a // scrollable pager that extends // the range when the user scrolls to the bottom. rangeLabelPager is a pager that displays the // current range, but does not // have any controls to change the range. contactsPanel.setDisplay(cellList); // rangeLabelPager.setDisplay(cellList); presenter = new Presenter(this, fbCore, userEmail.toLowerCase(), userToken); turnLabel.setHorizontalAlignment(Label.ALIGN_CENTER); warnLabel.setHorizontalAlignment(Label.ALIGN_CENTER); aiMovesLabel.setHorizontalAlignment(Label.ALIGN_CENTER); hideStartGameElements(); initializeAudios(); initializeHandlers(); // presenter.setState(Presenter.deserializeState(stateStr)); setUserNameLabelText("Name: " + nickName + " (" + playerRating + "|" + playerRD + ")"); initializeUILanguage(); }