Example usage for com.google.gwt.user.client.ui Image prefetch

List of usage examples for com.google.gwt.user.client.ui Image prefetch

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui Image prefetch.

Prototype

public static void prefetch(SafeUri url) 

Source Link

Document

Causes the browser to pre-fetch the image at a given URL.

Usage

From source file:asquare.gwt.tk.client.ui.AlertDialog.java

License:Apache License

/**
 * Set the image will be displayed in the caption. You can use an
 * {@link Icon} to ensure size information is available when the dialog
 * layout is calculated.//from w  w w . ja v  a 2  s. c o m
 * 
 * @param icon an image or null
 * @see Icon
 */
public void setIcon(Image icon) {
    if (m_captionIcon != null) {
        m_captionIcon = null;
    }
    if (icon != null) {
        m_captionIcon = icon;
        m_captionIcon.addStyleName("tk-AlertDialog-captionIcon");
        Image.prefetch(icon.getUrl());
    }
}

From source file:cc.kune.core.client.init.PrefetchUtilities.java

License:GNU Affero Public License

/**
 * Do tasks deferred.//from w ww .j a v a 2 s  .  c  o  m
 */
public void doTasksDeferred() {

    Scheduler.get().scheduleIncremental(new RepeatingCommand() {
        String[] ext = { "default/shadow-c.png", "default/shadow-lr.png", "default/shadow.png",
                "gray/window/left-corners.png", "gray/window/left-right.png", "gray/window/right-corners.png",
                "gray/window/top-bottom.png" };
        int i = 0;

        int j = 0;

        String[] lic = { "gnu-fdl.gif", "bynd80x15.png", "byncsa80x15.png", "byncnd80x15.png", "bync80x15.png",
                "by80x15.png", "fal-license.gif" };

        @Override
        public boolean execute() {

            while (i < lic.length) {
                final String licImg = lic[i];
                Image.prefetch(FileConstants.ASITE_PREFIX + "images/lic/" + licImg);
                i++;
            }

            while (j < ext.length) {
                final String extImg = ext[j];
                Image.prefetch(FileConstants.ASITE_PREFIX + "gxt/images/" + extImg);
                j++;
            }

            final boolean notFinished = i + j < lic.length + ext.length;

            final boolean finished = !notFinished;

            if (finished) {
                // Nothing currently
            }

            return notFinished;
        }
    });
}

From source file:cc.kune.core.client.init.PrefetchUtilities.java

License:GNU Affero Public License

/**
 * Pre fetch imp images./*from ww w  .  ja v  a  2  s  . c om*/
 */
public void preFetchImpImages() {
    final String[] imgs = { "images/corner.png", "images/hborder.png" };

    for (final String img : imgs) {
        Image.prefetch(FileConstants.ASITE_PREFIX + img);
    }
}

From source file:com.calclab.emiteuimodule.client.ImagesHelper.java

License:Open Source License

public static void preFetchImages() {
    DeferredCommand.addCommand(new Command() {
        public void execute() {
            final String[] imgs = { "ext-load.gif", "group_add.gif", "group-chat.gif", "moderatoruser.gif",
                    "normaluser.gif", "person-def.gif", "smile.gif", "user_add.gif", "user-unavail.gif" };
            final String[] cssImgs = { "add.gif", "cancel.gif", "emite-chat.gif", "colors.gif ", "del.gif",
                    "exit.gif", "extload.gif", "forbidden.gif", "group-chat.gif", "group.gif", "new-chat.gif",
                    "new-message.gif", "useradd.gif", "userf.gif", "user.gif", "e-icon.gif", "e-icon-a.gif" };
            prefetchImages(imgs, "images");
            prefetchImages(cssImgs, "images");
        }//w ww. j  ava  2  s  . c  o m

        private void prefetchImages(final String[] imgs, final String prefix) {
            for (int i = 0; i < imgs.length; i++) {
                final String img = imgs[i];
                Image.prefetch(prefix + "/" + img);
            }
        }
    });
}

From source file:com.fullmetalgalaxy.client.game.context.WgtContextMinimap.java

License:Open Source License

