org.lobobrowser.html.gui
Class HtmlBlockPanel

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by org.lobobrowser.html.gui.HtmlBlockPanel
All Implemented Interfaces:
java.awt.datatransfer.ClipboardOwner, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, NodeRenderer, RenderableContainer

public class HtmlBlockPanel
extends javax.swing.JComponent
implements NodeRenderer, RenderableContainer, java.awt.datatransfer.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.

See Also:
HtmlPanel, FrameSetPanel, Serialized Form

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.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  java.awt.Insets defaultMarginInsets
           
protected  int defaultOverflowX
           
protected  int defaultOverflowY
           
protected  RenderableSpot endSelection
           
protected  FrameContext frameContext
           
protected  int preferredWidth
           
protected  RBlock rblock
           
protected  HtmlRendererContext rcontext
           
protected  RenderableSpot startSelection
           
protected  UserAgentContext ucontext
           
 
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
HtmlBlockPanel(java.awt.Color background, boolean opaque, UserAgentContext pcontext, HtmlRendererContext rcontext, FrameContext frameContext)
           
HtmlBlockPanel(UserAgentContext pcontext, HtmlRendererContext rcontext, FrameContext frameContext)
           
 
Method Summary
 java.awt.Component addComponent(java.awt.Component component)
           
 void addDelayedPair(DelayedPair pair)
           
 void clearDelayedPairs()
           
 boolean copy()
           
 void doLayout()
           
 void finalize()
           
 void focus()
           
 java.awt.Insets getDefaultMarginInsets()
           
 int getDefaultOverflowX()
           
 int getDefaultOverflowY()
           
 java.util.Collection getDelayedPairs()
           
 int getFirstLineHeight()
           
 java.awt.Point getGUIPoint(int clientX, int clientY)
           
 java.awt.Rectangle getNodeBounds(org.w3c.dom.Node node, boolean relativeToScrollable)
          Gets the rectangular bounds of the given node.
 java.awt.Color getPaintedBackgroundColor()
           
 RenderableContainer getParentContainer()
           
 java.awt.Dimension getPreferredSize()
          If the preferred size has been set with JComponent.setPreferredSize(Dimension), then that size is returned.
 NodeImpl getRootNode()
           
 BoundableRenderable getRootRenderable()
           
 org.w3c.dom.Node getSelectionNode()
           
 java.lang.String getSelectionText()
           
 boolean hasSelection()
           
 void invalidateLayoutUpTree()
           
 boolean isSelectionAvailable()
           
 void lostOwnership(java.awt.datatransfer.Clipboard arg0, java.awt.datatransfer.Transferable arg1)
           
 void paint(java.awt.Graphics g)
           
protected  void paintChildren(java.awt.Graphics g)
           
 void relayout()
           
 void repaint(ModelNode modelNode)
          Implementation of UINode.repaint().
protected  void revalidatePanel()
           
 void scrollBy(int xOffset, int yOffset)
           
 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)
          Scrolls the body area to the given location.
 void setDefaultMarginInsets(java.awt.Insets defaultMarginInsets)
          Sets the default margin insets.
 void setDefaultOverflowX(int defaultOverflowX)
           
 void setDefaultOverflowY(int defaultOverflowY)
           
 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()
           
 
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, 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, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, 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, transferFocusBackward, 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, 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 Detail

frameContext

protected final FrameContext frameContext

ucontext

protected final UserAgentContext ucontext

rcontext

protected final HtmlRendererContext rcontext

startSelection

protected RenderableSpot startSelection

endSelection

protected RenderableSpot endSelection

rblock

protected RBlock rblock

preferredWidth

protected int preferredWidth

defaultMarginInsets

protected java.awt.Insets defaultMarginInsets

defaultOverflowX

protected int defaultOverflowX

defaultOverflowY

protected int defaultOverflowY
Constructor Detail

HtmlBlockPanel

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

HtmlBlockPanel

public HtmlBlockPanel(java.awt.Color background,
                      boolean opaque,
                      UserAgentContext pcontext,
                      HtmlRendererContext rcontext,
                      FrameContext frameContext)
Method Detail

scrollTo

public void scrollTo(java.awt.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.

scrollBy

public void scrollBy(int xOffset,
                     int yOffset)

scrollTo

public void scrollTo(org.w3c.dom.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.

getNodeBounds

public java.awt.Rectangle getNodeBounds(org.w3c.dom.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).

getRootRenderable

public BoundableRenderable getRootRenderable()

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.

getPreferredSize

public java.awt.Dimension getPreferredSize()
If the preferred size has been set with JComponent.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.

Overrides:
getPreferredSize in class javax.swing.JComponent

finalize

public void finalize()
              throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

copy

public boolean copy()

getFirstLineHeight

public int getFirstLineHeight()

setSelectionEnd

public void setSelectionEnd(RenderableSpot rpoint)

setSelectionStart

public void setSelectionStart(RenderableSpot rpoint)

isSelectionAvailable

public boolean isSelectionAvailable()

getSelectionNode

public org.w3c.dom.Node getSelectionNode()

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

validateAll

protected void validateAll()

revalidatePanel

protected void revalidatePanel()

getRootNode

public NodeImpl getRootNode()

paint

public void paint(java.awt.Graphics g)
Overrides:
paint in class javax.swing.JComponent

doLayout

public void doLayout()
Overrides:
doLayout in class java.awt.Container

repaint

public void repaint(ModelNode modelNode)
Implementation of UINode.repaint().


getSelectionText

public java.lang.String getSelectionText()

hasSelection

public boolean hasSelection()

paintChildren

protected void paintChildren(java.awt.Graphics g)
Overrides:
paintChildren in class javax.swing.JComponent

getPaintedBackgroundColor

public java.awt.Color getPaintedBackgroundColor()
Specified by:
getPaintedBackgroundColor in interface RenderableContainer

lostOwnership

public void lostOwnership(java.awt.datatransfer.Clipboard arg0,
                          java.awt.datatransfer.Transferable arg1)
Specified by:
lostOwnership in interface java.awt.datatransfer.ClipboardOwner

relayout

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

invalidateLayoutUpTree

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

updateAllWidgetBounds

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

getGUIPoint

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

focus

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

addDelayedPair

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

getParentContainer

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

getDelayedPairs

public java.util.Collection getDelayedPairs()
Specified by:
getDelayedPairs in interface RenderableContainer

clearDelayedPairs

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

addComponent

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

getDefaultMarginInsets

public java.awt.Insets getDefaultMarginInsets()

setDefaultMarginInsets

public void setDefaultMarginInsets(java.awt.Insets defaultMarginInsets)
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)


SourceForge.net LogoCopyright © 2005, 2006, 2007 The Lobo Project. All Rights Reserved.
[Cobra Project Home]