All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.sun.java.swing.text.ComponentView

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

public class ComponentView
extends AbstractView
Component decorator that implements the view interface. The entire element is used to represent the component. This acts as a gateway from the display-only View implementations to interactive lightweight components (ie it allows components to be embedded into the View hierarchy. The parent of the component is the container that is handed out by the associated view factory.


Constructor Index

 o ComponentView(Element, Component, ViewFactory)
Creates a new JComponentView object.

Method Index

 o changedUpdate(DocumentEvent, Shape, ViewFactory)
Gives notification from the document that attributes were changed in a location that this view is responsible for.
 o getPreferredShape(Shape, ViewFactory)
Calculates the desired shape of the component.
 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 coordinate space of the model to that of the view.
 o paint(Graphics, Shape, ViewFactory)
The real paint behavior occurs naturally from the association that the component has with it's parent container (the same container hosting this view), so this simply allows us to position the component properly relative to 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 ComponentView
 public ComponentView(Element elem,
                      Component c,
                      ViewFactory f)
Creates a new JComponentView object.

Parameters:
elem - the element to decorate
c - the component
f - the view factory

Methods

 o paint
 public void paint(Graphics g,
                   Shape a,
                   ViewFactory f)
The real paint behavior occurs naturally from the association that the component has with it's parent container (the same container hosting this view), so this simply allows us to position the component properly relative to the view. Since the coordinate system for the view is simply the parent containers, positioning the child component is easy.

Parameters:
g - the graphics context
a - the shape
f - the view factory
Overrides:
paint in class AbstractView
See Also:
paint
 o getPreferredShape
 public Shape getPreferredShape(Shape candidate,
                                ViewFactory f)
Calculates the desired shape of the component. The preferred size of the component is used unless it doesn't fit within the parents constraints. If it doesn't fit, it shrinks the component to the maximum of either the constraint or the mimimum size.

Parameters:
candidate - the candidate shape
f - the view factory
Returns:
the desired shape
Overrides:
getPreferredShape in class AbstractView
See Also:
getPreferredShape
 o modelToView
 public Shape modelToView(int pos,
                          Shape a,
                          ViewFactory f) throws BadLocationException
Provides a mapping from the coordinate space of the model to that of the view.

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
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 evnt,
                          Shape a,
                          ViewFactory f)
Gives notification that something was inserted into the document in a location that this view is responsible for.

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

Parameters:
evnt - 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
 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

All Packages  Class Hierarchy  This Package  Previous  Next  Index