com.borland.primetime.editor
Class EditorView
java.lang.Object
|
+--javax.swing.text.View
|
+--javax.swing.text.PlainView
|
+--com.borland.primetime.editor.EditorView
- public class EditorView
- extends javax.swing.text.PlainView
This is the editor view for the PrimeTime editor. The view is responsible
for rendering the editing surface, including the text and any syntax
highlighting or marked lines present.
The EditorView works in conjunctions with an EditorDocument, reading the
special information stored within.
Field Summary |
protected int |
sel0
|
protected int |
sel1
|
Fields inherited from class javax.swing.text.PlainView |
metrics |
Fields inherited from class javax.swing.text.View |
BadBreakWeight,
ExcellentBreakWeight,
ForcedBreakWeight,
GoodBreakWeight,
X_AXIS,
Y_AXIS |
Constructor Summary |
EditorView(javax.swing.text.Element elem)
|
Method Summary |
void |
changedUpdate(javax.swing.event.DocumentEvent changes,
java.awt.Shape a,
javax.swing.text.ViewFactory f)
We override this because we need to call our own updateDamage method. |
protected void |
damageLineRange(int line0,
int line1,
java.awt.Shape a,
java.awt.Component host)
This is copied from PlainView because it isn't accessible there. |
protected void |
drawLine(int lineIndex,
java.awt.Graphics g,
int x,
int y)
Renders a line of text, suppressing whitespace at the end
and exanding any tabs. |
protected int |
drawSelectedText(java.awt.Graphics g,
EditorDocument.StyledLeafElement line,
java.awt.Color textColor,
java.awt.Color selectColor,
int x,
int y,
int p0,
int p1)
|
protected int |
drawSelectedText(java.awt.Graphics g,
EditorDocument.StyledLeafElement line,
int x,
int y,
int p0,
int p1)
|
protected int |
drawUnselectedText(java.awt.Graphics g,
EditorDocument.StyledLeafElement line,
int x,
int y,
int p0,
int p1)
|
protected int |
getTabSize()
Returns the tab size to use to render this document. |
void |
insertUpdate(javax.swing.event.DocumentEvent changes,
java.awt.Shape a,
javax.swing.text.ViewFactory f)
We override this because we need to call our own updateDamage method. |
protected java.awt.Rectangle |
lineToRect(java.awt.Shape a,
int line)
This is copied from PlainView because it isn't accessible there. |
void |
paint(java.awt.Graphics g,
java.awt.Shape a)
Renders using the given rendering surface and area on that surface. |
void |
removeUpdate(javax.swing.event.DocumentEvent changes,
java.awt.Shape a,
javax.swing.text.ViewFactory f)
We override this because we need to call our own updateDamage method. |
protected void |
updateDamage(javax.swing.event.DocumentEvent changes,
java.awt.Shape a,
javax.swing.text.ViewFactory f)
This is copied from PlainView because it isn't accessible there. |
Methods inherited from class javax.swing.text.PlainView |
drawSelectedText,
drawUnselectedText,
getLineBuffer,
getPreferredSpan,
modelToView,
nextTabStop,
preferenceChanged,
viewToModel |
Methods inherited from class javax.swing.text.View |
breakView,
createFragment,
getAlignment,
getAttributes,
getBreakWeight,
getChildAllocation,
getContainer,
getDocument,
getElement,
getEndOffset,
getMaximumSpan,
getMinimumSpan,
getNextVisualPositionFrom,
getParent,
getResizeWeight,
getStartOffset,
getView,
getViewCount,
getViewFactory,
isVisible,
modelToView,
modelToView,
setParent,
setSize,
viewToModel |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
sel0
protected int sel0
sel1
protected int sel1
EditorView
public EditorView(javax.swing.text.Element elem)
paint
public void paint(java.awt.Graphics g,
java.awt.Shape a)
- Renders using the given rendering surface and area on that surface.
The view may need to do layout and create child views to enable
itself to render into the given allocation.
- Overrides:
- paint in class javax.swing.text.PlainView
- Parameters:
g
- the rendering surface to usea
- the allocated region to render into- See Also:
View.paint(java.awt.Graphics, java.awt.Shape)
drawLine
protected void drawLine(int lineIndex,
java.awt.Graphics g,
int x,
int y)
- Renders a line of text, suppressing whitespace at the end
and exanding any tabs. This is implemented to make calls
to the methods
drawUnselectedText
and
drawSelectedText
so that the way selected and
unselected text are rendered can be customized.
- Overrides:
- drawLine in class javax.swing.text.PlainView
drawSelectedText
protected int drawSelectedText(java.awt.Graphics g,
EditorDocument.StyledLeafElement line,
int x,
int y,
int p0,
int p1)
throws javax.swing.text.BadLocationException
drawSelectedText
protected int drawSelectedText(java.awt.Graphics g,
EditorDocument.StyledLeafElement line,
java.awt.Color textColor,
java.awt.Color selectColor,
int x,
int y,
int p0,
int p1)
throws javax.swing.text.BadLocationException
drawUnselectedText
protected int drawUnselectedText(java.awt.Graphics g,
EditorDocument.StyledLeafElement line,
int x,
int y,
int p0,
int p1)
throws javax.swing.text.BadLocationException
insertUpdate
public void insertUpdate(javax.swing.event.DocumentEvent changes,
java.awt.Shape a,
javax.swing.text.ViewFactory f)
- We override this because we need to call our own updateDamage method.
- Overrides:
- insertUpdate in class javax.swing.text.PlainView
removeUpdate
public void removeUpdate(javax.swing.event.DocumentEvent changes,
java.awt.Shape a,
javax.swing.text.ViewFactory f)
- We override this because we need to call our own updateDamage method.
- Overrides:
- removeUpdate in class javax.swing.text.PlainView
changedUpdate
public void changedUpdate(javax.swing.event.DocumentEvent changes,
java.awt.Shape a,
javax.swing.text.ViewFactory f)
- We override this because we need to call our own updateDamage method.
- Overrides:
- changedUpdate in class javax.swing.text.PlainView
updateDamage
protected void updateDamage(javax.swing.event.DocumentEvent changes,
java.awt.Shape a,
javax.swing.text.ViewFactory f)
- This is copied from PlainView because it isn't accessible there.
We don't call updateMetrics() because the font is stored in the individual
styles. We also don't bother with the mess of longest line checks that
PlainView does because we don't care.
Whenever we receive a change, we damage the line range from the start
of the range to the end of the range. If lines are added or removed, we
will damage the whole view.
damageLineRange
protected void damageLineRange(int line0,
int line1,
java.awt.Shape a,
java.awt.Component host)
- This is copied from PlainView because it isn't accessible there.
lineToRect
protected java.awt.Rectangle lineToRect(java.awt.Shape a,
int line)
- This is copied from PlainView because it isn't accessible there.
getTabSize
protected int getTabSize()
- Returns the tab size to use to render this document. PlainView gets this
from the Document itself, but we'll get it from the EditorManager.
- Overrides:
- getTabSize in class javax.swing.text.PlainView
- Returns:
- the tab size