Package org.lobobrowser.html.gui
Class HtmlBlockPanel
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
org.lobobrowser.html.gui.HtmlBlockPanel
- All Implemented Interfaces:
ClipboardOwner
,ImageObserver
,MenuContainer
,Serializable
,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.
HtmlBlockPanel
is used by HtmlPanel
whenever the DOM
is determined not to be a FRAMESET.- Author:
- J. H. S.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Insets
protected int
protected int
protected RenderableSpot
protected final FrameContext
protected int
protected RBlock
protected final HtmlRendererContext
protected RenderableSpot
protected final UserAgentContext
Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Fields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
-
Constructor Summary
ConstructorsConstructorDescriptionHtmlBlockPanel
(Color background, boolean opaque, UserAgentContext pcontext, HtmlRendererContext rcontext, FrameContext frameContext) HtmlBlockPanel
(UserAgentContext pcontext, HtmlRendererContext rcontext, FrameContext frameContext) -
Method Summary
Modifier and TypeMethodDescriptionaddComponent
(Component component) void
addDelayedPair
(DelayedPair pair) void
boolean
copy()
void
doLayout()
void
finalize()
void
focus()
int
int
int
getGUIPoint
(int clientX, int clientY) getNodeBounds
(Node node, boolean relativeToScrollable) Gets the rectangular bounds of the given node.If the preferred size has been set withJComponent.setPreferredSize(Dimension)
, then that size is returned.boolean
void
boolean
void
lostOwnership
(Clipboard arg0, Transferable arg1) void
protected void
void
relayout()
void
Implementation of UINode.repaint().protected void
void
scrollBy
(int xOffset, int yOffset) void
Scrolls the body area to the given location.void
Scrolls the body area to the node given, if it is part of the current document.void
setDefaultMarginInsets
(Insets defaultMarginInsets) Sets the default margin insets.void
setDefaultOverflowX
(int defaultOverflowX) void
setDefaultOverflowY
(int defaultOverflowY) void
setPreferredWidth
(int width) AllowsgetPreferredSize()
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
protected void
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUI, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.lobobrowser.html.renderer.RenderableContainer
repaint
-
Field Details
-
frameContext
-
ucontext
-
rcontext
-
startSelection
-
endSelection
-
rblock
-
preferredWidth
protected int preferredWidth -
defaultMarginInsets
-
defaultOverflowX
protected int defaultOverflowX -
defaultOverflowY
protected int defaultOverflowY
-
-
Constructor Details
-
HtmlBlockPanel
public HtmlBlockPanel(UserAgentContext pcontext, HtmlRendererContext rcontext, FrameContext frameContext) -
HtmlBlockPanel
public HtmlBlockPanel(Color background, boolean opaque, UserAgentContext pcontext, HtmlRendererContext rcontext, FrameContext frameContext)
-
-
Method Details
-
scrollTo
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.
-
scrollBy
public void scrollBy(int xOffset, int yOffset) -
scrollTo
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.
-
getNodeBounds
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 thisHtmlBlockPanel
minus Swing borders).
-
getRootRenderable
-
setPreferredWidth
public void setPreferredWidth(int width) AllowsgetPreferredSize()
to render the HTML block in order to determine the preferred size of this component. Note thatgetPreferredSize()
is a potentially time-consuming operation if the preferred width is set.
- Parameters:
width
- The preferred blocked width. Use-1
to unset.
-
getPreferredSize
If the preferred size has been set withJComponent.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 withsetPreferredWidth(int)
. An arbitrary preferred size is returned in other scenarios.- Overrides:
getPreferredSize
in classJComponent
-
finalize
-
copy
public boolean copy() -
getFirstLineHeight
public int getFirstLineHeight() -
setSelectionEnd
-
setSelectionStart
-
isSelectionAvailable
public boolean isSelectionAvailable() -
getSelectionNode
-
setRootNode
Sets the root node to render. This method should be invoked in the GUI dispatch thread.- Specified by:
setRootNode
in interfaceNodeRenderer
-
validateAll
protected void validateAll() -
revalidatePanel
protected void revalidatePanel() -
getRootNode
-
paint
- Overrides:
paint
in classJComponent
-
doLayout
public void doLayout() -
repaint
Implementation of UINode.repaint(). -
getSelectionText
-
hasSelection
public boolean hasSelection() -
paintChildren
- Overrides:
paintChildren
in classJComponent
-
getPaintedBackgroundColor
- Specified by:
getPaintedBackgroundColor
in interfaceRenderableContainer
-
lostOwnership
- Specified by:
lostOwnership
in interfaceClipboardOwner
-
relayout
public void relayout()- Specified by:
relayout
in interfaceRenderableContainer
-
invalidateLayoutUpTree
public void invalidateLayoutUpTree()- Specified by:
invalidateLayoutUpTree
in interfaceRenderableContainer
-
updateAllWidgetBounds
public void updateAllWidgetBounds()- Specified by:
updateAllWidgetBounds
in interfaceRenderableContainer
-
getGUIPoint
- Specified by:
getGUIPoint
in interfaceRenderableContainer
-
focus
public void focus()- Specified by:
focus
in interfaceRenderableContainer
-
addDelayedPair
- Specified by:
addDelayedPair
in interfaceRenderableContainer
-
getParentContainer
- Specified by:
getParentContainer
in interfaceRenderableContainer
-
getDelayedPairs
- Specified by:
getDelayedPairs
in interfaceRenderableContainer
-
clearDelayedPairs
public void clearDelayedPairs()- Specified by:
clearDelayedPairs
in interfaceRenderableContainer
-
addComponent
- Specified by:
addComponent
in interfaceRenderableContainer
-
getDefaultMarginInsets
-
setDefaultMarginInsets
Sets the default margin insets. Note that in the root block, the margin behaves like padding.- Parameters:
defaultMarginInsets
- The default margin insets.
-
getDefaultOverflowX
public int getDefaultOverflowX() -
setDefaultOverflowX
public void setDefaultOverflowX(int defaultOverflowX) -
getDefaultOverflowY
public int getDefaultOverflowY() -
setDefaultOverflowY
public void setDefaultOverflowY(int defaultOverflowY)
-