|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.swing.text.View
javax.swing.text.AsyncBoxView
public class AsyncBoxView
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; } }
Nested Class Summary | |
---|---|
class |
AsyncBoxView.ChildLocator
Manages the effective position of child views. |
class |
AsyncBoxView.ChildState
Represents the layout state of a child view. |
Field Summary | |
---|---|
protected AsyncBoxView.ChildLocator |
locator
The child locator for this view. |
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 | |
---|---|
AsyncBoxView(Element elem,
int axis)
Creates a new AsyncBoxView that represents the specified
element and layouts its children along the specified axis. |
Method Summary | |
---|---|
protected AsyncBoxView.ChildState |
createChildState(View v)
Creates a ChildState object for the specified view. |
protected void |
flushRequirementChanges()
Flushes the requirements changes upwards to the parent view. |
float |
getBottomInset()
Returns the bottom inset. |
Shape |
getChildAllocation(int index,
Shape a)
Returns the child allocation for the child view with the specified index . |
protected AsyncBoxView.ChildState |
getChildState(int index)
Returns the ChildState object associated with the child view
at the specified index . |
protected boolean |
getEstimatedMajorSpan()
Determines whether the major span should be treated as estimated or as beeing accurate. |
protected float |
getInsetSpan(int axis)
Returns the span along an axis that is taken up by the insets. |
protected LayoutQueue |
getLayoutQueue()
Returns the LayoutQueue used for layouting the box view. |
float |
getLeftInset()
Returns the left inset. |
int |
getMajorAxis()
Returns the major layout axis. |
float |
getMaximumSpan(int axis)
Returns the maximum span of this view along the specified axis. |
float |
getMinimumSpan(int axis)
Returns the minimum span along the specified axis. |
int |
getMinorAxis()
Returns the minor layout axis, that is the axis orthogonal to the major layout axis. |
float |
getPreferredSpan(int axis)
Returns the preferred span of this view along the specified layout axis. |
float |
getRightInset()
Returns the right inset. |
float |
getTopInset()
Returns the top inset. |
View |
getView(int index)
Returns the view at the specified index . |
int |
getViewCount()
Returns the number of child views. |
int |
getViewIndex(int pos,
Position.Bias 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. |
protected void |
loadChildren(ViewFactory f)
Loads the child views of this view. |
protected void |
majorRequirementChange(AsyncBoxView.ChildState cs,
float delta)
Receives notification from the child states that the requirements along the major axis have changed. |
protected void |
minorRequirementChange(AsyncBoxView.ChildState cs)
Receives notification from the child states that the requirements along the minor axis have changed. |
Shape |
modelToView(int pos,
Shape a,
Position.Bias b)
Maps a model location to view coordinates. |
void |
paint(Graphics g,
Shape s)
Paints the view. |
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. |
void |
replace(int offset,
int length,
View[] views)
Replaces child views with new child views. |
void |
setBottomInset(float bottom)
Sets the bottom inset. |
protected void |
setEstimatedMajorSpan(boolean estimated)
Sets the estimatedMajorSpan property that determines if
the major span should be treated as beeing estimated. |
void |
setLeftInset(float left)
Sets the left inset. |
void |
setParent(View parent)
Sets the parent for this view. |
void |
setRightInset(float right)
Sets the right inset. |
void |
setSize(float width,
float height)
Sets the size of this view. |
void |
setTopInset(float top)
Sets the top inset. |
protected void |
updateLayout(DocumentEvent.ElementChange ec,
DocumentEvent e,
Shape a)
Updates the layout for this view. |
int |
viewToModel(float x,
float y,
Shape a,
Position.Bias[] b)
Maps view coordinates to a model location. |
Methods inherited from class javax.swing.text.View |
---|
append, breakView, changedUpdate, createFragment, dump, forwardUpdate, forwardUpdateToView, getAlignment, getAttributes, getBreakWeight, getContainer, getDocument, getElement, getEndOffset, getGraphics, getNextVisualPositionFrom, getParent, getResizeWeight, getStartOffset, getToolTipText, getViewFactory, getViewIndex, insert, insertUpdate, isVisible, modelToView, modelToView, remove, removeAll, removeUpdate, updateChildren, viewToModel |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected AsyncBoxView.ChildLocator locator
Constructor Detail |
---|
public AsyncBoxView(Element elem, int axis)
AsyncBoxView
that represents the specified
element and layouts its children along the specified axis.
elem
- the elementaxis
- the layout axisMethod Detail |
---|
public int getMajorAxis()
public int getMinorAxis()
public View getView(int index)
index
.
getView
in class View
index
- the index of the requested child view
index
public int getViewCount()
getViewCount
in class View
public int getViewIndex(int pos, Position.Bias bias)
getViewIndex
in class View
pos
- the model position for which we search the view indexbias
- the bias
public float getTopInset()
public void setTopInset(float top)
top
- the top insetpublic float getBottomInset()
public void setBottomInset(float bottom)
bottom
- the bottom insetpublic float getLeftInset()
public void setLeftInset(float left)
left
- the left insetpublic float getRightInset()
public void setRightInset(float right)
right
- the right insetprotected void loadChildren(ViewFactory f)
setParent(View)
.
f
- the view factory to build child views withprotected float getInsetSpan(int axis)
axis
- the axis
protected void setEstimatedMajorSpan(boolean estimated)
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 notprotected boolean getEstimatedMajorSpan()
true
if the major span should be treated as
estimated, false
if the major span should be treated
as accurateprotected void minorRequirementChange(AsyncBoxView.ChildState cs)
cs
- the child state from which this notification is messagedprotected void majorRequirementChange(AsyncBoxView.ChildState cs, float delta)
cs
- the child state from which this notification is messagedpublic void setParent(View parent)
parent
is not null
and there have not been any
child views initializes.
setParent
in class View
parent
- the new parent view; null
if this view is
removed from the view hierarchyView.setParent(View)
public void setSize(float width, float height)
paint(java.awt.Graphics, java.awt.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 class View
width
- the width of the viewheight
- the height of the viewpublic void replace(int offset, int length, View[] views)
replace
in class View
offset
- the offset at which to remove/insertlength
- the number of child views to removeviews
- the new child views to insertpublic void paint(Graphics g, Shape s)
AsyncBoxView.ChildLocator
to paint the views
after setting the allocation on it.
paint
in class View
g
- the graphics context to uses
- the allocation for this viewpublic float getPreferredSpan(int axis)
getPreferredSpan
in class View
axis
- the axis
public Shape modelToView(int pos, Shape a, Position.Bias b) throws BadLocationException
modelToView
in class View
pos
- the model locationa
- the current allocation of this viewb
- the bias
BadLocationException
- if pos
is invalidpublic int viewToModel(float x, float y, Shape a, Position.Bias[] b)
viewToModel
in class 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 exita
- the allocation of this View
public Shape getChildAllocation(int index, Shape a)
index
.
getChildAllocation
in class View
index
- the index of the child viewa
- the current allocation of this view
public float getMaximumSpan(int axis)
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 class View
axis
- the axis
public float getMinimumSpan(int axis)
getMinimumSpan
in class View
axis
- the axis
public void preferenceChanged(View view, boolean width, boolean height)
preferenceChanged
in class View
view
- the view that has changed its preferenceswidth
- true
if the width preference has changedheight
- true
if the height preference has changedprotected void updateLayout(DocumentEvent.ElementChange ec, DocumentEvent e, Shape a)
AsyncBoxView.ChildLocator.childChanged(javax.swing.text.AsyncBoxView.ChildState)
for the changed view, if there is
any.
updateLayout
in class View
ec
- the element change, may be null
if there were
no changes to the element of this viewe
- the document eventa
- the current allocation of this viewprotected AsyncBoxView.ChildState getChildState(int index)
ChildState
object associated with the child view
at the specified index
.
index
- the index of the child view for which to query the state
protected LayoutQueue getLayoutQueue()
LayoutQueue
used for layouting the box view.
This simply returns LayoutQueue.getDefaultQueue()
.
LayoutQueue
used for layouting the box viewprotected int getViewIndexAtPosition(int pos, Position.Bias b)
pos
- the position in the modelb
- the bias
protected AsyncBoxView.ChildState createChildState(View v)
ChildState
object for the specified view.
v
- the view for which to create a child state object
protected void flushRequirementChanges()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |