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

pack-priv Class GlyphPainter1

extends GlyphPainter
Class Inheritance
Imports
java.awt.*

A class to perform rendering of the glyphs. This can be implemented to be stateless, or to hold some information as a cache to facilitate faster rendering and model/view translation. At a minimum, the GlyphPainter allows a View implementation to perform its duties independent of a particular version of JVM and selection of capabilities (i.e. shaping for i18n, etc).

This implementation is intended for operation under the JDK1.1 API of the Java Platform. Since the JDK is backward compatible with JDK1.1 API, this class will also function on Java 2. The JDK introduces improved API for rendering text however, so the GlyphPainter2 is recommended for the DK.

Author
Timothy Prinzing
See Also
GlyphView

Field Summary

Modifier and TypeField and Description
pack-priv FontMetrics

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public float
getAscent(GlyphView v)

Implements abstract javax.swing.text.GlyphView.GlyphPainter.getAscent.

Fetches the ascent above the baseline for the glyphs corresponding to the given range in the model.

public int

Returns:

the model location desired for a break
getBoundedPosition
(GlyphView
the view
v
,
int
the location in the model where the fragment should start its representation >= 0
p0
,
float
the graphic location along the axis that the broken view would occupy >= 0; this may be useful for things like tab calculations
x
,
float
specifies the distance into the view where a potential break is desired >= 0
len
)

Implements abstract javax.swing.text.GlyphView.GlyphPainter.getBoundedPosition.

Determines the best location (in the model) to break the given view.

public float
getDescent(GlyphView v)

Implements abstract javax.swing.text.GlyphView.GlyphPainter.getDescent.

Fetches the descent below the baseline for the glyphs corresponding to the given range in the model.

public float
getHeight(GlyphView v)

Implements abstract javax.swing.text.GlyphView.GlyphPainter.getHeight.

Returns of the height.

private int[]
getJustificationData(GlyphView v)

Returns: justificationData from the ParagraphRow this GlyphView is in or null if no justification is needed

public float
getSpan(GlyphView v, int p0, int p1, TabExpander e, float x)

Implements abstract javax.swing.text.GlyphView.GlyphPainter.getSpan.

Determine the span the glyphs given a start location (for tab expansion).

public Shape
modelToView(GlyphView v, int pos, Position.Bias bias, Shape a)

Implements abstract javax.swing.text.GlyphView.GlyphPainter.modelToView.

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

public void
paint(GlyphView v, Graphics g, Shape a, int p0, int p1)

Implements abstract javax.swing.text.GlyphView.GlyphPainter.paint.

Paints the glyphs representing the given range.

pack-priv void
public int

Returns:

the location within the model that best represents the given point in the view
viewToModel
(GlyphView
the view containing the view coordinates
v
,
float
the X coordinate
x
,
float
the Y coordinate
y
,
Shape
the allocated region to render into
a
,
Position.Bias[]
always returns Position.Bias.Forward as the zero-th element of this array
biasReturn
)

Implements abstract javax.swing.text.GlyphView.GlyphPainter.viewToModel.

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

Inherited from javax.swing.text.GlyphView.GlyphPainter:
getNextVisualPositionFromgetPainter

Field Detail

metricsback to summary
pack-priv FontMetrics metrics

Constructor Detail

GlyphPainter1back to summary
pack-priv GlyphPainter1()

Method Detail

getAscentback to summary
public float getAscent(GlyphView v)

Implements abstract javax.swing.text.GlyphView.GlyphPainter.getAscent.

Fetches the ascent above the baseline for the glyphs corresponding to the given range in the model.

getBoundedPositionback to summary
public int getBoundedPosition(GlyphView v, int p0, float x, float len)

Implements abstract javax.swing.text.GlyphView.GlyphPainter.getBoundedPosition.

Determines the best location (in the model) to break the given view. This method attempts to break on a whitespace location. If a whitespace location can't be found, the nearest character location is returned.

Parameters
v:GlyphView

the view

p0:int

the location in the model where the fragment should start its representation >= 0

x:float

the graphic location along the axis that the broken view would occupy >= 0; this may be useful for things like tab calculations

len:float

specifies the distance into the view where a potential break is desired >= 0

Returns:int

the model location desired for a break

See Also
View#breakView
getDescentback to summary
public float getDescent(GlyphView v)

Implements abstract javax.swing.text.GlyphView.GlyphPainter.getDescent.

Fetches the descent below the baseline for the glyphs corresponding to the given range in the model.

getHeightback to summary
public float getHeight(GlyphView v)

Implements abstract javax.swing.text.GlyphView.GlyphPainter.getHeight.

Doc from javax.swing.text.GlyphView.GlyphPainter.getHeight.

Returns of the height.

getJustificationDataback to summary
private int[] getJustificationData(GlyphView v)
Returns:int[]

justificationData from the ParagraphRow this GlyphView is in or null if no justification is needed

getSpanback to summary
public float getSpan(GlyphView v, int p0, int p1, TabExpander e, float x)

Implements abstract javax.swing.text.GlyphView.GlyphPainter.getSpan.

Determine the span the glyphs given a start location (for tab expansion).

modelToViewback to summary
public Shape modelToView(GlyphView v, int pos, Position.Bias bias, Shape a) throws BadLocationException

Implements abstract javax.swing.text.GlyphView.GlyphPainter.modelToView.

Doc from javax.swing.text.GlyphView.GlyphPainter.modelToView.

Provides a mapping from the document model coordinate space to the coordinate space of the view mapped to it. This is shared by the broken views.

Exceptions
BadLocationException:
if the given position does not represent a valid location in the associated document
paintback to summary
public void paint(GlyphView v, Graphics g, Shape a, int p0, int p1)

Implements abstract javax.swing.text.GlyphView.GlyphPainter.paint.

Paints the glyphs representing the given range.

syncback to summary
pack-priv void sync(GlyphView v)
Annotations
@SuppressWarnings:deprecation
viewToModelback to summary
public int viewToModel(GlyphView v, float x, float y, Shape a, Position.Bias[] biasReturn)

Implements abstract javax.swing.text.GlyphView.GlyphPainter.viewToModel.

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

Parameters
v:GlyphView

the view containing the view coordinates

x:float

the X coordinate

y:float

the Y coordinate

a:Shape

the allocated region to render into

biasReturn:Position.Bias[]

always returns Position.Bias.Forward as the zero-th element of this array

Returns:int

the location within the model that best represents the given point in the view

See Also
View#viewToModel