01: /*
02: * MyGWT Widget Library
03: * Copyright(c) 2007, MyGWT.
04: * licensing@mygwt.net
05: *
06: * http://mygwt.net/license
07: */
08: package net.mygwt.ui.client.widget;
09:
10: import net.mygwt.ui.client.widget.impl.PNGImageImpl;
11:
12: import com.google.gwt.core.client.GWT;
13: import com.google.gwt.user.client.ui.Image;
14:
15: /**
16: * Image widget that overcomes PNG browser incompatabilities.
17: *
18: * <p>
19: * Implementation adapted from GWT Widget Library
20: * (http://gwt-widget.sourceforge.net/).
21: * </p>
22: */
23: public class PNGImage extends Image {
24:
25: private PNGImageImpl impl;
26:
27: /**
28: * Creates a new image instance.
29: *
30: * @param url the url of the image
31: */
32: public PNGImage(String url) {
33: this (url, 1, 1);
34: }
35:
36: /**
37: * Creates a new image instance.
38: *
39: * @param url the url of the image
40: * @param width the width
41: * @param height the height
42: */
43: public PNGImage(String url, int width, int height) {
44: impl = (PNGImageImpl) GWT.create(PNGImageImpl.class);
45:
46: setElement(impl.createElement(url, width, height));
47: }
48:
49: /**
50: * Should not be used. Throws a RuntimeException.
51: */
52: public void setUrl(String url) {
53: throw new RuntimeException(
54: "Not allowed to set url for a PNG image");
55: }
56: }
|