javax.swing.text
Class GlyphPainter1

java.lang.Object
  |
  +--javax.swing.text.GlyphView.GlyphPainter
        |
        +--javax.swing.text.GlyphPainter1

class GlyphPainter1
extends javax.swing.text.GlyphView.GlyphPainter

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 Java 2 SDK is backward compatible with JDK1.1 API, this class will also function on Java 2. The Java 2 SDK introduces improved API for rendering text however, so the GlyphPainter2 is recommended for the Java 2 SDK.

Version:
1.12 12/03/01
Author:
Timothy Prinzing
See Also:
GlyphView

Field Summary
(package private)  FontMetrics metrics
           
 
Constructor Summary
(package private) GlyphPainter1()
           
 
Method Summary
 float getAscent(GlyphView v)
          Fetches the ascent above the baseline for the glyphs corresponding to the given range in the model.
 int getBoundedPosition(GlyphView v, int p0, float x, float len)
          Determines the best location (in the model) to break the given view.
 float getDescent(GlyphView v)
          Fetches the descent below the baseline for the glyphs corresponding to the given range in the model.
 float getHeight(GlyphView v)
           
 float getSpan(GlyphView v, int p0, int p1, TabExpander e, float x)
          Determine the span the glyphs given a start location (for tab expansion).
 Shape modelToView(GlyphView v, int pos, javax.swing.text.Position.Bias bias, Shape a)
          Provides a mapping from the document model coordinate space to the coordinate space of the view mapped to it.
 void paint(GlyphView v, Graphics g, Shape a, int p0, int p1)
          Paints the glyphs representing the given range.
(package private)  void sync(GlyphView v)
           
 int viewToModel(GlyphView v, float x, float y, Shape a, javax.swing.text.Position.Bias[] biasReturn)
          Provides a mapping from the view coordinate space to the logical coordinate space of the model.
 
Methods inherited from class javax.swing.text.GlyphPainter
getNextVisualPositionFrom, getPainter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

metrics

FontMetrics metrics
Constructor Detail

GlyphPainter1

GlyphPainter1()
Method Detail

getSpan

public float getSpan(GlyphView v,
                     int p0,
                     int p1,
                     TabExpander e,
                     float x)
Determine the span the glyphs given a start location (for tab expansion).

Specified by:
getSpan in class javax.swing.text.GlyphView.GlyphPainter

getHeight

public float getHeight(GlyphView v)
Specified by:
getHeight in class javax.swing.text.GlyphView.GlyphPainter

getAscent

public float getAscent(GlyphView v)
Fetches the ascent above the baseline for the glyphs corresponding to the given range in the model.

Specified by:
getAscent in class javax.swing.text.GlyphView.GlyphPainter

getDescent

public float getDescent(GlyphView v)
Fetches the descent below the baseline for the glyphs corresponding to the given range in the model.

Specified by:
getDescent in class javax.swing.text.GlyphView.GlyphPainter

paint

public void paint(GlyphView v,
                  Graphics g,
                  Shape a,
                  int p0,
                  int p1)
Paints the glyphs representing the given range.

Specified by:
paint in class javax.swing.text.GlyphView.GlyphPainter

modelToView

public Shape modelToView(GlyphView v,
                         int pos,
                         javax.swing.text.Position.Bias bias,
                         Shape a)
                  throws BadLocationException
Description copied from class: javax.swing.text.GlyphView.GlyphPainter
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.

Specified by:
modelToView in class javax.swing.text.GlyphView.GlyphPainter
Parameters:
pos - the position to convert
a - the allocated region to render into
Returns:
the bounding box of the given position
BadLocationException
See Also:
View.modelToView(int, java.awt.Shape, javax.swing.text.Position.Bias)

viewToModel

public int viewToModel(GlyphView v,
                       float x,
                       float y,
                       Shape a,
                       javax.swing.text.Position.Bias[] biasReturn)
Provides a mapping from the view coordinate space to the logical coordinate space of the model.

Specified by:
viewToModel in class javax.swing.text.GlyphView.GlyphPainter
Parameters:
v - the view containing the view coordinates
x - the X coordinate
y - the Y coordinate
a - the allocated region to render into
biasReturn - always returns Position.Bias.Forward as the zero-th element of this array
Returns:
the location within the model that best represents the given point in the view
See Also:
View.viewToModel(float, float, java.awt.Shape, javax.swing.text.Position.Bias[])

getBoundedPosition

public int getBoundedPosition(GlyphView v,
                              int p0,
                              float x,
                              float len)
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.

Specified by:
getBoundedPosition in class javax.swing.text.GlyphView.GlyphPainter
Parameters:
v - the view
p0 - the location in the model where the fragment should start its representation >= 0
len - specifies the distance into the view where a potential break is desired >= 0
Returns:
the model location desired for a break
See Also:
View.breakView(int, int, float, float)

sync

void sync(GlyphView v)


comments?