All Libraries | This Library | Package | Class | Use | Tree | Deprecated | Index | Grand Index | Help
|  | Components |
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.sas.swing.visuals
Class ImageView

    com.sas.swing.visuals.ImageView

All Implemented Interfaces:
  ResourceConsumerInterface, com.sas.PublicClonable, com.sas.visuals.IconInterface, com.sas.visuals.PainterInterface, ResizeToFitInterface, java.awt.image.ImageObserver, java.awt.MenuContainer, java.beans.PropertyChangeListener, java.io.Serializable, java.lang.Cloneable, java.util.EventListener, javax.swing.Icon

    public class ImageView

implements javax.swing.Icon, com.sas.visuals.IconInterface, ResizeToFitInterface, com.sas.PublicClonable, java.beans.PropertyChangeListener, ResourceConsumerInterface

The ImageView displays an image in the component area. The image can be specified with either a URL, the image name and path, or a java.awt.image object.

Creating an ImageView Component

A valid instance is created by instantiating an object of ImageView from one of the three constructors.

     // Default Constructor
     ImageView imageView1 = new ImageView();
     // Sets source path
     ImageView imageView2 = new ImageView("d:/source.gif");
     ImageView imageView3 = new ImageView("http://www.example.com/source.gif");
     // Sets image to specified java.net.URL object
     ImageView imageView4 = new ImageView( new java.net.URL("http://www.example.com/source.gif") );
     // Sets image to specified source relative to a certain class
     ImageView imageView4 = new ImageView( com.sas.visuals.AutoSizingGridLayout.class, "res/DefaultIDEImage32.gif" );
     // Sets image to specified java.awt.image object
     ImageView imageView4 = new ImageView( (java.awt.image)imgSource );

Usage

Source

There are several different ways of setting the source of the image to be displayed.

- One method is to set the absolute file path and name as the source. An example of this is simply "c:/somepath/source.gif". This method does not allow the image to be seen if it is not in this exact location every time the applet runs.
- Another method is to set the URL path to the image. An example of this is "http://www.somewebsite.com/images/source.gif". This allows for setting an absolute or applet relative URL as the source of the image. To set the source relative, however, the codeBase of the applet needs to be used and the URL will have to be set in code instead of using the ImageView customizer.
- A third method is to set the source relative to some class. The getResource(String) method will be called on the relative class to get a URL to load the image from. An example of this is setting the relativeSourceClass property to "com.foo.SomeClass" and setting the relativeSource property to "imgs/source.gif", where the actual path of the image source is "com/foo/imgs/source.gif".
- The final method of setting the source is similar to setting the source relative to a class except it uses the class of the applet to call getResource(String) on. This is done by setting the sourceAppletRelative property to true and setting the source property to the relative path of the image. The path needs to be relative to the location of the applet class or to the codeBase of the applet. The ImageView first attempts to get a URL for the applet using the getResource(String) method on the applet class. If this returns null, however, the ImageView attempts to create a URL to the source using Applet.getCodeBase() and the given source stringc. IF YOU ARE USING A .JAR FILE WITH IMAGES CONTAINED WITHIN IT, THE SOURCE CANNOT CONTAIN ".." TO GO BACK A DIRECTORY. This appears to be a limitation of the java.lang.Class.getResource(String) method.

ResizeToFit

The image will resize the component if possible to fit the current source image. This only works when the Display Mode is set to NO_SCALE. When the Display Mode is set to something else, ResizeToFit will automatically be set to false.

Display Mode

The Display mode sets how the image will be displayed within the component area. There are five display modes.

- NO_SCALE - the image will be displayed at the center of the component unscaled.
- SCALE - the image will be scaled to the size of the component.
- SCALE_HEIGHT - the image will keep its aspect ratio and scale to fit the height.
- SCALE_WIDTH - the image will keep its aspect ratio and scale to fit the width.
- TILE - the image will be tiled on the component area, starting at the upper left.

ImageFilter

The ImageFilter will create and display a filtered image based on the current source image. If no imageFilter is set or the imageFilter is set to null, the original source image will be displayed.

MediaTracker

This allows an application that uses the imageView to wait until all of the image is loaded. IF THE PREFERRED SIZE OF AN IMAGEVIEW IS CHECKED BEFORE THE IMAGE IS LOADED IT WILL BE INCORRECT.

     ImageView imageView1.setSource("d:/source.gif");
     java.awt.MediaTracker mediaTrack = imageView1.getMediaTracker();
     try
     {
         mediaTrack.waitForAll();  // Waits for all images associated with this tracker to be loaded.
     }
     catch ( InterruptedException e )
     {
     }

ImageLoadWait

The ImageLoadWait uses the MediaTracker to wait for the images to load. This is set to true by default.

See Also:
  `Icon`, `ResourceLocatorInterface`, Serialized Form