public void redraw() {
    assert GameEngine.model() != null;
    Game game = GameEngine.model().getGame();

    // if( m_lastResfreshTurn != game.getCurrentTimeStep() ||
    // m_lastResfreshGameId != game.getId() )
    {//from w  w  w . ja  v a2 s  .c o m
        m_lastResfreshTurn = game.getCurrentTimeStep();
        m_lastResfreshGameId = game.getId();

        canvas.setCoordinateSpaceWidth(game.getLandWidth() * 8);
        canvas.setCoordinateSpaceHeight(game.getLandHeight() * 8 + 4);

        Context2d gc = canvas.getContext2d();
        gc.clearRect(0, 0, game.getLandWidth(), game.getLandHeight());

        // draw lands
        ImageElement[] images = new ImageElement[LandType.values().length];
        for (int iLand = 0; iLand < LandType.values().length; iLand++) {
            LandType land = LandType.values()[iLand];
            Image img = new Image("/images/board/" + game.getPlanetType().getFolderName() + "/minimap/"
                    + land.getImageName(game.getCurrentTide()));
            img.addLoadHandler(new LoadHandler() {
                @Override
                public void onLoad(LoadEvent event) {
                    m_lastResfreshTurn = -1;
                    m_lastResfreshGameId = -1;
                }
            });
            images[iLand] = ImageElement.as(img.getElement());
            Image.prefetch(img.getUrl());
        }
        for (int ix = 0; ix < game.getLandWidth(); ix++) {
            for (int iy = 0; iy < game.getLandHeight(); iy++) {
                if (game.getLand(ix, iy) == LandType.Montain) {
                    gc.drawImage(images[game.getLand(ix, iy).ordinal()], ix * 8, iy * 8 + (ix % 2) * 4, 8, 8);
                } else {
                    gc.drawImage(images[game.getLand(ix, iy).ordinal()], ix * 8, iy * 8 + (ix % 2) * 4, 8, 8);
                }
            }
        }

        // draw units
        for (EbToken token : game.getSetToken()) {
            if (token.getLocation() == Location.Board && token.getColor() != EnuColor.None) {
                gc.drawImage(tokenImages[token.getColor()], token.getPosition().getX() * 8,
                        token.getPosition().getY() * 8 + (token.getPosition().getX() % 2) * 4, 8, 8);
                for (AnBoardPosition position : token.getExtraPositions(game.getCoordinateSystem())) {
                    gc.drawImage(tokenImages[token.getColor()], position.getX() * 8,
                            position.getY() * 8 + (position.getX() % 2) * 4, 8, 8);
                }
            }
        }
    }

    if (game.getStatus() == GameStatus.Open || game.getStatus() == GameStatus.Pause) {
        m_panel.add(new Image(Icons.s_instance.pause32()), FmpConstant.miniMapWidth / 2 - 16,
                FmpConstant.miniMapHeight / 2 - 16);
        m_panel.add(new Label("En Pause"), 0, FmpConstant.miniMapHeight / 2 + 30);
    } else if (game.isFinished()) {
        m_panel.add(new Label("Partie termine"), 0, FmpConstant.miniMapHeight / 2 - 40);
        m_panel.add(new Image(Icons.s_instance.winner32()), FmpConstant.miniMapWidth / 2 - 16,
                FmpConstant.miniMapHeight / 2 - 16);
        String strWinner = "";
        EbTeam winnerTeam = game.getWinnerTeam();
        if ((winnerTeam != null)) {
            strWinner += winnerTeam.getCompany().getFullName() + ":\n";
            for (EbRegistration registration : winnerTeam.getPlayers(game.getPreview()))
                if (registration.haveAccount()) {
                    strWinner += registration.getAccount().getPseudo() + "\n";
                }
        }
        m_panel.add(new Label(strWinner), 0, FmpConstant.miniMapHeight / 2 + 30);
    }

}

From source file:com.italianasoftware.echoes.client.Echoes.java

License:Open Source License

