GNU Classpath (0.95) | |
Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
javax.swing.text.View
javax.swing.text.GlyphView
View
subclass paints the
characters of the Element
it is responsible for using
the style information from that Element
.
Nested Class Summary | |
static class |
|
Field Summary |
Fields inherited from class javax.swing.text.View | |
BadBreakWeight , ExcellentBreakWeight , ForcedBreakWeight , GoodBreakWeight , X_AXIS , Y_AXIS |
Fields inherited from interface javax.swing.SwingConstants | |
BOTTOM , CENTER , EAST , HORIZONTAL , LEADING , LEFT , NEXT , NORTH , NORTH_EAST , NORTH_WEST , PREVIOUS , RIGHT , SOUTH , SOUTH_EAST , SOUTH_WEST , TOP , TRAILING , VERTICAL , WEST |
Method Summary | |
View |
|
void |
|
protected void |
|
protected Object |
|
View |
|
float |
|
Color |
|
int |
|
int |
|
Font |
|
Color |
|
GlyphView.GlyphPainter |
|
int |
|
float |
|
float |
|
int |
|
TabExpander |
|
float |
|
Segment |
|
void |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
Shape |
|
void | |
void |
|
void |
|
int |
|
Methods inherited from class java.lang.Object | |
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
public View breakView(int axis, int p0, float pos, float len)
Tries to break the view near the specified view spanlen
. The glyph view can only be broken in the X direction. For Y direction it returns itself.
- Parameters:
axis
- the axis for breaking, may beView.X_AXIS
orView.Y_AXIS
p0
- the model location where the fragment should startpos
- the view position along the axis where the fragment startslen
- the desired length of the fragment view
- Returns:
- the fragment view, or
this
if breaking was not possible
public void changedUpdate(DocumentEvent e, Shape a, ViewFactory vf)
Receives notification that some text attributes have changed within the text fragment that this view is responsible for. This callsView.preferenceChanged(View,boolean,boolean)
on the parent for both width and height.
- Overrides:
- changedUpdate in interface View
- Parameters:
e
- the document event describing the change; not used herea
- the view allocation on screen; not used herevf
- the view factory; not used here
protected void checkPainter()
Checks if aGlyphPainer
is installed. If this is not the case, a default painter is installed.
protected final Object clone()
Creates and returns a shallow clone of this GlyphView. This is used by thecreateFragment(int,int)
andbreakView(int,int,float,float)
methods.
- Returns:
- a shallow clone of this GlyphView
public View createFragment(int p0, int p1)
Creates a fragment view of this view that starts atp0
and ends atp1
.
- Overrides:
- createFragment in interface View
- Parameters:
p0
- the start location for the fragment viewp1
- the end location for the fragment view
- Returns:
- the fragment view
public float getAlignment(int axis)
Returns the alignment of this view along the specified axis. For the Y axis this is(height - descent) / height
for the used font, so that it is aligned along the baseline. For the X axis the superclass is called.
- Overrides:
- getAlignment in interface View
public Color getBackground()
Returns the background color which should be used to paint the text. This is fetched from the associated element's text attributes usingStyleConstants.getBackground(AttributeSet)
.
- Returns:
- the background color which should be used to paint the text
public int getBreakWeight(int axis, float pos, float len)
Determines how well the specified view location is suitable for inserting a line break. Ifaxis
isView.Y_AXIS
, then this method forwards to the superclass, ifaxis
isView.X_AXIS
then this method returnsView.ExcellentBreakWeight
if there is a suitable break location (usually whitespace) within the specified view span, orView.GoodBreakWeight
if not.
- Overrides:
- getBreakWeight in interface View
- Parameters:
axis
- the axis along which the break weight is requestedpos
- the starting view locationlen
- the length of the span at which the view should be broken
- Returns:
- the break weight
public int getEndOffset()
Returns the end offset in the document model of the portion of text that this view is responsible for.
- Overrides:
- getEndOffset in interface View
- Returns:
- the end offset in the document model of the portion of text that this view is responsible for
public Font getFont()
Returns the font for the text run for which thisGlyphView
is responsible.
- Returns:
- the font for the text run for which this
GlyphView
is responsible
public Color getForeground()
Returns the foreground color which should be used to paint the text. This is fetched from the associated element's text attributes usingStyleConstants.getForeground(AttributeSet)
.
- Returns:
- the foreground color which should be used to paint the text
public GlyphView.GlyphPainter getGlyphPainter()
Returns theGlyphPainter
that is used by thisGlyphView
. If noGlyphPainer
has been installednull
is returned.
- Returns:
- the glyph painter that is used by this glyph view or
null
if no glyph painter has been installed
public int getNextVisualPositionFrom(int pos, Position.Bias bias, Shape a, int direction, Position.Bias[] biasRet) throws BadLocationException
Returns the model location that should be used to place a caret when moving the caret through the document.
- Overrides:
- getNextVisualPositionFrom in interface View
- Parameters:
pos
- the current model locationbias
- the bias forp
a
- the allocated region for the glyph viewdirection
- the direction from the current position; Must be one ofSwingConstants.EAST
,SwingConstants.WEST
,SwingConstants.NORTH
orSwingConstants.SOUTH
biasRet
- filled with the bias of the resulting location when method returns
- Returns:
- the location within the document that should be used to place the caret when moving the caret around the document
- Throws:
BadLocationException
- ifpos
is an invalid model locationIllegalArgumentException
- ifd
is invalid
public float getPartialSpan(int p0, int p1)
Returns the span of a portion of the view. This is used in TAB expansion for fragments that don't contain TABs.
- Specified by:
- getPartialSpan in interface TabableView
- Parameters:
p0
- the start indexp1
- the end index
- Returns:
- the span of the specified portion of the view
public float getPreferredSpan(int axis)
Returns the preferred span of the content managed by thisView
along the specifiedaxis
.
- Overrides:
- getPreferredSpan in interface View
- Parameters:
axis
- the axis
- Returns:
- the preferred span of this
View
.
public int getStartOffset()
Returns the start offset in the document model of the portion of text that this view is responsible for.
- Overrides:
- getStartOffset in interface View
- Returns:
- the start offset in the document model of the portion of text that this view is responsible for
public TabExpander getTabExpander()
Return theTabExpander
to use.
- Returns:
- the
TabExpander
to use
public float getTabbedSpan(float x, TabExpander te)
Returns the preferred span of this view for tab expansion.
- Specified by:
- getTabbedSpan in interface TabableView
- Parameters:
x
- the location of the viewte
- the tab expander to use
- Returns:
- the preferred span of this view for tab expansion
public Segment getText(int p0, int p1)
Returns the text segment that this view is responsible for.
- Parameters:
p0
- the start index in the document modelp1
- the end index in the document model
- Returns:
- the text segment that this view is responsible for
public void insertUpdate(DocumentEvent e, Shape a, ViewFactory vf)
Receives notification that some text has been inserted within the text fragment that this view is responsible for. This callsView.preferenceChanged(View,boolean,boolean)
for the direction in which the glyphs are rendered.
- Overrides:
- insertUpdate in interface View
- Parameters:
e
- the document event describing the change; not used herea
- the view allocation on screen; not used herevf
- the view factory; not used here
public boolean isStrikeThrough()
Determines whether the text should be rendered strike-through or not. This is determined using the methodStyleConstants.isStrikeThrough(AttributeSet)
on the element of this view.
- Returns:
- whether the text should be rendered strike-through or not
public boolean isSubscript()
Determines whether the text should be rendered as subscript or not. This is determined using the methodStyleConstants.isSubscript(AttributeSet)
on the element of this view.
- Returns:
- whether the text should be rendered as subscript or not
public boolean isSuperscript()
Determines whether the text should be rendered as superscript or not. This is determined using the methodStyleConstants.isSuperscript(AttributeSet)
on the element of this view.
- Returns:
- whether the text should be rendered as superscript or not
public boolean isUnderline()
Determines whether the text should be rendered as underlined or not. This is determined using the methodStyleConstants.isUnderline(AttributeSet)
on the element of this view.
- Returns:
- whether the text should be rendered as underlined or not
public Shape modelToView(int pos, Shape a, Position.Bias b) throws BadLocationException
Maps a position in the document into the coordinate space of the View. The output rectangle usually reflects the font height but has a width of zero.
- Overrides:
- modelToView in interface View
- Parameters:
pos
- the position of the character in the modela
- the area that is occupied by the viewb
- eitherPosition.Bias.Forward
orPosition.Bias.Backward
depending on the preferred direction bias. Ifnull
this defaults toPosition.Bias.Forward
- Returns:
- a rectangle that gives the location of the document position inside the view coordinate space
- Throws:
BadLocationException
- ifpos
is invalidIllegalArgumentException
- if b is not one of the above listed valid values
public void paint(Graphics g, Shape a)
Renders theElement
that is associated with thisView
.
- Parameters:
g
- theGraphics
context to render toa
- the allocated region for theElement
public void removeUpdate(DocumentEvent e, Shape a, ViewFactory vf)
Receives notification that some text has been removed within the text fragment that this view is responsible for. This callsView.preferenceChanged(View,boolean,boolean)
on the parent for width.
- Overrides:
- removeUpdate in interface View
- Parameters:
e
- the document event describing the change; not used herea
- the view allocation on screen; not used herevf
- the view factory; not used here
public void setGlyphPainter(GlyphView.GlyphPainter painter)
Sets theGlyphView.GlyphPainter
to be used for thisGlyphView
.
- Parameters:
painter
- the glyph painter to be used for this glyph view
public int viewToModel(float x, float y, Shape a, Position.Bias[] b)
Maps coordinates from theView
's space into a position in the document model.
- Overrides:
- viewToModel in interface View
- Parameters:
x
- the x coordinate in the view spacey
- the y coordinate in the view spacea
- the allocation of thisView
b
- the bias to use
- Returns:
- the position in the document that corresponds to the screen coordinates
x, y
GNU Classpath (0.95) |