Class ImageReference

All Implemented Interfaces:
EventListener, IFontConsumer, IGProp<ReferenceString>, IPropReference, IReferencingGProp, Cloneable
Direct Known Subclasses:
BackgroundImageReference

public class ImageReference extends FixedVirtualizedAbstractReference<IImageTarget> implements IFontConsumer
The Image Reference property class hold the reference to an image definition implementing IImageTarget that in turn has images for various states and resolutions.
Author:
Christopher Mindus
  • Constructor Details

    • ImageReference

      protected ImageReference()
      Creates a Action Reference property with no name and with a null value.
    • ImageReference

      public ImageReference(Atom propertyAtom)
      Creates a Image Reference property with the specified name with a null value.
      Parameters:
      propertyAtom - the property atom.
    • ImageReference

      public ImageReference(Atom propertyAtom, String newValue)
      Creates a Image Reference property with the specified name and value.
      Parameters:
      propertyAtom - the property atom.
      newValue - the new string value for the property.
  • Method Details

    • setImageTypes

      public void setImageTypes(int... types)
      Assigns the image types that are requested.
      Parameters:
      types - The list of image types requested, each value is combined of the AbstractImageDefinition.ID_MASK_* values. If types is empty or null or contains a single value -1 (or less than zero), all types are used.
    • initializeProp

      protected void initializeProp(Element element) throws PropException
      Called to initialize the property from an Element. The property should initialize itself from attributes and nodes with appropriate information.

      Subclasses should override this method if custom initialization is required.

      The default implementation gets the attribute "value" and calls the methods object=convertPropertyValue(string) followed by setPropertyValue(object).

      Overrides:
      initializeProp in class GProp<ReferenceString>
      Parameters:
      element - The Element.
      Throws:
      PropException - when the initialization fails.
    • initializeElement

      protected void initializeElement(Element element)
      Called when the XML file for the property tree is serialized from properties. The property should fill attributes and nodes with appropriate information.

      Subclasses should override this method if custom initialization is required.

      Overrides:
      initializeElement in class GProp<ReferenceString>
      Parameters:
      element - The Element to initialize.
    • getReferenceType

      public IPropReference.IRefType getReferenceType()
      Gets the reference Type.
      Specified by:
      getReferenceType in interface IPropReference
      Specified by:
      getReferenceType in interface IReferencingGProp
      Specified by:
      getReferenceType in class AbstractReference<IImageTarget>
      Returns:
      IPropReference.RefType.Image.
    • getPropertyClass

      public Class<?> getPropertyClass()
      Gets the class wanted.
      Specified by:
      getPropertyClass in class AbstractReference<IImageTarget>
      Returns:
      The property class that should be referenced.
    • isReferenceValid

      public boolean isReferenceValid(GProp<?> property)
      Validates the property reference that has been looked up.
      Specified by:
      isReferenceValid in interface IPropReference
      Specified by:
      isReferenceValid in class AbstractReference<IImageTarget>
      Parameters:
      property - The property to validate.
      Returns:
      true if valid, false otherwise.
    • setImage

      public boolean setImage(IImageTarget image)
      Sets the image reference to the specified image.
      Parameters:
      image - The image.
      Returns:
      true for changed, false for no change.
      Throws:
      NullPointerException - If image is null.
    • getClientImageData

      public ClientImageData getClientImageData()
      Gets the ClientImageData instance.
      Returns:
      The instance of the Client image data, or null if not a valid reference.
    • onEventSelf

      public void onEventSelf(GEvent event)
      Overridden to check for cache clearing...
      Specified by:
      onEventSelf in interface IGProp<ReferenceString>
      Overrides:
      onEventSelf in class AbstractReference<IImageTarget>
      Parameters:
      event - The property event.
    • informResolved

      protected void informResolved()
      Called when the property has been resolved. Subclasses override this method to implement some behavior. The default implementation performs nothing, i.e. there is no need to call super.informResolved().
      Overrides:
      informResolved in class FixedVirtualizedAbstractReference<IImageTarget>
    • informError

      protected void informError()
      Called when the property has an error. Subclasses override this method to implement some behavior. The default implementation performs nothing, i.e. there is no need to call super.informError().
      Overrides:
      informError in class FixedVirtualizedAbstractReference<IImageTarget>
    • clone

      public ImageReference clone()
      Cloning first makes sure there is a cached ClientImageData instance available in source.
      Overrides:
      clone in class AbstractReference<IImageTarget>
    • appendPropValue

      protected void appendPropValue(PropMgr propertyManager, SendTransaction trans, Object value)
      Sends the data to the client in a transaction.
      Overrides:
      appendPropValue in class AbstractReference<IImageTarget>
      Parameters:
      propertyManager - the property manager instance.
      trans - transaction to append the properties to.
      value - the value to append to the transaction, a reference to the current property value.
    • collectConsumedFonts

      public void collectConsumedFonts(Set<FontConsumed> fonts)
      Collects the consumed fonts.
      Specified by:
      collectConsumedFonts in interface IFontConsumer
      Parameters:
      fonts - The set of consumed fonts is filled in by this method.