Package org.lobobrowser.html.renderer
Class RBlockViewport
- java.lang.Object
-
- org.lobobrowser.html.renderer.RBlockViewport
-
- All Implemented Interfaces:
BoundableRenderable,RCollection,Renderable
public class RBlockViewport extends java.lang.ObjectA 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 Summary
Fields Modifier and Type Field Description intheightprotected booleanlayoutUpTreeCanBeInvalidatedStarts as true because ancestors could be invalidated.protected ModelNodemodelNodeprotected RCollectionoriginalParentParent for invalidation.protected RCollectionparentParent for graphics coordinates.protected static java.awt.ColorSELECTION_COLORprotected static java.awt.ColorSELECTION_XORintwidthintxintystatic java.awt.InsetsZERO_INSETS-
Fields inherited from interface org.lobobrowser.html.renderer.Renderable
EMPTY_ARRAY
-
-
Constructor Summary
Constructors Constructor Description RBlockViewport(ModelNode modelNode, RenderableContainer container, int listNesting, UserAgentContext pcontext, HtmlRendererContext rcontext, FrameContext frameContext, RCollection parent)Constructs an HtmlBlockLayout.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidalignX(int alignXPercent, int canvasWidth, java.awt.Insets paddingInsets)Applies any horizonal aLignment.voidalignY(int alignYPercent, int canvasHeight, java.awt.Insets paddingInsets)Applies vertical alignment.voidblur()booleancontains(int x, int y)booleanextractSelectionText(java.lang.StringBuffer buffer, boolean inSelection, RenderableSpot startPoint, RenderableSpot endPoint)voidfocus()intgetAvailContentWidth()java.awt.ColorgetBlockBackgroundColor()java.awt.RectanglegetBounds()FloatingInfogetExportableFloatingInfo()intgetFirstBaselineOffset()intgetFirstLineHeight()java.awt.PointgetGUIPoint(int clientX, int clientY)intgetHeight()RenderableSpotgetLowestRenderableSpot(int x, int y)ModelNodegetModelNode()intgetOrdinal()java.awt.PointgetOrigin()RCollectiongetOriginalOrCurrentParent()ReturnsBoundableRenderable.getOriginalParent()if not null.RCollectiongetOriginalParent()This is the parent based on the original element hierarchy.java.awt.PointgetOriginRelativeTo(RCollection ancestor)RCollectiongetParent()Gets the parent where the renderable is rendered.BoundableRenderablegetRenderable(int x, int y)BoundableRenderablegetRenderable(java.awt.Point point)java.awt.PointgetRenderablePoint(int guiX, int guiY)java.util.IteratorgetRenderables()Gets the collection ofRenderablechildren.java.util.IteratorgetRenderables(int pointx, int pointy)java.util.IteratorgetRenderables(java.awt.Point point)java.util.IteratorgetRenderables(java.awt.Rectangle clipBounds)Renderable[]getRenderablesArray()java.awt.DimensiongetSize()intgetWidth()intgetX()intgetY()intgetZIndex()voidinvalidateLayoutDeep()Invalidates layout in all descendents.voidinvalidateLayoutLocal()voidinvalidateLayoutUpTree()Invalidates this Renderable and its parent (i.e.booleanisContainedByNode()Returns true if the renderable is fully contained by its modelNode, but said modelNode does not fully contain an ancestor renderable.protected booleanisValid()voidlayout(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.voidmarkLayoutValid()booleanonDoubleClick(java.awt.event.MouseEvent event, int x, int y)booleanonMouseClick(java.awt.event.MouseEvent event, int x, int y)booleanonMouseDisarmed(java.awt.event.MouseEvent event)voidonMouseMoved(java.awt.event.MouseEvent event, int x, int y, boolean triggerEvent, ModelNode limit)voidonMouseOut(java.awt.event.MouseEvent event, int x, int y, ModelNode limit)booleanonMousePressed(java.awt.event.MouseEvent event, int x, int y)Returns false if the event is consumed.booleanonMouseReleased(java.awt.event.MouseEvent event, int x, int y)booleanonRightClick(java.awt.event.MouseEvent event, int x, int y)voidpaint(java.awt.Graphics g)booleanpaintSelection(java.awt.Graphics g, boolean inSelection, RenderableSpot startPoint, RenderableSpot endPoint)Asks the Renderable to paint the selection between two points.voidpaintTranslated(java.awt.Graphics g)Paints by either creating a new clipped graphics context corresponding to the bounds of the Renderable, or by translating the origin.voidrelayout()Invalidates the current Renderable (which invalidates its ancestors) and then requests the top level GUI container to do the layout and repaint.voidrelayoutIfValid()voidrepaint()voidrepaint(int x, int y, int width, int height)voidsetBounds(int x, int y, int width, int height)voidsetHeight(int height)voidsetOrdinal(int ordinal)voidsetOrigin(int x, int y)voidsetOriginalParent(RCollection origParent)voidsetParent(RCollection parent)voidsetWidth(int width)voidsetX(int x)voidsetY(int y)java.lang.StringtoString()protected java.awt.PointtranslateDescendentPoint(BoundableRenderable descendent, int x, int y)voidupdateWidgetBounds(int guiX, int guiY)Updates bounds of all descendent's GUI components, based on root bounds.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.lobobrowser.html.renderer.BoundableRenderable
getBounds, getGUIPoint, getHeight, getModelNode, getOrdinal, getOrigin, getOriginalOrCurrentParent, getOriginalParent, getOriginRelativeTo, getParent, getRenderablePoint, getSize, getWidth, getX, getY, getZIndex, invalidateLayoutUpTree, paintTranslated, relayout, repaint, repaint, setBounds, setHeight, setOrdinal, setOrigin, setOriginalParent, setParent, setWidth, setX, setY
-
-
-
-
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 ofcontainer.
-
-
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,layoutwill throwSizeExceededExceptionin 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:RCollectionGets the collection ofRenderablechildren.
-
getRenderables
public java.util.Iterator getRenderables(java.awt.Rectangle clipBounds)
-
getRenderable
public BoundableRenderable getRenderable(int x, int y)
-
getRenderable
public BoundableRenderable getRenderable(java.awt.Point point)
-
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:BoundableRenderableReturns 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:BoundableRenderableReturns 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:
toStringin classjava.lang.Object
-
getExportableFloatingInfo
public FloatingInfo getExportableFloatingInfo()
-
focus
public void focus()
- Specified by:
focusin interfaceRCollection
-
blur
public void blur()
- Specified by:
blurin interfaceRCollection
-
updateWidgetBounds
public void updateWidgetBounds(int guiX, int guiY)Updates bounds of all descendent's GUI components, based on root bounds.- Specified by:
updateWidgetBoundsin interfaceRCollection
-
paintSelection
public boolean paintSelection(java.awt.Graphics g, boolean inSelection, RenderableSpot startPoint, RenderableSpot endPoint)Description copied from interface:BoundableRenderableAsks the Renderable to paint the selection between two points. Nothing will be done if the points are outside the Renderable.- Specified by:
paintSelectionin interfaceBoundableRenderable- Returns:
- True iff it's in selection when finished painting.
-
extractSelectionText
public boolean extractSelectionText(java.lang.StringBuffer buffer, boolean inSelection, RenderableSpot startPoint, RenderableSpot endPoint)- Specified by:
extractSelectionTextin interfaceBoundableRenderable
-
invalidateLayoutDeep
public void invalidateLayoutDeep()
Description copied from interface:RCollectionInvalidates layout in all descendents.- Specified by:
invalidateLayoutDeepin interfaceRCollection
-
onMouseMoved
public void onMouseMoved(java.awt.event.MouseEvent event, int x, int y, boolean triggerEvent, ModelNode limit)- Specified by:
onMouseMovedin interfaceBoundableRenderable
-
onMouseOut
public void onMouseOut(java.awt.event.MouseEvent event, int x, int y, ModelNode limit)- Specified by:
onMouseOutin interfaceBoundableRenderable
-
onRightClick
public boolean onRightClick(java.awt.event.MouseEvent event, int x, int y)- Specified by:
onRightClickin interfaceBoundableRenderable
-
markLayoutValid
public void markLayoutValid()
-
getGUIPoint
public java.awt.Point getGUIPoint(int clientX, int clientY)- Specified by:
getGUIPointin interfaceBoundableRenderable
-
getRenderablePoint
public java.awt.Point getRenderablePoint(int guiX, int guiY)- Specified by:
getRenderablePointin interfaceBoundableRenderable
-
getHeight
public int getHeight()
- Specified by:
getHeightin interfaceBoundableRenderable
-
getWidth
public int getWidth()
- Specified by:
getWidthin interfaceBoundableRenderable
-
setWidth
public void setWidth(int width)
- Specified by:
setWidthin interfaceBoundableRenderable
-
getX
public int getX()
- Specified by:
getXin interfaceBoundableRenderable
-
getY
public int getY()
- Specified by:
getYin interfaceBoundableRenderable
-
contains
public boolean contains(int x, int y)
-
getBounds
public java.awt.Rectangle getBounds()
- Specified by:
getBoundsin interfaceBoundableRenderable
-
getSize
public java.awt.Dimension getSize()
- Specified by:
getSizein interfaceBoundableRenderable
-
getModelNode
public ModelNode getModelNode()
- Specified by:
getModelNodein interfaceBoundableRenderable- Specified by:
getModelNodein interfaceRenderable
-
setBounds
public void setBounds(int x, int y, int width, int height)- Specified by:
setBoundsin interfaceBoundableRenderable
-
setX
public void setX(int x)
- Specified by:
setXin interfaceBoundableRenderable
-
setY
public void setY(int y)
- Specified by:
setYin interfaceBoundableRenderable
-
setHeight
public void setHeight(int height)
- Specified by:
setHeightin interfaceBoundableRenderable
-
setOrigin
public void setOrigin(int x, int y)- Specified by:
setOriginin interfaceBoundableRenderable
-
invalidateLayoutUpTree
public final void invalidateLayoutUpTree()
Invalidates this Renderable and its parent (i.e. all ancestors).- Specified by:
invalidateLayoutUpTreein interfaceBoundableRenderable
-
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:
relayoutin interfaceBoundableRenderable
-
relayoutIfValid
public void relayoutIfValid()
-
setParent
public void setParent(RCollection parent)
- Specified by:
setParentin interfaceBoundableRenderable
-
getParent
public RCollection getParent()
Description copied from interface:BoundableRenderableGets the parent where the renderable is rendered.- Specified by:
getParentin interfaceBoundableRenderable
-
setOriginalParent
public void setOriginalParent(RCollection origParent)
- Specified by:
setOriginalParentin interfaceBoundableRenderable
-
getOriginalParent
public RCollection getOriginalParent()
This is the parent based on the original element hierarchy.- Specified by:
getOriginalParentin interfaceBoundableRenderable
-
getOriginalOrCurrentParent
public RCollection getOriginalOrCurrentParent()
Description copied from interface:BoundableRenderableReturnsBoundableRenderable.getOriginalParent()if not null. Otherwise it returnsBoundableRenderable.getParent().- Specified by:
getOriginalOrCurrentParentin interfaceBoundableRenderable
-
repaint
public void repaint(int x, int y, int width, int height)- Specified by:
repaintin interfaceBoundableRenderable
-
repaint
public void repaint()
- Specified by:
repaintin interfaceBoundableRenderable
-
getBlockBackgroundColor
public java.awt.Color getBlockBackgroundColor()
-
paintTranslated
public final void paintTranslated(java.awt.Graphics g)
Description copied from interface:BoundableRenderablePaints by either creating a new clipped graphics context corresponding to the bounds of the Renderable, or by translating the origin.- Specified by:
paintTranslatedin interfaceBoundableRenderable- Parameters:
g- Parent's Graphics context.
-
translateDescendentPoint
protected final java.awt.Point translateDescendentPoint(BoundableRenderable descendent, int x, int y)
-
getOrigin
public java.awt.Point getOrigin()
- Specified by:
getOriginin interfaceBoundableRenderable
-
getOriginRelativeTo
public java.awt.Point getOriginRelativeTo(RCollection ancestor)
- Specified by:
getOriginRelativeToin interfaceBoundableRenderable
-
getOrdinal
public int getOrdinal()
-
getZIndex
public int getZIndex()
-
setOrdinal
public void setOrdinal(int ordinal)
-
-