Hello!

I try to use the ClientBundle implementation to manage my Images to a
large File and minimize the HTTP-Requests.

I put <inherits name="com.google.gwt.resources.Resources" /> in my
gwt.xml

Generate the ClientBundle

public interface ResourceBundle extends ClientBundle {

        public static final ResourceBundle INSTANCE =
GWT.create(ResourceBundle.class);

        @Source("tiles/smiley.png")
        ImageResource smiley();

}

The Image would be found, no errors.

Here is the code

@Override
        public void onModuleLoad() {

                CLogger.log("Start Engine");

                int width = 800;
                int height = 600;

                Canvas canvas = Canvas.createIfSupported();
                canvas.setWidth(width + "px");
                canvas.setHeight(height + "px");
                canvas.setCoordinateSpaceWidth(width);
                canvas.setCoordinateSpaceHeight(height);
                Context2d c = canvas.getContext2d();

                Image img = new Image(ResourceBundle.INSTANCE.smiley());
                img.addLoadHandler(new LoadHandler() {

                        @Override
                        public void onLoad(LoadEvent event) {
                                CLogger.log(event.getSource() + " loaded");
                        }
                });
                CLogger.log("Visible: " + img.isVisible());

                c.drawImage((ImageElement) new
Image(ResourceBundle.INSTANCE.smiley()).getElement().cast(), 0, 0);

                RootPanel.get().add(canvas);

}

I create a simple Canvas and set the size to 800x600. I create a new
Context2D Object to draw the Image at the Context and add the Canvas
to the RootPanel.

The logs shows:

[20:10:21.676] - Start Engine
[20:10:21.851] - Visible: true
[20:10:21.853] - 
http://127.0.0.1:8888/engine/7D39451825E9952050F44A6B8E2E15F3.cache.png

The Image exists under the logged URL so everything looks fine. But
the Image would not be draw or it would draw but not display.

Anybody an idea?

I thought the ClientBundle loads the Images as the start in the
backend. So if I get an Instance every Image/Css and others fill be
loaded?

Regars Markus

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to