All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.sun.java.swing.text.ParagraphView

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

public class ParagraphView
extends CompositeView
Implements View interface for a simple line-wrapping paragraph that supports multiple fonts, colors, components, icons, etc. It is basically a vertical box with a margin around it. The contents of the box are a bunch of rows which are special horizontal boxes.

See Also:
View

Constructor Index

 o ParagraphView(Element, ViewFactory)
Constructs a JParagraphView for the given element.

Method Index

 o calculateSize(Rectangle, ViewFactory)
Calculates the size needed by the paragraph which is much like the vertical box except that it takes into account the spacing between each line if there are more than one line.
 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)
Allocates space for child views.
 o getPreferredShape(Shape, ViewFactory)
Calculates the shape of the paragraph.
 o getViewAtPoint(Point, Rectangle, ViewFactory)
Not used
 o getViewAtPosition(int, Rectangle, ViewFactory)
Fetches the child view that represents the given position in the model.
 o insertUpdate(DocumentEvent, Shape, ViewFactory)
Gives notification that something was inserted into the document in a location that this view is responsible for.
 o isAfter(Point, Rectangle)
Checks whether the point is after the region.
 o isBefore(Point, Rectangle)
Checks whether the point is before the region.
 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)
Renders the view.
 o removeUpdate(DocumentEvent, Shape, ViewFactory)
Gives notification that something was removed from the document in a location that this view is responsible for.
 o viewToModel(Point, Shape, ViewFactory)
Provides a mapping from the view coordinate space to the logical coordinate space of the model.

Constructors

 o ParagraphView
 public ParagraphView(Element elem,
                      ViewFactory f)
Constructs a JParagraphView for the given element.

Parameters:
elem - the element that this view is responsible for
f - the factory to use to create views of the elements that are children of the element this view is responsible for

Methods

 o paint
 public void paint(Graphics g,
                   Shape allocation,
                   ViewFactory f)
Renders the view. If the allocated width has changed, layout is done again. The allocation given is reduced by the margins of the paragraph and forwarded to the base functionality.

Parameters:
g - the rendering surface
allocation - the allocated region to render into
f - the factory to use if children need to be created
Overrides:
paint in class CompositeView
See Also:
paint
 o getPreferredShape
 public Shape getPreferredShape(Shape candidate,
                                ViewFactory f)
Calculates the shape of the paragraph. The width is basically whatever was given, but the height is calculated based upon the width. If the width has changed, a new height is calculated, otherwise the answer to the size request is cheap as it is simply whatever the last layout produced.

Parameters:
candidate - a region that the parent is considering allocating to the view
the - view factor that can be used to create child views
Returns:
the shape the view would like to be rendered into
Overrides:
getPreferredShape in class CompositeView
See Also:
getPreferredShape
 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
Throws: BadLocation
if the given position does not represent a valid location in the associated document
Overrides:
modelToView in class CompositeView
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 CompositeView
See Also:
viewToModel
 o insertUpdate
 public void insertUpdate(DocumentEvent changes,
                          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 CompositeView
See Also:
insertUpdate
 o removeUpdate
 public void removeUpdate(DocumentEvent changes,
                          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 CompositeView
See Also:
removeUpdate
 o changedUpdate
 public void changedUpdate(DocumentEvent changes,
                           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 CompositeView
See Also:
changedUpdate
 o calculateSize
 protected Dimension calculateSize(Rectangle alloc,
                                   ViewFactory f)
Calculates the size needed by the paragraph which is much like the vertical box except that it takes into account the spacing between each line if there are more than one line.

Parameters:
alloc - the current allocation
f - the view factory
Returns:
the size
Overrides:
calculateSize in class CompositeView
 o childAllocation
 protected Rectangle childAllocation(int index,
                                     Shape allocation,
                                     ViewFactory f)
Allocates space for child views.

Parameters:
index - the child view index
allocation - the currently allocated region
f - the view factory
Returns:
the space as a rectangle
Overrides:
childAllocation in class CompositeView
 o getViewAtPosition
 protected View getViewAtPosition(int pos,
                                  Rectangle a,
                                  ViewFactory f)
Fetches the child view that represents the given position in the model. This is implemented to walk through the children looking for a range that contains the given position.

Parameters:
pos - the search position
a - the allocation to the box on entry, and the allocation of the view containing the position on exit
f - the view factory
Returns:
s the view representing the given position, or null if there isn't one
Overrides:
getViewAtPosition in class CompositeView
 o isBefore
 protected boolean isBefore(Point pt,
                            Rectangle alloc)
Checks whether the point is before the region.

Parameters:
pt - the point
alloc - the region
Returns:
true if the point lies before the region else false
Overrides:
isBefore in class CompositeView
 o isAfter
 protected boolean isAfter(Point pt,
                           Rectangle alloc)
Checks whether the point is after the region.

Parameters:
pt - the point
alloc - the region
Returns:
true if the point lies after the region else false
Overrides:
isAfter in class CompositeView
 o getViewAtPoint
 protected View getViewAtPoint(Point p,
                               Rectangle alloc,
                               ViewFactory f)
Not used

Overrides:
getViewAtPoint in class CompositeView

All Packages  Class Hierarchy  This Package  Previous  Next  Index