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.
| Modifier and Type | Field and Description |
|---|---|
| pack-priv boolean | |
| pack-priv int | |
| pack-priv int[] | |
| pack-priv SizeRequirements | |
| pack-priv boolean | |
| pack-priv int | |
| pack-priv int[] | |
| pack-priv boolean | |
| pack-priv int[] | |
| pack-priv SizeRequirements | |
| pack-priv boolean | |
| pack-priv int | |
| pack-priv int[] | |
| pack-priv Rectangle | tempRect
used in paint. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| protected void | baselineLayout(int
the total span given to the view, which
would be used to layout the children targetSpan, int the axis being studied, either
axis, int[] View.X_AXIS or View.Y_AXISan empty array filled by this method with
values specifying the location of each child view offsets, int[] an empty array filled by this method with
values specifying the extent of each child view spans)Computes the location and extent of each child view
in this |
| protected SizeRequirements | Returns: the newly initializedSizeRequirements objectthe axis being studied axis, SizeRequirements the r)SizeRequirements object;
if null one will be createdCalculates the size requirements for this |
| protected SizeRequirements | Returns: the newly initializedSizeRequirements objectthe axis being studied axis, SizeRequirements the r)SizeRequirements object;
if null one will be createdCalculates the size requirements for the major axis
|
| protected SizeRequirements | Returns: the newly initializedSizeRequirements objectthe axis being studied axis, SizeRequirements the r)SizeRequirements object;
if null one will be createdCalculates the size requirements for the minor axis
|
| pack-priv void | |
| protected void | childAllocation(int
the index of the child view to
allocate, >= 0 && < getViewCount() index, Rectangle the allocated region alloc)Implements abstract javax. Allocates a region for a child view. |
| protected boolean | Returns: true if theViews surrounding the
View responding for rendering
position and bias
are laid out in descending order; otherwise falseposition into the model position, Position.either biasPosition.Bias.Forward or
Position.Bias.BackwardOverrides javax. Determines in which direction the next view lays. |
| protected void | forwardUpdate(DocumentEvent.
changes to the element this view is responsible
for (may be ec,null if there were no changes)the change information from the associated document e, Shape the current allocation of the view a, ViewFactory the factory to use to rebuild if the view has children f)Overrides javax. Forwards the given |
| public float | Returns: the desired alignment >= 0.0f && <= 1.0f; this should be a value between 0.0 and 1.0 where 0 indicates alignment at the origin and 1.0 indicates alignment to the full span away from the origin; an alignment of 0.5 would be the center of the viewmay be either axis)View.X_AXIS
or View.Y_AXISOverrides javax. Determines the desired alignment for this view along an axis. |
| public int | Returns: the major axis of the box, eitherView.X_AXIS or View.Y_AXISFetches the tile axis property. |
| public Shape | Returns: the allocation to the child; ornull
if a is null;
or null if the layout is invalidthe index of the child, >= 0 && > getViewCount() index, Shape the allocation to this view a)Overrides javax. Fetches the allocation for the given child view. |
| public int | |
| public float | Returns: the span the view would like to be rendered into >= 0; typically the view is told to render into the span that is returned, although there is no guarantee; the parent may choose to resize or break the viewmay be either axis)View.X_AXIS
or View.Y_AXISOverrides javax. Determines the maximum span for this view along an axis. |
| public float | Returns: the span the view would like to be rendered into >= 0; typically the view is told to render into the span that is returned, although there is no guarantee; the parent may choose to resize or break the viewmay be either axis)View.X_AXIS
or View.Y_AXISOverrides javax. Determines the minimum span for this view along an axis. |
| protected int | Returns: the offset (location) for the specified childthe axis being studied axis, int the index of the requested child childIndex)Fetches the offset of a particular child's current layout. |
| public float | Returns: the span the view would like to be rendered into >= 0; typically the view is told to render into the span that is returned, although there is no guarantee; the parent may choose to resize or break the viewmay be either axis)View.X_AXIS
or View.Y_AXISImplements abstract javax. Determines the preferred span for this view along an axis. |
| public int | Returns: the weightmay be either axis)View.X_AXIS or
View.Y_AXISOverrides javax. Gets the resize weight. |
| protected int | Returns: the span (width or height) of the specified childthe axis being studied axis, int the index of the requested child childIndex)Fetches the span of a particular child's current layout. |
| pack-priv float | Returns: the current span of the view along the given axis, >= 0may be either axis)View.X_AXIS or
View.Y_AXISReturns the size of the view along an axis. |
| protected View | Returns: the viewthe X coordinate >= 0 x, int the Y coordinate >= 0 y, Rectangle the parents inner allocation on entry, which should
be changed to the child's allocation on exit alloc)Implements abstract javax. Fetches the child view at the given coordinates. |
| public int | |
| protected boolean | Returns: true if the point lies after the region else falsethe X coordinate >= 0 x, int the Y coordinate >= 0 y, Rectangle the allocated region; this is the area
inside of the insets innerAlloc)Implements abstract javax. Determines if a point falls after an allocated region. |
| protected boolean | Returns: true if allocations still validAre the allocations for the children still valid? |
| protected boolean | Returns: true if the point lies before the region else falsethe X coordinate >= 0 x, int the Y coordinate >= 0 y, Rectangle the allocated region; this is the area
inside of the insets innerAlloc)Implements abstract javax. Determines if a point falls before an allocated region. |
| protected boolean | Returns: true if the layout is valid along the given axis,
otherwise falseeither axis)View.X_AXIS or View.Y_AXISDetermines if the layout is valid along the given axis. |
| protected void | layout(int
the width (inside of the insets) >= 0 width, int the height (inside of the insets) >= 0 height)Perform layout on the box |
| public void | |
| protected void | layoutMajorAxis(int
the total span given to the view, which
would be used to layout the children targetSpan, int the axis being laid out axis, int[] the offsets from the origin of the view for
each of the child views; this is a return value and is
filled in by the implementation of this method offsets, int[] the span of each child view; this is a return
value and is filled in by the implementation of this method spans)Performs layout for the major axis of the box (i.e. the axis that it represents). |
| protected void | layoutMinorAxis(int
the total span given to the view, which
would be used to layout the children targetSpan, int the axis being laid out axis, int[] the offsets from the origin of the view for
each of the child views; this is a return value and is
filled in by the implementation of this method offsets, int[] the span of each child view; this is a return
value and is filled in by the implementation of this method spans)Performs layout for the minor axis of the box (i.e. the axis orthogonal to the axis that it represents). |
| public Shape | Returns: the bounding box of the given positionthe position to convert >= 0 pos, Shape the allocated region to render into a, Position.Overrides javax. Provides a mapping from the document model coordinate space to the coordinate space of the view mapped to it. |
| public void | paint(Graphics
the rendering surface to use g, Shape the allocated region to render into allocation)Implements abstract javax. Renders the |
| protected void | paintChild(Graphics
the graphics context g, Rectangle the allocated region to paint into alloc, int the child index, >= 0 && < getViewCount() index)Paints a child. |
| public void | preferenceChanged(View
the child view child, boolean true if the width preference should change width, boolean true if the height preference should change height)Overrides javax. This is called by a child to indicate its preferred span has changed. |
| public void | replace(int
the starting index into the child views to insert
the new views; this should be a value >= 0 and <= getViewCount index, int the number of existing child views to remove;
This should be a value >= 0 and <= (getViewCount() - offset) length, View[] the child views to add; this value can be
elems)nullto indicate no children are being added
(useful to remove)Overrides javax. Invalidates the layout and resizes the cache of requests/allocations. |
| public void | |
| public void | setSize(float
the width >= 0 width, float the height >= 0 height)Overrides javax. Sets the size of the view. |
| pack-priv void | setSpanOnAxis(int
may be either axis, float View.X_AXIS or
View.Y_AXISthe span to layout to >= 0 span)Sets the size of the view along an axis. |
| pack-priv void | |
| pack-priv int[] | Returns: the new layout arraythe original layout array oldArray, int location where new views will be inserted offset, int the number of child views being inserted;
therefore the number of blank spaces to leave in the
new array at location nInserted)offsetResizes the given layout array to match the new number of child views. |
| public int | Returns: the location within the model that best represents the given point in the view >= 0x coordinate of the view location to convert >= 0 x, float y coordinate of the view location to convert >= 0 y, Shape the allocated region to render into a, Position.Overrides javax. Provides a mapping from the view coordinate space to the logical coordinate space of the model. |
| majorAllocValid | back to summary |
|---|---|
| pack-priv boolean majorAllocValid | |
| majorAxis | back to summary |
|---|---|
| pack-priv int majorAxis | |
| majorOffsets | back to summary |
|---|---|
| pack-priv int[] majorOffsets | |
| majorRequest | back to summary |
|---|---|
| pack-priv SizeRequirements majorRequest | |
| majorReqValid | back to summary |
|---|---|
| pack-priv boolean majorReqValid | |
| majorSpan | back to summary |
|---|---|
| pack-priv int majorSpan | |
| majorSpans | back to summary |
|---|---|
| pack-priv int[] majorSpans | |
| minorAllocValid | back to summary |
|---|---|
| pack-priv boolean minorAllocValid | |
| minorOffsets | back to summary |
|---|---|
| pack-priv int[] minorOffsets | |
| minorRequest | back to summary |
|---|---|
| pack-priv SizeRequirements minorRequest | |
| minorReqValid | back to summary |
|---|---|
| pack-priv boolean minorReqValid | |
| minorSpan | back to summary |
|---|---|
| pack-priv int minorSpan | |
| minorSpans | back to summary |
|---|---|
| pack-priv int[] minorSpans | |
| tempRect | back to summary |
|---|---|
| pack-priv Rectangle tempRect used in paint. | |
| BoxView | back to summary |
|---|---|
| public BoxView(Element elem, int axis) Constructs a
| |
| baselineLayout | back to summary |
|---|---|
| protected void baselineLayout(int targetSpan, int axis, int[] offsets, int[] spans) Computes the location and extent of each child view
in this
| |
| baselineRequirements | back to summary |
|---|---|
| protected SizeRequirements baselineRequirements(int axis, SizeRequirements r) Calculates the size requirements for this
| |
| calculateMajorAxisRequirements | back to summary |
|---|---|
| protected SizeRequirements calculateMajorAxisRequirements(int axis, SizeRequirements r) Calculates the size requirements for the major axis
| |
| calculateMinorAxisRequirements | back to summary |
|---|---|
| protected SizeRequirements calculateMinorAxisRequirements(int axis, SizeRequirements r) Calculates the size requirements for the minor axis
| |
| checkRequests | back to summary |
|---|---|
| pack-priv void checkRequests(int axis) Checks the request cache and update if needed.
| |
| childAllocation | back to summary |
|---|---|
| protected void childAllocation(int index, Rectangle alloc) Implements abstract javax. Allocates a region for a child view.
| |
| flipEastAndWestAtEnds | back to summary |
|---|---|
| protected boolean flipEastAndWestAtEnds(int position, Position. Overrides javax. Determines in which direction the next view lays.
Consider the View at index n. Typically the
If the receiver is laying its | |
| forwardUpdate | back to summary |
|---|---|
| protected void forwardUpdate(DocumentEvent. Overrides javax. Forwards the given
| |
| getAlignment | back to summary |
|---|---|
| public float getAlignment(int axis) Overrides javax. Determines the desired alignment for this view along an axis. This is implemented to give the total alignment needed to position the children with the alignment points lined up along the axis orthogonal to the axis that is being tiled. The axis being tiled will request to be centered (i.e. 0.5f).
| |
| getAxis | back to summary |
|---|---|
| public int getAxis() Fetches the tile axis property. This is the axis along which the child views are tiled.
| |
| getChildAllocation | back to summary |
|---|---|
| public Shape getChildAllocation(int index, Shape a) Overrides javax. Fetches the allocation for the given child view.
This enables finding out where various views
are located. This is implemented to return
| |
| getHeight | back to summary |
|---|---|
| public int getHeight() Returns the current height of the box. This is the height that it was last allocated.
| |
| getMaximumSpan | back to summary |
|---|---|
| public float getMaximumSpan(int axis) Overrides javax. Determines the maximum span for this view along an axis.
| |
| getMinimumSpan | back to summary |
|---|---|
| public float getMinimumSpan(int axis) Overrides javax. Determines the minimum span for this view along an axis.
| |
| getOffset | back to summary |
|---|---|
| protected int getOffset(int axis, int childIndex) Fetches the offset of a particular child's current layout.
| |
| getPreferredSpan | back to summary |
|---|---|
| public float getPreferredSpan(int axis) Implements abstract javax. Determines the preferred span for this view along an axis.
| |
| getResizeWeight | back to summary |
|---|---|
| public int getResizeWeight(int axis) Overrides javax. Gets the resize weight. A value of 0 or less is not resizable.
| |
| getSpan | back to summary |
|---|---|
| protected int getSpan(int axis, int childIndex) Fetches the span of a particular child's current layout.
| |
| getSpanOnAxis | back to summary |
|---|---|
| pack-priv float getSpanOnAxis(int axis) Returns the size of the view along an axis. This is implemented to return zero.
| |
| getViewAtPoint | back to summary |
|---|---|
| protected View getViewAtPoint(int x, int y, Rectangle alloc) Implements abstract javax. Fetches the child view at the given coordinates. | |
| getWidth | back to summary |
|---|---|
| public int getWidth() Returns the current width of the box. This is the width that it was last allocated.
| |
| isAfter | back to summary |
|---|---|
| protected boolean isAfter(int x, int y, Rectangle innerAlloc) Implements abstract javax. Determines if a point falls after an allocated region.
| |
| isAllocationValid | back to summary |
|---|---|
| protected boolean isAllocationValid() Are the allocations for the children still valid?
| |
| isBefore | back to summary |
|---|---|
| protected boolean isBefore(int x, int y, Rectangle innerAlloc) Implements abstract javax. Determines if a point falls before an allocated region.
| |
| isLayoutValid | back to summary |
|---|---|
| protected boolean isLayoutValid(int axis) Determines if the layout is valid along the given axis.
| |
| layout | back to summary |
|---|---|
| protected void layout(int width, int height) Perform layout on the box
| |
| layoutChanged | back to summary |
|---|---|
| public void layoutChanged(int axis) Invalidates the layout along an axis. This happens
automatically if the preferences have changed for
any of the child views. In some cases the layout
may need to be recalculated when the preferences
have not changed. The layout can be marked as
invalid by calling this method. The layout will
be updated the next time the
| |
| layoutMajorAxis | back to summary |
|---|---|
| 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). The results of the layout (the offset and span for each children) are placed in the given arrays which represent the allocations to the children along the major axis.
| |
| layoutMinorAxis | back to summary |
|---|---|
| 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). The results of the layout (the offset and span for each children) are placed in the given arrays which represent the allocations to the children along the minor axis.
| |
| modelToView | back to summary |
|---|---|
| public Shape modelToView(int pos, Shape a, Position. Overrides javax. Provides a mapping from the document model coordinate space to the coordinate space of the view mapped to it. This makes sure the allocation is valid before calling the superclass.
| |
| paint | back to summary |
|---|---|
| public void paint(Graphics g, Shape allocation) Implements abstract javax. Renders the
| |
| paintChild | back to summary |
|---|---|
| protected void paintChild(Graphics g, Rectangle alloc, int index) Paints a child. By default that is all it does, but a subclass can use this to paint things relative to the child. | |
| preferenceChanged | back to summary |
|---|---|
| public void preferenceChanged(View child, boolean width, boolean height) Overrides javax. This is called by a child to indicate its preferred span has changed. This is implemented to throw away cached layout information so that new calculations will be done the next time the children need an allocation.
| |
| replace | back to summary |
|---|---|
| public void replace(int index, int length, View[] elems) Overrides javax. Invalidates the layout and resizes the cache of requests/allocations. The child allocations can still be accessed for the old layout, but the new children will have an offset and span of 0.
| |
| setAxis | back to summary |
|---|---|
| public void setAxis(int axis) Sets the tile axis property. This is the axis along which the child views are tiled.
| |
| setSize | back to summary |
|---|---|
| public void setSize(float width, float height) Overrides javax. Sets the size of the view. This should cause layout of the view if the view caches any layout information. This is implemented to call the layout method with the sizes inside of the insets.
| |
| setSpanOnAxis | back to summary |
|---|---|
| pack-priv void setSpanOnAxis(int axis, float span) Sets the size of the view along an axis. This should cause layout of the view along the given axis.
| |
| updateChildSizes | back to summary |
|---|---|
| pack-priv void updateChildSizes() Propagates the current allocations to the child views. | |
| updateLayoutArray | back to summary |
|---|---|
| pack-priv int[] updateLayoutArray(int[] oldArray, int offset, int nInserted) Resizes the given layout array to match the new number of child views. The current number of child views are used to produce the new array. The contents of the old array are inserted into the new array at the appropriate places so that the old layout information is transferred to the new array.
| |
| viewToModel | back to summary |
|---|---|
| public int viewToModel(float x, float y, Shape a, Position. Overrides javax. Provides a mapping from the view coordinate space to the logical coordinate space of the model.
| |