com.droplets.api
Class ImageComponent

java.lang.Object
  |
  +--com.droplets.api.Component
        |
        +--com.droplets.api.ImageComponent
All Implemented Interfaces:
Clickable

public class ImageComponent
extends Component
implements Clickable

Component that displays an image. The Image can send events if it is clicked or allow the end user to save the image locally.

The image to be displayed may be specified in one of two ways: using an absolute URL and the setImageUrl and getImageUrl() methods, or using a Droplets "image name" and setImageSetName and getImageSetName(). An "image name" is the filename of a .gif, not including the .gif extension, to be fetched by the Droplet Client according to skinning rules (from the imagedir or imagejar). See Skinning Droplets for details.

You have several choices for how the image should be displayed. Each choice is represented by a static final constant of type ImageComponent.ImageMode defined within this class. See below for a list of those constants and what they represent.


Inner Class Summary
static class ImageComponent.ImageMode
          Typesafe constant class to represent the different ways in which an image can be displayed in a panel.
 
Field Summary
static ImageComponent.ImageMode IMAGE_CENTER
          Centers the image in the component
static ImageComponent.ImageMode IMAGE_FIT
          Fits the image to the component's exact size, changing its aspect ratio accordingly.
static ImageComponent.ImageMode IMAGE_SCALE_BOTH
          Scales the image to fit the component without changing the aspect ratio
