CompositeView is an abstract View
implementation which manages one or more child views.
(Note that CompositeView is intended
for managing relatively small numbers of child views.)
CompositeView is intended to be used as
a starting point for View implementations,
such as BoxView, that will contain child
Views. Subclasses that wish to manage the
collection of child Views should use the
replace method. As View invokes
replace during DocumentListener
notification, you normally won't need to directly
invoke replace.
While CompositeView
does not impose a layout policy on its child Views,
it does allow for insetting the child Views
it will contain. The insets can be set by either
setInsets or setParagraphInsets.
In addition to the abstract methods of
javax.,
subclasses of CompositeView will need to
override:
isBefore - Used to test if a given
View location is before the visual space
of the CompositeView.
isAfter - Used to test if a given
View location is after the visual space
of the CompositeView.
getViewAtPoint - Returns the view at
a given visual location.
childAllocation - Returns the bounds of
a particular child View.
getChildAllocation will invoke
childAllocation after offsetting
the bounds by the Insets of the
CompositeView.
| Modifier and Type | Field and Description |
|---|---|
| private short | |
| private Rectangle | |
| private View[] | |
| private short | |
| private int | |
| private short | |
| private short | |
| private static View[] |
| Access | Constructor and Description |
|---|---|
| public | CompositeView(Element
the element this view is responsible for elem)Constructs a |
| Modifier and Type | Method and Description |
|---|---|
| protected abstract void | childAllocation(int
the index of the child, >= 0 && < getViewCount() index, Rectangle the allocation to the interior of the box on entry,
and the allocation of the child view at the index on exit. a)Returns the allocation for a given child. |
| protected boolean | Returns: falseposition into the model position, Position.either biasPosition.Bias.Forward or
Position.Bias.BackwardDetermines in which direction the next view lays. |
| protected short | |
| public Shape | Returns: the allocation to the childthe index of the child, >= 0 && < getViewCount() index, Shape the allocation to this view a)Overrides javax. Fetches the allocation for the given child view to render into. |
| protected Rectangle | Returns: the allocation that represents the inside of the view after the margins have all been removed; if the given allocation wasnull,
the return value is nullthe allocation given to the view a)Translates the immutable allocation given to the view to a mutable allocation that represents the interior allocation (i.e. the bounds of the given allocation with the top, left, bottom, and right insets removed. |
| protected short | |
| protected int | Returns: the location within the model that best represents the next west or east locationthe position to convert >= 0 pos, Position.a bias value of either b,Position.Bias.Forward
or Position.Bias.Backwardthe allocated region to render into a, int the direction from the current position that can
be thought of as the arrow keys typically found on a keyboard;
this may be one of the following:
direction, Position.
an array containing the bias that was checked biasRetReturns the next visual position for the cursor, in either the east or west direction. |
| protected int | Returns: the location within the model that best represents the next north or south locationthe position to convert >= 0 pos, Position.a bias value of either b,Position.Bias.Forward
or Position.Bias.Backwardthe allocated region to render into a, int the direction from the current position that can
be thought of as the arrow keys typically found on a keyboard;
this may be one of the following:
direction, Position.
an array containing the bias that was checked biasRetReturns the next visual position for the cursor, in either the north or south direction. |
| public int | Returns: the location within the model that best represents the next location visual positionthe position to convert pos, Position.a bias value of either b,Position.Bias.Forward
or Position.Bias.Backwardthe allocated region to render into a, int the direction from the current position that can
be thought of as the arrow keys typically found on a keyboard;
this may be one of the following:
direction, Position.
an array containing the bias that was checked biasRetOverrides javax. Provides a way to determine the next visually represented model location that one might place a caret. |
| protected short | |
| protected short | |
| public View | Returns: the view at indexnthe number of the desired view, >= 0 && < getViewCount() n)Overrides javax. Returns the n-th view in this container. |
| protected abstract View | Returns: the child viewthe X coordinate >= 0 x, int the Y coordinate >= 0 y, Rectangle the parent's allocation on entry, which should
be changed to the child's allocation on exit alloc)Fetches the child view at the given coordinates. |
| protected View | Returns: the view representing the given position, ornull if there isn't onethe position >= 0 pos, Rectangle the allocation to the interior of the box on entry,
and the allocation of the view containing the position on exit a)Fetches the child view that represents the given position in the model. |
| public int | Returns: the number of views >= 0Overrides javax. Returns the number of child views of this view. |
| public int | Returns: index of the view representing the given position, or -1 if no view represents that positionthe position >= 0 pos, Position.Overrides javax. Returns the child view index representing the given position in the model. |
| protected int | Returns: index of the view representing the given position, or -1 if no view represents that positionthe position >= 0 pos)Fetches the child view index representing the given position in the model. |
| protected abstract boolean | |
| protected abstract boolean | |
| protected void | |
| public Shape | Returns: the bounding box of the given positionthe position to convert >= 0 pos, Shape the allocated region to render into a, Position.a bias value of either bPosition.Bias.Forward
or Position.Bias.BackwardImplements abstract javax. Provides a mapping from the document model coordinate space to the coordinate space of the view mapped to it. |
| public Shape | Returns: the bounding box of the given position is returnedthe position to convert >= 0 p0, Position.the bias toward the previous character or the
next character represented by p0, in case the
position is a boundary of two views; either
b0,Position.Bias.Forward or
Position.Bias.Backwardthe position to convert >= 0 p1, Position.the bias toward the previous character or the
next character represented by p1, in case the
position is a boundary of two views b1,the allocated region to render into a)Overrides javax. Provides a mapping from the document model coordinate space to the coordinate space of the view mapped to it. |
| public void | replace(int
the starting index into the child views to insert
the new views; >= 0 and <= getViewCount offset, 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
views)null
to indicate no children are being added (useful to remove)Overrides javax. Replaces child views. |
| protected void | setInsets(short
the top inset >= 0 top, short the left inset >= 0 left, short the bottom inset >= 0 bottom, short the right inset >= 0 right)Sets the insets for the view. |
| protected void | setParagraphInsets(AttributeSet
the attributes attr)Sets the insets from the paragraph attributes specified in the given attributes. |
| public void | setParent(View
the parent of the view, parent)null if noneOverrides javax. Sets the parent of the view. |
| 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.either biasPosition.Bias.Forward or
Position.Bias.BackwardImplements abstract javax. Provides a mapping from the view coordinate space to the logical coordinate space of the model. |
| bottom | back to summary |
|---|---|
| private short bottom | |
| childAlloc | back to summary |
|---|---|
| private Rectangle childAlloc | |
| children | back to summary |
|---|---|
| private View[] children | |
| left | back to summary |
|---|---|
| private short left | |
| nchildren | back to summary |
|---|---|
| private int nchildren | |
| right | back to summary |
|---|---|
| private short right | |
| top | back to summary |
|---|---|
| private short top | |
| ZERO | back to summary |
|---|---|
| private static View[] ZERO | |
| CompositeView | back to summary |
|---|---|
| public CompositeView(Element elem) Constructs a
| |
| childAllocation | back to summary |
|---|---|
| protected abstract void childAllocation(int index, Rectangle a) Returns the allocation for a given child.
| |
| flipEastAndWestAtEnds | back to summary |
|---|---|
| protected boolean flipEastAndWestAtEnds(int position, Position. Determines in which direction the next view lays.
Consider the
This unconditionally returns false, subclasses should override this
method if there is the possibility for laying | |
| getBottomInset | back to summary |
|---|---|
| protected short getBottomInset() Gets the bottom inset.
| |
| getChildAllocation | back to summary |
|---|---|
| public Shape getChildAllocation(int index, Shape a) Overrides javax. Fetches the allocation for the given child view to render into. This enables finding out where various views are located. | |
| getInsideAllocation | back to summary |
|---|---|
| protected Rectangle getInsideAllocation(Shape a) Translates the immutable allocation given to the view
to a mutable allocation that represents the interior
allocation (i.e. the bounds of the given allocation
with the top, left, bottom, and right insets removed.
It is expected that the returned value would be further
mutated to represent an allocation to a child view.
This is implemented to reuse an instance variable so
it avoids creating excessive Rectangles. Typically
the result of calling this method would be fed to
the | |
| getLeftInset | back to summary |
|---|---|
| protected short getLeftInset() Gets the left inset.
| |
| getNextEastWestVisualPositionFrom | back to summary |
|---|---|
| protected int getNextEastWestVisualPositionFrom(int pos, Position. Returns the next visual position for the cursor, in either the east or west direction.
| |
| getNextNorthSouthVisualPositionFrom | back to summary |
|---|---|
| protected int getNextNorthSouthVisualPositionFrom(int pos, Position. Returns the next visual position for the cursor, in either the north or south direction.
| |
| getNextVisualPositionFrom | back to summary |
|---|---|
| public int getNextVisualPositionFrom(int pos, Position. Overrides javax. Provides a way to determine the next visually represented model
location that one might place a caret. Some views may not be visible,
they might not be in the same order found in the model, or they just
might not allow access to some of the locations in the model.
This is a convenience method for
| |
| getRightInset | back to summary |
|---|---|
| protected short getRightInset() Gets the right inset.
| |
| getTopInset | back to summary |
|---|---|
| protected short getTopInset() Gets the top inset.
| |
| getView | back to summary |
|---|---|
| public View getView(int n) Overrides javax. Returns the n-th view in this container.
| |
| getViewAtPoint | back to summary |
|---|---|
| protected abstract View getViewAtPoint(int x, int y, Rectangle alloc) Fetches the child view at the given coordinates. | |
| getViewAtPosition | back to summary |
|---|---|
| protected View getViewAtPosition(int pos, Rectangle a) Fetches the child view that represents the given position in the model. This is implemented to fetch the view in the case where there is a child view for each child element. | |
| getViewCount | back to summary |
|---|---|
| public int getViewCount() Overrides javax. Returns the number of child views of this view.
| |
| getViewIndex | back to summary |
|---|---|
| public int getViewIndex(int pos, Position. Overrides javax. Returns the child view index representing the given
position in the model. This is implemented to call the
| |
| getViewIndexAtPosition | back to summary |
|---|---|
| protected int getViewIndexAtPosition(int pos) Fetches the child view index representing the given position in the model. This is implemented to fetch the view in the case where there is a child view for each child element.
| |
| isAfter | back to summary |
|---|---|
| protected abstract boolean isAfter(int x, int y, Rectangle alloc) Tests whether a point lies after the rectangle range.
| |
| isBefore | back to summary |
|---|---|
| protected abstract boolean isBefore(int x, int y, Rectangle alloc) Tests whether a point lies before the rectangle range.
| |
| loadChildren | back to summary |
|---|---|
| protected void loadChildren(ViewFactory f) Loads all of the children to initialize the view.
This is called by the
| |
| modelToView | back to summary |
|---|---|
| public Shape modelToView(int pos, Shape a, Position. Implements abstract javax. Provides a mapping from the document model coordinate space to the coordinate space of the view mapped to it.
| |
| modelToView | back to summary |
|---|---|
| public Shape modelToView(int p0, Position. Overrides javax. Provides a mapping from the document model coordinate space to the coordinate space of the view mapped to it.
| |
| replace | back to summary |
|---|---|
| public void replace(int offset, int length, View[] views) Overrides javax. Replaces child views. If there are no views to remove
this acts as an insert. If there are no views to
add this acts as a remove. Views being removed will
have the parent set to
| |
| setInsets | back to summary |
|---|---|
| protected void setInsets(short top, short left, short bottom, short right) Sets the insets for the view.
| |
| setParagraphInsets | back to summary |
|---|---|
| protected void setParagraphInsets(AttributeSet attr) Sets the insets from the paragraph attributes specified in the given attributes.
| |
| setParent | back to summary |
|---|---|
| public void setParent(View parent) Overrides javax. Sets the parent of the view.
This is reimplemented to provide the superclass
behavior as well as calling the
| |
| viewToModel | back to summary |
|---|---|
| public int viewToModel(float x, float y, Shape a, Position. Implements abstract javax. Provides a mapping from the view coordinate space to the logical coordinate space of the model.
| |