Package editor
Class GosuStyleContext.GosuSourceView
- java.lang.Object
-
- javax.swing.text.View
-
- javax.swing.text.CompositeView
-
- javax.swing.text.BoxView
-
- javax.swing.text.WrappedPlainView
-
- editor.GosuStyleContext.GosuSourceView
-
- All Implemented Interfaces:
javax.swing.SwingConstants,javax.swing.text.TabExpander
- Enclosing class:
- GosuStyleContext
class GosuStyleContext.GosuSourceView extends javax.swing.text.WrappedPlainViewView that uses the lexical information to determine the style characteristics of the text that it renders. This simply colorizes the various tokens and assumes a constant font family and size.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) GosuDocument.Scanner_lexer
-
Constructor Summary
Constructors Constructor Description GosuSourceView(javax.swing.text.Element elem)Construct a simple syntax highlight view of gosu source.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected intdrawSelectedText(java.awt.Graphics g, int x, int y, int p0, int p1)Renders the given range in the model as normal unselected text.intdrawTabbedText(javax.swing.text.Segment s, javax.swing.text.Style style, java.awt.Font font, int x, int y, java.awt.Graphics2D g, javax.swing.text.TabExpander e, int startOffset)voiddrawText(java.awt.Graphics2D g2, javax.swing.text.Style style, java.awt.Font font, java.lang.String text, int x, int y)Draws text using a TextLayout.protected intdrawUnselectedText(java.awt.Graphics g, int x, int y, int p0, int p1)voidpaint(java.awt.Graphics g, java.awt.Shape a)Renders using the given rendering surface and area on that surface.(package private) voidupdateScanner(int p)Update the scanner (if necessary) to point to the appropriate token for the given start position needed for rendering.-
Methods inherited from class javax.swing.text.WrappedPlainView
calculateBreakPosition, changedUpdate, drawLine, drawLine, drawSelectedText, drawUnselectedText, getLineBuffer, getMaximumSpan, getMinimumSpan, getPreferredSpan, getTabSize, insertUpdate, loadChildren, nextTabStop, removeUpdate, setSize
-
Methods inherited from class javax.swing.text.BoxView
baselineLayout, baselineRequirements, calculateMajorAxisRequirements, calculateMinorAxisRequirements, childAllocation, flipEastAndWestAtEnds, forwardUpdate, getAlignment, getAxis, getChildAllocation, getHeight, getOffset, getResizeWeight, getSpan, getViewAtPoint, getWidth, isAfter, isAllocationValid, isBefore, isLayoutValid, layout, layoutChanged, layoutMajorAxis, layoutMinorAxis, modelToView, paintChild, preferenceChanged, replace, setAxis, viewToModel
-
Methods inherited from class javax.swing.text.CompositeView
getBottomInset, getInsideAllocation, getLeftInset, getNextEastWestVisualPositionFrom, getNextNorthSouthVisualPositionFrom, getNextVisualPositionFrom, getRightInset, getTopInset, getView, getViewAtPosition, getViewCount, getViewIndex, getViewIndexAtPosition, modelToView, setInsets, setParagraphInsets, setParent
-
Methods inherited from class javax.swing.text.View
append, breakView, createFragment, forwardUpdateToView, getAttributes, getBreakWeight, getContainer, getDocument, getElement, getEndOffset, getGraphics, getParent, getStartOffset, getToolTipText, getViewFactory, getViewIndex, insert, isVisible, modelToView, remove, removeAll, updateChildren, updateLayout, viewToModel
-
-
-
-
Field Detail
-
_lexer
GosuDocument.Scanner _lexer
-
-
Method Detail
-
paint
public void paint(java.awt.Graphics g, java.awt.Shape a)Renders using the given rendering surface and area on that surface. This is implemented to invalidate the lexical scanner after rendering so that the next request to drawUnselectedText will set a new range for the scanner.- Overrides:
paintin classjavax.swing.text.WrappedPlainView- Parameters:
g- The rendering surface to usea- The allocated region to render into
-
drawSelectedText
protected int drawSelectedText(java.awt.Graphics g, int x, int y, int p0, int p1) throws javax.swing.text.BadLocationExceptionRenders the given range in the model as normal unselected text. This is implemented to paint colors based upon the token-to-color translations. To reduce the number of calls to the Graphics object, text is batched up until a color change is detected or the entire requested range has been reached.- Overrides:
drawSelectedTextin classjavax.swing.text.WrappedPlainView- Parameters:
g- The graphics contextx- The starting X coordinatey- The starting Y coordinatep0- The beginning position in the modelp1- The ending position in the model- Returns:
- The location of the end of the range
- Throws:
javax.swing.text.BadLocationException- if the range is invalid
-
drawUnselectedText
protected int drawUnselectedText(java.awt.Graphics g, int x, int y, int p0, int p1) throws javax.swing.text.BadLocationException- Overrides:
drawUnselectedTextin classjavax.swing.text.WrappedPlainView- Throws:
javax.swing.text.BadLocationException
-
updateScanner
void updateScanner(int p)
Update the scanner (if necessary) to point to the appropriate token for the given start position needed for rendering.
-
drawTabbedText
public final int drawTabbedText(javax.swing.text.Segment s, javax.swing.text.Style style, java.awt.Font font, int x, int y, java.awt.Graphics2D g, javax.swing.text.TabExpander e, int startOffset)
-
drawText
public final void drawText(java.awt.Graphics2D g2, javax.swing.text.Style style, java.awt.Font font, java.lang.String text, int x, int y)Draws text using a TextLayout. This method of drawing text is necessary to support certain attribute esp. TextAttribute.UNDERLINE and TextAttribute.STRIKETHROUGH .
-
-