1 29 30 package nextapp.echo2.webcontainer.image; 31 32 import nextapp.echo2.app.AwtImageReference; 33 import nextapp.echo2.app.Component; 34 import nextapp.echo2.app.HttpImageReference; 35 import nextapp.echo2.app.ImageReference; 36 import nextapp.echo2.app.StreamImageReference; 37 import nextapp.echo2.webcontainer.RenderContext; 38 39 42 public class ImageTools { 43 44 54 public static String getUri(RenderContext rc, ImageRenderSupport irs, Component component, String imageId) { 55 ImageReference imageReference = irs.getImage(component, imageId); 56 if (imageReference instanceof StreamImageReference) { 57 rc.getContainerInstance().getIdTable().register(imageReference); 58 return StreamImageService.INSTANCE.createUri(rc.getContainerInstance(), imageReference.getRenderId()); 59 } else if (imageReference instanceof HttpImageReference) { 60 return ((HttpImageReference) imageReference).getUri(); 61 } else if (imageReference instanceof AwtImageReference) { 62 rc.getContainerInstance().getIdTable().register(imageReference); 63 return AwtImageService.INSTANCE.createUri(rc.getContainerInstance(), imageReference.getRenderId()); 64 } else { 65 throw new IllegalArgumentException ("Unsupported image type."); 66 } 67 } 68 } 69 | Popular Tags |