Class 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.
    Author:
    J. H. S.
    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.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      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​(java.awt.Rectangle bounds, boolean xIfNeeded, boolean yIfNeeded)
      Scrolls the body area to the given location.
      void scrollTo​(org.w3c.dom.Node node)
      Scrolls the body area to the node given, if it is part of the current document.
      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, 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
    • Field Detail

      • rblock

        protected RBlock rblock
      • preferredWidth

        protected int preferredWidth
      • defaultMarginInsets

        protected java.awt.Insets defaultMarginInsets
      • defaultOverflowX

        protected int defaultOverflowX
      • defaultOverflowY

        protected int defaultOverflowY
    • 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).
      • 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
      • lostOwnership

        public void lostOwnership​(java.awt.datatransfer.Clipboard arg0,
                                  java.awt.datatransfer.Transferable arg1)
        Specified by:
        lostOwnership in interface java.awt.datatransfer.ClipboardOwner
      • 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)