Field Summary
`protected java.lang.String` | `absoluteSource` The absolute path and name of the source
`static int` | `AUTO_SCALE` DisplayMode value AUTO_SCALE: Image is scaled to fit within the component but keeps its aspect ratio.
`protected java.awt.Insets` | `currentInsets` The insets set on the ImageView less the amount of the border insets at the time the insets were set.
`protected boolean` | `defaultImageLoaded` Flag indicating the defaultImage is loaded.
`protected java.awt.Image` | `disabledImage` The disabled image filtered using a GrayFilter.
`protected java.awt.Image` | `dispImage` The image actually painted.
`protected int` | `displayMode` The displayMode of the image
`protected java.awt.Image` | `filteredImage` The original image filtered using the imageFilter.
`protected java.awt.Image` | `image` The original image created to display.
`protected boolean` | `imageWait` Flag indicating that the MediaTracker will be used to load the images.
`static int` | `LAST_DISPLAY_MODE` The last DisplayMode value used
`protected java.awt.Image` | `missingImage` The missing file image.
`static int` | `NO_SCALE` DisplayMode value NO_SCALE: Image is displayed at original size.
`protected int` | `oldHeight` The previous height the image was painted at.
`protected int` | `oldWidth` The previous width the image was painted at.
`static java.lang.String` | `RB_KEY`
`protected java.lang.String` | `relativeSource` The path and name of the source relative to the relativeSourceClass location.
`protected java.lang.Class` | `relativeSourceClass` The class to use as the root location for the relative path and name of the source.
`protected java.lang.String` | `relativeSourceClassName` The name of the class to use as the root location for the relative path and name of the source.
`protected com.sas.net.ResourceLocatorInterface` | `resourceLocator` The ResourceLocator used to locate the image to be displayed, returns a valid URL is possible.
`static int` | `SCALE` DisplayMode value SCALE: Image is scaled to the size of the component and then displayed.
`static int` | `SCALE_HEIGHT` DisplayMode value SCALE_HEIGHT: Image is scaled to the height of the component with the original aspect ratio.
`static int` | `SCALE_WIDTH` DisplayMode value SCALE_WIDTH: Image is scaled to the width of the component with the original aspect ratio.
`protected java.lang.String` | `source` The source of the image displayed.
`protected boolean` | `sourceAppletRelative` Flag indicating to use find the source relative to the applet the ImageView is used in
`protected java.net.URL` | `sourceURL` The URL of the source.
`static int` | `TILE` DisplayMode value TILE: Image is tiled of the area of the component

Constructor Summary
`ImageView()` Default constructor
`ImageView(java.lang.Class relativeClass, java.lang.String relativeSrc)` Constructor that creates an ImageView with a relative class and a source relative to that class.
`ImageView(java.awt.Image img)` Constructor that displays an existing image.
`ImageView(com.sas.net.ResourceLocatorInterface resourceLocator)` Constuctor that creates an ImageView using the given ResourceLocatorInterface to locate the image to display.
`ImageView(java.lang.String src)` Constructor that takes a String holding the source path or URL string for the image
`ImageView(java.net.URL srcURL)` Constuctor that creates an ImageView with URL source.

