APIdia Launch Partner
Top Description Fields Constructors Methods
javax.swing.text

public Class IconView

extends View
Class Inheritance
Imports
java.awt.*, javax.swing.Icon, javax.swing.event.*

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 (that is, 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.
Author
Timothy Prinzing

Field Summary

Modifier and TypeField and Description
private Icon
c

Inherited from javax.swing.text.View:
BadBreakWeightExcellentBreakWeightfirstUpdateIndexForcedBreakWeightGoodBreakWeightlastUpdateIndexsharedBiasReturnX_AXISY_AXIS

Constructor Summary

AccessConstructor and Description
public
IconView(Element
the element to create a view for
elem
)

Creates a new icon view that represents an element.

Method Summary

Modifier and TypeMethod and Description
public float

Returns:

the desired alignment >= 0.0f && <= 1.0f. This should be a value between 0.0 and 1.0 where 0 indicates alignment at the origin and 1.0 indicates alignment to the full span away from the origin. An alignment of 0.5 would be the center of the view.
getAlignment
(int
may be either View.X_AXIS or View.Y_AXIS
axis
)

Overrides javax.swing.text.View.getAlignment.

Determines the desired alignment for this view along an axis.

public float

Returns:

the span the view would like to be rendered into Typically the view is told to render into the span that is returned, although there is no guarantee. The parent may choose to resize or break the view.
getPreferredSpan
(int
may be either View.X_AXIS or View.Y_AXIS
axis
)

Implements abstract javax.swing.text.View.getPreferredSpan.

Determines the preferred span for this view along an axis.

public Shape

Returns:

the bounding box of the given position
modelToView
(int
the position to convert >= 0
pos
,
Shape
the allocated region to render into
a
,
Position.Bias b)

Implements abstract javax.swing.text.View.modelToView.

Provides a mapping from the document model coordinate space to the coordinate space of the view mapped to it.

public void
paint(Graphics
the rendering surface to use
g
,
Shape
the allocated region to render into
a
)

Implements abstract javax.swing.text.View.paint.

Paints the icon.

public int

Returns:

the location within the model that best represents the given point of view >= 0
viewToModel
(float
the X coordinate >= 0
x
,
float
the Y coordinate >= 0
y
,
Shape
the allocated region to render into
a
,
Position.Bias[] bias)

Implements abstract javax.swing.text.View.viewToModel.

Provides a mapping from the view coordinate space to the logical coordinate space of the model.

Inherited from javax.swing.text.View:
appendbreakViewcalculateUpdateIndexeschangedUpdatecreateFragmentforwardUpdateforwardUpdateToViewgetAttributesgetBreakWeightgetChildAllocationgetContainergetDocumentgetElementgetEndOffsetgetGraphicsgetMaximumSpangetMinimumSpangetNextVisualPositionFromgetParentgetResizeWeightgetStartOffsetgetToolTipTextgetViewgetViewCountgetViewFactorygetViewIndexgetViewIndexinsertinsertUpdateisVisiblemodelToViewmodelToViewpreferenceChangedremoveremoveAllremoveUpdatereplacesetParentsetSizeupdateAfterChangeupdateChildrenupdateLayoutviewToModel

Field Detail

cback to summary
private Icon c

Constructor Detail

IconViewback to summary
public IconView(Element elem)

Creates a new icon view that represents an element.

Parameters
elem:Element

the element to create a view for

Method Detail

getAlignmentback to summary
public float getAlignment(int axis)

Overrides javax.swing.text.View.getAlignment.

Determines the desired alignment for this view along an axis. This is implemented to give the alignment to the bottom of the icon along the y axis, and the default along the x axis.

Parameters
axis:int

may be either View.X_AXIS or View.Y_AXIS

Returns:float

the desired alignment >= 0.0f && <= 1.0f. This should be a value between 0.0 and 1.0 where 0 indicates alignment at the origin and 1.0 indicates alignment to the full span away from the origin. An alignment of 0.5 would be the center of the view.

getPreferredSpanback to summary
public float getPreferredSpan(int axis)

Implements abstract javax.swing.text.View.getPreferredSpan.

Determines the preferred span for this view along an axis.

Parameters
axis:int

may be either View.X_AXIS or View.Y_AXIS

Returns:float

the span the view would like to be rendered into Typically the view is told to render into the span that is returned, although there is no guarantee. The parent may choose to resize or break the view.

Exceptions
IllegalArgumentException:
for an invalid axis
modelToViewback to summary
public Shape modelToView(int pos, Shape a, Position.Bias b) throws BadLocationException

Implements abstract javax.swing.text.View.modelToView.

Provides a mapping from the document model coordinate space to the coordinate space of the view mapped to it.

Parameters
pos:int

the position to convert >= 0

a:Shape

the allocated region to render into

Returns:Shape

the bounding box of the given position

Exceptions
BadLocationException:
if the given position does not represent a valid location in the associated document
See Also
View#modelToView
paintback to summary
public void paint(Graphics g, Shape a)

Implements abstract javax.swing.text.View.paint.

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:Graphics

the rendering surface to use

a:Shape

the allocated region to render into

See Also
View#paint
viewToModelback to summary
public int viewToModel(float x, float y, Shape a, Position.Bias[] bias)

Implements abstract javax.swing.text.View.viewToModel.

Provides a mapping from the view coordinate space to the logical coordinate space of the model.

Parameters
x:float

the X coordinate >= 0

y:float

the Y coordinate >= 0

a:Shape

the allocated region to render into

Returns:int

the location within the model that best represents the given point of view >= 0

See Also
View#viewToModel