Class ImageHandle

All Implemented Interfaces:
IReportItemMethodContext, org.eclipse.birt.report.model.elements.interfaces.IDesignElementModel, org.eclipse.birt.report.model.elements.interfaces.IImageItemModel, org.eclipse.birt.report.model.elements.interfaces.IInternalReportItemModel, org.eclipse.birt.report.model.elements.interfaces.IStyledElementModel

public class ImageHandle extends ReportItemHandle implements org.eclipse.birt.report.model.elements.interfaces.IImageItemModel
Represents an image report item. The image can come from a number of sources:
  • embedded image in the report design
  • image file
  • image presented by URL
  • expression which returns the image contents

The image has the following properties:

  • An optional hyperlink for this image.
  • An optional help text for the image.
  • An optional text message to display in place of the image in a web browser.
The image item can be sized to the image (in which case the height and width attributes are ignored), or the image can be sized or clipped to fit the item. Images are always scaled as percentage proportionately.
See Also:
  • Constructor Details

    • ImageHandle

      public ImageHandle(org.eclipse.birt.report.model.core.Module module, org.eclipse.birt.report.model.core.DesignElement element)
      Constructs a image handle with the given design and the element. The application generally does not create handles directly. Instead, it uses one of the navigation methods available on other element handles.
      Parameters:
      module - the module
      element - the model representation of the element
  • Method Details

    • getScale

      public double getScale()
      Returns the image scale. The scale factor for the image given as a percentage.
      Returns:
      the scale of this image.
    • getSize

      public String getSize()
      Returns the image size. The size must be the internal name that is one the following options defined in DesignChoiceConstants:

      • IMAGE_SIZE_SIZE_TO_IMAGE
      • IMAGE_SIZE_SCALE_TO_ITEM
      • IMAGE_SIZE_CLIP
      Returns:
      the internal value of the image size.
    • getAltText

      @Deprecated public String getAltText()
      Deprecated.
      Returns the alternate text of this image.
      Returns:
      the alternate text of the image item.
    • setAltText

      @Deprecated public void setAltText(String altText) throws SemanticException
      Deprecated.
      Sets the the alternate text of this image.
      Parameters:
      altText - the alternate text
      Throws:
      SemanticException
    • getSource

      public String getSource()
      Returns the image source type. This is one of the following options defined in DesignChoiceConstants:

      • IMAGE_REF_TYPE_NONE
      • IMAGE_REF_TYPE_URL
      • IMAGE_REF_TYPE_FILE
      • IMAGE_REF_TYPE_EXPR
      • IMAGE_REF_TYPE_EMBED
      Returns:
      the image source type.
    • setSource

      public void setSource(String source) throws SemanticException
      Sets the image source type. This is one of the following options defined in DesignChoiceConstants:

      • IMAGE_REF_TYPE_NONE
      • IMAGE_REF_TYPE_URL
      • IMAGE_REF_TYPE_FILE
      • IMAGE_REF_TYPE_EXPR
      • IMAGE_REF_TYPE_EMBED
      Parameters:
      source - the image source type.
      Throws:
      SemanticException - if the source is not one of the above.
    • getURI

      public String getURI()
      Returns the image URI if the image source type is IMAGE_REF_TYPE_URL or IMAGE_REF_TYPE_FILE.
      Returns:
      the image URI if the image source type is IMAGE_REF_TYPE_URL or IMAGE_REF_TYPE_FILE. Otherwise, return null.
    • getURL

      public String getURL()
      Returns the image URI if the image source type is IMAGE_REF_TYPE_URL or IMAGE_REF_TYPE_FILE.
      Overrides:
      getURL in class ReportItemHandleImpl
      Returns:
      the image URI if the image source type is IMAGE_REF_TYPE_URL , Otherwise, return null.
    • getFile

      public String getFile()
      Returns the image URI if the image source type is IMAGE_REF_TYPE_URL or IMAGE_REF_TYPE_FILE.
      Returns:
      the image URI if the image source type is IMAGE_REF_TYPE_FILE. Otherwise, return null.
    • getTypeExpression

      public String getTypeExpression()
      Returns the type expression of the image item if the image source type is IMAGE_REF_TYPE_EXPR.
      Returns:
      the type expression, if the image source type is IMAGE_REF_TYPE_EXPR. Otherwise, return null.
    • getValueExpression

      public String getValueExpression()
      Returns the value expression of the image if the image source type is IMAGE_REF_TYPE_EXPR.
      Returns:
      the value expression, if the image source type is IMAGE_REF_TYPE_EXPR. Otherwise, return null.
    • getImageName

      public String getImageName()
      Returns the embedded image name that this image refers, if the image source type is IMAGE_REF_TYPE_EMBED. This is not the same as DesignElementHandle.getName()of this image item.
      Returns:
      the embedded image name, if the image source type is IMAGE_REF_TYPE_EMBED. Otherwise, return null.
    • getEmbeddedImage

      public EmbeddedImageHandle getEmbeddedImage()
      Returns the embedded image handle that this image refers, if the image source type is IMAGE_REF_TYPE_EMBED.
      Returns:
      the embedded image handle, if the image source type is IMAGE_REF_TYPE_EMBED and the referred embedded image is found. Otherwise, return null.
    • setImageName

      public void setImageName(String name) throws SemanticException
      Sets the embedded image name that this image refers, if the image source type is IMAGE_REF_TYPE_EMBED. The reference type is automatically set in this method. This is not the same as DesignElementHandle.setName(String).
      Parameters:
      name - the embedded image name
      Throws:
      SemanticException - if the property is locked.
    • setURL

      public void setURL(String url) throws SemanticException
      Sets the image uri property. The source type is IMAGE_REF_TYPE_URL, and will automatically set in this method.
      Overrides:
      setURL in class ReportItemHandleImpl
      Parameters:
      url - the url to be set.
      Throws:
      SemanticException - if the property is locked.
    • setURI

      @Deprecated public void setURI(String uri) throws SemanticException
      Deprecated.
      Sets the image uri property. The source type is IMAGE_REF_TYPE_URL, and will automatically set in this method.
      Parameters:
      uri - the uri to be set.
      Throws:
      SemanticException - if the property is locked.
    • setFile

      public void setFile(String file) throws SemanticException
      Sets the image uri property. The source type is IMAGE_REF_TYPE_FILE, and will automatically set in this method.
      Parameters:
      file - the file to be set.
      Throws:
      SemanticException - if the property is locked.
    • setScale

      public void setScale(double scale) throws SemanticException
      Sets the image scale property. The scale factor for the image given as a percentage. The default is 100%.
      Parameters:
      scale - the scale value to be set.
      Throws:
      SemanticException - if the property is locked.
    • setSize

      public void setSize(String size) throws SemanticException
      Sets the image size property. The input value is one of the followings defined in DesignChoiceConstants:

      • IMAGE_SIZE_SIZE_TO_IMAGE
      • IMAGE_SIZE_SCALE_TO_ITEM
      • IMAGE_SIZE_CLIP
      Parameters:
      size - the size value to be set.
      Throws:
      SemanticException - if the input size is not one of the above, or if the property is locked.
    • setTypeExpression

      public void setTypeExpression(String value) throws SemanticException
      Sets the type expression value. The source type is automatically set to IMAGE_REF_TYPE_EXPR.
      Parameters:
      value - the type expression value.
      Throws:
      SemanticException - if the property is locked.
    • setValueExpression

      public void setValueExpression(String value) throws SemanticException
      Sets the value expression value. The source type is automatically set to IMAGE_REF_TYPE_EXPR.
      Parameters:
      value - the value expression.
      Throws:
      SemanticException - if the property is locked.
    • getActionHandle

      public ActionHandle getActionHandle()
      Returns a handle to work with the action property, action is a structure that defines a hyperlink.
      Returns:
      a handle to the action property, return null if the action has not been set on the image.
      See Also:
    • setAction

      public ActionHandle setAction(Action action) throws SemanticException
      Set an action on the image.
      Parameters:
      action - new action to be set on the image, it represents a bookmark link, hyper-link, and drill through etc.
      Returns:
      a handle to the action property, return null if the action has not been set on the image.
      Throws:
      SemanticException - if member of the action is not valid.
    • actionsIterator

      public Iterator<ActionHandle> actionsIterator()
      Returns the iterator for action defined on this image item.
      Returns:
      the iterator for Action structure list defined on this image item
    • getHelpText

      public String getHelpText()
      Returns the help text of this image item.
      Returns:
      the help text
    • setHelpText

      public void setHelpText(String helpText) throws SemanticException
      Sets the help text of this image item.
      Parameters:
      helpText - the help text
      Throws:
      SemanticException - if the property is locked.
    • getHelpTextKey

      public String getHelpTextKey()
      Returns the resource key of the help text of this image item.
      Returns:
      the resource key of the help text
    • setHelpTextKey

      public void setHelpTextKey(String helpTextKey) throws SemanticException
      Sets the resource key of help text of this image item.
      Parameters:
      helpTextKey - the help text
      Throws:
      SemanticException - if the property is locked.
    • fitToContainer

      public boolean fitToContainer()
      Gets the fit to container property value of this image item.
      Returns:
      the fit to container of this image item.
    • setFitToContainer

      public void setFitToContainer(boolean fitToContainer) throws SemanticException
      Sets the fit to container property value of this image item.
      Parameters:
      fitToContainer - the value of fit to container.
      Throws:
      SemanticException - if the property is locked.
    • setURL

      public void setURL(Expression expr) throws SemanticException
      Sets the image uri property by an expression. The source type is IMAGE_REF_TYPE_URL, and will automatically set in this method.
      Parameters:
      expr - the expression to be set.
      Throws:
      SemanticException - if the property is locked.
    • setFile

      public void setFile(Expression expr) throws SemanticException
      Sets the image uri property by an expression. The source type is IMAGE_REF_TYPE_FILE, and will automatically set in this method.
      Parameters:
      expr - the expression to be set.
      Throws:
      SemanticException - if the property is locked.
    • isProportionalScale

      public boolean isProportionalScale()
      Gets the flag which indicates whether the image scales proportionally or not.
      Returns:
      true if the image scale proportionally, othewise false
    • setProportionalScale

      public void setProportionalScale(boolean proportionalScale) throws SemanticException
      Sets the flag which indicates whether the image scales proportionally or not.
      Parameters:
      proportionalScale - the new flag to set
      Throws:
      SemanticException