Method Summary
`java.lang.Object` | `clone()` Create a clone of this ImageView.
`java.awt.Dimension` | `computePreferredSize()` Compute the preferred size of the image.
`protected java.awt.Image` | `createDisabledImage(java.awt.Image img)` Create an image based on the image given that greys out the colors.
`protected void` | `createDisplayImage(int width, int height)` Create the image to be displayed.
`java.awt.Image` | `createFilteredImage(java.awt.Image img, java.awt.image.ImageFilter imgFilter)` Create an image based on the image given that is filtered using the given ImageFilter.
`protected java.awt.Image` | `createTiledImage(java.awt.Image img, int width, int height)` Create an image based on the image given that is tiled over the entire area of the ImageView.
`static int` | `getDefaultHeight()` Returns the default height to display the ImageView with.
`static int` | `getDefaultWidth()` Returns the default width to display the ImageView with.
`int` | `getDisplayMode()` Returns the display mode of the imageView.
`static com.sas.beans.ExtendedBeanInfo` | `getExtendedBeanInfo()` Returns information used by the `com.sas.beans.Introspector` to augment the automatically introspected information about this ImageView.
`int` | `getIconHeight()` Gets the height of the image.
`int` | `getIconWidth()` Gets the width of the image.
`java.awt.Image` | `getImage()` Returns the original image object for the current display.
`java.awt.image.ImageFilter` | `getImageFilter()` Returns the image filter to apply to the image.
`java.awt.MediaTracker` | `getMediaTracker()` Returns the MediaTracker so external sources can track the loading of the images.
`java.awt.Dimension` | `getMinimumSize()` Returns the minimum size of the ImageView.
`java.awt.Image` | `getMissingFileImage()` Returns the image used if the image is missing.
`java.awt.Dimension` | `getPreferredSize()` Gets the preferredSizeon the ImageView, normally just the size of the image.
`java.lang.Class` | `getRelativeSourceClass()` Gets the class that is used with the relative source path.
`java.util.Vector` | `getRequiredInterfaces()` Returns the required interfaces Vector for this component.
`com.sas.net.ResourceLocatorInterface` | `getResourceLocator()` Gets the instance of ResourceLocatorInterface that is used to locate the URL of the image.
`java.lang.String` | `getSource()` Gets the source (file location) for obtaining the image
`java.lang.String` | `getSourceAbsolute()` Gets the absolute source name for the image to display.
`java.lang.String` | `getSourceRelative()` Gets the source, relative to the relativeSourceClass, of the image to display.
`java.net.URL` | `getSourceURL()` Gets the URL object for the image file to be displayed.
`static boolean` | `imageExists(com.sas.net.ResourceLocatorInterface rli)` Returns true if an image get be retrieved from the given ResourceLocatorInterface, false otherwise.
`boolean` | `isImageLoadWait()` Returns if the ImageView will wait for the image to load.
`boolean` | `isResizeToFit()` Returns the value of the resizeToFit property If set to true, then the ImageView object will resize itself to the size of the image it displays.
`boolean` | `isSourceAppletRelative()` Returns whether or not the image source is relative to the applet For true to be returned, the ResourceLocatorInterface must be of type AppletResourceLocator, else false is returned.
`protected void` | `loadDisplayImage()` Load the images that have been created.
`void` | `paint(java.awt.Component comp, java.awt.Graphics g, int x, int y, int width, int height)` Paints the image in the ImageView objects with specified displayMode
`void` | `paintComponent(java.awt.Component comp, java.awt.Graphics g, int x, int y, int width, int height)` Paints the image in the ImageView objects with specified displayMode
`void` | `paintComponent(java.awt.Graphics g)` Paint the ImageView
`void` | `paintIcon(java.awt.Component c, java.awt.Graphics g, int x, int y)` Paints the ImageView.
`void` | `propertyChange(java.beans.PropertyChangeEvent event)` Handle PropertyChangeEvents from the model.
`void` | `refresh()` Sets the source for the image from the attached model.
`void` | `resizeToFit()` Reset the size of the ImageView to the preferredSize.
`void` | `setBorder(javax.swing.border.Border border)` Sets the border for the ImageView.
`void` | `setBounds(int x, int y, int width, int height)` Call super.setBounds() and then repaint the entire component.
`static void` | `setDefaultHeight(int newHeight)` Sets the default height to display the ImageView with.
`void` | `setDefaultValues()` This method sets the initial values to the default values.
`static void` | `setDefaultWidth(int newWidth)` Sets the default width to display the ImageView with.
`void` | `setDisplayMode(int mode)` Sets the display mode of the image.
`void` | `setImage(java.awt.Image img)` Sets the image object to be displayed in the ImageView.
`void` | `setImageFilter(java.awt.image.ImageFilter imgFilter)` Sets the image filter that will be applied to the original image source to produce the image that is displayed.
`void` | `setImageLoadWait(boolean loadWait)` Sets the ImageView to wait for the image to load
`void` | `setRelativeSourceClass(java.lang.Class newValue)` Sets the class that is used with the relative source path.
`void` | `setResizeToFit(boolean resizeToFit)` Sets the value of the resizeToFit property
`void` | `setResourceLocator(com.sas.net.ResourceLocatorInterface newValue)` Sets the instance of ResourceLocatorInterface for obtaining the image.
`void` | `setSource(java.lang.String newValue)` Sets the source (location) for obtaining the image.
`void` | `setSourceAbsolute(java.lang.String newValue)` Sets the absolute source name for the image to display.
`void` | `setSourceAppletRelative(boolean newValue)` Sets the source to be relative to the applet location.
`void` | `setSourceRelative(java.lang.String newValue)` Sets the relative source.
`void` | `setSourceURL(java.net.URL newValue)` Sets the URL object for the image file to be displayed.
`protected boolean` | `validateDisplayMode(int mode)` Validate the displayMode value.

Methods inherited from interface com.sas.visuals.PainterInterface
`getInsets`

Field Detail

### RB_KEY

    public static final java.lang.String RB_KEY

See Also:
  Constant Field Values

### NO_SCALE

    public static final int NO_SCALE

  DisplayMode value NO_SCALE: Image is displayed at original size.

  See Also:
    Constant Field Values

### SCALE

    public static final int SCALE

  DisplayMode value SCALE: Image is scaled to the size of the component and then displayed.

  See Also:
    Constant Field Values

### SCALE_HEIGHT

    public static final int SCALE_HEIGHT

  DisplayMode value SCALE_HEIGHT: Image is scaled to the height of the component with the original aspect ratio.

  See Also:
    Constant Field Values

### SCALE_WIDTH

    public static final int SCALE_WIDTH

  DisplayMode value SCALE_WIDTH: Image is scaled to the width of the component with the original aspect ratio.

  See Also:
    Constant Field Values

### TILE

    public static final int TILE

  DisplayMode value TILE: Image is tiled of the area of the component

  See Also:
    Constant Field Values

### AUTO_SCALE

    public static final int AUTO_SCALE

  DisplayMode value AUTO_SCALE: Image is scaled to fit within the component but keeps its aspect ratio.

  See Also:
    Constant Field Values

### LAST_DISPLAY_MODE

    public static final int LAST_DISPLAY_MODE

  The last DisplayMode value used

  See Also:
    Constant Field Values

### image

    protected transient java.awt.Image image

  The original image created to display.

### dispImage

    protected transient java.awt.Image dispImage

  The image actually painted.

### filteredImage

    protected transient java.awt.Image filteredImage

  The original image filtered using the imageFilter.

### disabledImage

    protected transient java.awt.Image disabledImage

  The disabled image filtered using a GrayFilter.

### missingImage

    protected transient java.awt.Image missingImage

  The missing file image.

### oldWidth

    protected transient int oldWidth

  The previous width the image was painted at.

### oldHeight

    protected transient int oldHeight

  The previous height the image was painted at.

### currentInsets

    protected java.awt.Insets currentInsets

  The insets set on the ImageView less the amount of the border insets at the time the insets were set.

### source

    protected java.lang.String source

  The source of the image displayed.

### imageWait

    protected boolean imageWait

  Flag indicating that the MediaTracker will be used to load the images.

### displayMode

    protected int displayMode

  The displayMode of the image

### defaultImageLoaded

    protected boolean defaultImageLoaded

  Flag indicating the defaultImage is loaded.

### absoluteSource

    protected java.lang.String absoluteSource

  The absolute path and name of the source

### relativeSourceClassName

    protected java.lang.String relativeSourceClassName

  The name of the class to use as the root location for the relative path and name of the source.

### relativeSourceClass

    protected transient java.lang.Class relativeSourceClass

  The class to use as the root location for the relative path and name of the source.

### relativeSource

    protected java.lang.String relativeSource

  The path and name of the source relative to the relativeSourceClass location.

### sourceURL

    protected java.net.URL sourceURL

  The URL of the source.

### sourceAppletRelative

    protected boolean sourceAppletRelative

  Flag indicating to use find the source relative to the applet the ImageView is used in

### resourceLocator

    protected com.sas.net.ResourceLocatorInterface resourceLocator

  The ResourceLocator used to locate the image to be displayed, returns a valid URL is possible.

Constructor Detail

### ImageView

    public ImageView()

  Default constructor

### ImageView

    public ImageView(java.net.URL srcURL)

  Constuctor that creates an ImageView with URL source.

  Parameters:
    `srcURL` - the URL of the image source
  See Also:
    `setSourceURL(java.net.URL)`

### ImageView

    public ImageView(java.lang.Class relativeClass,
                     java.lang.String relativeSrc)

  Constructor that creates an ImageView with a relative class and a source relative to that class.

  Parameters:
    `relativeClass` - the class relative to the image source
    `relativeSrc` - the source relative to the class given
  See Also:
    `setSourceRelative(java.lang.String)`, `setRelativeSourceClass(java.lang.Class)`

### ImageView

    public ImageView(java.lang.String src)

  Constructor that takes a String holding the source path or URL string for the image

  Parameters:
    `src` - full valid path string to an image
  See Also:
    `setSource(java.lang.String)`

### ImageView

    public ImageView(java.awt.Image img)

  Constructor that displays an existing image. The image will not be serialized in the ImageView.

  Parameters:
    `img` - a java.awt.Image to display
  See Also:
    `setImage(java.awt.Image)`

### ImageView

    public ImageView(com.sas.net.ResourceLocatorInterface resourceLocator)

  Constuctor that creates an ImageView using the given ResourceLocatorInterface to locate the image to display.

  Parameters:
    `resourceLocator` - an instance of ResourceLocatorInterface to locate the image
  See Also:
    `setResourceLocator(ResourceLocatorInterface)`, `ResourceLocatorInterface`

Method Detail

### getExtendedBeanInfo

    public static com.sas.beans.ExtendedBeanInfo getExtendedBeanInfo()

  Returns information used by the `com.sas.beans.Introspector` to augment the automatically introspected information about this ImageView.

  Returns:
    the ExtendedBeanInfo for this class

### getDefaultHeight

    public static int getDefaultHeight()

  Returns the default height to display the ImageView with.

  Returns:
    the default height of an ImageView object

