javax.swing.text
public abstract class FlowView extends BoxView
View
that can flows it's children into it's layout space.
The FlowView
manages a set of logical views (that are
the children of the layoutPool
field). These are translated
at layout time into a set of physical views. These are the views that
are managed as the real child views. Each of these child views represents
a row and are laid out within a box using the superclasses behaviour.
The concrete implementation of the rows must be provided by subclasses.Modifier and Type | Class and Description |
---|---|
static class |
FlowView.FlowStrategy
A strategy for translating the logical views of a
FlowView
into the real views. |
Modifier and Type | Field and Description |
---|---|
protected View |
layoutPool
Represents the logical child elements of this view, encapsulated within
one parent view (an instance of a package private
LogicalView
class). |
protected int |
layoutSpan
The span of the
FlowView that should be flowed. |
protected FlowView.FlowStrategy |
strategy
The
FlowStrategy to use for translating between the
logical and physical view. |
BadBreakWeight, ExcellentBreakWeight, ForcedBreakWeight, GoodBreakWeight, X_AXIS, Y_AXIS
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
Constructor and Description |
---|
FlowView(Element element,
int axis)
Creates a new
FlowView for the given
Element and axis . |
Modifier and Type | Method and Description |
---|---|
protected SizeRequirements |
calculateMinorAxisRequirements(int axis,
SizeRequirements r)
Calculates the size requirements of this
BoxView along
its minor axis, that is the axis opposite to the axis specified in the
constructor. |
void |
changedUpdate(DocumentEvent changes,
Shape a,
ViewFactory vf)
Receice notification that some attributes changed in the region
that this view is responsible for.
|
protected abstract View |
createRow()
Creates a new view that represents a row within a flow.
|
int |
getFlowAxis()
Returns the axis along which the view should be flowed.
|
int |
getFlowSpan(int index)
Returns the span of the flow for the specified child view.
|
int |
getFlowStart(int index)
Returns the location along the flow axis where the flow span starts
given a child view index.
|
protected int |
getViewIndexAtPosition(int pos)
Returns the index of the child
View for the given model
position. |
void |
insertUpdate(DocumentEvent changes,
Shape a,
ViewFactory vf)
Receice notification that some content has been inserted in the region
that this view is responsible for.
|
protected void |
layout(int width,
int height)
Performs the layout of this view.
|
protected void |
loadChildren(ViewFactory vf)
Loads the children of this view.
|
void |
removeUpdate(DocumentEvent changes,
Shape a,
ViewFactory vf)
Receice notification that some content has been removed from the region
that this view is responsible for.
|
baselineLayout, baselineRequirements, calculateMajorAxisRequirements, childAllocation, flipEastAndWestAtEnds, forwardUpdate, getAlignment, getAxis, getChildAllocation, getHeight, getMaximumSpan, getMinimumSpan, getOffset, getPreferredSpan, getResizeWeight, getSpan, getViewAtPoint, getWidth, isAfter, isAllocationValid, isBefore, isLayoutValid, layoutChanged, layoutMajorAxis, layoutMinorAxis, modelToView, paint, paintChild, preferenceChanged, replace, setAxis, setSize, viewToModel
getBottomInset, getInsideAllocation, getLeftInset, getNextEastWestVisualPositionFrom, getNextNorthSouthVisualPositionFrom, getNextVisualPositionFrom, getRightInset, getTopInset, getView, getViewAtPosition, getViewCount, getViewIndex, modelToView, setInsets, setParagraphInsets, setParent
append, breakView, createFragment, dump, forwardUpdateToView, getAttributes, getBreakWeight, getContainer, getDocument, getElement, getEndOffset, getGraphics, getParent, getStartOffset, getToolTipText, getViewFactory, getViewIndex, insert, isVisible, modelToView, remove, removeAll, updateChildren, updateLayout, viewToModel
protected int layoutSpan
FlowView
that should be flowed.protected View layoutPool
LogicalView
class). These will be translated to a set of real views that are then
displayed on screen. This translation is performed by the inner class
FlowView.FlowStrategy
.protected FlowView.FlowStrategy strategy
FlowStrategy
to use for translating between the
logical and physical view.public int getFlowAxis()
public int getFlowSpan(int index)
index
- the index of the child for which to return the spanpublic int getFlowStart(int index)
index
- the index of the child for which to return the flow locationprotected abstract View createRow()
protected void loadChildren(ViewFactory vf)
FlowView
does not
directly load its children. Instead it creates a logical view
(layoutPool
) which is filled by the logical child views.
The real children are created at layout time and each represent one
row.
This method is called by View.setParent(javax.swing.text.View)
in order to initialize
the view.loadChildren
in class CompositeView
vf
- the view factory to use for creating the child viewsCompositeView.setParent(javax.swing.text.View)
protected void layout(int width, int height)
FlowView.FlowStrategy.layout(javax.swing.text.FlowView)
in order to rebuild the
rows of this view. Then the superclass's behaviour is called to arrange
the rows within the box.public void insertUpdate(DocumentEvent changes, Shape a, ViewFactory vf)
FlowView.FlowStrategy.insertUpdate(javax.swing.text.FlowView, javax.swing.event.DocumentEvent, java.awt.Rectangle)
.insertUpdate
in class View
changes
- the document event describing the changesa
- the current allocation of the viewvf
- the view factory that is used for creating new child viewspublic void removeUpdate(DocumentEvent changes, Shape a, ViewFactory vf)
FlowView.FlowStrategy.removeUpdate(javax.swing.text.FlowView, javax.swing.event.DocumentEvent, java.awt.Rectangle)
.removeUpdate
in class View
changes
- the document event describing the changesa
- the current allocation of the viewvf
- the view factory that is used for creating new child viewspublic void changedUpdate(DocumentEvent changes, Shape a, ViewFactory vf)
FlowView.FlowStrategy.changedUpdate(javax.swing.text.FlowView, javax.swing.event.DocumentEvent, java.awt.Rectangle)
.changedUpdate
in class View
changes
- the document event describing the changesa
- the current allocation of the viewvf
- the view factory that is used for creating new child viewsprotected int getViewIndexAtPosition(int pos)
View
for the given model
position.
This is implemented to iterate over the children of this
view (the rows) and return the index of the first view that contains
the given position.getViewIndexAtPosition
in class CompositeView
pos
- the model position for whicht the child View
is
queriedView
for the given model
positionprotected SizeRequirements calculateMinorAxisRequirements(int axis, SizeRequirements r)
BoxView
along
its minor axis, that is the axis opposite to the axis specified in the
constructor.
This is overridden and forwards the request to the logical view.calculateMinorAxisRequirements
in class BoxView
axis
- the axis that is examinedr
- the SizeRequirements
object to hold the result,
if null
, a new one is createdBoxView
along
the specified axis