com.sas.visuals
Class ImageView

com.sas.visuals.ImageView
All Implemented Interfaces:
com.sas.awt.print.PrintableInterface, VisualInterface, com.sas.beans.PropertyChangeSource, com.sas.beans.VetoableChangeSource, com.sas.ComponentInterface, com.sas.LinkPropertiesInterface, com.sas.ModelInterface, ResourceConsumerInterface, com.sas.PublicClonable, com.sas.ViewInterface, com.sas.visuals.IconInterface, MultipleValueEventSourceInterface, com.sas.visuals.PainterInterface, ResizeToFitInterface, java.awt.image.ImageObserver, java.awt.MenuContainer, java.beans.PropertyChangeListener, java.io.ObjectInputValidation, java.io.Serializable, java.lang.Cloneable, java.util.EventListener, javax.swing.Icon
Direct Known Subclasses:
ImageSequence

public class ImageView
implements javax.swing.Icon, com.sas.visuals.IconInterface, ResizeToFitInterface, com.sas.PublicClonable, 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.viuals.ImageView.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.

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.

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:
IconInterface, 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
 void addNotify()
          Makes this Component displayable by connecting it to a native screen resource.
 void attachModel(com.sas.ModelInterface model)
          Attaches a model to the ImageView.
 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.
 void detachModel(com.sas.ModelInterface model)
          Detach the current model.
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.Insets getInsets()
          Returns the insets of the ImageView.
 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.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 paint(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 print(java.awt.Graphics g, int pageNumber, int pageWidth, int pageHeight)
          Prints the requested page.
 void propertyChange(java.beans.PropertyChangeEvent event)
          Handle PropertyChangeEvents from the model.
 void refresh()
          Sets the source for the image from the attached model.
 void refresh(com.sas.ModelInterface model)
          Refresh the image displayed based on the model changing.
 void resizeToFit()
          Reset the size of the ImageView to the preferredSize.
 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 setInsets(java.awt.Insets newInsets)
          Sets the Insets for the ImageView.
 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 class com.sas.awt.ComponentVisualComponent
addLink, addPropertyChangeListener, addVetoableChangeListener, anyPropertyChangeListeners, attachView, detachView, dumpComponent, firePropertyChange, firePropertyChange, fireVetoableChange, getBackgroundColor, getBorder, getComponentDescription, getComponentSupportInfo, getEventMethod, getEventValues, getFont, getForegroundColor, getHeight, getHorizontalPosition, getLinkInfo, getModelInterface, getPageBounds, getPreferredSize, getPrePainter, getPrintOptionsPanel, getVerticalPosition, getViewInterfaceSupportInfo, getVisualInterfaceSupportInfo, getWidth, initialize, initializeComponent, isDesignTime, isEnabled, isFocus, isLinked, isTransparent, isVisible, pageExists, printFinalize, printInitialize, queryLinks, queryLinks, removeAllLinks, removeInterfaceTraps, removeLink, removePropertyChangeListener, removeVetoableChangeListener, setBackgroundColor, setBorder, setComponentDescription, setComponentSupportInfo, setEnabled, setFocus, setFont, setForegroundColor, setHeight, setHorizontalPosition, setLinkInfo, setModelInterface, setPreferredSize, setPrePainter, setRequiredInterfaces, setTransparent, setVerticalPosition, setViewInterfaceSupportInfo, setVisible, setVisualInterfaceSupportInfo, setWidth, superGetFont, superGetMinimumSize, superGetPreferredSize, superIsEnabled, superIsVisible, superPaint, superSetBounds, superSetEnabled, superSetFont, superSetVisible, superUpdate, supportsListenerInterface, supportsRequiredInterfaces, trapInterfaceEvents, update, validateObject
 
Methods inherited from interface com.sas.visuals.IconInterface
getPreferredSize
 

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

attachModel

public void attachModel(com.sas.ModelInterface model)
Attaches a model to the ImageView. Listens for PropertyChangeEvents from the model.

Specified by:
attachModel in interface com.sas.ViewInterface
Overrides:
attachModel in class ComponentVisualComponent
Parameters:
model - Model to attach to
See Also:
ViewInterface.attachModel(com.sas.ModelInterface)

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 ComponentVisualComponent
Returns:
the created ImageView clone
Throws:
java.lang.CloneNotSupportedException - if clone creation fails

detachModel

public void detachModel(com.sas.ModelInterface model)
Detach the current model. Stops listening to PropertyChangeEvents on the model.

Specified by:
detachModel in interface com.sas.ViewInterface
Overrides:
detachModel in class ComponentVisualComponent
Parameters:
model - Model to detach
See Also:
ViewInterface.detachModel(com.sas.ModelInterface)

addNotify

public void addNotify()
Makes this Component displayable by connecting it to a native screen resource. This method is called internally by the toolkit and should not be called directly by programs. Overridden to call resizeToFit() to resize a component after it has been added to its parent.

Overrides:
addNotify in class java.awt.Component

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.

Specified by:
getRequiredInterfaces in interface com.sas.ViewInterface
Overrides:
getRequiredInterfaces in class ComponentVisualComponent
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)

