javax.swing.text

Class AsyncBoxView.ChildLocator

public class AsyncBoxView.ChildLocator extends Object

Manages the effective position of child views. That keeps the visible layout stable while the AsyncBoxView might be changing until the layout thread decides to publish the new layout.
Field Summary
protected RectanglechildAlloc
A Rectangle used for child allocation calculation to avoid creation of lots of garbage Rectangle objects.
protected RectanglelastAlloc
The last allocation.
protected AsyncBoxView.ChildStatelastValidOffset
The last valid location.
Constructor Summary
ChildLocator()
Creates a new ChildLocator.
Method Summary
voidchildChanged(AsyncBoxView.ChildState cs)
Receives notification that a child has changed.
ShapegetChildAllocation(int index, Shape a)
Returns the current allocation for a child view.
protected ShapegetChildAllocation(int index)
Returns the current allocation of the child view with the specified index.
intgetViewIndexAtPoint(float x, float y, Shape a)
Returns the view index of the view that occupies the specified area, or -1 if there is no such child view.
protected intgetViewIndexAtVisualOffset(float targetOffset)
Returns the index of the view at the specified offset along the major layout axis.
voidpaintChildren(Graphics g)
Paints all child views.
protected voidsetAllocation(Shape a)
Sets the current allocation for this view.

Field Detail

childAlloc

protected Rectangle childAlloc
A Rectangle used for child allocation calculation to avoid creation of lots of garbage Rectangle objects.

lastAlloc

protected Rectangle lastAlloc
The last allocation.

lastValidOffset

protected AsyncBoxView.ChildState lastValidOffset
The last valid location.

Constructor Detail

ChildLocator

public ChildLocator()
Creates a new ChildLocator.

Method Detail

childChanged

public void childChanged(AsyncBoxView.ChildState cs)
Receives notification that a child has changed. This is called by child state objects that have changed it's major span. This sets the {@link #lastValidOffset} field to cs if the new child state's view start offset is smaller than the start offset of the current child state's view or when lastValidOffset is null.

Parameters: cs the child state object that has changed

getChildAllocation

public Shape getChildAllocation(int index, Shape a)
Returns the current allocation for a child view. This updates the offsets for all children before the requested child view.

Parameters: index the index of the child view a the current allocation of this view

Returns: the current allocation for a child view

getChildAllocation

protected Shape getChildAllocation(int index)
Returns the current allocation of the child view with the specified index. Note that this will not update any location information.

Parameters: index the index of the requested child view

Returns: the current allocation of the child view with the specified index

getViewIndexAtPoint

public int getViewIndexAtPoint(float x, float y, Shape a)
Returns the view index of the view that occupies the specified area, or -1 if there is no such child view.

Parameters: x the x coordinate (relative to a) y the y coordinate (relative to a) a the current allocation of this view

Returns: the view index of the view that occupies the specified area, or -1 if there is no such child view

getViewIndexAtVisualOffset

protected int getViewIndexAtVisualOffset(float targetOffset)
Returns the index of the view at the specified offset along the major layout axis.

Parameters: targetOffset the requested offset

Returns: the index of the view at the specified offset along the major layout axis

paintChildren

public void paintChildren(Graphics g)
Paints all child views.

Parameters: g the graphics context to use

setAllocation

protected void setAllocation(Shape a)
Sets the current allocation for this view.

Parameters: a the allocation to set