- java.lang.Object
-
- javax.swing.text.View
-
- javax.swing.text.html.ImageView
-
- All Implemented Interfaces:
-
SwingConstants
public class ImageView extends View
视图,旨在支持HTML <IMG>标签。 通过标签的HEIGHT和WIDTH属性支持缩放。 如果无法加载图像,则将渲染通过ALT属性指定的任何文本。虽然这个课程现在已经有一段时间了,但它是公开的1.4。
- 从以下版本开始:
- 1.4
- 另请参见:
-
IconView
-
-
Field Summary
-
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
-
Fields inherited from class javax.swing.text.View
BadBreakWeight, ExcellentBreakWeight, ForcedBreakWeight, GoodBreakWeight, X_AXIS, Y_AXIS
-
-
方法摘要
所有方法 接口方法 具体的方法 Modifier and Type 方法 描述 voidchangedUpdate(DocumentEvent e, Shape a, ViewFactory f)当Elements属性更改时调用。floatgetAlignment(int axis)确定沿着轴的该视图的所需对准。StringgetAltText()如果图像无法加载,返回要显示的文本。AttributeSetgetAttributes()获取渲染时要使用的属性。ImagegetImage()返回要呈现的图像。URLgetImageURL()返回图像源的URL,如果无法确定,则返回null。IcongetLoadingImageIcon()在加载图像的过程中返回要使用的图标。booleangetLoadsSynchronously()如果第一次要求时应该加载图像,则返回true。IcongetNoImageIcon()如果找不到图像,则返回要使用的图标。floatgetPreferredSpan(int axis)确定沿着轴的此视图的首选跨度。protected StyleSheetgetStyleSheet()方便的方法来获取StyleSheet。StringgetToolTipText(float x, float y, Shape allocation)对于图像,工具提示文本来自使用ALT属性指定的文本。ShapemodelToView(int pos, Shape a, Position.Bias b)提供从文档模型坐标空间映射到映射到它的视图的坐标空间的映射。voidpaint(Graphics g, Shape a)绘制视图。voidsetLoadsSynchronously(boolean newValue)设置图像的加载方式。voidsetParent(View parent)建立此视图的父视图。protected voidsetPropertiesFromAttributes()更新来自属性的任何缓存值。voidsetSize(float width, float height)设置视图的大小。intviewToModel(float x, float y, Shape a, Position.Bias[] bias)提供从视图坐标空间到模型的逻辑坐标空间的映射。-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from class javax.swing.text.View
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, viewToModel
-
-
-
-
构造方法详细信息
-
ImageView
public ImageView(Element elem)
创建一个代表IMG元素的新视图。- 参数
-
elem- 创建视图的元素
-
-
方法详细信息
-
getAltText
public String getAltText()
如果图像无法加载,返回要显示的文本。 这是从属性名称为HTML.Attribute.ALT的Elements属性集获得的。- 结果
- 测试显示图像是否无法加载。
-
getImageURL
public URL getImageURL()
返回图像源的URL,如果无法确定,则返回null。- 结果
- 图像源的URL,如果无法确定,则为null。
-
getNoImageIcon
public Icon getNoImageIcon()
如果找不到图像,则返回要使用的图标。- 结果
- 如果无法找到图像,则使用图标。
-
getLoadingImageIcon
public Icon getLoadingImageIcon()
在加载图像的过程中返回要使用的图标。- 结果
- 在加载图像的过程中使用的图标。
-
getImage
public Image getImage()
返回要呈现的图像。- 结果
- 要呈现的图像。
-
setLoadsSynchronously
public void setLoadsSynchronously(boolean newValue)
设置图像的加载方式。 如果newValue为真,图像将在第一次询问时加载,否则将异步加载。 默认是不同步加载,即异步加载映像。- 参数
-
newValue- 如果true图像将在第一次询问时加载,否则将异步。
-
getLoadsSynchronously
public boolean getLoadsSynchronously()
如果第一次要求时应该加载图像,则返回true。- 结果
-
true如果图像应该在第一次要求时加载。
-
getStyleSheet
protected StyleSheet getStyleSheet()
方便的方法来获取StyleSheet。- 结果
- StyleSheet
-
getAttributes
public AttributeSet getAttributes()
获取渲染时要使用的属性。 这是为了将模型中指定的属性与StyleSheet进行复用。- 重写:
-
getAttributes在View - 结果
- 渲染时要使用的属性
-
getToolTipText
public String getToolTipText(float x, float y, Shape allocation)
对于图像,工具提示文本来自使用ALT属性指定的文本。 这是覆盖以返回getAltText。- 重写:
-
getToolTipText在View - 参数
-
x- x坐标 -
y- y坐标 -
allocation- 视图的当前分配。 - 结果
- 在指定位置的工具提示文本
- 另请参见:
-
JTextComponent.getToolTipText(java.awt.event.MouseEvent)
-
setPropertiesFromAttributes
protected void setPropertiesFromAttributes()
更新来自属性的任何缓存值。
-
setParent
public void setParent(View parent)
建立此视图的父视图。 抓住这一刻缓存我所在的AWT集装箱。
-
changedUpdate
public void changedUpdate(DocumentEvent e, Shape a, ViewFactory f)
当Elements属性更改时调用。 重新创建图像。- 重写:
-
changedUpdate在View - 参数
-
e- 相关文件的更改信息 -
a- 视图的当前分配 -
f- 如果视图有孩子,工厂要重建 - 另请参见:
-
View.changedUpdate(javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory)
-
paint
public void paint(Graphics g, Shape a)
绘制视图。- Specified by:
-
paint在View - 参数
-
g- 要使用的渲染表面 -
a- 要分配的区域 - 另请参见:
-
View.paint(java.awt.Graphics, java.awt.Shape)
-
getPreferredSpan
public float getPreferredSpan(int axis)
确定沿着轴的此视图的首选跨度。- Specified by:
-
getPreferredSpan在View - 参数
-
axis- 可以是X_AXIS或Y_AXIS - 结果
- 视图想要渲染的跨度; 通常,该视图被告知要呈现返回的跨度,尽管不能保证; 父母可以选择调整大小或打破视图
- 另请参见:
-
View.getPreferredSpan(int)
-
getAlignment
public float getAlignment(int axis)
确定沿着轴的该视图的所需对准。 这是为了给出沿着y轴的图标底部的对齐方式,并且沿着x轴的默认值。- 重写:
-
getAlignment中的View - 参数
-
axis- 可以是X_AXIS或Y_AXIS - 结果
- 所需的对齐方式 这应该是0.0和1.0之间的值,其中0表示原点对齐,1.0表示与原点的全跨距对齐; 0.5的对齐将是视野的中心
-
modelToView
public Shape modelToView(int pos, Shape a, Position.Bias b) throws BadLocationException
提供从文档模型坐标空间映射到映射到它的视图的坐标空间的映射。- Specified by:
-
modelToView在View - 参数
-
pos- 转换的位置 -
a- 要分配的区域 -
b- 在位置是两个视图的边界的情况下,偏移朝向前一个字符或由偏移表示的下一个字符;b将具有以下值之一:-
Position.Bias.Forward -
Position.Bias.Backward
-
- 结果
- 给定位置的边界框
- 异常
-
BadLocationException- 如果给定的位置不表示相关文档中的有效位置 - 另请参见:
-
View.modelToView(int, java.awt.Shape, javax.swing.text.Position.Bias)
-
viewToModel
public int viewToModel(float x, float y, Shape a, Position.Bias[] bias)提供从视图坐标空间到模型的逻辑坐标空间的映射。- Specified by:
-
viewToModel在View - 参数
-
x- X坐标 -
y- Y坐标 -
a- 要分配的区域 -
bias- 返回的偏差 - 结果
- 模型中最能代表给定观点的位置
- 另请参见:
-
View.viewToModel(float, float, java.awt.Shape, javax.swing.text.Position.Bias[])
-
-