public void onModuleLoad() {
    createLyricsDialog();//from w  w w. j  a va2  s .c  o m

    Image.prefetch(logoURL);
    location.setText("socket://localhost:10100");

    VerticalPanel mainVPanel = new VerticalPanel();
    mainVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);
    RootPanel.get().add(mainVPanel);

    HorizontalPanel hPanel;
    hPanel = new HorizontalPanel();
    mainVPanel.add(hPanel);

    VerticalPanel vPanel = new VerticalPanel();
    hPanel.add(vPanel);
    VerticalPanel playlistVPanel = new VerticalPanel();
    playlistVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);
    playlistVPanel.setVerticalAlignment(VerticalPanel.ALIGN_MIDDLE);
    hPanel.add(playlistVPanel);

    vPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);
    vPanel.setVerticalAlignment(VerticalPanel.ALIGN_MIDDLE);
    Image logo = new Image(logoURL);
    createAboutDialog();
    logo.addClickListener(new ClickListener() {
        public void onClick(Widget arg0) {
            aboutDialog.center();
            aboutDialog.show();
        }
    });
    vPanel.add(logo);
    vPanel.addStyleName("panel-rightborder");

    //hPanel = new HorizontalPanel();
    DisclosurePanel dPanel = new DisclosurePanel("Location", false);
    VerticalPanel locVPanel = new VerticalPanel();
    locVPanel.setHorizontalAlignment(HorizontalPanel.ALIGN_CENTER);
    locVPanel.add(location);
    final Button connectButton = new NativeButton("Connect");
    connectButton.addClickListener(new ClickListener() {
        public void onClick(Widget arg0) {
            startClientSession();
            waitForStateChange();
            connectButton.setText("Connected");
            connectButton.setEnabled(false);
        }
    });

    dPanel.add(locVPanel);
    //hPanel.add( dPanel );
    vPanel.add(dPanel);
    vPanel.add(connectButton);

    //hPanel = new HorizontalPanel();
    Label l = new Label("Currently playing");
    l.addStyleName("label-bold");
    mainVPanel.add(l);
    mainVPanel.add(cpLabel);
    //mainvPanel.add( hPanel );

    HorizontalPanel buttonsPanel = new HorizontalPanel();
    mainVPanel.add(buttonsPanel);

    Button playButton = new NativeButton("Play");
    playButton.addClickListener(new ClickListener() {
        public void onClick(Widget arg0) {
            JolieService.Util.getInstance().call("play", getLocationValue(), new EchoesCallback() {
                @Override
                public void onSuccess(Value response) {
                    //updateNowPlaying();
                }
            });
        }
    });

    Button pauseButton = new NativeButton("Pause");
    pauseButton.addClickListener(new ClickListener() {
        public void onClick(Widget arg0) {
            JolieService.Util.getInstance().call("pause", getLocationValue(), new EchoesCallback() {
                @Override
                public void onSuccess(Value response) {
                }
            });
        }
    });

    Button prevButton = new NativeButton("&lt;");
    prevButton.addClickListener(new ClickListener() {
        public void onClick(Widget arg0) {
            JolieService.Util.getInstance().call("previous", getLocationValue(), new EchoesCallback() {
                @Override
                public void onSuccess(Value response) {
                    //updateNowPlaying();
                }
            });
        }
    });

    Button nextButton = new NativeButton("&gt;");
    nextButton.addClickListener(new ClickListener() {
        public void onClick(Widget arg0) {
            JolieService.Util.getInstance().call("next", getLocationValue(), new EchoesCallback() {
                @Override
                public void onSuccess(Value response) {
                    //updateNowPlaying();
                }
            });
        }
    });

    buttonsPanel.add(prevButton);
    buttonsPanel.add(playButton);
    buttonsPanel.add(pauseButton);
    buttonsPanel.add(nextButton);

    playlistBox = new ListBox();
    playlistBox.setVisibleItemCount(8);
    playlistVPanel.add(playlistBox);
    playlistBox.setWidth("250px");

    playlistBox.addClickListener(new ClickListener() {
        public void onClick(Widget widget) {
            playSongByIndex(playlistBox.getSelectedIndex());
        }
    });

    hPanel = new HorizontalPanel();

    Button showLyricsButton = new NativeButton("Show lyrics");
    showLyricsButton.addClickListener(new ClickListener() {
        public void onClick(Widget arg0) {
            showLyrics();
        }
    });

    hPanel.add(showLyricsButton);
    playlistVPanel.add(hPanel);

    dPanel = new DisclosurePanel("Volume");
    playlistVPanel.add(dPanel);
    volumeMenu = new ListBox();
    dPanel.add(volumeMenu);
    addVolumeMenuItems(volumeMenu);
    volumeMenu.addChangeListener(new ChangeListener() {
        public void onChange(Widget arg0) {
            String volume = volumeMenu.getValue(volumeMenu.getSelectedIndex());
            setVolume(volume);
        }
    });
}