### getDefaultWidth

    public static int getDefaultWidth()

  Returns the default width to display the ImageView with.

  Returns:
    the default width of an ImageView object

### setDefaultHeight

    public static void setDefaultHeight(int newHeight)

  Sets the default height to display the ImageView with.

  Parameters:
    `newHeight` - the default height of an ImageView object

### setDefaultWidth

    public static void setDefaultWidth(int newWidth)

  Sets the default width to display the ImageView with.

  Parameters:
    `newWidth` - the default width of an ImageView object

### clone

    public java.lang.Object clone()
                           throws java.lang.CloneNotSupportedException

  Create a clone of this ImageView.

  Specified by:
    `clone` in interface `com.sas.PublicClonable`
  Overrides:
    `clone` in class `java.lang.Object`
  Returns:
    the created ImageView clone
  Throws:
    `java.lang.CloneNotSupportedException` - if clone creation fails

### imageExists

    public static final boolean imageExists(com.sas.net.ResourceLocatorInterface rli)

  Returns true if an image get be retrieved from the given ResourceLocatorInterface, false otherwise.

  Parameters:
    `rli` - an instance of a ResourceLocatorInterface that should have an image set as the resource
  See Also:
    `ResourceLocatorInterface`

### getMissingFileImage

    public java.awt.Image getMissingFileImage()

  Returns the image used if the image is missing.

  Returns:
    the image used if the image file can not be found or an erro occurred while trying to retrieve it

### getRequiredInterfaces

    public java.util.Vector getRequiredInterfaces()

  Returns the required interfaces Vector for this component.

  Returns:
    the required interfaces Vector for this component.
  See Also:
    `ViewInterface.getRequiredInterfaces()`

### createFilteredImage

    public java.awt.Image createFilteredImage(java.awt.Image img,
                                              java.awt.image.ImageFilter imgFilter)

  Create an image based on the image given that is filtered using the given ImageFilter.

  Parameters:
    `img` - the image to create a filtered image of.
    `imgFilter` - the filter to use on the img object.
  Returns:
    the filtered image that was created.

### createTiledImage

    protected java.awt.Image createTiledImage(java.awt.Image img,
                                              int width,
                                              int height)

  Create an image based on the image given that is tiled over the entire area of the ImageView.

  Parameters:
    `img` - the image to create a tiled image of.
    `width` - the width in pixels that the image should be tiled within
    `height` - the height in pixels that the image should be tiled within
  Returns:
    the tiled image that was created.

### createDisabledImage

    protected java.awt.Image createDisabledImage(java.awt.Image img)

  Create an image based on the image given that greys out the colors.

  Parameters:
    `img` - the image to create a disabled image of.
  Returns:
    the disabled image that was created.

### createDisplayImage

    protected void createDisplayImage(int width,
                                      int height)

  Create the image to be displayed.

  Parameters:
    `width` - the width of the area to display the image in.
    `height` - the height of the area to display the image in.

### loadDisplayImage

    protected void loadDisplayImage()

  Load the images that have been created.

### getDisplayMode

    public int getDisplayMode()

  Returns the display mode of the imageView. The display mode is the how the image view choose to display the image. It can be set to either of the following: SCALE, NO_SCALE, TILE, SCALE_HEIGHT, SCALE_WIDTH, AUTO_SCALE ( which is the last used mode ), and LAST_DISPLAY_MODE ( which is identical to AUTO_SCALE )

  Returns:
    a valid displayMode id.
  See Also:
    `setDisplayMode(int)`

### getImage

    public java.awt.Image getImage()

  Returns the original image object for the current display.

  Returns:
    the unfiltered java.awt.image object
  See Also:
    `setImage(java.awt.Image)`

### getImageFilter

    public java.awt.image.ImageFilter getImageFilter()

  Returns the image filter to apply to the image.

  Returns:
    the image filter applied to the image, can be null.
  See Also:
    `setImageFilter(java.awt.image.ImageFilter)`

### isImageLoadWait

    public boolean isImageLoadWait()

  Returns if the ImageView will wait for the image to load.

  Returns:
    if true the ImageView will use the MediaTracker to wait for the image to load; otherwise the ImageView will return immediately after the source is set.
  See Also:
    `setImageLoadWait(boolean)`

### getMediaTracker

    public java.awt.MediaTracker getMediaTracker()

  Returns the MediaTracker so external sources can track the loading of the images.

  Returns:
    the media tracker object

### getMinimumSize

    public java.awt.Dimension getMinimumSize()

  Returns the minimum size of the ImageView. This is the normal size of the image and the insets for the ImageView

  Overrides:
    `getMinimumSize` in class `javax.swing.JComponent`
  Returns:
    minimum size of the ImageView.
  See Also:
    `computePreferredSize()`

