A
View
implementation that lays out its child views in a box, either
vertically or horizontally. The difference to
BoxView
is that the
layout is performed in an asynchronous manner. This helps to keep the
eventqueue free from non-GUI related tasks.
This view is currently not used in standard text components. In order to
use it you would have to implement a special
EditorKit
with a
ViewFactory
that returns this view. For example:
static class AsyncEditorKit extends StyledEditorKit implements ViewFactory
{
public View create(Element el)
{
if (el.getName().equals(AbstractDocument.SectionElementName))
return new AsyncBoxView(el, View.Y_AXIS);
return super.getViewFactory().create(el);
}
public ViewFactory getViewFactory() {
return this;
}
}
flushRequirementChanges
protected void flushRequirementChanges()
Flushes the requirements changes upwards to the parent view. This is
called from the layout thread.
getChildAllocation
public Shape getChildAllocation(int index,
Shape a)
Returns the child allocation for the child view with the specified
index
.
- getChildAllocation in interface View
index
- the index of the child viewa
- the current allocation of this view
- the allocation of the child view
getChildState
protected AsyncBoxView.ChildState getChildState(int index)
Returns the ChildState
object associated with the child view
at the specified index
.
index
- the index of the child view for which to query the state
- the child state for the specified child view
getEstimatedMajorSpan
protected boolean getEstimatedMajorSpan()
Determines whether the major span should be treated as estimated or as
beeing accurate.
true
if the major span should be treated as
estimated, false
if the major span should be treated
as accurate
getInsetSpan
protected float getInsetSpan(int axis)
Returns the span along an axis that is taken up by the insets.
- the span along an axis that is taken up by the insets
getLeftInset
public float getLeftInset()
Returns the left inset.
getMajorAxis
public int getMajorAxis()
Returns the major layout axis.
getMaximumSpan
public float getMaximumSpan(int axis)
Returns the maximum span of this view along the specified axis.
This is implemented to return the
preferredSpan
for the
major axis (that means the box can't be resized along the major axis) and
Short.MAX_VALUE
for the minor axis.
- getMaximumSpan in interface View
- the maximum span of this view along the specified axis
getMinorAxis
public int getMinorAxis()
Returns the minor layout axis, that is the axis orthogonal to the major
layout axis.
getPreferredSpan
public float getPreferredSpan(int axis)
Returns the preferred span of this view along the specified layout axis.
- getPreferredSpan in interface View
- the preferred span of this view along the specified layout axis
getRightInset
public float getRightInset()
Returns the right inset.
getTopInset
public float getTopInset()
Returns the top inset.
getView
public View getView(int index)
Returns the view at the specified index
.
- getView in interface View
index
- the index of the requested child view
- the view at the specified
index
getViewIndex
public int getViewIndex(int pos,
Position.Bias bias)
Returns the view index of the child view that represents the specified
model position.
- getViewIndex in interface View
pos
- the model position for which we search the view indexbias
- the bias
- the view index of the child view that represents the specified
model position
getViewIndexAtPosition
protected int getViewIndexAtPosition(int pos,
Position.Bias b)
Returns the child view index of the view that represents the specified
position in the document model.
pos
- the position in the modelb
- the bias
- the child view index of the view that represents the specified
position in the document model
majorRequirementChange
protected void majorRequirementChange(AsyncBoxView.ChildState cs,
float delta)
Receives notification from the child states that the requirements along
the major axis have changed.
cs
- the child state from which this notification is messaged
minorRequirementChange
protected void minorRequirementChange(AsyncBoxView.ChildState cs)
Receives notification from the child states that the requirements along
the minor axis have changed.
cs
- the child state from which this notification is messaged
preferenceChanged
public void preferenceChanged(View view,
boolean width,
boolean height)
Receives notification that one of the child views has changed its
layout preferences along one or both axis.
This queues a layout request for that child view if necessary.
- preferenceChanged in interface View
view
- the view that has changed its preferenceswidth
- true
if the width preference has changedheight
- true
if the height preference has changed
replace
public void replace(int offset,
int length,
View[] views)
Replaces child views with new child views.
This creates ChildState objects for all the new views and adds layout
requests for them to the layout queue.
- replace in interface View
offset
- the offset at which to remove/insertlength
- the number of child views to removeviews
- the new child views to insert
setBottomInset
public void setBottomInset(float bottom)
Sets the bottom inset.
bottom
- the bottom inset
setEstimatedMajorSpan
protected void setEstimatedMajorSpan(boolean estimated)
Sets the estimatedMajorSpan
property that determines if
the major span should be treated as beeing estimated.
estimated
- if the major span should be treated as estimated or not
setLeftInset
public void setLeftInset(float left)
Sets the left inset.
setParent
public void setParent(View parent)
Sets the parent for this view. This calls loadChildren if
parent
is not null
and there have not been any
child views initializes.
- setParent in interface View
parent
- the new parent view; null
if this view is
removed from the view hierarchy
setRightInset
public void setRightInset(float right)
Sets the right inset.
setSize
public void setSize(float width,
float height)
Sets the size of this view. This is ususally called before
paint(Graphics,Shape)
is called to make sure the view has a valid layout.
This implementation queues layout requests for every child view if the
minor axis span has changed. (The major axis span is requested to never
change for this view).
- setSize in interface View
width
- the width of the viewheight
- the height of the view
setTopInset
public void setTopInset(float top)
Sets the top inset.
viewToModel
public int viewToModel(float x,
float y,
Shape a,
Position.Bias[] b)
Maps view coordinates to a model location.
- viewToModel in interface View
x
- the x coordinate (relative to a
)y
- the y coordinate (relative to a
)b
- holds the bias of the model location on method exit
- the model location for the specified view location
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.