Class BoxView
- All Implemented Interfaces:
SwingConstants
- Direct Known Subclasses:
BlockView
,FlowView
,TableView
,TableView.TableCell
,TableView.TableRow
,WrappedPlainView
,ZoneView
Layout for each axis is handled separately by the methods
layoutMajorAxis
and layoutMinorAxis
.
Subclasses can change the layout algorithm by
reimplementing these methods. These methods will be called
as necessary depending upon whether or not there is cached
layout information and the cache is considered
valid. These methods are typically called if the given size
along the axis changes, or if layoutChanged
is
called to force an updated layout. The layoutChanged
method invalidates cached layout information, if there is any.
The requirements published to the parent view are calculated by
the methods calculateMajorAxisRequirements
and calculateMinorAxisRequirements
.
If the layout algorithm is changed, these methods will
likely need to be reimplemented.
-
Field Summary
Fields declared in class javax.swing.text.View
BadBreakWeight, ExcellentBreakWeight, ForcedBreakWeight, GoodBreakWeight, X_AXIS, Y_AXIS
Fields declared in 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
baselineLayout
(int targetSpan, int axis, int[] offsets, int[] spans) Computes the location and extent of each child view in thisBoxView
given thetargetSpan
, which is the width (or height) of the region we have to work with.protected SizeRequirements
baselineRequirements
(int axis, SizeRequirements r) Calculates the size requirements for thisBoxView
by examining the size of each child view.protected SizeRequirements
calculateMajorAxisRequirements
(int axis, SizeRequirements r) Calculates the size requirements for the major axisaxis
.protected SizeRequirements
calculateMinorAxisRequirements
(int axis, SizeRequirements r) Calculates the size requirements for the minor axisaxis
.protected void
childAllocation
(int index, Rectangle alloc) Allocates a region for a child view.protected boolean
flipEastAndWestAtEnds
(int position, Position.Bias bias) Determines in which direction the next view lays.protected void
Forwards the givenDocumentEvent
to the child views that need to be notified of the change to the model.float
getAlignment
(int axis) Determines the desired alignment for this view along an axis.int
getAxis()
Fetches the tile axis property.getChildAllocation
(int index, Shape a) Fetches the allocation for the given child view.int
Returns the current height of the box.float
getMaximumSpan
(int axis) Determines the maximum span for this view along an axis.float
getMinimumSpan
(int axis) Determines the minimum span for this view along an axis.protected int
getOffset
(int axis, int childIndex) Fetches the offset of a particular child's current layout.float
getPreferredSpan
(int axis) Determines the preferred span for this view along an axis.int
getResizeWeight
(int axis) Gets the resize weight.protected int
getSpan
(int axis, int childIndex) Fetches the span of a particular child's current layout.protected View
getViewAtPoint
(int x, int y, Rectangle alloc) Fetches the child view at the given coordinates.int
getWidth()
Returns the current width of the box.protected boolean
Determines if a point falls after an allocated region.protected boolean
Are the allocations for the children still valid?protected boolean
Determines if a point falls before an allocated region.protected boolean
isLayoutValid
(int axis) Determines if the layout is valid along the given axis.protected void
layout
(int width, int height) Perform layout on the boxvoid
layoutChanged
(int axis) Invalidates the layout along an axis.protected void
layoutMajorAxis
(int targetSpan, int axis, int[] offsets, int[] spans) Performs layout for the major axis of the box (i.e. the axis that it represents).protected void
layoutMinorAxis
(int targetSpan, int axis, int[] offsets, int[] spans) Performs layout for the minor axis of the box (i.e. the axis orthogonal to the axis that it represents).modelToView
(int pos, Shape a, Position.Bias b) Provides a mapping from the document model coordinate space to the coordinate space of the view mapped to it.void
Renders theBoxView
using the given rendering surface and area on that surface.protected void
paintChild
(Graphics g, Rectangle alloc, int index) Paints a child.void
preferenceChanged
(View child, boolean width, boolean height) This is called by a child to indicate its preferred span has changed.void
Invalidates the layout and resizes the cache of requests/allocations.void
setAxis
(int axis) Sets the tile axis property.void
setSize
(float width, float height) Sets the size of the view.int
viewToModel
(float x, float y, Shape a, Position.Bias[] bias) Provides a mapping from the view coordinate space to the logical coordinate space of the model.Methods declared in class javax.swing.text.CompositeView
getBottomInset, getInsideAllocation, getLeftInset, getNextEastWestVisualPositionFrom, getNextNorthSouthVisualPositionFrom, getNextVisualPositionFrom, getRightInset, getTopInset, getView, getViewAtPosition, getViewCount, getViewIndex, getViewIndexAtPosition, loadChildren, modelToView, setInsets, setParagraphInsets, setParent
Methods declared in class javax.swing.text.View
append, breakView, changedUpdate, createFragment, forwardUpdateToView, getAttributes, getBreakWeight, getContainer,