FieldImage

public final class FieldImage extends Field

Adds an image to an Input.

Inherited Constant Summary

Inherited Field Summary

Public Constructor Summary

FieldImage(String name, String src, int width, int height, String altText)

Public Method Summary

FieldImage
clone()
static FieldImage
fromJson(JSONObject json)
String
int
String
String
int
void
setAltText(String altText)
Sets the alt-text for the image.
boolean
setFromString(String text)
Sets the values of the field from a string.
void
setImage(String src, int width, int height)
Sets a new image to be shown.

Inherited Method Summary

Public Constructors

public FieldImage (String name, String src, int width, int height, String altText)

Parameters
name
src
width
height
altText

Public Methods

public FieldImage clone ()

public static FieldImage fromJson (JSONObject json)

Parameters
json

public String getAltText ()

Returns
  • The alt-text for the image.

public int getHeight ()

Returns
  • The display height of the image in dips.

public String getSerializedValue ()

Returns
  • The value serialized into a string.

public String getSource ()

Returns
  • The source for the image.

public int getWidth ()

Returns
  • The display width of the image in dips.

public void setAltText (String altText)

Sets the alt-text for the image.

Parameters
altText

public boolean setFromString (String text)

Sets the values of the field from a string.

This is used for setting values of all types of fields when loading a workspace from XML. It is also used, however, as the primary means of setting text fields (e.g., inputs, labels, dates).

There should be a concrete implementation for each field type.

Parameters
text The text value for this field from the XML.
Returns
  • True if the value was set, false otherwise.

public void setImage (String src, int width, int height)

Sets a new image to be shown.

Changes will induce a onValueChanged(Field, String, String), even though FieldImages do not store a value. This trigger updates to the matching Fieldview, but in might also generate a no-op BlocklyEvent.ChangeEvent.

Parameters
src A web address or Blockly reference to the image.
width The display width of the image in dips.
height The display height of the image in dips.