Class 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:
  • Field Details

    • 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 Insets defaultMarginInsets
    • defaultOverflowX

      protected int defaultOverflowX
    • defaultOverflowY

      protected int defaultOverflowY
  • Constructor Details

  • Method Details

    • 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.
    • scrollBy

      public void scrollBy(int xOffset, int yOffset)
    • 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.
    • 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).
    • 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 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 JComponent
    • finalize

      public void finalize() throws Throwable
      Overrides:
      finalize in class Object
      Throws:
      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 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(Graphics g)
      Overrides:
      paint in class JComponent
    • doLayout

      public void doLayout()
      Overrides:
      doLayout in class Container
    • repaint

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

      public String getSelectionText()
    • hasSelection

      public boolean hasSelection()
    • paintChildren

      protected void paintChildren(Graphics g)
      Overrides:
      paintChildren in class JComponent
    • getPaintedBackgroundColor

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

      public void lostOwnership(Clipboard arg0, Transferable arg1)
      Specified by:
      lostOwnership in interface 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 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 Collection getDelayedPairs()
      Specified by:
      getDelayedPairs in interface RenderableContainer
    • clearDelayedPairs

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

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

      public Insets getDefaultMarginInsets()
    • setDefaultMarginInsets

      public void setDefaultMarginInsets(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)