static ImageComponent.ImageMode IMAGE_SCALE_DOWN
          Shrinks the image to fit the component, without changing the aspect ratio (doesn't enlarge the image beyond its native size)
static ImageComponent.ImageMode IMAGE_SCALE_UP
          Enlarges the image to fit the component, without changing the aspect ratio (doesn't shrink the image below its native size)
static ImageComponent.ImageMode IMAGE_TILE
          Tiles the image with the upper left of the component as the tile origin
static ImageComponent.ImageMode IMAGE_TILE_WRT_WINDOW
          Tiles the image with the upper left of the enclosing window as the tile origin (WRT = "with respect to")
 
Fields inherited from class com.droplets.api.Component
ANCHOR_CENTER, ANCHOR_EAST, ANCHOR_NORTH, ANCHOR_NORTHEAST, ANCHOR_NORTHWEST, ANCHOR_SOUTH, ANCHOR_SOUTHEAST, ANCHOR_SOUTHWEST, ANCHOR_WEST, FILL_BOTH, FILL_HORIZONTAL, FILL_NONE, FILL_VERTICAL
 
Constructor Summary
ImageComponent(LayoutPlacement p, Window window)
          Constructs a new ImageComponent.
 
Method Summary
protected  void action(java.lang.String action, java.lang.String args)
          Called by the server when the user has performed an action on this component.
 void addClickListener(ClickListener l)
          Add a listener for the Click event of this component
 ImageComponent.ImageMode getImageMode()
          Gets the value of the imageMode property.
 java.lang.String getImageSetName()
          Gets the name of the image set to use for the button.
 java.lang.String getImageUrl()
          Returns the current URL of the image file.
 boolean getIsResizeHandle()
          True if dragging the component will resize the window.
 java.lang.String getRedirectorURL()
          Gets the current value of the Redirector URL.
 boolean getSaveOnDoubleClick()
          Returns true if the image will allow the user to save the image when it is double-clicked.
protected  boolean isFocusTraversableDefault()
          See Component.isFocusTraversableDefault().
 void removeClickListener(ClickListener l)
          Remove a listener of the Click event of this component
 void setImageMode(ImageComponent.ImageMode value)
          Sets the image mode for this component (see above for details.)
 void setImageMode(ImageComponent.ImageMode value, java.lang.String skin)
          Sets the image mode for this component (see above for details.)
 void setImageSetName(java.lang.String value)
          Sets the name of the image set to use for the Component.
 void setImageSetName(java.lang.String value, java.lang.String skin)
          Sets the name of the image set to use for the Component.
 void setImageUrl(java.lang.String value)
          Sets the URL of the image that will be displayed.
 void setImageUrl(java.lang.String value, java.lang.String skin)
          Sets the URL of the image that will be displayed.
 void setIsResizeHandle(boolean value)
          If value is true, dragging this component will resize the window
 void setIsResizeHandle(boolean value, java.lang.String skin)
          If value is true, dragging this component will resize the window
 void setRedirectorURL(java.lang.String value)
          The method allows you to override the default redirector location.
 void setRedirectorURL(java.lang.String value, java.lang.String skin)
          The method allows you to override the default redirector location.
 void setSaveOnDoubleClick(boolean value)
          If value is true, allow the user to save the image with a double-click
 void setSaveOnDoubleClick(boolean value, java.lang.String skin)
          If value is true, allow the user to save the image with a double-click
 
Methods inherited from class com.droplets.api.Component
addActionListener, addAttributeChangeListener, addValueChangeListener, attributeChanged, constructionFailed, equals, fireActionEvent, fireAttributeChangeEvent, fireValueChangeEvent, getAnchor, getAttribute, getBgColor, getBoolAttribute, getBordersAttribute, getColorAttribute, getCursor, getCursorType, getDoubleAttribute, getEnabled, getFgColor, getFill, getFont, getGridHeight, getGridWidth, getGridX, getGridY, getInsets, getIntAttribute, getIPadX, getIPadY, getOpaque, getParent, getScriptingName, getSpecification, getStringAttribute, getToolTip, getValue, getVisible, getWeightX, getWeightY, getWindow, invalidate, isAddedToWindow, isContainer, isFocusTraversable, isValid, removeActionListener, removeAttributeChangeListener, removeValueChangeListener, requestFocus, reset, sendCommandAttribute, setAnchor, setAnchor, setArg, setAttribute, setBgColor, setBgColor, setBoolAttribute, setBordersAttribute, setColorAttribute, setCursor, setCursor, setCursorType, setDoubleAttribute, setEnabled, setEnabled, setEnterButton, setEnterButton, setEnterButton, setFgColor, setFgColor, setFill, setFill, setFocusTraversable, setFont, setFont, setGridHeight, setGridHeight, setGridWidth, setGridWidth, setGridX, setGridX, setGridY, setGridY, setInsets, setInsets, setIntAttribute, setIPadX, setIPadX, setIPadY, setIPadY, setItemListAttribute, setOpaque, setOpaque, setScriptingName, setStringAttribute, setToolTip, setValue, setValue, setVisible, setVisible, setWeightX, setWeightX, setWeightY, setWeightY, storeAttribute, valueChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

IMAGE_CENTER

public static final ImageComponent.ImageMode IMAGE_CENTER
Centers the image in the component

IMAGE_TILE

public static final ImageComponent.ImageMode IMAGE_TILE
Tiles the image with the upper left of the component as the tile origin

IMAGE_TILE_WRT_WINDOW

public static final ImageComponent.ImageMode IMAGE_TILE_WRT_WINDOW
Tiles the image with the upper left of the enclosing window as the tile origin (WRT = "with respect to")

IMAGE_SCALE_BOTH

public static final ImageComponent.ImageMode IMAGE_SCALE_BOTH
Scales the image to fit the component without changing the aspect ratio

IMAGE_SCALE_UP

public static final ImageComponent.ImageMode IMAGE_SCALE_UP
Enlarges the image to fit the component, without changing the aspect ratio (doesn't shrink the image below its native size)

IMAGE_SCALE_DOWN

public static final ImageComponent.ImageMode IMAGE_SCALE_DOWN
Shrinks the image to fit the component, without changing the aspect ratio (doesn't enlarge the image beyond its native size)

IMAGE_FIT

public static final ImageComponent.ImageMode IMAGE_FIT
Fits the image to the component's exact size, changing its aspect ratio accordingly.
Constructor Detail

ImageComponent

public ImageComponent(LayoutPlacement p,
                      Window window)
Constructs a new ImageComponent.
Parameters:
p - specifies how this component should be laid out in the enclosing panel (see LayoutPlacement)
window - the window in which this component will be placed
Method Detail

getImageSetName

public java.lang.String getImageSetName()
Gets the name of the image set to use for the button. See above for details.
Returns:
the image set name

setImageSetName

public void setImageSetName(java.lang.String value,
                            java.lang.String skin)
Sets the name of the image set to use for the Component. See above for details.
Parameters:
value - the image set name
skin - the skin name to use for this attribute

setImageSetName

public void setImageSetName(java.lang.String value)
Sets the name of the image set to use for the Component. See above for details.
Parameters:
value - the image set name
skin - the skin name to use for this attribute

getImageUrl

public java.lang.String getImageUrl()
Returns the current URL of the image file.
Returns:
Current value of this attribute.

setImageUrl

public void setImageUrl(java.lang.String value,
                        java.lang.String skin)
Sets the URL of the image that will be displayed. See above for information on your options for displaying images.
Parameters:
value - Complete URL of the image file.
skin - The name by which this attribute will referred to from skin files.

setImageUrl

public void setImageUrl(java.lang.String value)
Sets the URL of the image that will be displayed. See above for information on your options for displaying images.
Parameters:
value - Complete URL of the image file.

getRedirectorURL

public java.lang.String getRedirectorURL()
Gets the current value of the Redirector URL. An empty string indicates that the default location is in use.
Returns:
Current value of this attribute.

setRedirectorURL

public void setRedirectorURL(java.lang.String value,
                             java.lang.String skin)
The method allows you to override the default redirector location. You do not need to call this method if you are using the standard Droplets installation.
Parameters:
value - The URL of the content redirector.
skin - The name to use for this attribute in the skin files.

setRedirectorURL

public void setRedirectorURL(java.lang.String value)
The method allows you to override the default redirector location. You do not need to call this method if you are using the standard Droplets installation.
Parameters:
value - The URL of the content redirector.

getImageMode

public ImageComponent.ImageMode getImageMode()
Gets the value of the imageMode property. See above for details.
Returns:
current value of the property

setImageMode

public void setImageMode(ImageComponent.ImageMode value,
                         java.lang.String skin)
Sets the image mode for this component (see above for details.)
Parameters:
value - the desired image mode
skin - the skin name to use for this attribute

setImageMode

public void setImageMode(ImageComponent.ImageMode value)
Sets the image mode for this component (see above for details.)
Parameters:
value - the desired image mode

getSaveOnDoubleClick

public boolean getSaveOnDoubleClick()
Returns true if the image will allow the user to save the image when it is double-clicked.
Returns:
the value of this attribute

setSaveOnDoubleClick

public void setSaveOnDoubleClick(boolean value,
                                 java.lang.String skin)
If value is true, allow the user to save the image with a double-click
Parameters:
value - true if double-click on the image should allow the end-user to save the image
skin - the skin name of the attribute

setSaveOnDoubleClick

public void setSaveOnDoubleClick(boolean value)
If value is true, allow the user to save the image with a double-click
Parameters:
value - true if double-click on the image should allow the end-user to save the image

getIsResizeHandle

public boolean getIsResizeHandle()
True if dragging the component will resize the window.
Returns:
true if dragging the image will resize the window

setIsResizeHandle

public void setIsResizeHandle(boolean value,
                              java.lang.String skin)
If value is true, dragging this component will resize the window
Parameters:
value - true if dragging the image should resize the window
skin - the skin name of the attribute

setIsResizeHandle

public void setIsResizeHandle(boolean value)
If value is true, dragging this component will resize the window
Parameters:
value - true if dragging the image should resize the window

action

protected void action(java.lang.String action,
                      java.lang.String args)
Description copied from class: Component
Called by the server when the user has performed an action on this component. Subclasses should overridde to handle any actions that they need to handle in a special way - for example, if they maintain a separate listener list for some kinds of actions. If a subclass gets an action it doesn't recognize or is not interested in, it should pass the call on to this implementation in order to support notification of ActionListeners.
Overrides:
action in class Component
Following copied from class: com.droplets.api.Component
Parameters:
action - Identifies the type of action that occurred
args - Action-specific arguments (extra information)

addClickListener

public void addClickListener(ClickListener l)
Add a listener for the Click event of this component
Specified by:
addClickListener in interface Clickable
Parameters:
l - a listener to be notified if this component is clicked

removeClickListener

public void removeClickListener(ClickListener l)
Remove a listener of the Click event of this component
Specified by:
removeClickListener in interface Clickable
Parameters:
l - a listener to no longer be notified if this component is clicked

isFocusTraversableDefault

protected boolean isFocusTraversableDefault()
See Component.isFocusTraversableDefault().
Overrides:
isFocusTraversableDefault in class Component
Following copied from class: com.droplets.api.Component
See Also:
Component.setFocusTraversable(boolean)


Copyright © Droplets, 2001. All Rights Reserved.