All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.sun.java.swing.text.AbstractView

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

public abstract class AbstractView
extends Object
implements View
Implements some default behavior for the View interface to simplify creation of new text-oriented views. The implementation represents an entire element from the model, and claims to be unbreakable (ie doesn't support breaking behavior).


Constructor Index

 o AbstractView(Element)
Creates a new JView object.

Method Index

 o breakView(int, float, Shape)
Breaks this view on the given axis at the given length.
 o changedUpdate(DocumentEvent, Shape, ViewFactory)
Gives notification from the document that attributes were changed in a location that this view is responsible for.
 o getBreakPenalty(int, float)
Determines the penalty for breaking the view.
 o getDocument()
Fetches the model associated with the view.
 o getElement()
Fetches the structural portion of the subject that this view is mapped to.
 o getEndOffset()
Fetches the portion of the model that this view is responsible for.
 o getPreferredShape(Shape, ViewFactory)
Determines the preferred region for this view.
 o getResizePenalty(int, float)
Determines the penalty for changing the size of the view if it supports multiple sizes.
 o getStartOffset()
Fetches the portion of the model that this view is responsible for.
 o insertUpdate(DocumentEvent, Shape, ViewFactory)
Gives notification that something was inserted into the document in a location that this view is responsible for.
 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 using the given rendering surface and area on that surface.
 o removeUpdate(DocumentEvent, Shape, ViewFactory)
Gives notification from the document that attributes were removed 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 AbstractView
 public AbstractView(Element elem)
Creates a new JView object.

Parameters:
elem - the element to represent

Methods

 o getPreferredShape
 public abstract Shape getPreferredShape(Shape candidate,
                                         ViewFactory f)
Determines the preferred region for this view. The candidate shape may be mutated and used as the return value. The factory is given because a view may recreate children if it does layout to satisfy the request.

Parameters:
candidate - a region that the parent is considering allocating to the view. Typically this will be whatever is left for the parent to allocate.
f - a factory that can be used to create child views if a new layout is needed to determine the desired shape.
Returns:
the shape the view would like to be rendered into. Typically the view is told to render into the shape that that is returned, although there is no guarantee. The parent may choose to resize or break the view.
See Also:
getPreferredShape
 o paint
 public abstract void paint(Graphics g,
                            Shape allocation,
                            ViewFactory f)
Renders using the given rendering surface and area on that surface. The view may need to do layout and create child views to enable itself to render into the given allocation.

Parameters:
g - the rendering surface to use
a - the allocated region to render into
f - the factory to use if children need to be created
See Also:
paint
 o modelToView
 public abstract 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 is returned
Throws: BadLocation
if the given position does not represent a valid location in the associated document
See Also:
modelToView
 o viewToModel
 public abstract 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
See Also:
viewToModel
 o insertUpdate
 public abstract 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
See Also:
insertUpdate
 o removeUpdate
 public abstract void removeUpdate(DocumentEvent e,
                                   Shape a,
                                   ViewFactory f)
Gives notification from the document that attributes were removed 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
See Also:
removeUpdate
 o changedUpdate
 public abstract 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
See Also:
changedUpdate
 o getDocument
 public Document getDocument()
Fetches the model associated with the view.

Returns:
the view model
See Also:
getDocument
 o getStartOffset
 public int getStartOffset()
Fetches the portion of the model that this view is responsible for.

Returns:
the starting offset into the model
See Also:
getStartOffset
 o getEndOffset
 public int getEndOffset()
Fetches the portion of the model that this view is responsible for.

Returns:
the ending offset into the model
See Also:
getEndOffset
 o getElement
 public Element getElement()
Fetches the structural portion of the subject that this view is mapped to. The view may not be responsible for the entire portion of the element.

Returns:
the subject
See Also:
getElement
 o breakView
 public View breakView(int axis,
                       float len,
                       Shape a)
Breaks this view on the given axis at the given length.

Parameters:
axis - may be either X_AXIS or Y_AXIS
len - specifies where a potential break is desired along the given axis
a - the current allocation of the view
Returns:
the fragment of the view that represents the given span, if the view can be broken. If the view doesn't support breaking behavior, null is returned.
See Also:
breakView
 o getBreakPenalty
 public int getBreakPenalty(int axis,
                            float len)
Determines the penalty for breaking the view.

Parameters:
axis - may be either X_AXIS or Y_AXIS
len - specifies where a potential break is desired
Returns:
the penalty
See Also:
getBreakPenalty
 o getResizePenalty
 public int getResizePenalty(int axis,
                             float len)
Determines the penalty for changing the size of the view if it supports multiple sizes.

Parameters:
axis - may be either X_AXIS or Y_AXIS
len - specifies where a potential break is desired
Returns:
the penalty
See Also:
getResizePenalty

All Packages  Class Hierarchy  This Package  Previous  Next  Index