Class Image

All Implemented Interfaces:
Animatable<Image>, CanDrop<Image>, Clickable<Image>, Draggable<Image>, Focusable<Image>, HandleHotKey<Image>, HandleMouseEvents<Image>, Scrollable<Image>, Touchable<Image>

Image component

With the use of this component, an image can be displayed on the interface. This image must be made accessible to the application through the URL. This means that the image must be in the application's WebContent If the image is not stored there, the system will look for the image in the specified URL.

Supported events:

AnimationStart AnimationEnd, Focus FocusOut FocusIn LosesFocus Click, DoubleClick, MouseDown, MouseDown, MouseLeave, MouseMove, MouseOver, MouseOut, MouseUp, Wheel, Scrollable TouchCancel, TouchEnd, TouchMove, TouchStart, Drop, DragStart, DragEnd HotKey

Since:
4.0
Author:
JBStrap
  • Constructor Details

    • Image

      public Image(String url)
      Creates an Image component, and sets the source of the image
      Parameters:
      url - The full URL of the image
      Throws:
      IllegalStateException - If the component is set to be both Private and Public, through an annotation.
    • Image

      public Image(String id, String url)
      Creates an Image component, and sets the source of the image
      Parameters:
      id - The component ID. The ID specified here will appear in the HTML tag as an ID attribute. If there are multiple components displayed, that have the same ID, the ID numbers will be numbered, in the order they are displayed. (For example, if the ID is 'COMPONENT' then it will be numbered like this: COMPONENT, COMPONENT_1, COMPONENT_2 etc.)
      url - The full URL of the image
      Throws:
      IllegalStateException - If the component is set to be both Private and Public, through an annotation.
    • Image

      public Image(String url, ImageStyle... styles)
      Creates an Image component, and sets the source of the image, and it's style
      Parameters:
      url - The full URL of the image
      styles - The image style. The applicable styles can be found in the ImageStyle enum.
      Throws:
      IllegalStateException - If the component is set to be both Private and Public, through an annotation.
    • Image

      public Image(String id, String url, ImageStyle... styles)
      Creates an Image component, and sets the source of the image, and it's style
      Parameters:
      id - The component ID. The ID specified here will appear in the HTML tag as an ID attribute. If there are multiple components displayed, that have the same ID, the ID numbers will be numbered, in the order they are displayed. (For example, if the ID is 'COMPONENT' then it will be numbered like this: COMPONENT, COMPONENT_1, COMPONENT_2 etc.)
      url - The full URL of the image
      styles - The image style. The applicable styles can be found in the ImageStyle enum.
      Throws:
      IllegalStateException - If the component is set to be both Private and Public, through an annotation.
    • Image

      public Image(String url, String width, String height)
      Creates an Image component, and sets width, height and the source of the image
      Parameters:
      url - The full URL of the image
      width - The width of the image, specified by using CSS3 units. Can be specified in pixel or percentage.
      height - The height of the image, specified by using CSS3 units. Can be specified in pixel or percentage.
      Throws:
      IllegalStateException - If the component is set to be both Private and Public, through an annotation.
    • Image

      public Image(String id, String url, String width, String height)
      Creates an Image component, and sets width, height and the source of the image
      Parameters:
      id - The component ID. The ID specified here will appear in the HTML tag as an ID attribute. If there are multiple components displayed, that have the same ID, the ID numbers will be numbered, in the order they are displayed. (For example, if the ID is 'COMPONENT' then it will be numbered like this: COMPONENT, COMPONENT_1, COMPONENT_2 etc.)
      url - The full URL of the image
      width - The width of the image, specified by using CSS3 units. Can be specified in pixel or percentage.
      height - The height of the image, specified by using CSS3 units. Can be specified in pixel or percentage.
      Throws:
      IllegalStateException - If the component is set to be both Private and Public, through an annotation.
    • Image

      public Image(String url, String width, String height, ImageStyle... styles)
      Creates an Image component, and sets width, height, style and the source of the image
      Parameters:
      url - The full URL of the image
      width - The width of the image, specified by using CSS3 units. Can be specified in pixel or percentage.
      height - The height of the image, specified by using CSS3 units. Can be specified in pixel or percentage.
      styles - The image style. The applicable styles can be found in the ImageStyle enum.
      Throws:
      IllegalStateException - If the component is set to be both Private and Public, through an annotation.
    • Image

      public Image(String id, String url, String width, String height, ImageStyle... styles)
      Creates an Image component, and sets width, height, style and the source of the image
      Parameters:
      id - The component ID. The ID specified here will appear in the HTML tag as an ID attribute. If there are multiple components displayed, that have the same ID, the ID numbers will be numbered, in the order they are displayed. (For example, if the ID is 'COMPONENT' then it will be numbered like this: COMPONENT, COMPONENT_1, COMPONENT_2 etc.)
      url - The full URL of the image
      width - The width of the image, specified by using CSS3 units. Can be specified in pixel or percentage.
      height - The height of the image, specified by using CSS3 units. Can be specified in pixel or percentage.
      styles - The image style. The applicable styles can be found in the ImageStyle enum.
      Throws:
      IllegalStateException - If the component is set to be both Private and Public, through an annotation.
  • Method Details

    • getUrl

      public String getUrl()
      Gets the image url
      Returns:
      The image url or null if it wasn't specified
    • setUrl

      public final Image setUrl(String url)
      Sets the image url
      Parameters:
      url - The full URL where the image is located
      Returns:
      The image component
    • getAltText

      public String getAltText()
      Gets the image alt text
      Returns:
      The image alt text or null if not specified
    • setAltText

      public final Image setAltText(String altText)

      Sets the image alt text.

      The alt text will appear if the image cannot be displayed. There can be multiple reasons for this:

      • The image hasn't loaded yet
      • The URL cannot be reached or if the image is not found
      • The user's browser doesn't support images, or has them blocked

      Parameters:
      altText - The alt text
      Returns:
      The image component
    • writeHTML

      public boolean writeHTML(StringWriter writer)
      Description copied from class: Component
      Creates the component's HTML equivalent

      This method doesn't need to be used during application development. This method is used when developing a custom component. When creating a custom component, this method needs to be implemented. In the parameter (StringWriter class) the component's HTML equivalent must be specified, and the method has to return with a Boolean value. This boolean value determines if the component was drawn. If the user doesn't have access right to the component, or if the component couldn't be drawn, it should return with false. Otherwise, it must return with true.

      Specified by:
      writeHTML in class Component<Image>
      Returns:
      If the componentwas drawn, true, otherwise false