All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.sun.java.swing.text.IconView

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

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


Constructor Index

 o IconView(Element, Icon, ViewFactory)
Creates a new view that represents an element.

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 icon.
 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)
Paints the icon.
 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 IconView
 public IconView(Element elem,
                 Icon c,
                 ViewFactory f)
Creates a new view that represents an element.

Parameters:
elem - the element to create a view for
c - the icon
f - the view factory

Methods

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

Parameters:
g - the rendering surface to use
a - the allocated region to render into
f - the view factor to use if children need to be created
Overrides:
paint in class AbstractView
See Also:
paint
 o getPreferredShape
 public Shape getPreferredShape(Shape candidate,
                                ViewFactory f)
Calculates the desired shape of the icon. The preferred size of the icon is used unless it doesn't fit within the parents constraints. If it doesn't fit, it shrinks the icon to the maximum of either the constraint or the mimimum size.

Parameters:
candidate - the shape candidate
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 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 of 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
the - factory to use to rebuilld 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
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 - teh factory to use to rebuild if the view has children
Overrides:
changedUpdate in class AbstractView

All Packages  Class Hierarchy  This Package  Previous  Next  Index