|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
org.lobobrowser.html.gui.HtmlPanel
public class HtmlPanel
The HtmlPanel
class is a Swing
component that can render a HTML DOM. It uses
either HtmlBlockPanel
or FrameSetPanel
internally, depending on whether the document
is determined to be a FRAMESET or not.
Invoke method setDocument(Document, HtmlRendererContext)
in order to schedule a document for rendering.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
javax.swing.JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
java.awt.Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
Field Summary | |
---|---|
protected FrameSetPanel |
frameSetPanel
|
protected HtmlBlockPanel |
htmlBlockPanel
|
Fields inherited from class javax.swing.JComponent |
---|
accessibleContext, 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 |
---|
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 | |
---|---|
HtmlPanel()
Constructs an HtmlPanel . |
Method Summary | |
---|---|
void |
addSelectionChangeListener(SelectionChangeListener listener)
Adds listener of selection changes. |
void |
clearDocument()
Clears the current document if any. |
boolean |
copy()
Copies the current selection, if any, into the clipboard. |
protected FrameSetPanel |
createFrameSetPanel()
Method invoked internally to create a FrameSetPanel . |
protected HtmlBlockPanel |
createHtmlBlockPanel(UserAgentContext ucontext,
HtmlRendererContext rcontext)
Method invoked internally to create a HtmlBlockPanel . |
void |
delayedRelayout(NodeImpl node)
Invalidates the layout of the given node and schedules it to be layed out later. |
void |
expandSelection(RenderableSpot rpoint)
Internal method used to expand the selection to the given point. |
BoundableRenderable |
getBlockRenderable()
Gets the root Renderable of
the HTML block. |
FrameSetPanel |
getFrameSetPanel()
Gets an instance of FrameSetPanel in case
the currently rendered page is a FRAMESET. |
NodeImpl |
getRootNode()
Gets the HTML DOM node currently rendered if any. |
org.w3c.dom.Node |
getSelectionNode()
Gets a DOM node enclosing the selection. |
java.lang.String |
getSelectionText()
Gets the selection text. |
boolean |
hasSelection()
Returns true only if the current block has a selection. |
void |
removeSelectionChangeListener(SelectionChangeListener listener)
Removes a listener of selection changes that was previously added. |
void |
resetSelection(RenderableSpot rpoint)
Internal method used to reset the selection so that it is empty at the given point. |
void |
scroll(int x,
int y)
Scrolls the document such that x and y coordinates are placed in the upper-left corner of the panel. |
void |
scrollBy(int x,
int y)
|
void |
scrollTo(org.w3c.dom.Node node)
Scrolls the body area to the node given, if it is part of the current document. |
void |
scrollTo(java.awt.Rectangle bounds,
boolean xIfNeeded,
boolean yIfNeeded)
If the current document is not a FRAMESET, this method scrolls the body area to the given location. |
void |
scrollToElement(java.lang.String nameOrId)
Scrolls to the element identified by the given ID in the current document. |
void |
setDefaultMarginInsets(java.awt.Insets insets)
Sets the default margin insets. |
void |
setDefaultOverflowX(int overflow)
Sets the default horizontal overflow. |
void |
setDefaultOverflowY(int overflow)
Sets the default vertical overflow. |
void |
setDocument(org.w3c.dom.Document node,
HtmlRendererContext rcontext)
Sets an HTML DOM node and invalidates the component so it is rendered as soon as possible in the GUI thread. |
void |
setHtml(java.lang.String htmlSource,
java.lang.String uri,
HtmlRendererContext rcontext)
Renders HTML given as a string. |
void |
setPreferredWidth(int width)
Sets a preferred width that serves as a hint in calculating the preferred size of the HtmlPanel . |
Methods inherited from class javax.swing.JComponent |
---|
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, 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, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, 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, doLayout, 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, 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, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, 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, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected volatile HtmlBlockPanel htmlBlockPanel
protected volatile FrameSetPanel frameSetPanel
Constructor Detail |
---|
public HtmlPanel()
HtmlPanel
.
Method Detail |
---|
public void setPreferredWidth(int width)
HtmlPanel
. Note that
the preferred size can only be calculated when a document is
available, and it will vary during incremental rendering.
This method currently does not have any effect when the document is a FRAMESET.
Note also that setting the preferred width (to a value other
than -1
) will negatively impact performance.
width
- The preferred width, or -1
to unset.public void scrollTo(java.awt.Rectangle bounds, boolean xIfNeeded, boolean yIfNeeded)
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.public void scrollTo(org.w3c.dom.Node node)
This method should be called from the GUI thread.
node
- A DOM node.public BoundableRenderable getBlockRenderable()
Renderable
of
the HTML block. It returns null
for FRAMESETs.
public FrameSetPanel getFrameSetPanel()
FrameSetPanel
in case
the currently rendered page is a FRAMESET.
Note: This method should be invoked in the GUI thread.
FrameSetPanel
instance or null
if the document currently rendered is not a FRAMESET.protected HtmlBlockPanel createHtmlBlockPanel(UserAgentContext ucontext, HtmlRendererContext rcontext)
HtmlBlockPanel
.
It is made available so it can be overridden.
protected FrameSetPanel createFrameSetPanel()
FrameSetPanel
.
It is made available so it can be overridden.
public void scroll(int x, int y)
This method may be called outside of the GUI Thread.
x
- The x coordinate.y
- The y coordinate.public void scrollBy(int x, int y)
public void clearDocument()
public void setDocument(org.w3c.dom.Document node, HtmlRendererContext rcontext)
If this method is called from a thread that is not the GUI
dispatch thread, the document is scheduled to be set later.
Note that preferred size
calculations should be done in the GUI dispatch thread for
this reason.
node
- This should
normally be a Document instance obtained with
DocumentBuilderImpl
.
rcontext
- A renderer context.DocumentBuilderImpl.parse(org.xml.sax.InputSource)
,
SimpleHtmlRendererContext
public void scrollToElement(java.lang.String nameOrId)
If this method is invoked outside the GUI thread, the operation is scheduled to be performed as soon as possible in the GUI thread.
nameOrId
- The name or ID of the element in the document.public void setHtml(java.lang.String htmlSource, java.lang.String uri, HtmlRendererContext rcontext)
htmlSource
- The HTML source code.uri
- A base URI used to resolve item URIs.rcontext
- The HtmlRendererContext
instance.SimpleHtmlRendererContext
,
setDocument(Document, HtmlRendererContext)
public NodeImpl getRootNode()
public void expandSelection(RenderableSpot rpoint)
Note: This method should be invoked in the GUI thread.
expandSelection
in interface FrameContext
public void resetSelection(RenderableSpot rpoint)
Note: This method should be invoked in the GUI thread.
resetSelection
in interface FrameContext
public java.lang.String getSelectionText()
Note: This method should be invoked in the GUI thread.
public org.w3c.dom.Node getSelectionNode()
Note: This method should be invoked in the GUI thread.
null
if there is no such node. It also returns null
for FRAMESETs.public boolean hasSelection()
public boolean copy()
public void addSelectionChangeListener(SelectionChangeListener listener)
listener
- An instance of SelectionChangeListener
.public void removeSelectionChangeListener(SelectionChangeListener listener)
public void setDefaultMarginInsets(java.awt.Insets insets)
This method has no effect on FRAMESETs.
insets
- The default margin insets.public void setDefaultOverflowX(int overflow)
This method has no effect on FRAMESETs.
overflow
- See RenderState
.public void setDefaultOverflowY(int overflow)
This method has no effect on FRAMESETs.
overflow
- See RenderState
.public void delayedRelayout(NodeImpl node)
delayedRelayout
in interface FrameContext
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |