public class OImageView extends View
| Modifier and Type | Class and Description |
|---|---|
protected class |
OImageView.ImageHandler
ImageHandler implements the ImageObserver to correctly update the display
as new parts of the image become available.
|
protected class |
OImageView.ImageLabelView
ImageLabelView is used if the image can't be loaded, and the attribute
specified an alt attribute.
|
| Modifier and Type | Field and Description |
|---|---|
protected View |
altView
Used for alt text.
|
protected AttributeSet |
attr |
protected Color |
borderColor |
protected short |
borderSize |
protected short |
bottomInset |
protected Container |
container |
protected static int |
DEFAULT_BORDER
Default border to use if one is not specified.
|
protected static int |
DEFAULT_HEIGHT |
protected static int |
DEFAULT_WIDTH |
protected Rectangle |
fBounds |
protected int |
height |
protected static int |
HEIGHT_FLAG |
protected Image |
image |
protected static String |
IMAGE_CACHE_PROPERTY
Document property for image cache.
|
protected ImageObserver |
imageObserver
We don't directly implement ImageObserver, instead we use an instance
that calls back to us.
|
protected short |
leftInset |
protected static int |
LINK_FLAG |
protected static int |
LOADING_FLAG |
protected static String |
MISSING_IMAGE
Property name for missing image icon
|
protected static String |
PENDING_IMAGE
Property name for pending image icon
|
protected static int |
RELOAD_FLAG |
protected static int |
RELOAD_IMAGE_FLAG |
protected short |
rightInset |
protected static int |
sIncRate
Repaint delay when some of the bits are available.
|
protected static boolean |
sIsInc
If true, when some of the bits are available a repaint is done.
|
protected int |
state
Bitmask containing some of the above bitmask values.
|
protected static int |
SYNC_LOAD_FLAG |
protected short |
topInset |
protected float |
vAlign
Alignment along the vertical (Y) axis.
|
protected int |
width |
protected static int |
WIDTH_FLAG |
BadBreakWeight, ExcellentBreakWeight, ForcedBreakWeight, GoodBreakWeight, X_AXIS, Y_AXISBOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST| Constructor and Description |
|---|
OImageView(Element elem)
Creates a new view that represents an IMG element.
|
| Modifier and Type | Method and Description |
|---|---|
void |
changedUpdate(DocumentEvent e,
Shape a,
ViewFactory f)
Invoked when the Elements attributes have changed.
|
float |
getAlignment(int axis)
Determines the desired alignment for this view along an axis.
|
String |
getAltText()
Returns the text to display if the image can't be loaded.
|
protected View |
getAltView()
Returns the view to use for alternate text.
|
AttributeSet |
getAttributes()
Fetches the attributes to use when rendering.
|
Image |
getEmbedImage() |
Image |
getImage()
Returns the image to render.
|
URL |
getImageURL()
Return a URL for the image source, or null if it could not be determined.
|
protected int |
getIntAttr(HTML.Attribute name,
int deflt)
Convenience method for getting an integer attribute from the elements
AttributeSet.
|
Icon |
getLoadingImageIcon()
Returns the icon to use while in the process of loading the image.
|
boolean |
getLoadsSynchronously()
Returns true if the image should be loaded when first asked for.
|
Icon |
getNoImageIcon()
Returns the icon to use if the image couldn't be found.
|
float |
getPreferredSpan(int axis)
Determines the preferred span for this view along an axis.
|
protected 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 |
getStyleSheet()
Convenience method to get the StyleSheet.
|
String |
getToolTipText(float x,
float y,
Shape allocation)
For images the tooltip text comes from text specified with the
ALT attribute. |
protected boolean |
hasPixels(Image image)
Returns true if the passed in image has a non-zero width and height.
|
protected boolean |
isLink()
Returns true if this image within a link?
|
protected void |
loadImage()
Loads the image from the URL
getImageURL. |
Shape |
modelToView(int pos,
Shape a,
Position.Bias b)
Provides a mapping from the document model coordinate space to the
coordinate space of the view mapped to it.
|
void |
paint(Graphics g,
Shape a)
Paints the View.
|
protected void |
paintBorder(Graphics g,
Rectangle rect) |
protected void |
paintHighlights(Graphics g,
Shape shape) |
protected void |
refreshImage()
Loads the image and updates the size accordingly.
|
protected void |
repaint(long delay)
Request that this view be repainted.
|
protected void |
safePreferenceChanged()
Invokes
preferenceChanged on the event displatching thread. |
void |
setLoadsSynchronously(boolean newValue)
Sets how the image is loaded.
|
void |
setParent(View parent)
Establishes the parent view for this view.
|
protected void |
setPropertiesFromAttributes()
Update any cached values that come from attributes.
|
void |
setSize(float width,
float height)
Sets the size of the view.
|
protected void |
sync()
Makes sure the necessary properties and image is loaded.
|
protected void |
updateAltTextView()
Updates the view representing the alt text.
|
protected void |
updateImageSize()
Recreates and reloads the image.
|
int |
viewToModel(float x,
float y,
Shape a,
Position.Bias[] bias)
Provides a mapping from the view coordinate space to the logical
coordinate space of the model.
|
append, breakView, createFragment, forwardUpdate, forwardUpdateToView, getBreakWeight, getChildAllocation, getContainer, getDocument, getElement, getEndOffset, getGraphics, getMaximumSpan, getMinimumSpan, getNextVisualPositionFrom, getParent, getResizeWeight, getStartOffset, getView, getViewCount, getViewFactory, getViewIndex, getViewIndex, insert, insertUpdate, isVisible, modelToView, modelToView, preferenceChanged, remove, removeAll, removeUpdate, replace, updateChildren, updateLayout, viewToModelprotected static boolean sIsInc
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).
protected static int sIncRate
protected static final String PENDING_IMAGE
protected static final String MISSING_IMAGE
protected static final String IMAGE_CACHE_PROPERTY
protected static final int DEFAULT_WIDTH
protected static final int DEFAULT_HEIGHT
protected static final int DEFAULT_BORDER
protected static final int LOADING_FLAG
protected static final int LINK_FLAG
protected static final int WIDTH_FLAG
protected static final int HEIGHT_FLAG
protected static final int RELOAD_FLAG
protected static final int RELOAD_IMAGE_FLAG
protected static final int SYNC_LOAD_FLAG
protected AttributeSet attr
protected Image image
protected int width
protected int height
protected int state
protected Container container
protected Rectangle fBounds
protected Color borderColor
protected short borderSize
protected short leftInset
protected short rightInset
protected short topInset
protected short bottomInset
protected ImageObserver imageObserver
protected View altView
protected float vAlign
public OImageView(Element elem)
elem - the element to create a view forpublic String getAltText()
HTML.Attribute.ALT.public URL getImageURL()
public Image getEmbedImage()
public Icon getNoImageIcon()
public Icon getLoadingImageIcon()
public Image getImage()
public void setLoadsSynchronously(boolean newValue)
newValue is true, the image
we be loaded when first asked for, otherwise it will be loaded
asynchronously. The default is to not load synchronously, that is to load
the image asynchronously.public boolean getLoadsSynchronously()
protected StyleSheet getStyleSheet()
public AttributeSet getAttributes()
getAttributes in class Viewpublic String getToolTipText(float x, float y, Shape allocation)
ALT attribute. This is overriden to return
getAltText.getToolTipText in class ViewJTextComponent.getToolTipText(java.awt.event.MouseEvent)protected void setPropertiesFromAttributes()
public void setParent(View parent)
public void changedUpdate(DocumentEvent e, Shape a, ViewFactory f)
changedUpdate in class Viewpublic void paint(Graphics g, Shape a)
paint in class Viewg - the rendering surface to usea - the allocated region to render intoView.paint(java.awt.Graphics, java.awt.Shape)public float getPreferredSpan(int axis)
getPreferredSpan in class Viewaxis - may be either X_AXIS or Y_AXISpublic float getAlignment(int axis)
getAlignment in class Viewaxis - may be either X_AXIS or Y_AXISpublic Shape modelToView(int pos, Shape a, Position.Bias b) throws BadLocationException
modelToView in class Viewpos - the position to converta - the allocated region to render intoBadLocationException - if the given position does not represent a valid location
in the associated documentView.modelToView(int, java.awt.Shape, javax.swing.text.Position.Bias)public int viewToModel(float x,
float y,
Shape a,
Position.Bias[] bias)
viewToModel in class Viewx - the X coordinatey - the Y coordinatea - the allocated region to render intoView.viewToModel(float, float, java.awt.Shape, javax.swing.text.Position.Bias[])public void setSize(float width,
float height)
protected boolean isLink()
protected boolean hasPixels(Image image)
protected float getPreferredSpanFromAltView(int axis)
protected void repaint(long delay)
protected int getIntAttr(HTML.Attribute name, int deflt)
protected void sync()
protected void refreshImage()
loadImage or
updateImageSize directly.protected void loadImage()
getImageURL. This should only
be invoked from refreshImage.protected void updateImageSize()
refreshImage.protected void updateAltTextView()
protected View getAltView()
protected void safePreferenceChanged()
preferenceChanged on the event displatching thread.Copyright © 2016 Imatia Innovation S.L.. All rights reserved.