All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.sun.java.swing.text.CompositeView

java.lang.Object
   |
   +----com.sun.java.swing.text.AbstractView
           |
           +----com.sun.java.swing.text.CompositeView

public abstract class CompositeView
extends AbstractView
A view of a text model that has a children box. If the box is vertical, it might be useful to represent something like a collection of lines or paragraphs. If the box is horizontal, it might be used to represent unwrapped lines.


Constructor Index

 o CompositeView(Element)
Constructs a JCompositeView for the given element.

Method Index

 o calculateSize(Rectangle, ViewFactory)
Calculates the size of a bounding box for the union of all the child views in the container.
 o changedUpdate(DocumentEvent, Shape, ViewFactory)
Gives notification from the document that attributes were changed in a location that this view is responsible for.
 o childAllocation(int, Shape, ViewFactory)
Returns the allocation for a given child.
 o getPreferredShape(Shape, ViewFactory)
Determines the preferred region for this view.
 o getView(int)
Gets the nth view in this container.
 o getViewAtPoint(Point, Rectangle, ViewFactory)
Fetches the child view at the given point.
 o getViewAtPosition(int, Rectangle, ViewFactory)
 o getViewCount()
Returns the number of views in this view.
 o insertUpdate(DocumentEvent, Shape, ViewFactory)
Gives notification that something was inserted into the document in a location that this view is responsible for.
 o insertView(int, View)
Inserts a view in the container.
 o invalidate()
Notes that the desired size has changed.
 o isAfter(Point, Rectangle)
Tests whether a point is after the rectangle range.
 o isBefore(Point, Rectangle)
Tests whether a point is before the rectangle range.
 o loadChildren(ViewFactory)
Loads all of the children for the case where children are created for each element.
 o modelToView(int, Shape, ViewFactory)
Provides a mapping from the document model coordinate space to the coordinate space of the view mapped to it.
 o paint(Graphics, Shape, ViewFactory)
This doesn't actually render anything, but it invalidates if the allocation has changed.
 o removeAllViews()
Removes all views from the container.
 o removeUpdate(DocumentEvent, Shape, ViewFactory)
Gives notification that something was removed from the document in a location that this view is responsible for.
 o removeView(int)
Removes a view from the container.
 o shouldNotHappen()
Called for internal errors.
 o viewToModel(Point, Shape, ViewFactory)
Provides a mapping from the view coordinate space to the logical coordinate space of the model.

Constructors

 o CompositeView
 public CompositeView(Element elem)
Constructs a JCompositeView for the given element.

Parameters:
elem - the element this view is responsible for

Methods

 o loadChildren
 protected void loadChildren(ViewFactory f)
Loads all of the children for the case where children are created for each element. Subclasses can call this if it's appropriate for their behavior.

Parameters:
f - the view factory
 o getViewCount
 public int getViewCount()
Returns the number of views in this view.

Returns:
the number of views
See Also:
getView
 o invalidate
 public void invalidate()
Notes that the desired size has changed.

 o getView
 public View getView(int n)
Gets the nth view in this container.

Parameters:
n - the number of the view to get
Returns:
the view
 o removeView
 public void removeView(int n)
Removes a view from the container.

Parameters:
n - the number of the view to remove
 o insertView
 public void insertView(int n,
                        View v)
Inserts a view in the container.

Parameters:
n - the position to insert the view at. All elements of equal or greater index will be shifted forward.
v - the view
 o removeAllViews
 public void removeAllViews()
Removes all views from the container.

 o getPreferredShape
 public Shape getPreferredShape(Shape candidate,
                                ViewFactory f)
Determines the preferred region for this view.

Parameters:
candidate - a region that the parent is considering allocating to the view
f - a factory that can be used to create child views if a new layout is needed to determine the the desired shape
Returns:
the shape the view would like to be rendered into
Overrides:
getPreferredShape in class AbstractView
See Also:
getPreferredShape
 o paint
 public void paint(Graphics g,
                   Shape allocation,
                   ViewFactory f)
This doesn't actually render anything, but it invalidates if the allocation has changed.

Parameters:
g - the rendering surface to use
allocation - the allocated region to render into
f - the factory to use if children need to be created
Overrides:
paint in class AbstractView
See Also:
paint
 o modelToView
 public Shape modelToView(int pos,
                          Shape a,
                          ViewFactory f) throws BadLocationException
Provides a mapping from the document model coordinate space to the coordinate space of the view mapped to it.

Parameters:
pos - the position to convert
a - the allocated region to render into
f - the factory to use if children need to be created
Returns:
the bounding box of the given position
Throws: BadLocation
if the given position does not represent a valid location in the associated document
Overrides:
modelToView in class AbstractView
See Also:
modelToView
 o viewToModel
 public int viewToModel(Point pt,
                        Shape a,
                        ViewFactory f)
Provides a mapping from the view coordinate space to the logical coordinate space of the model.

Parameters:
pt - the view location to convert
a - the allocated region to render into
f - the factory to use if children need to be created
Returns:
the location within the model that best represents the given point in the view
Overrides:
viewToModel in class AbstractView
See Also:
viewToModel
 o insertUpdate
 public void insertUpdate(DocumentEvent e,
                          Shape a,
                          ViewFactory f)
Gives notification that something was inserted into the document in a location that this view is responsible for.

Parameters:
e - 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
Overrides:
insertUpdate in class AbstractView
See Also:
insertUpdate
 o removeUpdate
 public void removeUpdate(DocumentEvent e,
                          Shape a,
                          ViewFactory f)
Gives notification that something was removed from the document in a location that this view is responsible for.

Parameters:
e - 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
Overrides:
removeUpdate in class AbstractView
See Also:
removeUpdate
 o changedUpdate
 public void changedUpdate(DocumentEvent e,
                           Shape a,
                           ViewFactory f)
Gives notification from the document that attributes were changed in a location that this view is responsible for.

Parameters:
e - 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
Overrides:
changedUpdate in class AbstractView
See Also:
changedUpdate
 o calculateSize
 protected abstract Dimension calculateSize(Rectangle alloc,
                                            ViewFactory f)
Calculates the size of a bounding box for the union of all the child views in the container.

Parameters:
alloc - the rectangle
f - the view factory
 o isBefore
 protected abstract boolean isBefore(Point p,
                                     Rectangle alloc)
Tests whether a point is before the rectangle range.

Parameters:
p - the point
alloc - the rectangle
Returns:
true if the point is before the specified range
 o isAfter
 protected abstract boolean isAfter(Point p,
                                    Rectangle alloc)
Tests whether a point is after the rectangle range.

Parameters:
p - the point
alloc - the rectangle
Returns:
true if the point is after the specified range
 o getViewAtPoint
 protected abstract View getViewAtPoint(Point p,
                                        Rectangle alloc,
                                        ViewFactory f)
Fetches the child view at the given point.

Parameters:
p - the location of the child to fetch
alloc - the parent's allocation on entry, which should be changed to the child's allocation on exit
f - the view factory
Returns:
the child view
 o childAllocation
 protected abstract Rectangle childAllocation(int index,
                                              Shape allocation,
                                              ViewFactory f)
Returns the allocation for a given child.

Parameters:
index - the index of the child
allocation - the shape
f - the factory
Returns:
the allocation
 o getViewAtPosition
 protected View getViewAtPosition(int pos,
                                  Rectangle a,
                                  ViewFactory f)
 o shouldNotHappen
 protected void shouldNotHappen()
Called for internal errors.


All Packages  Class Hierarchy  This Package  Previous  Next  Index