Package snap.view

Class ImageView

All Implemented Interfaces:
PropChange.DoChange, XMLArchiver.Archivable
Direct Known Subclasses:
GameActor

public class ImageView extends View
A View subclass for images.
  • Field Details

  • Constructor Details

    • ImageView

      public ImageView()
      Constructor.
    • ImageView

      public ImageView(Image anImage)
      Constructor with given Image.
    • ImageView

      public ImageView(Image anImage, boolean isFillWidth, boolean isFillHeight)
      Constructor with given Image and FillWidth/FillHeight params.
    • ImageView

      public ImageView(Object aSource)
      Constructor for given source URL.
  • Method Details

    • getImage

      public Image getImage()
      Returns the image.
    • setImage

      public void setImage(Image anImage)
      Sets the image.
    • getImageName

      public String getImageName()
      Returns the image name, if loaded from local resource.
    • setImageName

      public void setImageName(String aName)
      Sets the image name, if loaded from local resource.
    • isFillWidth

      public boolean isFillWidth()
      Returns whether to resize image to fill view width.
    • setFillWidth

      public void setFillWidth(boolean aValue)
      Sets whether to resize image to fill view width.
    • isFillHeight

      public boolean isFillHeight()
      Returns whether to resize image to fill view height.
    • setFillHeight

      public void setFillHeight(boolean aValue)
      Sets whether to resize image to fill view height.
    • isKeepAspect

      public boolean isKeepAspect()
      Returns whether to to preserve aspect ratio of image when resized.
    • setKeepAspect

      public void setKeepAspect(boolean aValue)
      Sets whether to to preserve aspect ratio of image when resized.
    • isAllowBleed

      public boolean isAllowBleed()
      Returns whether image size can extend outside view size.
    • setAllowBleed

      public void setAllowBleed(boolean aValue)
      Sets whether image size can extend outside view size.
    • getFrame

      public int getFrame()
      Returns the frame.
    • setFrame

      public void setFrame(int anIndex)
      Sets the frame.
    • getFrameMax

      public int getFrameMax()
      Returns the frame.
    • getFrameCount

      public int getFrameCount()
      Returns the frame.
    • getImageBounds

      public Rect getImageBounds()
      Returns the image bounds.
    • getImageBounds

      public static Rect getImageBounds(double imageW, double imageH, Rect areaBounds, Pos anAlign, boolean fillWidth, boolean fillHeight, boolean keepAspect)
      Returns the image bounds in a given rect.
    • getPrefWidthImpl

      protected double getPrefWidthImpl(double aH)
      Returns the preferred width.
      Overrides:
      getPrefWidthImpl in class View
    • getPrefHeightImpl

      protected double getPrefHeightImpl(double aW)
      Returns the preferred height.
      Overrides:
      getPrefHeightImpl in class View
    • getAspect

      protected double getAspect()
      Returns the ratio of the width/height.
    • paintFront

      protected void paintFront(Painter aPntr)
      Paints node.
      Overrides:
      paintFront in class View
    • getPropValue

      public Object getPropValue(String aPropName)
      Returns the value for given key.
      Overrides:
      getPropValue in class View
    • setPropValue

      public void setPropValue(String aPropName, Object aValue)
      Sets the value for given key.
      Overrides:
      setPropValue in class View
    • toXML

      public XMLElement toXML(XMLArchiver anArchiver)
      XML archival.
      Specified by:
      toXML in interface XMLArchiver.Archivable
      Overrides:
      toXML in class View
    • fromXML

      public Object fromXML(XMLArchiver anArchiver, XMLElement anElement)
      XML unarchival.
      Specified by:
      fromXML in interface XMLArchiver.Archivable
      Overrides:
      fromXML in class View