All Packages  Class Hierarchy  This Package  Previous  Next  Index

Interface com.sun.java.swing.text.View

public interface View
A view of some portion of document model. Provides a mapping to model coordinates from view coordinates and a mapping to view coordinates from model coordinates. A view also provides rendering and layout services. Many methods pass an allocated Shape and a ViewFactory as arguments. This enables the views to be dynamically computed if desired.


Variable Index

 o PENALTY_BAD
 o PENALTY_GOOD
These are the bounds for penalties used for determining breaks.
 o X_AXIS
axis for format/break operations.
 o Y_AXIS

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 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.

Variables

 o PENALTY_GOOD
 public static final int PENALTY_GOOD
These are the bounds for penalties used for determining breaks. A good penalty value should always be less than a bad penalty value. The penalty_good value is a value that is considered a forced break (ie. a value <= this value will be guaranteed to cause a break). The penalty_bad value is a value that is considered to be unbreakable (ie. a value >= this value will be guaranteed not to break).

 o PENALTY_BAD
 public static final int PENALTY_BAD
 o X_AXIS
 public static final int X_AXIS
axis for format/break operations.

 o Y_AXIS
 public static final int Y_AXIS

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:
s the shape the view would like to be rendered into. Typically the view is told to render into the shape that is returned, although there is no guarantee. The parent may choose to resize or break the view.
 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
 o getDocument
 public abstract Document getDocument()
Fetches the model associated with the view.

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

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

Returns:
the ending offset into the model
 o getElement
 public abstract 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:
getRange
 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:
s the bounding box of the given position is returned. Since a position has no width, the shape returned has only height.
Throws: BadLocation
the given position is not a valid location within the model
 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:
s the locaion within the model that best represents the given point in the view
 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
f - the factory to use to rebuild if the view has children
a - the current allocation of the view
 o removeUpdate
 public abstract 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
f - the factory to use to rebuild if the view has children
a - the current allocation of the view
 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
f - the factory to use to rebuild if the view has children
a - the current allocation of the view
 o breakView
 public abstract View breakView(int axis,
                                float len,
                                Shape a)
Breaks this view on the given axis at the given length. This causes a view to be created that represents the portion of the view that can fit within the given span. A factory is not needed for this operation since the view fragment created will be of the same type as the view being broken.

Parameters:
axis - may be either X_AXIS or Y_AXIS
len - specifies where a potential break is desired within the span along the given axis of the allocated area for the view
a - the current allocation of the view
Returns:
s 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.
 o getBreakPenalty
 public abstract int getBreakPenalty(int axis,
                                     float len)
Determines the penalty for breaking the view. The view might not support breaking (returns PENALTY_BAD), or the view might insist on being broken (returns PENALTY_GOOD), it might return some value between the two bounds.

Parameters:
axis - may be either X_AXIS or Y_AXIS
len - specifies where a potential break is desired within the span along the given axis of the allocated area for the view
Returns:
the penalty
 o getResizePenalty
 public abstract int getResizePenalty(int axis,
                                      float len)
Determines the penalty for changing the size of the view if it supports multiple sizes. Some views may look at this information and use it to determine whether to break or resize based upon it. Other views may ignore this value and enforce their own policy of break versus resize.

Parameters:
axis - may be either X_AXIS or Y_AXIS
len - specifies where a potential break is desired

All Packages  Class Hierarchy  This Package  Previous  Next  Index