javax.swing.text

Class AsyncBoxView.ChildLocator

Enclosing Class:
AsyncBoxView

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 Rectangle
childAlloc
A Rectangle used for child allocation calculation to avoid creation of lots of garbage Rectangle objects.
protected Rectangle
lastAlloc
The last allocation.
protected AsyncBoxView.ChildState
lastValidOffset
The last valid location.

Constructor Summary

ChildLocator()
Creates a new ChildLocator.

Method Summary

void
childChanged(AsyncBoxView.ChildState cs)
Receives notification that a child has changed.
protected Shape
getChildAllocation(int index)
Returns the current allocation of the child view with the specified index.
Shape
getChildAllocation(int index, Shape a)
Returns the current allocation for a child view.
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.
protected int
getViewIndexAtVisualOffset(float targetOffset)
Returns the index of the view at the specified offset along the major layout axis.
void
paintChildren(Graphics g)
Paints all child views.
protected void
setAllocation(Shape a)
Sets the current allocation for this view.

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

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 Details

ChildLocator

public ChildLocator()
Creates a new ChildLocator.

Method Details

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 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

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

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

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

AsyncBoxView.java -- A box view that performs layout asynchronously Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.