### computePreferredSize

    public java.awt.Dimension computePreferredSize()

  Compute the preferred size of the image.

  Returns:
    the minimum size of the image and border
  See Also:
    `getMinimumSize()`

### getSource

    public java.lang.String getSource()

  Gets the source (file location) for obtaining the image

  Returns:
    the location for obtaining the image
  See Also:
    `setSource(java.lang.String)`, `ResourceLocatorInterface`

### isResizeToFit

    public boolean isResizeToFit()

  Returns the value of the resizeToFit property If set to true, then the ImageView object will resize itself to the size of the image it displays.

  Specified by:
    `isResizeToFit` in interface `ResizeToFitInterface`
  Returns:
    value of the resizeToFit property
  See Also:
    `setResizeToFit(boolean)`, `resizeToFit`

### paintComponent

    public void paintComponent(java.awt.Graphics g)

  Paint the ImageView

  Overrides:
    `paintComponent` in class `javax.swing.JComponent`
  Parameters:
    `g` - the specified Graphics context

### paintIcon

    public void paintIcon(java.awt.Component c,
                          java.awt.Graphics g,
                          int x,
                          int y)

  Paints the ImageView. The top-left corner of the image is drawn at the point (`x`, `y`) in the coordinate space of the graphics context `g`.

  Specified by:
    `paintIcon` in interface `javax.swing.Icon`
  Parameters:
    `c` - the component to be used as the observer
    `g` - the graphics context
    `x` - the X coordinate of the icon's top-left corner
    `y` - the Y coordinate of the icon's top-left corner

### getIconWidth

    public int getIconWidth()

  Gets the width of the image.

  Specified by:
    `getIconWidth` in interface `javax.swing.Icon`
  Returns:
    the width in pixels of this imageview

### getIconHeight

    public int getIconHeight()

  Gets the height of the image.

  Specified by:
    `getIconHeight` in interface `javax.swing.Icon`
  Returns:
    the height in pixels of this imageview

### paint

    public void paint(java.awt.Component comp,
                      java.awt.Graphics g,
                      int x,
                      int y,
                      int width,
                      int height)

  Paints the image in the ImageView objects with specified displayMode

  Specified by:
    `paint` in interface `com.sas.visuals.PainterInterface`
  Parameters:
    `comp` - the Component to paint the IconInterface with.
    `g` - Graphics context
    `x` - the x coordinate
    `y` - the y coordinate
    `width` - the width to be painted.
    `height` - the height to be painted.
  See Also:
    `Icon`

### paintComponent

    public void paintComponent(java.awt.Component comp,
                               java.awt.Graphics g,
                               int x,
                               int y,
                               int width,
                               int height)

  Paints the image in the ImageView objects with specified displayMode

  Parameters:
    `comp` - the Component to paint the IconInterface with.
    `g` - Graphics context
    `x` - the x coordinate
    `y` - the y coordinate
    `width` - the width to be painted.
    `height` - the height to be painted.
  See Also:
    `Icon`

### propertyChange

    public void propertyChange(java.beans.PropertyChangeEvent event)

  Handle PropertyChangeEvents from the model.

  Specified by:
    `propertyChange` in interface `java.beans.PropertyChangeListener`
  Parameters:
    `event` - The event from the model indicating what property changed.

### refresh

    public void refresh()

  Sets the source for the image from the attached model.

### resizeToFit

    public void resizeToFit()

  Reset the size of the ImageView to the preferredSize. If the resizeToFit property is set to true the ImageView object will be resized to fit the entire image contained in the component .

  See Also:
    `setResizeToFit(boolean)`, `isResizeToFit()`

### getPreferredSize

    public java.awt.Dimension getPreferredSize()

  Gets the preferredSizeon the ImageView, normally just the size of the image.

  Specified by:
    `getPreferredSize` in interface `com.sas.visuals.IconInterface`
  Overrides:
    `getPreferredSize` in class `javax.swing.JComponent`

### setBorder

    public void setBorder(javax.swing.border.Border border)

  Sets the border for the ImageView.

  Overrides:
    `setBorder` in class `javax.swing.JComponent`
  Parameters:
    `border` - the border to be rendered for the ImageView

### setBounds

    public void setBounds(int x,
                          int y,
                          int width,
                          int height)

  Call super.setBounds() and then repaint the entire component.

  Overrides:
    `setBounds` in class `java.awt.Component`
  See Also:
    `Component.setBounds(int, int, int, int)`

### setDefaultValues

    public void setDefaultValues()

  This method sets the initial values to the default values. This method is called by the Component constructors. The setDefaultValues method of each class is responsible for setting its own initial values.

