javax.swing.text
Class AsyncBoxView.ChildLocator

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by javax.swing.text.AsyncBoxView.ChildLocator
Enclosing class:
AsyncBoxView sample code for javax.swing.text.AsyncBoxView definition code for javax.swing.text.AsyncBoxView

public class AsyncBoxView.ChildLocator
extends Object sample code for java.lang.Object definition code for java.lang.Object

A class to manage the effective position of the child views in a localized area while changes are being made around the localized area. The AsyncBoxView may be continuously changing, but the visible area needs to remain fairly stable until the layout thread decides to publish an update to the parent.


Field Summary
protected  Rectangle sample code for java.awt.Rectangle definition code for java.awt.Rectangle childAlloc sample code for javax.swing.text.AsyncBoxView.ChildLocator.childAlloc definition code for javax.swing.text.AsyncBoxView.ChildLocator.childAlloc
          A shape to use for the child allocation to avoid creating a lot of garbage.
protected  Rectangle sample code for java.awt.Rectangle definition code for java.awt.Rectangle lastAlloc sample code for javax.swing.text.AsyncBoxView.ChildLocator.lastAlloc definition code for javax.swing.text.AsyncBoxView.ChildLocator.lastAlloc
          The last seen allocation (for repainting when changes are flushed upward).
protected  AsyncBoxView.ChildState sample code for javax.swing.text.AsyncBoxView.ChildState definition code for javax.swing.text.AsyncBoxView.ChildState lastValidOffset sample code for javax.swing.text.AsyncBoxView.ChildLocator.lastValidOffset definition code for javax.swing.text.AsyncBoxView.ChildLocator.lastValidOffset
          The location of the last offset calculation that is valid.
 
Constructor Summary
AsyncBoxView.ChildLocator sample code for javax.swing.text.AsyncBoxView.ChildLocator.AsyncBoxView.ChildLocator() definition code for javax.swing.text.AsyncBoxView.ChildLocator.AsyncBoxView.ChildLocator() ()
          construct a child locator.
 
Method Summary
 void childChanged sample code for javax.swing.text.AsyncBoxView.ChildLocator.childChanged(javax.swing.text.AsyncBoxView.ChildState) definition code for javax.swing.text.AsyncBoxView.ChildLocator.childChanged(javax.swing.text.AsyncBoxView.ChildState) (AsyncBoxView.ChildState sample code for javax.swing.text.AsyncBoxView.ChildState definition code for javax.swing.text.AsyncBoxView.ChildState  cs)
          Notification that a child changed.
protected  Shape sample code for java.awt.Shape definition code for java.awt.Shape getChildAllocation sample code for javax.swing.text.AsyncBoxView.ChildLocator.getChildAllocation(int) definition code for javax.swing.text.AsyncBoxView.ChildLocator.getChildAllocation(int) (int index)
          Fetch the allocation to use for a child view.
 Shape sample code for java.awt.Shape definition code for java.awt.Shape getChildAllocation sample code for javax.swing.text.AsyncBoxView.ChildLocator.getChildAllocation(int, java.awt.Shape) definition code for javax.swing.text.AsyncBoxView.ChildLocator.getChildAllocation(int, java.awt.Shape) (int index, Shape sample code for java.awt.Shape definition code for java.awt.Shape  a)
          Fetch the allocation to use for a child view.
 int getViewIndexAtPoint sample code for javax.swing.text.AsyncBoxView.ChildLocator.getViewIndexAtPoint(float, float, java.awt.Shape) definition code for javax.swing.text.AsyncBoxView.ChildLocator.getViewIndexAtPoint(float, float, java.awt.Shape) (float x, float y, Shape sample code for java.awt.Shape definition code for java.awt.Shape  a)
          Fetches the child view index at the given point.
protected  int getViewIndexAtVisualOffset sample code for javax.swing.text.AsyncBoxView.ChildLocator.getViewIndexAtVisualOffset(float) definition code for javax.swing.text.AsyncBoxView.ChildLocator.getViewIndexAtVisualOffset(float) (float targetOffset)
          Locate the view responsible for an offset into the box along the major axis.
 void paintChildren sample code for javax.swing.text.AsyncBoxView.ChildLocator.paintChildren(java.awt.Graphics) definition code for javax.swing.text.AsyncBoxView.ChildLocator.paintChildren(java.awt.Graphics) (Graphics sample code for java.awt.Graphics definition code for java.awt.Graphics  g)
          Paint the children that intersect the clip area.
protected  void setAllocation sample code for javax.swing.text.AsyncBoxView.ChildLocator.setAllocation(java.awt.Shape) definition code for javax.swing.text.AsyncBoxView.ChildLocator.setAllocation(java.awt.Shape) (Shape sample code for java.awt.Shape definition code for java.awt.Shape  a)
          Copy the currently allocated shape into the Rectangle used to store the current allocation.
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
clone sample code for java.lang.Object.clone() definition code for java.lang.Object.clone() , equals sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) , finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , hashCode sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , toString sample code for java.lang.Object.toString() definition code for java.lang.Object.toString() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 

