Class RBlockViewport

  • All Implemented Interfaces:
    BoundableRenderable, RCollection, Renderable

    public class RBlockViewport
    extends java.lang.Object
    A substantial portion of the HTML rendering logic of the package can be found in this class. This class is in charge of laying out the DOM subtree of a node, usually on behalf of an RBlock. It creates a renderer subtree consisting of RLine's or RBlock's. RLine's in turn contain RWord's and so on. This class also happens to be used as an RBlock scrollable viewport.
    Author:
    J. H. S.
    • Field Detail

      • ZERO_INSETS

        public static final java.awt.Insets ZERO_INSETS
      • SELECTION_COLOR

        protected static final java.awt.Color SELECTION_COLOR
      • SELECTION_XOR

        protected static final java.awt.Color SELECTION_XOR
      • modelNode

        protected final ModelNode modelNode
      • x

        public int x
      • y

        public int y
      • width

        public int width
      • height

        public int height
      • layoutUpTreeCanBeInvalidated

        protected boolean layoutUpTreeCanBeInvalidated
        Starts as true because ancestors could be invalidated.
      • parent

        protected RCollection parent
        Parent for graphics coordinates.
      • originalParent

        protected RCollection originalParent
        Parent for invalidation.
    • Constructor Detail

      • RBlockViewport

        public RBlockViewport​(ModelNode modelNode,
                              RenderableContainer container,
                              int listNesting,
                              UserAgentContext pcontext,
                              HtmlRendererContext rcontext,
                              FrameContext frameContext,
                              RCollection parent)
        Constructs an HtmlBlockLayout.
        Parameters:
        container - This is usually going to be an RBlock.
        listNesting - The nesting level for lists. This is zero except inside a list.
        pcontext - The HTMLParserContext instance.
        frameContext - This is usually going to be HtmlBlock, an object where text selections are contained.
        parent - This is usually going to be the parent of container.
    • Method Detail

      • invalidateLayoutLocal

        public void invalidateLayoutLocal()
      • getAvailContentWidth

        public int getAvailContentWidth()
      • layout

        public void layout​(int desiredWidth,
                           int desiredHeight,
                           java.awt.Insets paddingInsets,
                           int yLimit,
                           org.lobobrowser.html.renderer.FloatingBounds floatBounds,
                           boolean sizeOnly)
        Builds the layout/renderer tree from scratch. Note: Returned dimension needs to be actual size needed for rendered content, not the available container size. This is relied upon by table layout.
        Parameters:
        yLimit - If other than -1, layout will throw SizeExceededException in the event that the layout goes beyond this y-coordinate point.
      • alignX

        public void alignX​(int alignXPercent,
                           int canvasWidth,
                           java.awt.Insets paddingInsets)
        Applies any horizonal aLignment. It may adjust height if necessary.
        Parameters:
        canvasWidth - The new width of the viewport. It could be different to the previously calculated width.
        paddingInsets -
      • alignY

        public void alignY​(int alignYPercent,
                           int canvasHeight,
                           java.awt.Insets paddingInsets)
        Applies vertical alignment.
        Parameters:
        canvasHeight -
        paddingInsets -
      • getRenderablesArray

        public Renderable[] getRenderablesArray()
      • getRenderables

        public java.util.Iterator getRenderables()
        Description copied from interface: RCollection
        Gets the collection of Renderable children.
      • getRenderables

        public java.util.Iterator getRenderables​(java.awt.Rectangle clipBounds)
      • getRenderables

        public java.util.Iterator getRenderables​(java.awt.Point point)
      • getRenderables

        public java.util.Iterator getRenderables​(int pointx,
                                                 int pointy)
      • getFirstLineHeight

        public int getFirstLineHeight()
      • getFirstBaselineOffset

        public int getFirstBaselineOffset()
      • getLowestRenderableSpot

        public RenderableSpot getLowestRenderableSpot​(int x,
                                                      int y)
      • onMouseClick

        public boolean onMouseClick​(java.awt.event.MouseEvent event,
                                    int x,
                                    int y)
      • onDoubleClick

        public boolean onDoubleClick​(java.awt.event.MouseEvent event,
                                     int x,
                                     int y)
      • onMouseDisarmed

        public boolean onMouseDisarmed​(java.awt.event.MouseEvent event)
      • onMousePressed

        public boolean onMousePressed​(java.awt.event.MouseEvent event,
                                      int x,
                                      int y)
        Description copied from interface: BoundableRenderable
        Returns false if the event is consumed. True to propagate further.
      • onMouseReleased

        public boolean onMouseReleased​(java.awt.event.MouseEvent event,
                                       int x,
                                       int y)
      • paint

        public void paint​(java.awt.Graphics g)
      • isContainedByNode

        public boolean isContainedByNode()
        Description copied from interface: BoundableRenderable
        Returns true if the renderable is fully contained by its modelNode, but said modelNode does not fully contain an ancestor renderable.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getExportableFloatingInfo

        public FloatingInfo getExportableFloatingInfo()
      • updateWidgetBounds

        public void updateWidgetBounds​(int guiX,
                                       int guiY)
        Updates bounds of all descendent's GUI components, based on root bounds.
        Specified by:
        updateWidgetBounds in interface RCollection
      • paintSelection

        public boolean paintSelection​(java.awt.Graphics g,
                                      boolean inSelection,
                                      RenderableSpot startPoint,
                                      RenderableSpot endPoint)
        Description copied from interface: BoundableRenderable
        Asks the Renderable to paint the selection between two points. Nothing will be done if the points are outside the Renderable.
        Specified by:
        paintSelection in interface BoundableRenderable
        Returns:
        True iff it's in selection when finished painting.
      • onRightClick

        public boolean onRightClick​(java.awt.event.MouseEvent event,
                                    int x,
                                    int y)
        Specified by:
        onRightClick in interface BoundableRenderable
      • markLayoutValid

        public void markLayoutValid()
      • contains

        public boolean contains​(int x,
                                int y)
      • invalidateLayoutUpTree

        public final void invalidateLayoutUpTree()
        Invalidates this Renderable and its parent (i.e. all ancestors).
        Specified by:
        invalidateLayoutUpTree in interface BoundableRenderable
      • isValid

        protected boolean isValid()
      • relayout

        public void relayout()
        Invalidates the current Renderable (which invalidates its ancestors) and then requests the top level GUI container to do the layout and repaint. It's safe to call this method outside the GUI thread.
        Specified by:
        relayout in interface BoundableRenderable
      • relayoutIfValid

        public void relayoutIfValid()
      • repaint

        public void repaint​(int x,
                            int y,
                            int width,
                            int height)
        Specified by:
        repaint in interface BoundableRenderable
      • getBlockBackgroundColor

        public java.awt.Color getBlockBackgroundColor()
      • paintTranslated

        public final void paintTranslated​(java.awt.Graphics g)
        Description copied from interface: BoundableRenderable
        Paints by either creating a new clipped graphics context corresponding to the bounds of the Renderable, or by translating the origin.
        Specified by:
        paintTranslated in interface BoundableRenderable
        Parameters:
        g - Parent's Graphics context.
      • translateDescendentPoint

        protected final java.awt.Point translateDescendentPoint​(BoundableRenderable descendent,
                                                                int x,
                                                                int y)
      • getOrdinal

        public int getOrdinal()
      • getZIndex

        public int getZIndex()
      • setOrdinal

        public void setOrdinal​(int ordinal)