org.lobobrowser.html.gui

Class HtmlBlockPanel

Implemented Interfaces:
ClipboardOwner, NodeRenderer, RenderableContainer

public class HtmlBlockPanel
extends JComponent
implements NodeRenderer, RenderableContainer, ClipboardOwner

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.
Author:
J. H. S.
See Also:
HtmlPanel, FrameSetPanel

Field Summary

protected Insets
defaultPaddingInsets
protected RenderableSpot
endSelection
protected FrameContext
frameContext
protected int
preferredWidth
protected RBlock
rblock
protected HtmlRendererContext
rcontext
protected RenderableSpot
startSelection
protected UserAgentContext
ucontext

Constructor Summary

HtmlBlockPanel(Color background, boolean opaque, UserAgentContext pcontext, HtmlRendererContext rcontext, FrameContext frameContext)
HtmlBlockPanel(UserAgentContext pcontext, HtmlRendererContext rcontext, FrameContext frameContext)

Method Summary

Component
addComponent(Component component)
void
addDelayedPair(DelayedPair pair)
void
clearDelayedPairs()
boolean
copy()
void
doLayout()
void
finalize()
void
focus()
Collection
getDelayedPairs()
int
getFirstLineHeight()
Point
getGUIPoint(int clientX, int clientY)
Rectangle
getNodeBounds(Node node, boolean relativeToScrollable)
Gets the rectangular bounds of the given node.
Color
getPaintedBackgroundColor()
RenderableContainer
getParentContainer()
Dimension
getPreferredSize()
If the preferred size has been set with setPreferredSize(Dimension), then that size is returned.
NodeImpl
getRootNode()
BoundableRenderable
getRootRenderable()
org.w3c.dom.Node
getSelectionNode()
String
getSelectionText()
boolean
hasSelection()
void
invalidateLayoutUpTree()
boolean
isSelectionAvailable()
void
lostOwnership(Clipboard arg0, Transferable arg1)
void
paint(Graphics g)
protected void
paintChildren(Graphics g)
void
relayout()
void
repaint(ModelNode modelNode)
Implementation of UINode.repaint().
protected void
revalidatePanel()
void
scrollTo(Node node)
Scrolls the body area to the node given, if it is part of the current document.
void
scrollTo(Rectangle bounds, boolean xIfNeeded, boolean yIfNeeded)
Scrolls the body area to the given location.
void
setDefaultPaddingInsets(Insets insets)
void
setPreferredWidth(int width)
Allows getPreferredSize() to render the HTML block in order to determine the preferred size of this component.
void
setRootNode(NodeImpl node)
Sets the root node to render.
void
setSelectionEnd(RenderableSpot rpoint)
void
setSelectionStart(RenderableSpot rpoint)
void
updateAllWidgetBounds()
protected void
validateAll()

Field Details

defaultPaddingInsets

protected Insets defaultPaddingInsets

endSelection

protected RenderableSpot endSelection

frameContext

protected final FrameContext frameContext

preferredWidth

protected int preferredWidth

rblock

protected RBlock rblock

rcontext

protected final HtmlRendererContext rcontext

startSelection

protected RenderableSpot startSelection

ucontext

protected final UserAgentContext ucontext

Constructor Details

HtmlBlockPanel

public HtmlBlockPanel(Color background,
                      boolean opaque,
                      UserAgentContext pcontext,
                      HtmlRendererContext rcontext,
                      FrameContext frameContext)

HtmlBlockPanel

public HtmlBlockPanel(UserAgentContext pcontext,
                      HtmlRendererContext rcontext,
                      FrameContext frameContext)

Method Details

addComponent

public Component addComponent(Component component)
Specified by:
addComponent in interface RenderableContainer

addDelayedPair

public void addDelayedPair(DelayedPair pair)
Specified by:
addDelayedPair in interface RenderableContainer

clearDelayedPairs

public void clearDelayedPairs()
Specified by:
clearDelayedPairs in interface RenderableContainer

copy

public boolean copy()

doLayout

public void doLayout()

finalize

public void finalize()
            throws Throwable

focus

public void focus()
Specified by:
focus in interface RenderableContainer

getDelayedPairs

public Collection getDelayedPairs()
Specified by:
getDelayedPairs in interface RenderableContainer

getFirstLineHeight

public int getFirstLineHeight()

getGUIPoint

public Point getGUIPoint(int clientX,
                         int clientY)
Specified by:
getGUIPoint in interface RenderableContainer

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.

Parameters:
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).

getPaintedBackgroundColor

public Color getPaintedBackgroundColor()
Specified by:
getPaintedBackgroundColor in interface RenderableContainer

getParentContainer

public RenderableContainer getParentContainer()
Specified by:
getParentContainer in interface RenderableContainer

getPreferredSize

public Dimension getPreferredSize()

getRootNode

public NodeImpl getRootNode()

getRootRenderable

public BoundableRenderable getRootRenderable()

getSelectionNode

public org.w3c.dom.Node getSelectionNode()

getSelectionText

public String getSelectionText()

hasSelection

public boolean hasSelection()

invalidateLayoutUpTree

public void invalidateLayoutUpTree()
Specified by:
invalidateLayoutUpTree in interface RenderableContainer

isSelectionAvailable

public boolean isSelectionAvailable()

lostOwnership

public void lostOwnership(Clipboard arg0,
                          Transferable arg1)

paint

public void paint(Graphics g)

paintChildren

protected void paintChildren(Graphics g)

relayout

public void relayout()
Specified by:
relayout in interface RenderableContainer

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.

Parameters:
node - A DOM node.

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.

Parameters:
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.
Parameters:
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.
Specified by:
setRootNode in interface NodeRenderer

setSelectionEnd

public void setSelectionEnd(RenderableSpot rpoint)

setSelectionStart

public void setSelectionStart(RenderableSpot rpoint)

updateAllWidgetBounds

public void updateAllWidgetBounds()
Specified by:
updateAllWidgetBounds in interface RenderableContainer

validateAll

protected void validateAll()