A Swing component that renders a HTML block, given
by a DOM root or an internal element, typically a DIV.
This component
cannot render FRAMESETs, which is done
by
FrameSetPanel
.
HtmlBlockPanel
is used by
HtmlPanel
whenever the DOM
is determined
not to be a FRAMESET.
defaultPaddingInsets
protected Insets defaultPaddingInsets
preferredWidth
protected int preferredWidth
copy
public boolean copy()
doLayout
public void doLayout()
finalize
public void finalize()
throws Throwable
getFirstLineHeight
public int getFirstLineHeight()
getNodeBounds
public Rectangle getNodeBounds(Node node,
boolean relativeToScrollable)
Gets the rectangular bounds of the given node.
This method should be called from the GUI thread.
node
- A node in the current document.relativeToScrollable
- Whether the bounds should be relative to the
scrollable body area. Otherwise, they are
relative to the root block (which is the
essentially the same as being relative to this
HtmlBlockPanel
minus Swing
borders).
getPreferredSize
public Dimension getPreferredSize()
If the preferred size has been set with
setPreferredSize(Dimension)
,
then that size is returned. Otherwise a preferred size is calculated by
rendering the HTML DOM, provided one is available and a preferred width other
than
-1
has been set with
setPreferredWidth(int)
.
An arbitrary preferred size is returned in other scenarios.
getRootNode
public NodeImpl getRootNode()
getSelectionNode
public org.w3c.dom.Node getSelectionNode()
getSelectionText
public String getSelectionText()
hasSelection
public boolean hasSelection()
isSelectionAvailable
public boolean isSelectionAvailable()
lostOwnership
public void lostOwnership(Clipboard arg0,
Transferable arg1)
paint
public void paint(Graphics g)
paintChildren
protected void paintChildren(Graphics g)
repaint
public void repaint(ModelNode modelNode)
Implementation of UINode.repaint().
revalidatePanel
protected void revalidatePanel()
scrollTo
public void scrollTo(Node node)
Scrolls the body area to the node given, if it is
part of the current document.
This method should be called from the GUI thread.
scrollTo
public void scrollTo(Rectangle bounds,
boolean xIfNeeded,
boolean yIfNeeded)
Scrolls the body area to the given location.
This method should be called from the GUI thread.
bounds
- The bounds in the scrollable block area that should
become visible.xIfNeeded
- If this parameter is true, scrolling will only occur if the
requested bounds are not currently visible horizontally.yIfNeeded
- If this parameter is true, scrolling will only occur if the
requested bounds are not currently visible vertically.
setDefaultPaddingInsets
public void setDefaultPaddingInsets(Insets insets)
setPreferredWidth
public void setPreferredWidth(int width)
Allows
getPreferredSize()
to render the HTML block
in order to determine the preferred size of this component.
Note that
getPreferredSize()
is a potentially time-consuming
operation if the preferred width is set.
width
- The preferred blocked width. Use -1
to unset.
setRootNode
public void setRootNode(NodeImpl node)
Sets the root node to render. This method should
be invoked in the GUI dispatch thread.
- setRootNode in interface NodeRenderer
validateAll
protected void validateAll()