Field Detail

lastValidOffset sample code for javax.swing.text.AsyncBoxView.ChildLocator.lastValidOffset

protected AsyncBoxView.ChildState sample code for javax.swing.text.AsyncBoxView.ChildState definition code for javax.swing.text.AsyncBoxView.ChildState  lastValidOffset
The location of the last offset calculation that is valid.


lastAlloc sample code for javax.swing.text.AsyncBoxView.ChildLocator.lastAlloc

protected Rectangle sample code for java.awt.Rectangle definition code for java.awt.Rectangle  lastAlloc
The last seen allocation (for repainting when changes are flushed upward).


childAlloc sample code for javax.swing.text.AsyncBoxView.ChildLocator.childAlloc

protected Rectangle sample code for java.awt.Rectangle definition code for java.awt.Rectangle  childAlloc
A shape to use for the child allocation to avoid creating a lot of garbage.

Constructor Detail

AsyncBoxView.ChildLocator sample code for javax.swing.text.AsyncBoxView.ChildLocator() definition code for javax.swing.text.AsyncBoxView.ChildLocator()

public AsyncBoxView.ChildLocator()
construct a child locator.

Method Detail

childChanged sample code for javax.swing.text.AsyncBoxView.ChildLocator.childChanged(javax.swing.text.AsyncBoxView.ChildState) definition code for javax.swing.text.AsyncBoxView.ChildLocator.childChanged(javax.swing.text.AsyncBoxView.ChildState)

public void childChanged(AsyncBoxView.ChildState sample code for javax.swing.text.AsyncBoxView.ChildState definition code for javax.swing.text.AsyncBoxView.ChildState  cs)
Notification that a child changed. This can effect whether or not new offset calculations are needed. This is called by a ChildState object that has changed it's major span. This can therefore be called by multiple threads.


paintChildren sample code for javax.swing.text.AsyncBoxView.ChildLocator.paintChildren(java.awt.Graphics) definition code for javax.swing.text.AsyncBoxView.ChildLocator.paintChildren(java.awt.Graphics)

public void paintChildren(Graphics sample code for java.awt.Graphics definition code for java.awt.Graphics  g)
Paint the children that intersect the clip area.


getChildAllocation sample code for javax.swing.text.AsyncBoxView.ChildLocator.getChildAllocation(int, java.awt.Shape) definition code for javax.swing.text.AsyncBoxView.ChildLocator.getChildAllocation(int, java.awt.Shape)

public Shape sample code for java.awt.Shape definition code for java.awt.Shape  getChildAllocation(int index,
                                Shape sample code for java.awt.Shape definition code for java.awt.Shape  a)
Fetch the allocation to use for a child view. This will update the offsets for all children not yet updated before the given index.


getViewIndexAtPoint sample code for javax.swing.text.AsyncBoxView.ChildLocator.getViewIndexAtPoint(float, float, java.awt.Shape) definition code for javax.swing.text.AsyncBoxView.ChildLocator.getViewIndexAtPoint(float, float, java.awt.Shape)

public int getViewIndexAtPoint(float x,
                               float y,
                               Shape sample code for java.awt.Shape definition code for java.awt.Shape  a)
Fetches the child view index at the given point. This is called by the various View methods that need to calculate which child to forward a message to. This should be called by a block synchronized on this object, and would typically be followed with one or more calls to getChildAllocation that should also be in the synchronized block.

Parameters:
x - the X coordinate >= 0
y - the Y coordinate >= 0
a - the allocation to the View
Returns:
the nearest child index

getChildAllocation sample code for javax.swing.text.AsyncBoxView.ChildLocator.getChildAllocation(int) definition code for javax.swing.text.AsyncBoxView.ChildLocator.getChildAllocation(int)

protected Shape sample code for java.awt.Shape definition code for java.awt.Shape  getChildAllocation(int index)
Fetch the allocation to use for a child view. This does not update the offsets in the ChildState records.


setAllocation sample code for javax.swing.text.AsyncBoxView.ChildLocator.setAllocation(java.awt.Shape) definition code for javax.swing.text.AsyncBoxView.ChildLocator.setAllocation(java.awt.Shape)

protected void setAllocation(Shape sample code for java.awt.Shape definition code for java.awt.Shape  a)
Copy the currently allocated shape into the Rectangle used to store the current allocation. This would be a floating point rectangle in a Java2D-specific implmentation.


getViewIndexAtVisualOffset sample code for javax.swing.text.AsyncBoxView.ChildLocator.getViewIndexAtVisualOffset(float) definition code for javax.swing.text.AsyncBoxView.ChildLocator.getViewIndexAtVisualOffset(float)

protected int getViewIndexAtVisualOffset(float targetOffset)
Locate the view responsible for an offset into the box along the major axis. Make sure that offsets are set on the ChildState objects up to the given target span past the desired offset.

Returns:
index of the view representing the given visual location (targetOffset), or -1 if no view represents that location