com.borland.primetime.editor
Class EditorView.DrawTextSegment

java.lang.Object
  |
  +--com.borland.primetime.editor.EditorView.DrawTextSegment
Enclosing class:
EditorView

protected class EditorView.DrawTextSegment
extends java.lang.Object

A protected class to help drawing a line of text. It will coalesce equivalent drawing into one call to draw the text. flush() must be after all segments have been added.


Field Summary
 java.awt.Color bgColor
           
 EditorDocument doc
           
 java.awt.Font font
           
 java.awt.Graphics g
           
 EditorPane host
           
 int p0
           
 int p1
           
 BasicStyleMap styleMap
           
 java.awt.Color textColor
           
 EditorView view
           
 boolean whiteSpace
           
 int x
           
 int y
           
 
Constructor Summary
EditorView.DrawTextSegment(java.awt.Graphics g, int x, int y, EditorPane host, EditorDocument doc, BasicStyleMap styleMap, EditorView view)
          Create a DrawTextSegment to draw on the given canvas and the given location.
 
Method Summary
 void addSegment(java.awt.Color textColor, java.awt.Color bgColor, java.awt.Font font, int p0, int p1, boolean whiteSpace)
          Add a segment of text to draw.
protected  int flush()
          Draw all pending segments
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

g

public java.awt.Graphics g

x

public int x

y

public int y

host

public EditorPane host

doc

public EditorDocument doc

styleMap

public BasicStyleMap styleMap

view

public EditorView view

textColor

public java.awt.Color textColor

bgColor

public java.awt.Color bgColor

font

public java.awt.Font font

p0

public int p0

p1

public int p1

whiteSpace

public boolean whiteSpace
Constructor Detail

EditorView.DrawTextSegment

public EditorView.DrawTextSegment(java.awt.Graphics g,
                                  int x,
                                  int y,
                                  EditorPane host,
                                  EditorDocument doc,
                                  BasicStyleMap styleMap,
                                  EditorView view)
Create a DrawTextSegment to draw on the given canvas and the given location.
Parameters:
g - the graphic to draw upon.
x - the x location to start drawing the segments
y - the y location to draw the segments
Method Detail

addSegment

public void addSegment(java.awt.Color textColor,
                       java.awt.Color bgColor,
                       java.awt.Font font,
                       int p0,
                       int p1,
                       boolean whiteSpace)
                throws javax.swing.text.BadLocationException
Add a segment of text to draw. If the segment is different than previous calls it will flush the segments previously added
Parameters:
textColor - the color to draw the text (must not be null).
bgColor - the color to draw the background (must not be null).
font - the font to draw the text in ((must not be null).
p0 - buffer position to start drawing from.
p1 - buffer position to stop drawing
whiteSpace - true if the buffer represents white space

flush

protected int flush()
             throws javax.swing.text.BadLocationException
Draw all pending segments
Returns:
the x location after all the segments have been drawn