GNU Classpath (0.95) | |
Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
javax.swing.text.View
javax.swing.text.AsyncBoxView
public class AsyncBoxView
extends View
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; } }
Nested Class Summary | |
class |
|
class |
|
Field Summary | |
protected AsyncBoxView.ChildLocator |
|
Fields inherited from class javax.swing.text.View | |
BadBreakWeight , ExcellentBreakWeight , ForcedBreakWeight , GoodBreakWeight , 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 | |
|
Method Summary | |
protected AsyncBoxView.ChildState |
|
protected void |
|
float |
|
Shape |
|
protected AsyncBoxView.ChildState |
|
protected boolean |
|
protected float |
|
protected LayoutQueue |
|
float |
|
int |
|
float |
|
float |
|
int |
|
float |
|
float |
|
float |
|
View |
|
int |
|
int |
|
protected int |
|
protected void |
|
protected void |
|
protected void |
|
Shape |
|
void | |
void |
|
void | |
void |
|
protected void |
|
void |
|
void | |
void |
|
void |
|
void |
|
protected void |
|
int |
|
Methods inherited from class java.lang.Object | |
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
public AsyncBoxView(Element elem, int axis)
Creates a newAsyncBoxView
that represents the specified element and layouts its children along the specified axis.
- Parameters:
elem
- the elementaxis
- the layout axis
protected AsyncBoxView.ChildState createChildState(View v)
Creates aChildState
object for the specified view.
- Parameters:
v
- the view for which to create a child state object
- Returns:
- the created child state
protected void flushRequirementChanges()
Flushes the requirements changes upwards to the parent view. This is called from the layout thread.
public Shape getChildAllocation(int index, Shape a)
Returns the child allocation for the child view with the specifiedindex
.
- Overrides:
- getChildAllocation in interface View
- Parameters:
index
- the index of the child viewa
- the current allocation of this view
- Returns:
- the allocation of the child view
protected AsyncBoxView.ChildState getChildState(int index)
Returns theChildState
object associated with the child view at the specifiedindex
.
- Parameters:
index
- the index of the child view for which to query the state
- Returns:
- the child state for the specified child view
protected boolean getEstimatedMajorSpan()
Determines whether the major span should be treated as estimated or as beeing accurate.
- Returns:
true
if the major span should be treated as estimated,false
if the major span should be treated as accurate
- Since:
- 1.4
protected float getInsetSpan(int axis)
Returns the span along an axis that is taken up by the insets.
- Parameters:
axis
- the axis
- Returns:
- the span along an axis that is taken up by the insets
- Since:
- 1.4
protected LayoutQueue getLayoutQueue()
Returns theLayoutQueue
used for layouting the box view. This simply returnsLayoutQueue.getDefaultQueue()
.
- Returns:
- the
LayoutQueue
used for layouting the box view
public float getMaximumSpan(int axis)
Returns the maximum span of this view along the specified axis. This is implemented to return thepreferredSpan
for the major axis (that means the box can't be resized along the major axis) andShort.MAX_VALUE
for the minor axis.
- Overrides:
- getMaximumSpan in interface View
- Parameters:
axis
- the axis
- Returns:
- the maximum span of this view along the specified axis
public float getMinimumSpan(int axis)
Returns the minimum span along the specified axis.
- Overrides:
- getMinimumSpan in interface View
public int getMinorAxis()
Returns the minor layout axis, that is the axis orthogonal to the major layout axis.
- Returns:
- the minor layout axis
public float getPreferredSpan(int axis)
Returns the preferred span of this view along the specified layout axis.
- Overrides:
- getPreferredSpan in interface View
- Returns:
- the preferred span of this view along the specified layout axis
public View getView(int index)
Returns the view at the specifiedindex
.
- Parameters:
index
- the index of the requested child view
- Returns:
- the view at the specified
index
public int getViewCount()
Returns the number of child views.
- Overrides:
- getViewCount in interface View
- Returns:
- the number of child views
public int getViewIndex(int pos, Position.Bias bias)
Returns the view index of the child view that represents the specified model position.
- Overrides:
- getViewIndex in interface View
- Parameters:
pos
- the model position for which we search the view indexbias
- the bias
- Returns:
- the view index of the child view that represents the specified model position
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.
- Parameters:
pos
- the position in the modelb
- the bias
- Returns:
- the child view index of the view that represents the specified position in the document model
protected void loadChildren(ViewFactory f)
Loads the child views of this view. This is triggered bysetParent(View)
.
- Parameters:
f
- the view factory to build child views with
protected void majorRequirementChange(AsyncBoxView.ChildState cs, float delta)
Receives notification from the child states that the requirements along the major axis have changed.
- Parameters:
cs
- the child state from which this notification is messaged
protected void minorRequirementChange(AsyncBoxView.ChildState cs)
Receives notification from the child states that the requirements along the minor axis have changed.
- Parameters:
cs
- the child state from which this notification is messaged
public Shape modelToView(int pos, Shape a, Position.Bias b) throws BadLocationException
Maps a model location to view coordinates.
- Overrides:
- modelToView in interface View
- Parameters:
pos
- the model locationa
- the current allocation of this viewb
- the bias
- Returns:
- the view allocation for the specified model location
public void paint(Graphics g, Shape s)
Paints the view. This requests theAsyncBoxView.ChildLocator
to paint the views after setting the allocation on it.
- Parameters:
g
- the graphics context to uses
- the allocation for this view
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.
- Overrides:
- preferenceChanged in interface View
- Parameters:
view
- the view that has changed its preferenceswidth
-true
if the width preference has changedheight
-true
if the height preference has changed
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.
- Parameters:
offset
- the offset at which to remove/insertlength
- the number of child views to removeviews
- the new child views to insert
public void setBottomInset(float bottom)
Sets the bottom inset.
- Parameters:
bottom
- the bottom inset
protected void setEstimatedMajorSpan(boolean estimated)
Sets theestimatedMajorSpan
property that determines if the major span should be treated as beeing estimated.
- Parameters:
estimated
- if the major span should be treated as estimated or not
- Since:
- 1.4
public void setLeftInset(float left)
Sets the left inset.
- Parameters:
left
- the left inset
public void setParent(View parent)
Sets the parent for this view. This calls loadChildren ifparent
is notnull
and there have not been any child views initializes.
- Parameters:
parent
- the new parent view;null
if this view is removed from the view hierarchy
- See Also:
View.setParent(View)
public void setRightInset(float right)
Sets the right inset.
- Parameters:
right
- the right inset
public void setSize(float width, float height)
Sets the size of this view. This is ususally called beforepaint(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).
- Parameters:
width
- the width of the viewheight
- the height of the view
protected void updateLayout(DocumentEvent.ElementChange ec, DocumentEvent e, Shape a)
Updates the layout for this view. This is implemented to triggerAsyncBoxView.ChildLocator.childChanged(AsyncBoxView.ChildState)
for the changed view, if there is any.
- Overrides:
- updateLayout in interface View
- Parameters:
ec
- the element change, may benull
if there were no changes to the element of this viewe
- the document eventa
- the current allocation of this view
public int viewToModel(float x, float y, Shape a, Position.Bias[] b)
Maps view coordinates to a model location.
- Overrides:
- viewToModel in interface View
- Parameters:
x
- the x coordinate (relative toa
)y
- the y coordinate (relative toa
)b
- holds the bias of the model location on method exit
- Returns:
- the model location for the specified view location
GNU Classpath (0.95) |