public class GapDocumentView extends GapBoxView
It is expected that this view will not act as an active
layout state i.e. that it will not be hosted by a view
implementing ViewLayoutState.Parent
.
The implementation tries to optimize calls to updateLayout()
so that if there are multiple changes in children then
they will all be serviced at once.
ViewLayoutState.Parent
GAP_BOX_VIEW_LAST_USED_STATUS_BIT
BadBreakWeight, ExcellentBreakWeight, ForcedBreakWeight, GoodBreakWeight, X_AXIS, Y_AXIS
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
Constructor and Description |
---|
GapDocumentView(Element elem)
Construct a view intended to cover the whole document.
|
GapDocumentView(Element elem,
boolean hideBottomPadding)
Construct a view intended to cover the whole document.
|
Modifier and Type | Method and Description |
---|---|
void |
changedUpdate(DocumentEvent e,
Shape a,
ViewFactory f) |
boolean |
checkDamageRange(int startOffset,
int endOffset,
Position.Bias startBias,
Position.Bias endBias)
Check whether damage range should be performed in a regular way
or whether the view hierarchy is not updated yet and so just the boundaries
of the damage should just be remembered until the insertUpdate() etc.
|
protected void |
directUpdateLayout()
This method is called when this view is not acting as active
layout state and its layout becomes invalid.
|
protected int |
getLastAllocationHeight() |
protected int |
getLastAllocationWidth() |
protected int |
getLastAllocationX() |
protected int |
getLastAllocationY() |
protected ViewLayoutQueue |
getLayoutQueue()
Fetch the queue to use for layout.
|
float |
getPreferredSpan(int axis)
Determines the preferred span for this view along an
axis.
|
void |
insertUpdate(DocumentEvent evt,
Shape a,
ViewFactory f) |
boolean |
isPendingUpdate()
Return true if this view (and its subviews) need to be updated after a document modification.
|
protected void |
layoutLock() |
protected void |
layoutUnlock() |
protected boolean |
markRepaint(int childIndex,
boolean repaintTillEnd)
Mark that the child with the given index should be repainted.
|
protected void |
markSizeInvalid(int childIndex,
int count)
This method marks sizes of all the children as invalid
so the next layout update will resize each children.
|
void |
paint(Graphics g,
Shape a)
Render the view using the given allocation and
rendering surface.
|
protected void |
processRepaint(ViewLayoutState.Parent lsParent)
Process pending repaint requests from children.
|
protected Rectangle |
reallocate(Shape a)
Reallocate the view to the new size given by the passed shape.
|
void |
removeUpdate(DocumentEvent evt,
Shape a,
ViewFactory f) |
void |
renderWithUpdateLayout(Runnable r) |
void |
repaint(ViewLayoutState child,
double majorAxisOffset,
double majorAxisSpan,
float minorAxisOffset,
float minorAxisSpan)
Inform the parent that the child layout state needs a repaint.
|
protected void |
resetEstimatedSpan(int childIndex,
int count)
Set estimated span flag to false on the given children views.
|
void |
setParent(View parent)
Sets the parent of the view.
|
void |
setSize(float width,
float height)
Sets the size of the view.
|
appendChildToStringBuffer, childrenToString, childrenToString, childToString, clearStatusBits, createChild, createCustomView, createDefaultChild, customInsertUpdate, customReloadChildren, customRemoveUpdate, elementReloadChildren, getAlignment, getChild, getChildAllocation, getChildIndex, getChildIndexNoCheck, getEndOffset, getInsertUpdateRebuildOffsetRange, getInsets, getInsetSpan, getLayoutMajorAxisPreferredSpan, getLayoutMajorAxisRawOffset, getLayoutMinorAxisAlignment, getLayoutMinorAxisMaximumSpan, getLayoutMinorAxisMinimumSpan, getLayoutMinorAxisPreferredSpan, getLayoutStateMajorAxis, getLayoutStateMinorAxis, getLayoutStateParent, getMajorAxis, getMajorAxisInsetSpan, getMaximumSpan, getMinimumSpan, getMinorAxis, getMinorAxisInsetSpan, getMinorAxisSpan, getNextVisualPositionFrom, getRemoveUpdateRebuildOffsetRange, getReplaceEstimatedThreshold, getStartOffset, getStatusBits, getView, getView, getViewCount, getViewIndex, getViewIndex, getViewIndexAtPoint, getViewRawIndex, isActiveLayoutState, isChildrenLayoutNecessary, isChildrenResizeDisabled, isEstimatedSpan, isFlyweight, isLayoutMinorAxisPreferenceChanged, isLayoutValid, isMajorAxisPreferenceChanged, isMinorAxisPreferenceChanged, isRepaintPending, isRepaintTillEnd, isStatusBitsNonZero, isXLayoutStateMajorAxis, layoutInvalid, majorAxisPreferenceChanged, markChildrenLayoutNecessary, markLayoutInvalid, markMajorAxisPreferenceChanged, markMinorAxisPreferenceChanged, markRepaintPending, markViewSizeInvalid, minorAxisPreferenceChanged, modelToView, offsetRebuild, preferenceChanged, rebuild, releaseChildren, reloadChildren, replace, resetAxesPreferenceChanged, resetRepaintPending, selectLayoutMajorAxis, setEstimatedSpan, setLayoutMajorAxisRawOffset, setSpanOnMajorAxis, setSpanOnMinorAxis, setStatusBits, setViewRawIndex, toString, unloadChildren, updateLayout, updateLayout, useCustomReloadChildren, viewPreferenceChanged, viewToModel
append, breakView, createFragment, forwardUpdate, forwardUpdateToView, getAttributes, getBreakWeight, getContainer, getDocument, getElement, getEndOffset, getGraphics, getParent, getResizeWeight, getStartOffset, getToolTipText, getViewFactory, getViewIndex, insert, isVisible, modelToView, modelToView, remove, removeAll, updateChildren, viewToModel
public GapDocumentView(Element elem)
elem
- the element of the model to represent.public GapDocumentView(Element elem, boolean hideBottomPadding)
elem
- the element of the model to represent.hideBottomPadding
- to avoid adding bottom padding to viewpublic float getPreferredSpan(int axis)
GapBoxView
getPreferredSpan
in class GapBoxView
axis
- may be either View.X_AXIS or View.Y_AXISprotected Rectangle reallocate(Shape a)
GapBoxView
reallocate
in class GapBoxView
a
- shape to which to reallocate the view.protected void directUpdateLayout()
GapBoxView
directUpdateLayout
in class GapBoxView
protected final void layoutLock()
protected final void layoutUnlock()
public void renderWithUpdateLayout(Runnable r)
public void setParent(View parent)
GapBoxView
getViewCount()
)
or for preferred, minimum or maximum span of this view.setParent
in class GapBoxView
parent
- the parent of the view, null
if nonepublic void setSize(float width, float height)
GapBoxView
The propagation of this operation to child views can be done asynchronously if appropriate.
setSize
in class GapBoxView
width
- the width >= 0height
- the height >= 0public void insertUpdate(DocumentEvent evt, Shape a, ViewFactory f)
insertUpdate
in class GapBoxView
public void removeUpdate(DocumentEvent evt, Shape a, ViewFactory f)
removeUpdate
in class GapBoxView
public void changedUpdate(DocumentEvent e, Shape a, ViewFactory f)
changedUpdate
in class GapBoxView
public boolean checkDamageRange(int startOffset, int endOffset, Position.Bias startBias, Position.Bias endBias)
JTextComponent.getUI().damageRange()
should be performed or false if there are pending view updates and the damageRange
will be invoked later by the view itself.public boolean isPendingUpdate()
JTextComponent.getUI().damageRange()
.public void paint(Graphics g, Shape a)
GapBoxView
paint
in class GapBoxView
g
- the rendering surface to usea
- the allocated region to render intoView.paint(java.awt.Graphics, java.awt.Shape)
public void repaint(ViewLayoutState child, double majorAxisOffset, double majorAxisSpan, float minorAxisOffset, float minorAxisSpan)
ViewLayoutState.Parent
updateLayout()
.
repaint
in interface ViewLayoutState.Parent
repaint
in class GapBoxView
child
- child that needs its area to be repainted.majorAxisOffset
- offset along the major axis defining
the begining of the repaint region. If the allocation
has changed along the major axis the view is fully repainted
(see majorAxisPreferenceChanged()
).
majorAxisSpan
- span along the major axis
that should be repainted. If it is set to zero then
it means that the end of the repaint region along the major axis
span is determined by the span allocated for the child
in this parent.minorAxisOffset
- offset along the minor axis
defining the begining of the repaint region.minorAxisSpan
- span along the minor axis
that should be repainted. If it is set to zero then
it means that the end of the repaint region along the minor axis
span is determined by the span of this parent.protected boolean markRepaint(int childIndex, boolean repaintTillEnd)
GapBoxView
markRepaint
in class GapBoxView
childIndex
- index of child that should be marked for repaint.repaintTillEnd
- if set to true then all children following
the child should be repainted as well.protected void processRepaint(ViewLayoutState.Parent lsParent)
GapBoxView
processRepaint
in class GapBoxView
protected void resetEstimatedSpan(int childIndex, int count)
GapBoxView
setEstimatedSpan()
and from children.replace()
if the number of added
children exceeds threshold count.
resetEstimatedSpan
in class GapBoxView
protected void markSizeInvalid(int childIndex, int count)
GapBoxView
markSizeInvalid
in class GapBoxView
count
- >0 total number of child views of this view. It's given
as parameter because subclasses will typically decide their
behavior based on the total view count.protected final int getLastAllocationX()
protected final int getLastAllocationY()
protected final int getLastAllocationWidth()
protected final int getLastAllocationHeight()
protected ViewLayoutQueue getLayoutQueue()