getInsets

public java.awt.Insets getInsets()
Returns the insets of the ImageView.

Specified by:
getInsets in interface com.sas.visuals.PainterInterface
Returns:
the current Insets
See Also:
setInsets(java.awt.Insets)

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

Specified by:
getMinimumSize in interface VisualInterface
Overrides:
getMinimumSize in class Component
Returns:
minimum size of the ImageView.
See Also:
computePreferredSize()

computePreferredSize

public java.awt.Dimension computePreferredSize()
Compute the preferred size of the image.

Specified by:
computePreferredSize in interface VisualInterface
Overrides:
computePreferredSize in class ComponentVisualComponent
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)

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

paint

public void paint(java.awt.Graphics g)
Paint the ImageView

Overrides:
paint in class ComponentVisualComponent
Parameters:
g - the specified Graphics context
See Also:
VisualInterfaceSupport.paint(com.sas.ComponentInterface, com.sas.awt.VisualInterface, java.awt.Component, java.awt.Graphics)

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:
IconInterface

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent event)
Handle PropertyChangeEvents from the model.

Specified by:
propertyChange in interface java.beans.PropertyChangeListener
Overrides:
propertyChange in class ComponentVisualComponent
Parameters:
event - The event from the model indicating what property changed.
See Also:
PropertyChangeListener.propertyChange(java.beans.PropertyChangeEvent)

refresh

public void refresh(com.sas.ModelInterface model)
Refresh the image displayed based on the model changing.

Specified by:
refresh in interface com.sas.ViewInterface
Overrides:
refresh in class ComponentVisualComponent
Parameters:
model - the model that has changed and needs to be refreshed
See Also:
ViewInterface.refresh(com.sas.ModelInterface)

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()

setBounds

public void setBounds(int x,
                      int y,
                      int width,
                      int height)
Call super.setBounds() and then repaint the entire component.

Specified by:
setBounds in interface VisualInterface
Overrides:
setBounds in class ComponentVisualComponent
See Also:
ComponentVisualComponent.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.

Specified by:
setDefaultValues in interface VisualInterface
Specified by:
setDefaultValues in interface com.sas.ComponentInterface
Overrides:
setDefaultValues in class Component
See Also:
ComponentInterface.setDefaultValues()

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.

setInsets

public void setInsets(java.awt.Insets newInsets)
Sets the Insets for the ImageView. The Insets will be the maximum of the new insets and the border insets.

Parameters:
newInsets - the new Insets.
See Also:
getInsets()

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: 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()

print

public void print(java.awt.Graphics g,
                  int pageNumber,
                  int pageWidth,
                  int pageHeight)
           throws com.sas.awt.print.PrintException
Description copied from class: ComponentVisualComponent
Prints the requested page.

This implementation temporarily resizes the component via setSize(pageWidth, pageHeight) and calls the standard print method, print(g). Therefore, subclasses should make sure that their paint method, which is called by the default implementation of standard print, is synchronized, as print is here, to guard against an independent call to paint, due to a window refresh for example, inadvertently using this size change.

Subclasses with multiple pages will have to override pageExists() since it returns false for page numbers other than one which will cause the implementation of this method to throw an IndexOutOfBoundsException. Such subclasses will also need to override this method in order to change pages.

Specified by:
print in interface com.sas.awt.print.PrintableInterface
Overrides:
print in class ComponentVisualComponent
Parameters:
g - The graphics context to use for printing.
pageNumber - The one-based index of the page to be printed.
pageWidth - The width of the page (in pixels) being printed to.
pageHeight - The height of the page (in pixels) being printed to.
Throws:
com.sas.awt.print.PrintException - Thrown if a failure occurred while printing.
See Also:
PrintableInterface.print(java.awt.Graphics, int, int, int)



Copyright © 2009 SAS Institute Inc. All Rights Reserved.