From source file:com.ricbit.gibit.client.Gibit.java

License:Apache License

/**
 * This is the entry point method.// w  w  w . j a  va  2s.  com
 */
public void onModuleLoad() {
    RootPanel.get().add(this);
    Image.prefetch("loading.gif");
    seriesPagination.setPresenter(this);
    History.addValueChangeHandler(this);
    searchState = new SearchState("");
    History.fireCurrentHistoryState();
}

From source file:com.seanchenxi.gwt.serenity.client.activity.ArticleActivity.java

License:Apache License

private void showView(Post post, AcceptsOneWidget panel) {
    view = clientFactory.getArticleView();
    view.bindPresenter(this);
    view.clearContent();/*from   ww w  .  j  a  va  2s .  c o  m*/
    view.setArticleId(post.getId());
    view.setTitle(post.getTitle());
    view.setDateString(SerenityUtil.toDateString(post.getCreatedDate()));
    view.setContent(post.getContent());
    //Show categories
    for (Category cat : post.getCategories()) {
        String anchorHref = SerenityPlaceUtil.getCategoryAnchor(cat.getSlug(), 0);
        view.addCategory(anchorHref, cat.getTitle());
    }
    //Show tags
    for (Tag tag : post.getTags()) {
        String anchorHref = SerenityPlaceUtil.getTagAnchor(tag.getSlug(), 0);
        view.addTag(anchorHref, tag.getTitle());
    }
    // Show comments
    boolean commentOpened = PostCommentStatus.OPEN.equals(post.getCommentStatus());
    int discussionCount = post.getComments().size();
    if (discussionCount > 1 || commentOpened) {
        discussionListView = clientFactory.getDiscussionListView();
        discussionListView.intView(discussionCount, commentOpened);
        for (Comment cmt : post.getComments()) {
            Image.prefetch(cmt.getGravatarURL()); // prefetch gravatar  
            discussionListView.addDiscussion(false, cmt.getId(), cmt.getGravatarURL(), cmt.getName(),
                    cmt.getURL(), cmt.getContent(), cmt.getDate(), cmt.getParentId());
        }
        // check and show respond view
        if (commentOpened) {
            RespondView respondView = clientFactory.getRespondView();
            respondView.reset();
            respondView.setArticleId(post.getId());
            respondView.bindPresenter(ArticleActivity.this);
            discussionListView.setRespondView(respondView);
        }
        view.setCommentsCount(discussionCount);
        view.setDiscussionListView(discussionListView);
    }

    panel.setWidget(view);
}

From source file:com.smartgwt.client.util.FileLoader.java

License:Open Source License

/**
 * Cache a list of images/*from  www .jav  a2  s.c  o m*/
 *
 * @param skinImgDir    the skinImgDir
 * @param baseImageURLs a list of base urls
 */
public static void cacheImgs(String skinImgDir, Iterable<String> baseImageURLs) {
    String skinDir = getSkinDir();
    for (String img : baseImageURLs) {
        img = img.replace("[SKINIMG]", skinDir + "images/");
        img = img.replace("[SKIN]", skinDir + skinImgDir);
        Image.prefetch(img);
    }
}

From source file:com.smartgwt.client.util.FileLoader.java

License:Open Source License

/**
 * Cache a list of images/* w  w  w.j  a  va  2s.c o m*/
 *
 * @param skinImgDir   the skinImgDir
 * @param baseImageURL the base urls
 */
public static void cacheImg(String skinImgDir, String baseImageURL) {
    String skinDir = getSkinDir();
    baseImageURL = baseImageURL.replace("[SKINIMG]", skinDir + "images/");
    baseImageURL = baseImageURL.replace("[SKIN]", skinDir + skinImgDir);
    Image.prefetch(baseImageURL);
}