### setDisplayMode

    public void setDisplayMode(int mode)

  Sets the display mode of the image. The display mode is the how the image view choose to display the image. It can be set to either of the following: SCALE, NO_SCALE, TILE, SCALE_HEIGHT, SCALE_WIDTH, AUTO_SCALE ( which is the last used mode ), and LAST_DISPLAY_MODE ( which is identical to AUTO_SCALE )

  Parameters:
    `mode` - any of the displayMode ids defined in this class.
  See Also:
    `getDisplayMode()`

### validateDisplayMode

    protected boolean validateDisplayMode(int mode)

  Validate the displayMode value.

  Parameters:
    `mode` - the displayMode to validate.
  Returns:
    true if the mode is valid; false otherwise.

### setResizeToFit

    public void setResizeToFit(boolean resizeToFit)

  Sets the value of the resizeToFit property

  Specified by:
    `setResizeToFit` in interface `ResizeToFitInterface`
  Parameters:
    `resizeToFit` - boolean value
  See Also:
    `isResizeToFit()`

### setImage

    public void setImage(java.awt.Image img)

  Sets the image object to be displayed in the ImageView. The image set here alone, will not be serialized.

  Parameters:
    `img` - the image object to be displayed
  See Also:
    `getImage(java.lang.Object)`

### setImageFilter

    public void setImageFilter(java.awt.image.ImageFilter imgFilter)

  Sets the image filter that will be applied to the original image source to produce the image that is displayed.

  Parameters:
    `imgFilter` - the image filter applied to the original image.
  See Also:
    `getImageFilter()`

### setImageLoadWait

    public void setImageLoadWait(boolean loadWait)

  Sets the ImageView to wait for the image to load

  Parameters:
    `loadWait` - true to set the ImageView to wait for the image to load before displaying
  See Also:
    `isImageLoadWait()`

### setResourceLocator

    public void setResourceLocator(com.sas.net.ResourceLocatorInterface newValue)

  Sets the instance of ResourceLocatorInterface for obtaining the image. It can be either a BaseResourceLocator, AppletResourceLocator, FileResourceLocator, ClassResourceLocator, or a ContextResourceLocator. Invokes the setImage() method to set the image displayed to the loaded image.

  Specified by:
    `setResourceLocator` in interface `ResourceConsumerInterface`
  Parameters:
    `newValue` - the instance of ResourceLocatorInterface for obtaining the image
  See Also:
    `getResourceLocator()`, `ResourceLocatorInterface`, `BaseResourceLocator`, `AppletResourceLocator`, `FileResourceLocator`, `ClassResourceLocator`, `ContextResourceLocator`, `URL`

### getResourceLocator

    public com.sas.net.ResourceLocatorInterface getResourceLocator()

  Gets the instance of ResourceLocatorInterface that is used to locate the URL of the image.

  Specified by:
    `getResourceLocator` in interface `ResourceConsumerInterface`
  Returns:
    the instance of a ResourceLocatorInterface that is used to locate the image.
  See Also:
    `setSourceAbsolute(java.lang.String)`, `ResourceLocatorInterface`, `AppletResourceLocator.getAbsolutePath()`

### setSource

    public void setSource(java.lang.String newValue)

  Sets the source (location) for obtaining the image. The string passed in can be either the URL qualified name, the full path name to the image file, or the relative path name based on the location of the relativeSourceClass or current directory. The source is set based on the following order:
  - URL
  - Relative to the applet
  - Relative to class
  - Absolute path
  Invokes the setImage() method to set the image displayed to the loaded image. The instance of ResourceLocatorInterface may also change depending on what value is passed in. If a new ResourceLocatorInterface instance will be created if necessary. For example, if the current ResourceLocatorInterface is an instance of ClassResourceLocator, and "C:\\images\\image1.gif" is passed in, a FileResourceLocator will be created in place of the existing ClassResourceLocator.

  Parameters:
    `newValue` - the location for obtaining the image
  See Also:
    `getSource()`, `ResourceLocatorInterface`, `URL`, `ClassLoader.getSystemResource(java.lang.String)`, `Class.getResource(java.lang.String)`

### getSourceAbsolute

    public java.lang.String getSourceAbsolute()

  Gets the absolute source name for the image to display. Will return the same value as getSource(), except if the ResourceLocatorInterface is an instance of AppletResourceLocator, then the absolute path of the file will be returned.

  Returns:
    the string path and name of the image to display.
  See Also:
    `setSourceAbsolute(java.lang.String)`, `ResourceLocatorInterface`, `AppletResourceLocator.getAbsolutePath()`

### setSourceAbsolute

    public void setSourceAbsolute(java.lang.String newValue)

  Sets the absolute source name for the image to display. If the ResourceLocatorInterface is not a FileResourceLocator, a FileResourceLocator will be created in its place, else the existing FileResourceLocator will be used and a new source will be set on it. The image is found using java.awt.Toolkit.getImage( String )

  Parameters:
    `newValue` - the string path and name of the image to display.
  See Also:
    `getSourceAbsolute()`, `ResourceLocatorInterface`, `FileResourceLocator`, `Toolkit.getImage(java.lang.String)`

