|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javax.swing.text.View | +--javax.swing.text.AsyncBoxView
Unsafe: A box that does layout asynchronously. This is useful to keep the GUI event thread moving by not doing any layout on it. The layout is done on a granularity of operations on the child views. After each child view is accessed for some part of layout (a potentially time consuming operation) the remaining tasks can be abandoned or a new higher priority task (i.e. to service a synchronous request or a visible area) can be taken on.
While the child view is being accessed a read lock is aquired on the associated document so that the model is stable while being accessed.
Field Summary | |
(package private) int |
axis
The major axis against which the children are tiled. |
(package private) float |
bottomInset
|
(package private) javax.swing.text.AsyncBoxView.ChildState |
changing
Child that is actively changing size. |
(package private) boolean |
estimatedMajorSpan
Is the span along the major axis estimated? |
(package private) Runnable |
flushTask
|
(package private) float |
leftInset
|
protected javax.swing.text.AsyncBoxView.ChildLocator |
locator
Object that manages the offsets of the children. |
(package private) boolean |
majorChanged
|
(package private) float |
majorSpan
Current span along the major axis. |
(package private) boolean |
minorChanged
|
(package private) float |
minorSpan
Current span along the minor axis. |
(package private) javax.swing.text.AsyncBoxView.ChildState |
minRequest
|
(package private) javax.swing.text.AsyncBoxView.ChildState |
prefRequest
|
(package private) float |
rightInset
|
(package private) List |
stats
The children and their layout statistics. |
(package private) float |
topInset
|
Fields inherited from class javax.swing.text.View |
BadBreakWeight, ExcellentBreakWeight, ForcedBreakWeight, GoodBreakWeight, sharedBiasReturn, X_AXIS, Y_AXIS |
Fields inherited from interface javax.swing.SwingConstants |
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST |
Constructor Summary | |
AsyncBoxView(Element elem,
int axis)
Suppressed: Construct a box view that does asynchronous layout. |
Method Summary | |
protected javax.swing.text.AsyncBoxView.ChildState |
createChildState(View v)
New ChildState records are created through this method to allow subclasses the extend the ChildState records to do/hold more |
protected void |
flushRequirementChanges()
Publish the changes in preferences upward to the parent view. |
float |
getBottomInset()
Suppressed: Get the bottom part of the margin around the view. |
Shape |
getChildAllocation(int index,
Shape a)
Suppressed: Fetches the allocation for the given child view. |
protected javax.swing.text.AsyncBoxView.ChildState |
getChildState(int index)
Fetch the object representing the layout state of of the child at the given index. |
protected boolean |
getEstimatedMajorSpan()
Is the major span currently estimated? |
protected float |
getInsetSpan(int axis)
Fetch the span along an axis that is taken up by the insets. |
protected LayoutQueue |
getLayoutQueue()
Fetch the queue to use for layout. |
float |
getLeftInset()
Suppressed: Get the left part of the margin around the view. |
int |
getMajorAxis()
Suppressed: Fetch the major axis (the axis the children are tiled along). |
float |
getMaximumSpan(int axis)
Suppressed: Determines the maximum span for this view along an axis. |
float |
getMinimumSpan(int axis)
Suppressed: Determines the minimum span for this view along an axis. |
int |
getMinorAxis()
Suppressed: Fetch the minor axis (the axis orthoginal to the tiled axis). |
int |
getNextVisualPositionFrom(int pos,
javax.swing.text.Position.Bias b,
Shape a,
int direction,
javax.swing.text.Position.Bias[] biasRet)
Suppressed: Provides a way to determine the next visually represented model location that one might place a caret. |
float |
getPreferredSpan(int axis)
Suppressed: Determines the preferred span for this view along an axis. |
float |
getRightInset()
Suppressed: Get the right part of the margin around the view. |
(package private) float |
getSpanOnAxis(int axis)
Retrieves the size of the view along an axis. |
float |
getTopInset()
Suppressed: Get the top part of the margin around the view. |
View |
getView(int n)
Suppressed: Gets the nth child view. |
int |
getViewCount()
Suppressed: Returns the number of views in this view. |
int |
getViewIndex(int pos,
javax.swing.text.Position.Bias b)
Suppressed: Returns the child view index representing the given position in the model. |
protected int |
getViewIndexAtPosition(int pos,
javax.swing.text.Position.Bias b)
Fetches the child view index representing the given position in the model. |
protected void |
loadChildren(ViewFactory f)
Loads all of the children to initialize the view. |
protected void |
majorRequirementChange(javax.swing.text.AsyncBoxView.ChildState cs,
float delta)
Requirements changed along the major axis. |
protected void |
minorRequirementChange(javax.swing.text.AsyncBoxView.ChildState cs)
Requirements changed along the minor axis. |
Shape |
modelToView(int pos,
Shape a,
javax.swing.text.Position.Bias b)
Suppressed: Provides a mapping from the document model coordinate space to the coordinate space of the view mapped to it. |
void |
paint(Graphics g,
Shape alloc)
Suppressed: Render the view using the given allocation and rendering surface. |
void |
preferenceChanged(View child,
boolean width,
boolean height)
Suppressed: Child views can call this on the parent to indicate that the preference has changed and should be reconsidered for layout. |
void |
replace(int offset,
int length,
View[] views)
Suppressed: Calls the superclass to update the child views, and updates the status records for the children. |
void |
setBottomInset(float i)
Suppressed: Set the bottom part of the margin around the view. |
protected void |
setEstimatedMajorSpan(boolean isEstimated)
Set the estimatedMajorSpan property that determines if the major span should be treated as being estimated. |
void |
setLeftInset(float i)
Suppressed: Set the left part of the margin around the view. |
void |
setParent(View parent)
Suppressed: Sets the parent of the view. |
void |
setRightInset(float i)
Suppressed: Set the right part of the margin around the view. |
void |
setSize(float width,
float height)
Suppressed: Sets the size of the view. |
(package private) void |
setSpanOnAxis(int axis,
float span)
Sets the size of the view along an axis. |
void |
setTopInset(float i)
Suppressed: Set the top part of the margin around the view. |
protected void |
updateLayout(javax.swing.event.DocumentEvent.ElementChange ec,
DocumentEvent e,
Shape a)
Update the layout in response to receiving notification of change from the model. |
int |
viewToModel(float x,
float y,
Shape a,
javax.swing.text.Position.Bias[] biasReturn)
Suppressed: Provides a mapping from the view coordinate space to the logical coordinate space of the model. |
Methods inherited from class javax.swing.text.View |
append, breakView, changedUpdate, createFragment, forwardUpdate, forwardUpdateToView, getAlignment, getAttributes, getBreakWeight, getContainer, getDocument, getElement, getEndOffset, getGraphics, getParent, getResizeWeight, getStartOffset, getToolTipText, getViewFactory, getViewIndex, insert, insertUpdate, isVisible, modelToView, modelToView, remove, removeAll, removeUpdate, updateChildren, viewToModel |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
int axis
List stats
float majorSpan
boolean estimatedMajorSpan
float minorSpan
protected javax.swing.text.AsyncBoxView.ChildLocator locator
float topInset
float bottomInset
float leftInset
float rightInset
javax.swing.text.AsyncBoxView.ChildState minRequest
javax.swing.text.AsyncBoxView.ChildState prefRequest
boolean majorChanged
boolean minorChanged
Runnable flushTask
javax.swing.text.AsyncBoxView.ChildState changing
Constructor Detail |
public AsyncBoxView(Element elem, int axis)
elem
- the element of the model to representaxis
- the axis to tile along. This can be
either X_AXIS or Y_AXIS.Method Detail |
public int getMajorAxis()
public int getMinorAxis()
public float getTopInset()
public void setTopInset(float i)
i
- the value of the insetpublic float getBottomInset()
public void setBottomInset(float i)
i
- the value of the insetpublic float getLeftInset()
public void setLeftInset(float i)
i
- the value of the insetpublic float getRightInset()
public void setRightInset(float i)
i
- the value of the insetprotected float getInsetSpan(int axis)
axis
- the axis to determine the total insets along,
either X_AXIS or Y_AXIS.protected void setEstimatedMajorSpan(boolean isEstimated)
protected boolean getEstimatedMajorSpan()
protected javax.swing.text.AsyncBoxView.ChildState getChildState(int index)
index
- the child index. This should be a
value >= 0 and < getViewCount().protected LayoutQueue getLayoutQueue()
protected javax.swing.text.AsyncBoxView.ChildState createChildState(View v)
protected void majorRequirementChange(javax.swing.text.AsyncBoxView.ChildState cs, float delta)
This is implemented to mark the major axis as having changed so that a future check to see if the requirements need to be published to the parent view will consider the major axis. If the span along the major axis is not estimated, it is updated by the given delta to reflect the incremental change. The delta is ignored if the major span is estimated.
protected void minorRequirementChange(javax.swing.text.AsyncBoxView.ChildState cs)
protected void flushRequirementChanges()
public void replace(int offset, int length, View[] views)
replace
in class View
offset
- the starting offset into the child views >= 0length
- the number of existing views to replace >= 0views
- the child views to insertprotected void loadChildren(ViewFactory f)
Normally a write-lock is held on the Document while the children are being changed, which keeps the rendering and layout threads safe. The exception to this is when the view is initialized to represent an existing element (via this method), so it is synchronized to exclude preferenceChanged while we are initializing.
f
- the view factorysetParent(javax.swing.text.View)
protected int getViewIndexAtPosition(int pos, javax.swing.text.Position.Bias b)
pos
- the position >= 0
protected void updateLayout(javax.swing.event.DocumentEvent.ElementChange ec, DocumentEvent e, Shape a)
updateLayout
in class View
ec
- changes to the element this view is responsible
for (may be null if there were no changes).e
- the change information from the associated documenta
- the current allocation of the viewView.insertUpdate(javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory)
,
View.removeUpdate(javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory)
,
View.changedUpdate(javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory)
public void setParent(View parent)
loadChildren
method if this view does not already have children.
The children should not be loaded in the
constructor because the act of setting the parent
may cause them to try to search up the hierarchy
(to get the hosting Container for example).
If this view has children (the view is being moved
from one place in the view hierarchy to another),
the loadChildren
method will not be called.
setParent
in class View
parent
- the parent of the view, null if nonepublic void preferenceChanged(View child, boolean width, boolean height)
preferenceChanged
in class View
child
- the child viewwidth
- true if the width preference has changedheight
- true if the height preference has changedjavax.swing.JComponent#revalidate
public void setSize(float width, float height)
Since the major axis is updated asynchronously and should be the sum of the tiled children the call is ignored for the major axis. Since the minor axis is flexible, work is queued to resize the children if the minor span changes.
setSize
in class View
width
- the width >= 0height
- the height >= 0float getSpanOnAxis(int axis)
axis
- may be either View.X_AXIS
or
View.Y_AXIS
void setSpanOnAxis(int axis, float span)
axis
- may be either View.X_AXIS
or
View.Y_AXIS
span
- the span to layout to >= 0public void paint(Graphics g, Shape alloc)
This is implemented to determine whether or not the desired region to be rendered (i.e. the unclipped area) is up to date or not. If up-to-date the children are rendered. If not up-to-date, a task to build the desired area is placed on the layout queue as a high priority task. This keeps by event thread moving by rendering if ready, and postponing until a later time if not ready (since paint requests can be rescheduled).
paint
in class View
g
- the rendering surface to usealloc
- the allocated region to render intoView.paint(java.awt.Graphics, java.awt.Shape)
public float getPreferredSpan(int axis)
getPreferredSpan
in class View
axis
- may be either View.X_AXIS or View.Y_AXIS
View.getPreferredSpan(int)
public float getMinimumSpan(int axis)
getMinimumSpan
in class View
axis
- may be either View.X_AXIS or View.Y_AXIS
View.getPreferredSpan(int)
public float getMaximumSpan(int axis)
getMaximumSpan
in class View
axis
- may be either View.X_AXIS or View.Y_AXIS
View.getPreferredSpan(int)
public int getViewCount()
getViewCount
in class View
View.getViewCount()
public View getView(int n)
getView
in class View
n
- the number of the view to get, >= 0 && < getViewCount()
public Shape getChildAllocation(int index, Shape a)
getChildAllocation
in class View
index
- the index of the child, >= 0 && < getViewCount()a
- the allocation to this view.
public int getViewIndex(int pos, javax.swing.text.Position.Bias b)
getViewIndex
in class View
pos
- the position >= 0
public Shape modelToView(int pos, Shape a, javax.swing.text.Position.Bias b) throws BadLocationException
modelToView
in class View
pos
- the position to convert >= 0a
- the allocated region to render intob
- the bias toward the previous character or the
next character represented by the offset, in case the
position is a boundary of two views.
BadLocationException
View.viewToModel(float, float, java.awt.Shape, javax.swing.text.Position.Bias[])
public int viewToModel(float x, float y, Shape a, javax.swing.text.Position.Bias[] biasReturn)
This is expected to be called by the GUI thread, holding a read-lock on the associated model. It is implemented to locate the child view and determine it's allocation with a lock on the ChildLocator object, and to call viewToModel on the child view with a lock on the ChildState object to avoid interaction with the layout thread.
viewToModel
in class View
x
- the X coordinate >= 0y
- the Y coordinate >= 0a
- the allocated region to render into
public int getNextVisualPositionFrom(int pos, javax.swing.text.Position.Bias b, Shape a, int direction, javax.swing.text.Position.Bias[] biasRet) throws BadLocationException
getNextVisualPositionFrom
in class View
pos
- the position to convert >= 0a
- the allocated region to render intodirection
- the direction from the current position that can
be thought of as the arrow keys typically found on a keyboard;
this may be one of the following:
SwingConstants.WEST
SwingConstants.EAST
SwingConstants.NORTH
SwingConstants.SOUTH
biasRet
- an array contain the bias that was checked
BadLocationException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |