FlowView (Java SE 15 & JDK 15) (original) (raw)
All Implemented Interfaces:
[SwingConstants](../SwingConstants.html "interface in javax.swing")
Direct Known Subclasses:
[ParagraphView](ParagraphView.html "class in javax.swing.text")
public abstract class FlowView extends BoxView
A View that tries to flow it's children into some partially constrained space. This can be used to build things like paragraphs, pages, etc. The flow is made up of the following pieces of functionality.
- A logical set of child views, which as used as a layout pool from which a physical view is formed.
- A strategy for translating the logical view to a physical (flowed) view.
- Constraints for the strategy to work against.
- A physical structure, that represents the flow. The children of this view are where the pieces of of the logical views are placed to create the flow.
Since:
1.3
See Also:
Nested Class Summary
Nested Classes
Modifier and Type | Class | Description |
---|---|---|
static class | FlowView.FlowStrategy | Strategy for maintaining the physical form of the flow. |
Field Summary
Fields
Modifier and Type | Field | Description |
---|---|---|
protected View | layoutPool | These are the views that represent the child elements of the element this view represents (The logical view to translate to a physical view). |
protected int | layoutSpan | Default constraint against which the flow is created against. |
protected FlowView.FlowStrategy | strategy | The behavior for keeping the flow updated. |
Fields declared in interface javax.swing.SwingConstants
[BOTTOM](../SwingConstants.html#BOTTOM), [CENTER](../SwingConstants.html#CENTER), [EAST](../SwingConstants.html#EAST), [HORIZONTAL](../SwingConstants.html#HORIZONTAL), [LEADING](../SwingConstants.html#LEADING), [LEFT](../SwingConstants.html#LEFT), [NEXT](../SwingConstants.html#NEXT), [NORTH](../SwingConstants.html#NORTH), [NORTH_EAST](../SwingConstants.html#NORTH%5FEAST), [NORTH_WEST](../SwingConstants.html#NORTH%5FWEST), [PREVIOUS](../SwingConstants.html#PREVIOUS), [RIGHT](../SwingConstants.html#RIGHT), [SOUTH](../SwingConstants.html#SOUTH), [SOUTH_EAST](../SwingConstants.html#SOUTH%5FEAST), [SOUTH_WEST](../SwingConstants.html#SOUTH%5FWEST), [TOP](../SwingConstants.html#TOP), [TRAILING](../SwingConstants.html#TRAILING), [VERTICAL](../SwingConstants.html#VERTICAL), [WEST](../SwingConstants.html#WEST)
Constructor Summary
Constructors
Constructor | Description |
---|---|
FlowView(Element elem, int axis) | Constructs a FlowView for the given element. |
Method Summary
Modifier and Type | Method | Description |
---|---|---|
protected SizeRequirements | calculateMinorAxisRequirements(int axis,SizeRequirements r) | Calculate requirements along the minor axis. |
void | changedUpdate(DocumentEvent changes,Shape a,ViewFactory f) | Gives notification from the document that attributes were changed in a location that this view is responsible for. |
protected abstract View | createRow() | Create a View that should be used to hold a a rows worth of children in a flow. |
int | getFlowAxis() | Fetches the axis along which views should be flowed. |
int | getFlowSpan(int index) | Fetch the constraining span to flow against for the given child index. |
int | getFlowStart(int index) | Fetch the location along the flow axis that the flow span will start at. |
protected int | getViewIndexAtPosition(int pos) | Fetches the child view index representing the given position in the model. |
void | insertUpdate(DocumentEvent changes,Shape a,ViewFactory f) | Gives notification that something was inserted into the document in a location that this view is responsible for. |
protected void | layout(int width, int height) | Lays out the children. |
protected void | loadChildren(ViewFactory f) | Loads all of the children to initialize the view. |
void | removeUpdate(DocumentEvent changes,Shape a,ViewFactory f) | Gives notification that something was removed from the document in a location that this view is responsible for. |
Methods declared in class javax.swing.text.BoxView
[baselineLayout](BoxView.html#baselineLayout%28int,int,int%5B%5D,int%5B%5D%29), [baselineRequirements](BoxView.html#baselineRequirements%28int,javax.swing.SizeRequirements%29), [calculateMajorAxisRequirements](BoxView.html#calculateMajorAxisRequirements%28int,javax.swing.SizeRequirements%29), [childAllocation](BoxView.html#childAllocation%28int,java.awt.Rectangle%29), [flipEastAndWestAtEnds](BoxView.html#flipEastAndWestAtEnds%28int,javax.swing.text.Position.Bias%29), [forwardUpdate](BoxView.html#forwardUpdate%28javax.swing.event.DocumentEvent.ElementChange,javax.swing.event.DocumentEvent,java.awt.Shape,javax.swing.text.ViewFactory%29), [getAlignment](BoxView.html#getAlignment%28int%29), [getAxis](BoxView.html#getAxis%28%29), [getChildAllocation](BoxView.html#getChildAllocation%28int,java.awt.Shape%29), [getHeight](BoxView.html#getHeight%28%29), [getMaximumSpan](BoxView.html#getMaximumSpan%28int%29), [getMinimumSpan](BoxView.html#getMinimumSpan%28int%29), [getOffset](BoxView.html#getOffset%28int,int%29), [getPreferredSpan](BoxView.html#getPreferredSpan%28int%29), [getResizeWeight](BoxView.html#getResizeWeight%28int%29), [getSpan](BoxView.html#getSpan%28int,int%29), [getViewAtPoint](BoxView.html#getViewAtPoint%28int,int,java.awt.Rectangle%29), [getWidth](BoxView.html#getWidth%28%29), [isAfter](BoxView.html#isAfter%28int,int,java.awt.Rectangle%29), [isAllocationValid](BoxView.html#isAllocationValid%28%29), [isBefore](BoxView.html#isBefore%28int,int,java.awt.Rectangle%29), [isLayoutValid](BoxView.html#isLayoutValid%28int%29), [layoutChanged](BoxView.html#layoutChanged%28int%29), [layoutMajorAxis](BoxView.html#layoutMajorAxis%28int,int,int%5B%5D,int%5B%5D%29), [layoutMinorAxis](BoxView.html#layoutMinorAxis%28int,int,int%5B%5D,int%5B%5D%29), [modelToView](BoxView.html#modelToView%28int,java.awt.Shape,javax.swing.text.Position.Bias%29), [paint](BoxView.html#paint%28java.awt.Graphics,java.awt.Shape%29), [paintChild](BoxView.html#paintChild%28java.awt.Graphics,java.awt.Rectangle,int%29), [preferenceChanged](BoxView.html#preferenceChanged%28javax.swing.text.View,boolean,boolean%29), [replace](BoxView.html#replace%28int,int,javax.swing.text.View%5B%5D%29), [setAxis](BoxView.html#setAxis%28int%29), [setSize](BoxView.html#setSize%28float,float%29), [viewToModel](BoxView.html#viewToModel%28float,float,java.awt.Shape,javax.swing.text.Position.Bias%5B%5D%29)
Methods declared in class javax.swing.text.CompositeView
[getBottomInset](CompositeView.html#getBottomInset%28%29), [getInsideAllocation](CompositeView.html#getInsideAllocation%28java.awt.Shape%29), [getLeftInset](CompositeView.html#getLeftInset%28%29), [getNextEastWestVisualPositionFrom](CompositeView.html#getNextEastWestVisualPositionFrom%28int,javax.swing.text.Position.Bias,java.awt.Shape,int,javax.swing.text.Position.Bias%5B%5D%29), [getNextNorthSouthVisualPositionFrom](CompositeView.html#getNextNorthSouthVisualPositionFrom%28int,javax.swing.text.Position.Bias,java.awt.Shape,int,javax.swing.text.Position.Bias%5B%5D%29), [getNextVisualPositionFrom](CompositeView.html#getNextVisualPositionFrom%28int,javax.swing.text.Position.Bias,java.awt.Shape,int,javax.swing.text.Position.Bias%5B%5D%29), [getRightInset](CompositeView.html#getRightInset%28%29), [getTopInset](CompositeView.html#getTopInset%28%29), [getView](CompositeView.html#getView%28int%29), [getViewAtPosition](CompositeView.html#getViewAtPosition%28int,java.awt.Rectangle%29), [getViewCount](CompositeView.html#getViewCount%28%29), [getViewIndex](CompositeView.html#getViewIndex%28int,javax.swing.text.Position.Bias%29), [modelToView](CompositeView.html#modelToView%28int,javax.swing.text.Position.Bias,int,javax.swing.text.Position.Bias,java.awt.Shape%29), [setInsets](CompositeView.html#setInsets%28short,short,short,short%29), [setParagraphInsets](CompositeView.html#setParagraphInsets%28javax.swing.text.AttributeSet%29), [setParent](CompositeView.html#setParent%28javax.swing.text.View%29)
Methods declared in class javax.swing.text.View
[append](View.html#append%28javax.swing.text.View%29), [breakView](View.html#breakView%28int,int,float,float%29), [createFragment](View.html#createFragment%28int,int%29), [forwardUpdateToView](View.html#forwardUpdateToView%28javax.swing.text.View,javax.swing.event.DocumentEvent,java.awt.Shape,javax.swing.text.ViewFactory%29), [getAttributes](View.html#getAttributes%28%29), [getBreakWeight](View.html#getBreakWeight%28int,float,float%29), [getContainer](View.html#getContainer%28%29), [getDocument](View.html#getDocument%28%29), [getElement](View.html#getElement%28%29), [getEndOffset](View.html#getEndOffset%28%29), [getGraphics](View.html#getGraphics%28%29), [getParent](View.html#getParent%28%29), [getStartOffset](View.html#getStartOffset%28%29), [getToolTipText](View.html#getToolTipText%28float,float,java.awt.Shape%29), [getViewFactory](View.html#getViewFactory%28%29), [getViewIndex](View.html#getViewIndex%28float,float,java.awt.Shape%29), [insert](View.html#insert%28int,javax.swing.text.View%29), [isVisible](View.html#isVisible%28%29), [modelToView](View.html#modelToView%28int,java.awt.Shape%29), [remove](View.html#remove%28int%29), [removeAll](View.html#removeAll%28%29), [updateChildren](View.html#updateChildren%28javax.swing.event.DocumentEvent.ElementChange,javax.swing.event.DocumentEvent,javax.swing.text.ViewFactory%29), [updateLayout](View.html#updateLayout%28javax.swing.event.DocumentEvent.ElementChange,javax.swing.event.DocumentEvent,java.awt.Shape%29), [viewToModel](View.html#viewToModel%28float,float,java.awt.Shape%29)
Methods declared in class java.lang.Object
[clone](../../../../java.base/java/lang/Object.html#clone%28%29), [equals](../../../../java.base/java/lang/Object.html#equals%28java.lang.Object%29), [finalize](../../../../java.base/java/lang/Object.html#finalize%28%29), [getClass](../../../../java.base/java/lang/Object.html#getClass%28%29), [hashCode](../../../../java.base/java/lang/Object.html#hashCode%28%29), [notify](../../../../java.base/java/lang/Object.html#notify%28%29), [notifyAll](../../../../java.base/java/lang/Object.html#notifyAll%28%29), [toString](../../../../java.base/java/lang/Object.html#toString%28%29), [wait](../../../../java.base/java/lang/Object.html#wait%28%29), [wait](../../../../java.base/java/lang/Object.html#wait%28long%29), [wait](../../../../java.base/java/lang/Object.html#wait%28long,int%29)
Field Details
layoutSpan
protected int layoutSpan
Default constraint against which the flow is created against.layoutPool
protected View layoutPool
These are the views that represent the child elements of the element this view represents (The logical view to translate to a physical view). These are not directly children of this view. These are either placed into the rows directly or used for the purpose of breaking into smaller chunks, to form the physical view.strategy
The behavior for keeping the flow updated. By default this is a singleton shared by all instances of FlowView (FlowStrategy is stateless). Subclasses can create an alternative strategy, which might keep state.
Constructor Details
FlowView
public FlowView(Element elem, int axis)
Constructs a FlowView for the given element.
Parameters:
elem
- the element that this view is responsible for
axis
- may be either View.X_AXIS or View.Y_AXISMethod Details
getFlowAxis
public int getFlowAxis()
Fetches the axis along which views should be flowed. By default, this will be the axis orthogonal to the axis along which the flow rows are tiled (the axis of the default flow rows themselves). This is typically used by theFlowStrategy
.
Returns:
the axis along which views should be flowedgetFlowSpan
public int getFlowSpan(int index)
Fetch the constraining span to flow against for the given child index. This is called by the FlowStrategy while it is updating the flow. A flow can be shaped by providing different values for the row constraints. By default, the entire span inside of the insets along the flow axis is returned.
Parameters:
index
- the index of the row being updated. This should be a value >= 0 and < getViewCount().
Returns:
the constraining span to flow against for the given child index
See Also:
getFlowStart(int)getFlowStart
public int getFlowStart(int index)
Fetch the location along the flow axis that the flow span will start at. This is called by the FlowStrategy while it is updating the flow. A flow can be shaped by providing different values for the row constraints.
Parameters:
index
- the index of the row being updated. This should be a value >= 0 and < getViewCount().
Returns:
the location along the flow axis that the flow span will start at
See Also:
getFlowSpan(int)createRow
protected abstract View createRow()
Create a View that should be used to hold a a rows worth of children in a flow. This is called by the FlowStrategy when new children are added or removed (i.e. rows are added or removed) in the process of updating the flow.
Returns:
a View that should be used to hold a a rows worth of children in a flowloadChildren
Loads all of the children to initialize the view. This is called by the
setParent
method. This is reimplemented to not load any children directly (as they are created in the process of formatting). If the layoutPool variable is null, an instance of LogicalView is created to represent the logical view that is used in the process of formatting.
Overrides:
[loadChildren](CompositeView.html#loadChildren%28javax.swing.text.ViewFactory%29)
in class[CompositeView](CompositeView.html "class in javax.swing.text")
Parameters:
f
- the view factory
See Also:
CompositeView.setParent(javax.swing.text.View)getViewIndexAtPosition
protected int getViewIndexAtPosition(int pos)
Fetches the child view index representing the given position in the model.
Overrides:
[getViewIndexAtPosition](CompositeView.html#getViewIndexAtPosition%28int%29)
in class[CompositeView](CompositeView.html "class in javax.swing.text")
Parameters:
pos
- the position >= 0
Returns:
index of the view representing the given position, or -1 if no view represents that positionlayout
protected void layout(int width, int height)
Lays out the children. If the span along the flow axis has changed, layout is marked as invalid which which will cause the superclass behavior to recalculate the layout along the box axis. The FlowStrategy.layout method will be called to rebuild the flow rows as appropriate. If the height of this view changes (determined by the preferred size along the box axis), a preferenceChanged is called. Following all of that, the normal box layout of the superclass is performed.
Overrides:
[layout](BoxView.html#layout%28int,int%29)
in class[BoxView](BoxView.html "class in javax.swing.text")
Parameters:
width
- the width to lay out against >= 0. This is the width inside of the inset area.
height
- the height to lay out against >= 0 This is the height inside of the inset area.calculateMinorAxisRequirements
Calculate requirements along the minor axis. This is implemented to forward the request to the logical view by calling getMinimumSpan, getPreferredSpan, and getMaximumSpan on it.
Overrides:
[calculateMinorAxisRequirements](BoxView.html#calculateMinorAxisRequirements%28int,javax.swing.SizeRequirements%29)
in class[BoxView](BoxView.html "class in javax.swing.text")
Parameters:
axis
- the axis being studied
r
- theSizeRequirements
object; ifnull
one will be created
Returns:
the newly initializedSizeRequirements
object
See Also:
SizeRequirementsinsertUpdate
Gives notification that something was inserted into the document in a location that this view is responsible for.
Overrides:
[insertUpdate](View.html#insertUpdate%28javax.swing.event.DocumentEvent,java.awt.Shape,javax.swing.text.ViewFactory%29)
in class[View](View.html "class in javax.swing.text")
Parameters:
changes
- the change information from the associated document
a
- the current allocation of the view
f
- the factory to use to rebuild if the view has children
See Also:
View.insertUpdate(javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory)removeUpdate
Gives notification that something was removed from the document in a location that this view is responsible for.
Overrides:
[removeUpdate](View.html#removeUpdate%28javax.swing.event.DocumentEvent,java.awt.Shape,javax.swing.text.ViewFactory%29)
in class[View](View.html "class in javax.swing.text")
Parameters:
changes
- the change information from the associated document
a
- the current allocation of the view
f
- the factory to use to rebuild if the view has children
See Also:
View.removeUpdate(javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory)changedUpdate
Gives notification from the document that attributes were changed in a location that this view is responsible for.
Overrides:
[changedUpdate](View.html#changedUpdate%28javax.swing.event.DocumentEvent,java.awt.Shape,javax.swing.text.ViewFactory%29)
in class[View](View.html "class in javax.swing.text")
Parameters:
changes
- the change information from the associated document
a
- the current allocation of the view
f
- the factory to use to rebuild if the view has children
See Also:
View.changedUpdate(javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory)