ALT attribute will be rendered.
While this class has been part of swing for a while now, it is public as of 1.4.
javax.swing.text.IconView
| Modifier and Type | Class and Description |
|---|---|
| private class | ImageView.
ImageHandler implements the ImageObserver to correctly update the display as new parts of the image become available. |
| private static class | ImageView.
ImageLabelView is used if the image can't be loaded, and the attribute specified an alt attribute. |
| Modifier and Type | Field and Description |
|---|---|
| private View | altView
Used for alt text. |
| private AttributeSet | |
| private Color | |
| private short | |
| private short | |
| private Container | |
| private static final int | DEFAULT_BORDER
Default border to use if one is not specified. |
| private static final int | |
| private static final int | |
| private Image | |
| private Rectangle | |
| private int | |
| private static final int | |
| private Image | |
| private static final String | IMAGE_CACHE_PROPERTY
Document property for image cache. |
| private ImageObserver | imageObserver
We don't directly implement ImageObserver, instead we use an instance that calls back to us. |
| private short | |
| private static final int | |
| private static final int | |
| private static final String | MISSING_IMAGE
Property name for missing image icon |
| private static final String | PENDING_IMAGE
Property name for pending image icon |
| private static final int | |
| private static final int | |
| private short | |
| private static int | sIncRate
Repaint delay when some of the bits are available. |
| private static boolean | sIsInc
If true, when some of the bits are available a repaint is done. |
| private int | state
Bitmask containing some of the above bitmask values. |
| private static final int | |
| private short | |
| private float | vAlign
Alignment along the vertical (Y) axis. |
| private int | |
| private static final int |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| private Dimension | |
| public void | changedUpdate(DocumentEvent e, Shape a, ViewFactory f)
Overrides javax. Invoked when the Elements attributes have changed. |
| public float | Returns: the desired alignment; this should be a value between 0.0 and 1.0 where 0 indicates alignment at the origin and 1.0 indicates alignment to the full span away from the origin; an alignment of 0.5 would be the center of the viewmay be either X_AXIS or Y_AXIS axis)Overrides javax. Determines the desired alignment for this view along an axis. |
| public String | Returns: the test to display if the image cannot be loaded.Returns the text to display if the image cannot be loaded. |
| private View | |
| public AttributeSet | getAttributes()
Overrides javax. Fetches the attributes to use when rendering. |
| public Image | |
| private Image | |
| public URL | Returns: the URL for the image source, or null if it could not be determined.Return a URL for the image source, or null if it could not be determined. |
| private int | getIntAttr(HTML.
Convenient method for getting an integer attribute from the elements AttributeSet. |
| public Icon | Returns: the icon to use while in the process of loading the image.Returns the icon to use while in the process of loading the image. |
| public boolean | Returns: true if the image should be loaded when first asked for.Returns |
| public Icon | Returns: the icon to use if the image could not be found.Returns the icon to use if the image could not be found. |
| public float | Returns: the span the view would like to be rendered into; typically the view is told to render into the span that is returned, although there is no guarantee; the parent may choose to resize or break the viewmay be either X_AXIS or Y_AXIS axis)Implements abstract javax. Determines the preferred span for this view along an axis. |
| private float | getPreferredSpanFromAltView(int axis)
Returns the preferred span of the View used to display the alt text, or 0 if the view does not exist. |
| protected StyleSheet | |
| public String | getToolTipText(float x, float y, Shape allocation)
Overrides javax. For images the tooltip text comes from text specified with the
|
| private boolean | |
| private boolean | |
| private void | |
| public Shape | Returns: the bounding box of the given positionthe position to convert pos, Shape the allocated region to render into a, Position.Implements abstract javax. Provides a mapping from the document model coordinate space to the coordinate space of the view mapped to it. |
| public void | paint(Graphics
the rendering surface to use g, Shape the allocated region to render into a)Implements abstract javax. Paints the View. |
| private void | |
| private void | |
| private void | |
| private void | |
| private void | |
| public void | setLoadsSynchronously(boolean
if newValue)true the image will be loaded when first asked for,
otherwise it will be asynchronously.Sets how the image is loaded. |
| public void | setParent(View parent)
Overrides javax. Establishes the parent view for this view. |
| protected void | |
| public void | setSize(float
the width >= 0 width, float the height >= 0 height)Overrides javax. Sets the size of the view. |
| private void | |
| private void | |
| private void | |
| public int | Returns: the location within the model that best represents the given point of viewthe X coordinate x, float the Y coordinate y, Shape the allocated region to render into a, Position.Implements abstract javax. Provides a mapping from the view coordinate space to the logical coordinate space of the model. |
| altView | back to summary |
|---|---|
| private View altView Used for alt text. Will be non-null if the image couldn't be found, and there is valid alt text. | |
| attr | back to summary |
|---|---|
| private AttributeSet attr | |
| borderColor | back to summary |
|---|---|
| private Color borderColor | |
| borderSize | back to summary |
|---|---|
| private short borderSize | |
| bottomInset | back to summary |
|---|---|
| private short bottomInset | |
| container | back to summary |
|---|---|
| private Container container | |
| DEFAULT_BORDER | back to summary |
|---|---|
| private static final int DEFAULT_BORDER Default border to use if one is not specified. | |
| DEFAULT_HEIGHT | back to summary |
|---|---|
| private static final int DEFAULT_HEIGHT | |
| DEFAULT_WIDTH | back to summary |
|---|---|
| private static final int DEFAULT_WIDTH | |
| disabledImage | back to summary |
|---|---|
| private Image disabledImage | |
| fBounds | back to summary |
|---|---|
| private Rectangle fBounds | |
| height | back to summary |
|---|---|
| private int height | |
| HEIGHT_FLAG | back to summary |
|---|---|
| private static final int HEIGHT_FLAG | |
| image | back to summary |
|---|---|
| private Image image | |
| IMAGE_CACHE_PROPERTY | back to summary |
|---|---|
| private static final String IMAGE_CACHE_PROPERTY Document property for image cache. | |
| imageObserver | back to summary |
|---|---|
| private ImageObserver imageObserver We don't directly implement ImageObserver, instead we use an instance that calls back to us. | |
| leftInset | back to summary |
|---|---|
| private short leftInset | |
| LINK_FLAG | back to summary |
|---|---|
| private static final int LINK_FLAG | |
| LOADING_FLAG | back to summary |
|---|---|
| private static final int LOADING_FLAG | |
| MISSING_IMAGE | back to summary |
|---|---|
| private static final String MISSING_IMAGE Property name for missing image icon | |
| PENDING_IMAGE | back to summary |
|---|---|
| private static final String PENDING_IMAGE Property name for pending image icon | |
| RELOAD_FLAG | back to summary |
|---|---|
| private static final int RELOAD_FLAG | |
| RELOAD_IMAGE_FLAG | back to summary |
|---|---|
| private static final int RELOAD_IMAGE_FLAG | |
| rightInset | back to summary |
|---|---|
| private short rightInset | |
| sIncRate | back to summary |
|---|---|
| private static int sIncRate Repaint delay when some of the bits are available. | |
| sIsInc | back to summary |
|---|---|
| private static boolean sIsInc If true, when some of the bits are available a repaint is done. This is set to false as swing does not offer a repaint that takes a delay. If this were true, a bunch of immediate repaints would get generated that end up significantly delaying the loading of the image (or anything else going on for that matter). | |
| state | back to summary |
|---|---|
| private int state Bitmask containing some of the above bitmask values. Because the image loading notification can happen on another thread access to this is synchronized (at least for modifying it). | |
| SYNC_LOAD_FLAG | back to summary |
|---|---|
| private static final int SYNC_LOAD_FLAG | |
| topInset | back to summary |
|---|---|
| private short topInset | |
| vAlign | back to summary |
|---|---|
| private float vAlign Alignment along the vertical (Y) axis. | |
| width | back to summary |
|---|---|
| private int width | |
| WIDTH_FLAG | back to summary |
|---|---|
| private static final int WIDTH_FLAG | |
| ImageView | back to summary |
|---|---|
| public ImageView(Element elem) Creates a new view that represents an IMG element.
| |
| adjustWidthHeight | back to summary |
|---|---|
| private Dimension adjustWidthHeight(int newWidth, int newHeight) | |
| changedUpdate | back to summary |
|---|---|
| public void changedUpdate(DocumentEvent e, Shape a, ViewFactory f) Overrides javax. Invoked when the Elements attributes have changed. Recreates the image. | |
| getAlignment | back to summary |
|---|---|
| public float getAlignment(int axis) Overrides javax. Determines the desired alignment for this view along an axis. This is implemented to give the alignment to the bottom of the icon along the y axis, and the default along the x axis.
| |
| getAltText | back to summary |
|---|---|
| public String getAltText() Returns the text to display if the image cannot be loaded. This is
obtained from the Elements attribute set with the attribute name
| |
| getAltView | back to summary |
|---|---|
| private View getAltView() Returns the view to use for alternate text. This may be null. | |
| getAttributes | back to summary |
|---|---|
| public AttributeSet getAttributes() Overrides javax. Fetches the attributes to use when rendering. This is implemented to multiplex the attributes specified in the model with a StyleSheet. | |
| getImage | back to summary |
|---|---|
| public Image getImage() Returns the image to render.
| |
| getImage | back to summary |
|---|---|
| private Image getImage(boolean enabled) | |
| getImageURL | back to summary |
|---|---|
| public URL getImageURL() Return a URL for the image source, or null if it could not be determined.
| |
| getIntAttr | back to summary |
|---|---|
| private int getIntAttr(HTML. Convenient method for getting an integer attribute from the elements AttributeSet. | |
| getLoadingImageIcon | back to summary |
|---|---|
| public Icon getLoadingImageIcon() Returns the icon to use while in the process of loading the image.
| |
| getLoadsSynchronously | back to summary |
|---|---|
| public boolean getLoadsSynchronously() Returns
| |
| getNoImageIcon | back to summary |
|---|---|
| public Icon getNoImageIcon() Returns the icon to use if the image could not be found.
| |
| getPreferredSpan | back to summary |
|---|---|
| public float getPreferredSpan(int axis) Implements abstract javax. Determines the preferred span for this view along an axis.
| |
| getPreferredSpanFromAltView | back to summary |
|---|---|
| private float getPreferredSpanFromAltView(int axis) Returns the preferred span of the View used to display the alt text, or 0 if the view does not exist. | |
| getStyleSheet | back to summary |
|---|---|
| protected StyleSheet getStyleSheet() Convenient method to get the StyleSheet.
| |
| getToolTipText | back to summary |
|---|---|
| public String getToolTipText(float x, float y, Shape allocation) Overrides javax. For images the tooltip text comes from text specified with the
| |
| hasPixels | back to summary |
|---|---|
| private boolean hasPixels(Image image) Returns true if the passed in image has a non-zero width and height. | |
| isLink | back to summary |
|---|---|
| private boolean isLink() Returns true if this image within a link? | |
| loadImage | back to summary |
|---|---|
| private void loadImage() Loads the image from the URL | |
| modelToView | back to summary |
|---|---|
| public Shape modelToView(int pos, Shape a, Position. Implements abstract javax. Provides a mapping from the document model coordinate space to the coordinate space of the view mapped to it.
| |
| paint | back to summary |
|---|---|
| public void paint(Graphics g, Shape a) Implements abstract javax. Paints the View.
| |
| paintBorder | back to summary |
|---|---|
| private void paintBorder(Graphics g, Rectangle rect) | |
| paintHighlights | back to summary |
|---|---|
| private void paintHighlights(Graphics g, Shape shape) | |
| refreshImage | back to summary |
|---|---|
| private void refreshImage() Loads the image and updates the size accordingly. This should be
invoked instead of invoking | |
| repaint | back to summary |
|---|---|
| private void repaint(long delay) Request that this view be repainted. Assumes the view is still at its last-drawn location. | |
| safePreferenceChanged | back to summary |
|---|---|
| private void safePreferenceChanged() Invokes | |
| setLoadsSynchronously | back to summary |
|---|---|
| public void setLoadsSynchronously(boolean newValue) Sets how the image is loaded. If
| |
| setParent | back to summary |
|---|---|
| public void setParent(View parent) Overrides javax. Establishes the parent view for this view. Seize this moment to cache the AWT Container I'm in. | |
| setPropertiesFromAttributes | back to summary |
|---|---|
| protected void setPropertiesFromAttributes() Update any cached values that come from attributes. | |
| setSize | back to summary |
|---|---|
| public void setSize(float width, float height) Overrides javax. Sets the size of the view. This should cause layout of the view if it has any layout duties.
| |
| sync | back to summary |
|---|---|
| private void sync() Makes sure the necessary properties and image is loaded. | |
| updateAltTextView | back to summary |
|---|---|
| private void updateAltTextView() Updates the view representing the alt text. | |
| updateImageSize | back to summary |
|---|---|
| private void updateImageSize() Recreates and reloads the image. This should
only be invoked from | |
| viewToModel | back to summary |
|---|---|
| public int viewToModel(float x, float y, Shape a, Position. Implements abstract javax. Provides a mapping from the view coordinate space to the logical coordinate space of the model.
| |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | imageUpdate(Image img, int flags, int x, int y, int newWidth, int newHeight)
Implements java. This method is called when information about an image which was previously requested using an asynchronous interface becomes available. |
| ImageHandler | back to summary |
|---|---|
| private ImageHandler() | |
| imageUpdate | back to summary |
|---|---|
| public boolean imageUpdate(Image img, int flags, int x, int y, int newWidth, int newHeight) Implements java. Doc from java. This method is called when information about an image which was previously requested using an asynchronous interface becomes available. Asynchronous interfaces are method calls such as getWidth(ImageObserver) and drawImage(img, x, y, ImageObserver) which take an ImageObserver object as an argument. Those methods register the caller as interested either in information about the overall image itself (in the case of getWidth(ImageObserver)) or about an output version of an image (in the case of the drawImage(img, x, y, [w, h,] ImageObserver) call). This method should return true if further updates are needed or false if the required information has been acquired. The image which was being tracked is passed in using the img argument. Various constants are combined to form the infoflags argument which indicates what information about the image is now available. The interpretation of the x, y, width, and height arguments depends on the contents of the infoflags argument.
The | |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public View | breakView(int axis, int p0, float pos, float len)
Overrides javax. Tries to break this view on the given axis. |
| public int | getEndOffset()
Overrides javax. Fetches the portion of the model that this view is responsible for. |
| public Color | getForeground()
Overrides javax. Fetches the foreground color to use to render the glyphs. |
| public int | getStartOffset()
Overrides javax. Fetches the portion of the model that this view is responsible for. |
| public Segment | getText(int p0, int p1)
Overrides javax. Fetch a reference to the text that occupies the given range. |
| public void | paint(Graphics g, Shape a)
Overrides javax. Renders a portion of a text style run. |
| public void |
| ImageLabelView | back to summary |
|---|---|
| pack-priv ImageLabelView(Element e, String text) | |
| breakView | back to summary |
|---|---|
| public View breakView(int axis, int p0, float pos, float len) Overrides javax. Doc from javax. Tries to break this view on the given axis. Refer to
Behavior of this method is unspecified in case | |
| getEndOffset | back to summary |
|---|---|
| public int getEndOffset() Overrides javax. Doc from javax. Fetches the portion of the model that this view is responsible for. | |
| getForeground | back to summary |
|---|---|
| public Color getForeground() Overrides javax. Doc from javax. Fetches the foreground color to use to render the glyphs.
This is implemented to return a cached foreground color,
which defaults to | |
| getStartOffset | back to summary |
|---|---|
| public int getStartOffset() Overrides javax. Doc from javax. Fetches the portion of the model that this view is responsible for. | |
| getText | back to summary |
|---|---|
| public Segment getText(int p0, int p1) Overrides javax. Doc from javax. Fetch a reference to the text that occupies the given range. This is normally used by the GlyphPainter to determine what characters it should render glyphs for. | |
| paint | back to summary |
|---|---|
| public void paint(Graphics g, Shape a) Overrides javax. Doc from javax. Renders a portion of a text style run. | |
| reset | back to summary |
|---|---|
| public void reset(String text) | |