001 /*
002 * This file is part of the Echo Point Project. This project is a
003 * collection of Components that have extended the Echo Web Application
004 * Framework Version 3.
005 *
006 * Version: MPL 1.1
007 *
008 * The contents of this file are subject to the Mozilla Public License Version
009 * 1.1 (the "License"); you may not use this file except in compliance with
010 * the License. You may obtain a copy of the License at
011 * http://www.mozilla.org/MPL/
012 *
013 * Software distributed under the License is distributed on an "AS IS" basis,
014 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
015 * for the specific language governing rights and limitations under the
016 * License.
017 */
018
019 package echopoint;
020
021 import nextapp.echo.app.HttpImageReference;
022 import nextapp.echo.app.ImageReference;
023
024 import echopoint.internal.AbstractImage;
025
026 /**
027 * The <code>ImageIcon</code> class provides an component
028 * that displays an {@link nextapp.echo.app.ImageReference}. A height and width
029 * value can be specified to overide what may be defined in the
030 * {@link nextapp.echo.app.ImageReference} itself. This allows images to be
031 * "scaled" to different dimensions.
032 *
033 * <p>The advantage of <code>ImageIcon</code> over using a {@link
034 * nextapp.echo.app.Label} is that you can scale {@link
035 * nextapp.echo.app.ImageReference} objects that you may not
036 * know the dimensions of, and it can be clicked on like a {@link
037 * nextapp.echo.app.Button}.</p>
038 *
039 * <p>The following code shows sample usage of this component.</p>
040 * <pre>
041 * import echopoint.ImageIcon;
042 *
043 * ...
044 * final ImageIcon icon = new ImageIcon( "image/imagemap.gif" );
045 * icon.setWidth( 500 );
046 * icon.setHeight( 300 );
047 * icon.setActionCommand( "iconClicked" );
048 * icon.addActionListener( ... );
049 *
050 * final Column column = new Columnn();
051 * column.add( icon );
052 * </pre>
053 *
054 * @author Rakesh Vidyadharan 2008-10-20
055 * @version $Id: ImageIcon.java 262 2009-12-18 21:29:16Z sptrakesh $
056 */
057 public class ImageIcon extends AbstractImage
058 {
059 private static final long serialVersionUID = 1l;
060
061 /** Default constructor. */
062 public ImageIcon() {}
063
064 /**
065 * Create a new instance using the specified image reference.
066 *
067 * @param icon The icon to associate with this component.
068 */
069 public ImageIcon( final ImageReference icon )
070 {
071 setIcon( icon );
072 }
073
074 /**
075 * Create a new instance using an image from the specified HTTP URI.
076 *
077 * @param url The URI for the image resource.
078 */
079 public ImageIcon( final String url )
080 {
081 this( new HttpImageReference( url ) );
082 }
083
084 /**
085 * Return the value of {@link #PROPERTY_IMAGE} property.
086 *
087 * @deprecated Use {@link #getImage} instead.
088 * @return The image reference for the icon.
089 */
090 @Deprecated
091 public ImageReference getIcon()
092 {
093 return getImage();
094 }
095
096 /**
097 * Set the value of {@link #PROPERTY_IMAGE} property.
098 *
099 * @deprecated Use {@link #setImage} instead.
100 * @param icon The image reference to set.
101 */
102 @Deprecated
103 public void setIcon( final ImageReference icon )
104 {
105 setImage( icon );
106 }
107 }