All Packages Class Hierarchy This Package Previous Next Index
Class com.ibm.eou.swingimageregionselector.ImageRegionSelector
java.lang.Object
|
+----java.awt.Component
|
+----java.awt.Container
|
+----com.sun.java.swing.JComponent
|
+----com.ibm.eou.swingimageregionselector.ImageRegionSelector
- public class ImageRegionSelector
- extends JComponent
- implements MouseListener, MouseMotionListener, ItemSelectable, Serializable
The ImageRegionSelector is a bean which allows the selection of pre-defined regions of an image which is displayed
to the user. The image the user sees (the "display" image) is referenced by a second image, the "color map"
image, which represents the separate selectable regions of the display image in a given sequence of colors.
The color map image is used for hit-correlation to detect which display image region has been selected
or rolled over. For example if the mouse is clicked on pixel (100,150) on the display image the color of the pixel
at (100,150) in the color map image is taken. This color, if the color map image has been correctly created, will
be one of the colors in the ordered set of valid index colors. The index of the valid color is returned and is
stored as the currently selected region.
The ImageRegionSelector also supports the highlighting of selected regions (mouse clicked inside a region) and rollover
regions (mouse moved within a region) to show clearly to the user which areas have been selected. Additionally,
tooltips are supported to give the user a short textual desription when the mouse hovers over a particular region.
The ImageRegionSelector bean has the following nine properties:
- Display Image - A string representing the name of the display image
- Color Map Image - A string representing the name of the color map image
- Cutaway Image - A String representing the name of the cutaway image
- Selection Emphasis Style - Integer value (int) indicating the selection emphasis style to use
- Rollover Emphasis Style - Integer value (int) indicating the rollover emphasis style to use
- Selected Index - Integer (int) value of the index of the selected region
- Selected Value - Name associated with the selected region
- Tooltips - An array of strings - one of which is displayed when the mouse hovers over a particular region
- Region Names - An array of strings to store the names of the regions. Used as an alternative way to get the
region that has been selected. Similar to a JList where the label on the list can be returned
The selection and rollover emphasis style properties should be set to one of the following values:
- NONE - No highlighting is applied to the region
- LIGHTEN - The region will be lightened
- DARKEN - The region will be darkened
- NEGATIVE - Each pixel in the region will be inverted
- CUTAWAY - The corresponding pixels in the cutaway image will displayed through a "cutaway" area representing the region
The ImageRegionSelector implements the java.awt.ItemSelectable interface which provides a standard mechanism
for other java components to interact with the ImageRegionSelector. The ImageRegionSelector fires java.awt.event.ItemEvent
events when regions are selected or deselected - which are received by any component that implements the
java.awt.event.ItemListener interface and has added itself to the ImageRegionSelector as an item listener via the
addItemListener method.
-
CUTAWAY
- Show cutaway image through selected or rollover region
-
DARKEN
- Darken selected or rollover region
-
LIGHTEN
- Lighten selected or rollover region
-
NEGATIVE
- Show selected or rollover region in negative
-
NONE
- No image emphasis
-
ImageRegionSelector()
- ImageRegionSelector constructor
-
addItemListener(ItemListener)
- Registers a component as an item listener so it can receive item events from the ImageRegionSelector
-
addNotify()
- Method is called when the ImageRegionSelector is added to its parent
-
copyright()
- IBM Copyright statement
-
getColorMapImage()
- Returns the name of the color map image
-
getCutawayImage()
- Returns the name of the cutaway image
-
getDisplayImage()
- Returns the name of the display image
-
getRegionNames()
- Returns the array of region names.
-
getRegionNamesList()
- Returns the region names in a StringList object - used within the visual builder.
-
getRolloverEmphasisStyle()
- Returns the current rollover emphasis style
-
getSelectedIndex()
- Returns the index of the selected region
-
getSelectedItem()
- Gets the region name corresponding to the selected region.
-
getSelectedObjects()
- Taken from the ItemSelectable interface.
-
getSelectionEmphasisStyle()
- Returns the current selection emphasis style
-
getTooltipList()
- Returns an array of tooltip strings wrapped in a StringList class
-
getTooltips()
- Returns the tooltip strings as an array
-
getToolTipText(MouseEvent)
- Sets the string to be displayed on the tooltip for the given MouseEvent
-
imageUpdate(Image, int, int, int, int, int)
- Taken from the ImageObserver interface and is used to control the painting of a filtered image.
-
mouseClicked(MouseEvent)
- From the MouseListener interface - captures mouse clicked events
-
mouseDragged(MouseEvent)
- From the MouseMotionListener interface - captures mouse dragged events
-
mouseEntered(MouseEvent)
- From the MouseListener interface - captures mouse entered events
-
mouseExited(MouseEvent)
- From the MouseListener interface - captures mouse exited events
-
mouseMoved(MouseEvent)
- From the MouseMotionListener interface - captures mouse moved events
-
mousePressed(MouseEvent)
- From the MouseListener interface - captures mouse pressed events
-
mouseReleased(MouseEvent)
- From the MouseListener interface - captures mouse released events
-
paintComponent(Graphics)
- paints the ImageRegionSelector
-
removeItemListener(ItemListener)
- Removes the component as an item listener - no longer wants to receive events from the image picker
-
setColorMapImage(String)
- Sets the color map image to be the image of the the file name specified
-
setCutawayImage(String)
- Sets the cutaway image to be the image of the the file name specified
-
setDisplayImage(String)
- Sets the display image to be the image of the the file name specified
-
setRegionNames(String[])
- Sets the array of region names
-
setRegionNamesList(StringList)
- Sets the array of region names as a StringList object - used in the visual builder
-
setRolloverEmphasisStyle(int)
- Sets the rollover emphasis style to be used.
-
setSelectedIndex(int)
- Specifies the region to be selected
-
setSelectionEmphasisStyle(int)
- Sets the selection emphasis style to be used.
-
setTooltipList(StringList)
- Sets the tooltips to be the new StringList object
-
setTooltips(String[])
- Sets the tooltips to be the values in the String array given
NONE
public static final int NONE
- No image emphasis
LIGHTEN
public static final int LIGHTEN
- Lighten selected or rollover region
DARKEN
public static final int DARKEN
- Darken selected or rollover region
NEGATIVE
public static final int NEGATIVE
- Show selected or rollover region in negative
CUTAWAY
public static final int CUTAWAY
- Show cutaway image through selected or rollover region
ImageRegionSelector
public ImageRegionSelector()
- ImageRegionSelector constructor
addItemListener
public void addItemListener(ItemListener il)
- Registers a component as an item listener so it can receive item events from the ImageRegionSelector
- Parameters:
- il - Component to listen for item events
addNotify
public void addNotify()
- Method is called when the ImageRegionSelector is added to its parent
- Overrides:
- addNotify in class JComponent
copyright
public static String copyright()
- IBM Copyright statement
getColorMapImage
public String getColorMapImage()
- Returns the name of the color map image
- Returns:
- Name of the color map image
getCutawayImage
public String getCutawayImage()
- Returns the name of the cutaway image
- Returns:
- The name of the cutaway image
getDisplayImage
public String getDisplayImage()
- Returns the name of the display image
- Returns:
- The name of the display image
getRegionNames
public String[] getRegionNames()
- Returns the array of region names.
- Returns:
- java.lang.String[] The names of the regions
getRegionNamesList
public StringList getRegionNamesList()
- Returns the region names in a StringList object - used within the visual builder.
- Returns:
- com.ibm.eou.swingimageregionselector..StringList Region names
getRolloverEmphasisStyle
public int getRolloverEmphasisStyle()
- Returns the current rollover emphasis style
- Returns:
- The rollover emphasis style
getSelectedIndex
public int getSelectedIndex()
- Returns the index of the selected region
- Returns:
- The index of the selected region
getSelectedItem
public Object getSelectedItem()
- Gets the region name corresponding to the selected region.
- Returns:
- java.lang.Object Name of the selected region
getSelectedObjects
public Object[] getSelectedObjects()
- Taken from the ItemSelectable interface. The ImageRegionSelector supports only single selection which means the
return value is an array of Objects with only one element - the selected index
- Returns:
- Array containing only the index of the selected region - or null if no region is selected
getSelectionEmphasisStyle
public int getSelectionEmphasisStyle()
- Returns the current selection emphasis style
- Returns:
- The selection emphasis style
getTooltipList
public StringList getTooltipList()
- Returns an array of tooltip strings wrapped in a StringList class
- Returns:
- StringList object containing the tooltip strings
getTooltips
public String[] getTooltips()
- Returns the tooltip strings as an array
- Returns:
- Array of tooltip values
getToolTipText
public String getToolTipText(MouseEvent e)
- Sets the string to be displayed on the tooltip for the given MouseEvent
- Parameters:
- e - MouseEvent that triggered the request for a new tooltip value
- Returns:
- String to appear on the tooltip
- Overrides:
- getToolTipText in class JComponent
imageUpdate
public boolean imageUpdate(Image img,
int flags,
int x,
int y,
int width,
int height)
- Taken from the ImageObserver interface and is used to control the painting of a filtered image. This method
is called when prepareImage is called for an image being filtered to record when the filtering is complete. A
repaint request is made only when the image is complete
- Parameters:
- img - The image being observed
- flags - The latest state of the image
- x - known x position of the image
- y - known y position of the image
- width - known width of the image
- height - known height of the image
- Returns:
- updated image status information
- Overrides:
- imageUpdate in class Component
mouseClicked
public void mouseClicked(MouseEvent e)
- From the MouseListener interface - captures mouse clicked events
- Parameters:
- e - mouse event
mouseDragged
public void mouseDragged(MouseEvent e)
- From the MouseMotionListener interface - captures mouse dragged events
- Parameters:
- e - mouse event
mouseEntered
public void mouseEntered(MouseEvent e)
- From the MouseListener interface - captures mouse entered events
- Parameters:
- e - mouse event
mouseExited
public void mouseExited(MouseEvent e)
- From the MouseListener interface - captures mouse exited events
- Parameters:
- e - mouse event
mouseMoved
public void mouseMoved(MouseEvent e)
- From the MouseMotionListener interface - captures mouse moved events
- Parameters:
- e - mouse event
mousePressed
public void mousePressed(MouseEvent e)
- From the MouseListener interface - captures mouse pressed events
- Parameters:
- e - mouse event
mouseReleased
public void mouseReleased(MouseEvent e)
- From the MouseListener interface - captures mouse released events
- Parameters:
- e - mouse event
paintComponent
public void paintComponent(Graphics g)
- paints the ImageRegionSelector
- Parameters:
- g - ImageRegionSelector's graphics context
- Overrides:
- paintComponent in class JComponent
removeItemListener
public void removeItemListener(ItemListener il)
- Removes the component as an item listener - no longer wants to receive events from the image picker
- Parameters:
- il - Component to be removed
setColorMapImage
public void setColorMapImage(String newValue)
- Sets the color map image to be the image of the the file name specified
- Parameters:
- newValue - File name of image
setCutawayImage
public void setCutawayImage(String newValue)
- Sets the cutaway image to be the image of the the file name specified
- Parameters:
- newValue - File name of image
setDisplayImage
public void setDisplayImage(String newValue)
- Sets the display image to be the image of the the file name specified
- Parameters:
- newValue - File name of image
setRegionNames
public void setRegionNames(String newValue[])
- Sets the array of region names
- Parameters:
- newValue - java.lang.String[] Array of region names
setRegionNamesList
public void setRegionNamesList(StringList newValue)
- Sets the array of region names as a StringList object - used in the visual builder
- Parameters:
- newValue - java.lang.String[] StringList object of the region names
setRolloverEmphasisStyle
public void setRolloverEmphasisStyle(int newValue)
- Sets the rollover emphasis style to be used. Should be set to one of the following values:
- ImageRegionSelector.NONE
- ImageRegionSelector.LIGHTEN
- ImageRegionSelector.DARKEN
- ImageRegionSelector.NEGATIVE
- ImageRegionSelector.CUTAWAY
- Parameters:
- newValue - new rollover emphasis style setting
setSelectedIndex
public void setSelectedIndex(int index)
- Specifies the region to be selected
- Parameters:
- index - Region to be selected
setSelectionEmphasisStyle
public void setSelectionEmphasisStyle(int newValue)
- Sets the selection emphasis style to be used. Should be set to one of the following values:
- ImageRegionSelector.NONE
- ImageRegionSelector.LIGHTEN
- ImageRegionSelector.DARKEN
- ImageRegionSelector.NEGATIVE
- ImageRegionSelector.CUTAWAY
- Parameters:
- newValue - new selection emphasis style setting
setTooltipList
public void setTooltipList(StringList values)
- Sets the tooltips to be the new StringList object
- Parameters:
- values - New tooltip values
setTooltips
public void setTooltips(String newValue[])
- Sets the tooltips to be the values in the String array given
- Parameters:
- newValue - Array of new tooltip values
All Packages Class Hierarchy This Package Previous Next Index