Home » openjdk-7 » javax » swing » text » [javadoc | source]
javax.swing.text
abstract public class: CompositeView [javadoc | source]
java.lang.Object
   javax.swing.text.View
      javax.swing.text.CompositeView

All Implemented Interfaces:
    SwingConstants

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 inseting the child Views it will contain. The insets can be set by either #setInsets or #setParagraphInsets .

In addition to the abstract methods of javax.swing.text.View , subclasses of CompositeView will need to override:

Fields inherited from javax.swing.text.View:
BadBreakWeight,  GoodBreakWeight,  ExcellentBreakWeight,  ForcedBreakWeight,  X_AXIS,  Y_AXIS,  sharedBiasReturn
Constructor:
 public CompositeView(Element elem) 
    Constructs a CompositeView for the given element.
    Parameters:
    elem - the element this view is responsible for
Method from javax.swing.text.CompositeView Summary:
childAllocation,   flipEastAndWestAtEnds,   getBottomInset,   getChildAllocation,   getInsideAllocation,   getLeftInset,   getNextEastWestVisualPositionFrom,   getNextNorthSouthVisualPositionFrom,   getNextVisualPositionFrom,   getRightInset,   getTopInset,   getView,   getViewAtPoint,   getViewAtPosition,   getViewCount,   getViewIndex,   getViewIndexAtPosition,   isAfter,   isBefore,   loadChildren,   modelToView,   modelToView,   replace,   setInsets,   setParagraphInsets,   setParent,   viewToModel
Methods from javax.swing.text.View:
append,   breakView,   changedUpdate,   createFragment,   forwardUpdate,   forwardUpdateToView,   getAlignment,   getAttributes,   getBreakWeight,   getChildAllocation,   getContainer,   getDocument,   getElement,   getEndOffset,   getGraphics,   getMaximumSpan,   getMinimumSpan,   getNextVisualPositionFrom,   getParent,   getPreferredSpan,   getResizeWeight,   getStartOffset,   getToolTipText,   getView,   getViewCount,   getViewFactory,   getViewIndex,   getViewIndex,   insert,   insertUpdate,   isVisible,   modelToView,   modelToView,   modelToView,   paint,   preferenceChanged,   remove,   removeAll,   removeUpdate,   replace,   setParent,   setSize,   updateChildren,   updateLayout,   viewToModel,   viewToModel
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from javax.swing.text.CompositeView Detail:
 abstract protected  void childAllocation(int index,
    Rectangle a)
    Returns the allocation for a given child.
 protected boolean flipEastAndWestAtEnds(int position,
    Bias bias) 
    Determines in which direction the next view lays. Consider the View at index n. Typically the Views are layed out from left to right, so that the View to the EAST will be at index n + 1, and the View to the WEST will be at index n - 1. In certain situations, such as with bidirectional text, it is possible that the View to EAST is not at index n + 1, but rather at index n - 1, or that the View to the WEST is not at index n - 1, but index n + 1. In this case this method would return true, indicating the Views are layed out in descending order.

    This unconditionally returns false, subclasses should override this method if there is the possibility for laying Views in descending order.

 protected short getBottomInset() 
    Gets the bottom inset.
 public Shape getChildAllocation(int index,
    Shape a) 
    Fetches the allocation for the given child view to render into. This enables finding out where various views are located.
 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 childAllocation method.
 protected short getLeftInset() 
    Gets the left inset.
 protected int getNextEastWestVisualPositionFrom(int pos,
    Bias b,
    Shape a,
    int direction,
    Bias[] biasRet) throws BadLocationException 
    Returns the next visual position for the cursor, in either the east or west direction.
 protected int getNextNorthSouthVisualPositionFrom(int pos,
    Bias b,
    Shape a,
    int direction,
    Bias[] biasRet) throws BadLocationException 
    Returns the next visual position for the cursor, in either the north or south direction.
 public int getNextVisualPositionFrom(int pos,
    Bias b,
    Shape a,
    int direction,
    Bias[] biasRet) throws BadLocationException 
    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 #getNextNorthSouthVisualPositionFrom and #getNextEastWestVisualPositionFrom .
 protected short getRightInset() 
    Gets the right inset.
 protected short getTopInset() 
    Gets the top inset.
 public View getView(int n) 
    Returns the n-th view in this container.
 abstract protected View getViewAtPoint(int x,
    int y,
    Rectangle alloc)
    Fetches the child view at the given coordinates.
 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.
 public int getViewCount() 
    Returns the number of child views of this view.
 public int getViewIndex(int pos,
    Bias b) 
    Returns the child view index representing the given position in the model. This is implemented to call the getViewIndexByPosition method for backward compatibility.
 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.
 abstract protected boolean isAfter(int x,
    int y,
    Rectangle alloc)
    Tests whether a point lies after the rectangle range.
 abstract protected boolean isBefore(int x,
    int y,
    Rectangle alloc)
    Tests whether a point lies before the rectangle range.
 protected  void loadChildren(ViewFactory f) 
    Loads all of the children to initialize the view. This is called by the #setParent method. Subclasses can reimplement this to initialize their child views in a different manner. The default implementation creates a child view for each child element.
 public Shape modelToView(int pos,
    Shape a,
    Bias b) throws BadLocationException 
    Provides a mapping from the document model coordinate space to the coordinate space of the view mapped to it.
 public Shape modelToView(int p0,
    Bias b0,
    int p1,
    Bias b1,
    Shape a) throws BadLocationException 
    Provides a mapping from the document model coordinate space to the coordinate space of the view mapped to it.
 public  void replace(int offset,
    int length,
    View[] views) 
    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 null, and the internal reference to them removed so that they may be garbage collected.
 protected  void setInsets(short top,
    short left,
    short bottom,
    short right) 
    Sets the insets for the view.
 protected  void setParagraphInsets(AttributeSet attr) 
    Sets the insets from the paragraph attributes specified in the given attributes.
 public  void setParent(View parent) 
    Sets the parent of the view. This is reimplemented to provide the superclass behavior as well as calling the loadChildren method if this view does not already have children. The children should not be loaded in the constructor because the act of setting the parent may cause them to try to search up the hierarchy (to get the hosting Container for example). If this view has children (the view is being moved from one place in the view hierarchy to another), the loadChildren method will not be called.
 public int viewToModel(float x,
    float y,
    Shape a,
    Bias[] bias) 
    Provides a mapping from the view coordinate space to the logical coordinate space of the model.