### getSourceURL

    public java.net.URL getSourceURL()

  Gets the URL object for the image file to be displayed.

  Returns:
    the URL of the image to display, null if a source is not set or an error occured
  See Also:
    `setSourceURL(java.net.URL)`, `ResourceLocatorInterface`, `ResourceLocatorInterface.getResource()`, `Toolkit.getImage(java.lang.String)`

### setSourceURL

    public void setSourceURL(java.net.URL newValue)

  Sets the URL object for the image file to be displayed. Create a new BaseResourceLocator if the current ResourceLocatorInterface is of a subclass of it, else it uses the existing BaseResourceLocator. The image is found using java.awt.Toolkit.getImage( URL )

  Parameters:
    `newValue` - the URL of the image to display
  See Also:
    `getSourceURL()`, `ResourceLocatorInterface`, `BaseResourceLocator`, `Toolkit.getImage(java.lang.String)`

### isSourceAppletRelative

    public boolean isSourceAppletRelative()

  Returns whether or not the image source is relative to the applet For true to be returned, the ResourceLocatorInterface must be of type AppletResourceLocator, else false is returned.

  Returns:
    true is image source is relative to where the applet is loaded
  See Also:
    `AppletResourceLocator`

### setSourceAppletRelative

    public void setSourceAppletRelative(boolean newValue)

  Sets the source to be relative to the applet location. If this is true, the ImageView will try to find the applet using GlobalInfoTable.getApplet(). It will attempt to get a URL using getResource(String) on the applet class and if this doesn't work, it will create a URL that uses the codebase of the applet. Any subsequent calls to setSource() will also attempt to find the source using the applet location first. If setSourceAbsolute(), setSourceRelative(), setSourceURL() are called they will not use this flag to locate the source. If true is passed in and the current ResourceLocatorInterface is not of type AppletResourceLocator, then an AppletResourceLocator instance will be created in its place, else the existing AppletResourceLocator will be used. If false is passed in and the current ResourceLocatorInterface is of type AppletResourceLocator, then a FileResourceLocator will be created in its place.

  Parameters:
    `newValue` - true if the source is located relative to the applet containing the ImageView
  See Also:
    `GlobalInfoTable.getApplet()`, `ResourceLocatorInterface`, `AppletResourceLocator`, `FileResourceLocator`, `Class.getResource(java.lang.String)`

### getSourceRelative

    public java.lang.String getSourceRelative()

  Gets the source, relative to the relativeSourceClass, of the image to display. Will return the exact same result as getSource().

  Returns:
    src the path and name of the image source relative to the relativeSourceClass location.
  See Also:
    `setSourceRelative(java.lang.String)`, `ResourceLocatorInterface`

### setSourceRelative

    public void setSourceRelative(java.lang.String newValue)

  Sets the relative source. This method will check the relative source based on ClassLoader.getSystemResource( relativeSource ). If no image resource is found the relativeSourceClass.getResource( relativeSource ) will be checked. If no resource is found the image will be set to null. This assumes a relative source class has been set. If the ResourceLocatorInterface instance is not of type ClassResourceLocator nor AppletResourceLocator, then a new ClassResourceLocator will be created in its place and the relative source class be set on it.

  Parameters:
    `src` - the relative path and name of the image source.
  See Also:
    `getSourceRelative()`, `ResourceLocatorInterface`, `AppletResourceLocator`, `ClassResourceLocator`, `ClassLoader.getSystemResource(java.lang.String)`, `Class.getResource(java.lang.String)`

### getRelativeSourceClass

    public java.lang.Class getRelativeSourceClass()

  Gets the class that is used with the relative source path. If the ResourceLocatorInterface is of type AppletResourceLocator, then the applet class will be returned if found.

  Returns:
    the class used to get the URL of the relative source.
  See Also:
    `setSourceRelative(java.lang.String)`, `getRelativeSourceClass()`, `ResourceLocatorInterface`, `AppletResourceLocator`, `ClassResourceLocator`

### setRelativeSourceClass

    public void setRelativeSourceClass(java.lang.Class newValue)

  Sets the class that is used with the relative source path. If the current ResourceLocatorInterface is not of type ClassResourceLocator, then a new ClassResourceLocator will be created in its place, else the existing one will be used.

  Parameters:
    `relativeClass` - the class used to get the URL of the relative source.
  See Also:
    `ResourceLocatorInterface`, `ClassResourceLocator`, `setSourceRelative(java.lang.String)`, `getRelativeSourceClass()`

All Libraries | This Library | Package | Class | Use | Tree | Deprecated | Index | Grand Index | Help
|  | Components |
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2009 SAS Institute Inc. All Rights Reserved.