Class ImageView

java.lang.Object
limn.scene.Widget
limn.components.ImageView

public class ImageView extends Widget
Displays an Image: a full-color picture, or a monochrome/mask icon when a tint is set (the image's alpha becomes the shape, recolored by the tint, so an icon follows the theme). ImageView.Fit controls how the image maps into the widget bounds.
  • Constructor Details

    • ImageView

      public ImageView(Image image)
      Shows an image at its natural size until the layout says otherwise.
  • Method Details

    • setImage

      public ImageView setImage(Image newImage)
      Replaces the image, re-measuring if its natural size differs. UI thread only.
    • setFit

      public ImageView setFit(ImageView.Fit newFit)
      How the image fills its box when the two aspect ratios differ.
    • setTint

      public ImageView setTint(Color newTint)
      Tints the image (icon mode); null draws it in full color.
    • setPreferredSize

      public ImageView setPreferredSize(float width, float height)
      Fixed preferred size in logical points (-1 = natural image size).
    • onMeasure

      protected Size onMeasure(Constraints constraints)
      Description copied from class: Widget
      Reports the size this widget wants within constraints. Called once per layout pass, and the result is cached against the constraints and the resolved axes (size step, layout direction, locale), so it must be a pure function of them and of this widget's own state.

      Resolve the ControlSize and the LayoutDirection once each here and thread them down; never read either in a constructor. The locale needs no threading: it is in scope, and I18n.locale() answers it wherever text is resolved.

      Specified by:
      onMeasure in class Widget
    • onPaint

      protected void onPaint(Canvas canvas)
      Description copied from class: Widget
      Widget's own background/content, in local coordinates.
      Overrides:
      onPaint in class Widget