Package editor
Class GosuStyleContext
- java.lang.Object
-
- javax.swing.text.StyleContext
-
- editor.GosuStyleContext
-
- All Implemented Interfaces:
java.io.Serializable,javax.swing.text.AbstractDocument.AttributeContext,javax.swing.text.ViewFactory
public class GosuStyleContext extends javax.swing.text.StyleContext implements javax.swing.text.ViewFactoryA collection of styles used to render gosu source.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) classGosuStyleContext.GosuSourceViewView that uses the lexical information to determine the style characteristics of the text that it renders.
-
Field Summary
Fields Modifier and Type Field Description private java.util.HashMap<javax.swing.text.AttributeSet,java.awt.Font>_fontCacheprivate int_iFontSizeprivate java.lang.String_strFontFamilyprivate java.util.HashMap<java.lang.Integer,javax.swing.text.Style>_tokenStylesstatic java.lang.StringDASHEDstatic intDEFAULTstatic intDEPRECATEDstatic java.lang.IntegerDEPRECATED_KEYstatic intENHANCEMENT_METHOD_CALLstatic java.lang.IntegerENHANCEMENT_METHOD_CALL_KEYstatic intENHANCEMENT_PROPERTYstatic java.lang.IntegerENHANCEMENT_PROPERTY_KEYstatic intFIELD_ERRORstatic java.lang.IntegerFIELD_ERROR_KEYstatic intFIELD_WARNINGstatic java.lang.IntegerFIELD_WARNING_KEYprivate static java.lang.Stringg_defFontFamilyprivate static intg_defFontSizestatic intKEY_WORDstatic java.lang.IntegerKEY_WORD_KEYstatic intMETHOD_CALLstatic java.lang.IntegerMETHOD_CALL_KEYstatic intNESTED_TYPE_LITERALstatic java.lang.IntegerNESTED_TYPE_LITERAL_KEYstatic intPACKAGEstatic java.lang.IntegerPACKAGE_KEYstatic intPARSE_ERRORstatic java.lang.IntegerPARSE_ERROR_KEYstatic intPARSE_WARNINGstatic java.lang.IntegerPARSE_WARNING_KEYstatic intPROPERTYstatic java.lang.IntegerPROPERTY_KEYstatic java.lang.StringSTYLE_Caretstatic java.lang.StringSTYLE_Commentstatic java.lang.StringSTYLE_DeprecatedMemberstatic java.lang.StringSTYLE_EnhancementMethodCallstatic java.lang.StringSTYLE_EnhancementPropertystatic java.lang.StringSTYLE_EOFstatic java.lang.StringSTYLE_EOLstatic java.lang.StringSTYLE_FieldErrorstatic java.lang.StringSTYLE_FieldWarningstatic java.lang.StringSTYLE_Integerstatic java.lang.StringSTYLE_KeyWordstatic java.lang.StringSTYLE_MethodCallstatic java.lang.StringSTYLE_NestedTypeLiteralstatic java.lang.StringSTYLE_Numberstatic java.lang.StringSTYLE_Operatorstatic java.lang.StringSTYLE_ParseErrorstatic java.lang.StringSTYLE_ParseWarningstatic java.lang.StringSTYLE_Propertystatic java.lang.StringSTYLE_StringLiteralstatic java.lang.StringSTYLE_TypeLiteralstatic java.lang.StringSTYLE_Whitespacestatic java.lang.StringSTYLE_Wordprivate static java.awt.ComponentTHISISSTUPIDstatic intTYPE_LITERALstatic java.lang.IntegerTYPE_LITERAL_KEYstatic intUSESstatic java.lang.IntegerUSES_KEY
-
Constructor Summary
Constructors Constructor Description GosuStyleContext()Constructs a set of styles to represent gosu lexical tokens.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanareStylesEquivalent(java.lang.String styleName1, java.lang.String styleName2)javax.swing.text.Viewcreate(javax.swing.text.Element elem)java.awt.ColorgetBackground(int code)static java.lang.StringgetDefaultFontFamily()static intgetDefaultFontSize()java.awt.FontgetFont(int code)Fetch the font to use for a lexical token with the given scan value.java.awt.FontgetFont(javax.swing.text.AttributeSet attr)Fetch the font to use for a given attribute set.private java.awt.FontgetFont(javax.swing.text.AttributeSet attr, java.lang.String strFamily)java.lang.StringgetFontFamily()java.lang.StringgetFontFamily(javax.swing.text.AttributeSet a)intgetFontSize()java.awt.ColorgetForeground(int code)Fetch the foreground color to use for a lexical token with the given value.javax.swing.text.StylegetStyleForScanValue(int code)Fetches the attribute set to use for the given scan code.java.util.List<javax.swing.text.Style>getStyles()voidsetAttribute(javax.swing.text.Style style, java.lang.Object attr, java.lang.Object value)voidsetBackground(javax.swing.text.Style style, java.awt.Color colorBack)voidsetBold(javax.swing.text.Style style, boolean bBold)static voidsetDefaultFontFamily(java.lang.String defFontFamily)static voidsetDefaultFontSize(int defFontSize)voidsetDefaultStyles()voidsetFontFamily(java.lang.String strFamily)voidsetFontSize(int iSize)voidsetForeground(javax.swing.text.Style style, java.awt.Color colorFore)voidsetItalic(javax.swing.text.Style style, boolean bItalic)voidsetStrikeThrough(javax.swing.text.Style style, boolean bStrikeThrough)voidsetUnderline(javax.swing.text.Style style, boolean bUnderline)-
Methods inherited from class javax.swing.text.StyleContext
addAttribute, addAttributes, addChangeListener, addStyle, createLargeAttributeSet, createSmallAttributeSet, getBackground, getChangeListeners, getCompressionThreshold, getDefaultStyleContext, getEmptySet, getFont, getFontMetrics, getForeground, getStaticAttribute, getStaticAttributeKey, getStyle, getStyleNames, readAttributes, readAttributeSet, reclaim, registerStaticAttributeKey, removeAttribute, removeAttributes, removeAttributes, removeChangeListener, removeStyle, toString, writeAttributes, writeAttributeSet
-
-
-
-
Field Detail
-
KEY_WORD
public static final int KEY_WORD
- See Also:
- Constant Field Values
-
PARSE_ERROR
public static final int PARSE_ERROR
- See Also:
- Constant Field Values
-
DEPRECATED
public static final int DEPRECATED
- See Also:
- Constant Field Values
-
PARSE_WARNING
public static final int PARSE_WARNING
- See Also:
- Constant Field Values
-
TYPE_LITERAL
public static final int TYPE_LITERAL
- See Also:
- Constant Field Values
-
NESTED_TYPE_LITERAL
public static final int NESTED_TYPE_LITERAL
- See Also:
- Constant Field Values
-
METHOD_CALL
public static final int METHOD_CALL
- See Also:
- Constant Field Values
-
USES
public static final int USES
- See Also:
- Constant Field Values
-
DEFAULT
public static final int DEFAULT
- See Also:
- Constant Field Values
-
FIELD_ERROR
public static final int FIELD_ERROR
- See Also:
- Constant Field Values
-
FIELD_WARNING
public static final int FIELD_WARNING
- See Also:
- Constant Field Values
-
PACKAGE
public static final int PACKAGE
- See Also:
- Constant Field Values
-
PROPERTY
public static final int PROPERTY
- See Also:
- Constant Field Values
-
ENHANCEMENT_METHOD_CALL
public static final int ENHANCEMENT_METHOD_CALL
- See Also:
- Constant Field Values
-
ENHANCEMENT_PROPERTY
public static final int ENHANCEMENT_PROPERTY
- See Also:
- Constant Field Values
-
KEY_WORD_KEY
public static final java.lang.Integer KEY_WORD_KEY
-
PARSE_ERROR_KEY
public static final java.lang.Integer PARSE_ERROR_KEY
-
DEPRECATED_KEY
public static final java.lang.Integer DEPRECATED_KEY
-
TYPE_LITERAL_KEY
public static final java.lang.Integer TYPE_LITERAL_KEY
-
NESTED_TYPE_LITERAL_KEY
public static final java.lang.Integer NESTED_TYPE_LITERAL_KEY
-
PARSE_WARNING_KEY
public static final java.lang.Integer PARSE_WARNING_KEY
-
METHOD_CALL_KEY
public static final java.lang.Integer METHOD_CALL_KEY
-
PROPERTY_KEY
public static final java.lang.Integer PROPERTY_KEY
-
ENHANCEMENT_METHOD_CALL_KEY
public static final java.lang.Integer ENHANCEMENT_METHOD_CALL_KEY
-
ENHANCEMENT_PROPERTY_KEY
public static final java.lang.Integer ENHANCEMENT_PROPERTY_KEY
-
USES_KEY
public static final java.lang.Integer USES_KEY
-
PACKAGE_KEY
public static final java.lang.Integer PACKAGE_KEY
-
FIELD_ERROR_KEY
public static final java.lang.Integer FIELD_ERROR_KEY
-
FIELD_WARNING_KEY
public static final java.lang.Integer FIELD_WARNING_KEY
-
DASHED
public static final java.lang.String DASHED
- See Also:
- Constant Field Values
-
THISISSTUPID
private static final java.awt.Component THISISSTUPID
-
g_defFontFamily
private static java.lang.String g_defFontFamily
-
g_defFontSize
private static int g_defFontSize
-
STYLE_EOL
public static final java.lang.String STYLE_EOL
- See Also:
- Constant Field Values
-
STYLE_EOF
public static final java.lang.String STYLE_EOF
- See Also:
- Constant Field Values
-
STYLE_Whitespace
public static final java.lang.String STYLE_Whitespace
- See Also:
- Constant Field Values
-
STYLE_Comment
public static final java.lang.String STYLE_Comment
- See Also:
- Constant Field Values
-
STYLE_Caret
public static final java.lang.String STYLE_Caret
- See Also:
- Constant Field Values
-
STYLE_Number
public static final java.lang.String STYLE_Number
- See Also:
- Constant Field Values
-
STYLE_Integer
public static final java.lang.String STYLE_Integer
- See Also:
- Constant Field Values
-
STYLE_Word
public static final java.lang.String STYLE_Word
- See Also:
- Constant Field Values
-
STYLE_Operator
public static final java.lang.String STYLE_Operator
- See Also:
- Constant Field Values
-
STYLE_StringLiteral
public static final java.lang.String STYLE_StringLiteral
- See Also:
- Constant Field Values
-
STYLE_KeyWord
public static final java.lang.String STYLE_KeyWord
- See Also:
- Constant Field Values
-
STYLE_ParseError
public static final java.lang.String STYLE_ParseError
- See Also:
- Constant Field Values
-
STYLE_ParseWarning
public static final java.lang.String STYLE_ParseWarning
- See Also:
- Constant Field Values
-
STYLE_DeprecatedMember
public static final java.lang.String STYLE_DeprecatedMember
- See Also:
- Constant Field Values
-
STYLE_TypeLiteral
public static final java.lang.String STYLE_TypeLiteral
- See Also:
- Constant Field Values
-
STYLE_NestedTypeLiteral
public static final java.lang.String STYLE_NestedTypeLiteral
- See Also:
- Constant Field Values
-
STYLE_MethodCall
public static final java.lang.String STYLE_MethodCall
- See Also:
- Constant Field Values
-
STYLE_Property
public static final java.lang.String STYLE_Property
- See Also:
- Constant Field Values
-
STYLE_EnhancementMethodCall
public static final java.lang.String STYLE_EnhancementMethodCall
- See Also:
- Constant Field Values
-
STYLE_EnhancementProperty
public static final java.lang.String STYLE_EnhancementProperty
- See Also:
- Constant Field Values
-
STYLE_FieldError
public static final java.lang.String STYLE_FieldError
- See Also:
- Constant Field Values
-
STYLE_FieldWarning
public static final java.lang.String STYLE_FieldWarning
- See Also:
- Constant Field Values
-
_strFontFamily
private java.lang.String _strFontFamily
-
_iFontSize
private int _iFontSize
-
_fontCache
private java.util.HashMap<javax.swing.text.AttributeSet,java.awt.Font> _fontCache
-
_tokenStyles
private java.util.HashMap<java.lang.Integer,javax.swing.text.Style> _tokenStyles
-
-
Method Detail
-
setForeground
public void setForeground(javax.swing.text.Style style, java.awt.Color colorFore)
-
setBackground
public void setBackground(javax.swing.text.Style style, java.awt.Color colorBack)
-
setBold
public void setBold(javax.swing.text.Style style, boolean bBold)
-
setItalic
public void setItalic(javax.swing.text.Style style, boolean bItalic)
-
setUnderline
public void setUnderline(javax.swing.text.Style style, boolean bUnderline)
-
setStrikeThrough
public void setStrikeThrough(javax.swing.text.Style style, boolean bStrikeThrough)
-
setAttribute
public void setAttribute(javax.swing.text.Style style, java.lang.Object attr, java.lang.Object value)
-
setDefaultStyles
public void setDefaultStyles()
-
setDefaultFontFamily
public static void setDefaultFontFamily(java.lang.String defFontFamily)
-
getDefaultFontFamily
public static java.lang.String getDefaultFontFamily()
-
setDefaultFontSize
public static void setDefaultFontSize(int defFontSize)
-
getDefaultFontSize
public static int getDefaultFontSize()
-
getForeground
public java.awt.Color getForeground(int code)
Fetch the foreground color to use for a lexical token with the given value.
-
getBackground
public java.awt.Color getBackground(int code)
-
getFont
public java.awt.Font getFont(int code)
Fetch the font to use for a lexical token with the given scan value.
-
getStyleForScanValue
public javax.swing.text.Style getStyleForScanValue(int code)
Fetches the attribute set to use for the given scan code. The set is stored in a table to facilitate relatively fast access to use in conjunction with the scanner.
-
getFont
public java.awt.Font getFont(javax.swing.text.AttributeSet attr)
Fetch the font to use for a given attribute set.- Overrides:
getFontin classjavax.swing.text.StyleContext
-
getFont
private java.awt.Font getFont(javax.swing.text.AttributeSet attr, java.lang.String strFamily)
-
getFontFamily
public java.lang.String getFontFamily(javax.swing.text.AttributeSet a)
-
getFontFamily
public java.lang.String getFontFamily()
-
setFontFamily
public void setFontFamily(java.lang.String strFamily)
-
getFontSize
public int getFontSize()
-
setFontSize
public void setFontSize(int iSize)
-
create
public javax.swing.text.View create(javax.swing.text.Element elem)
- Specified by:
createin interfacejavax.swing.text.ViewFactory
-
getStyles
public java.util.List<javax.swing.text.Style> getStyles()
-
areStylesEquivalent
public boolean areStylesEquivalent(java.lang.String styleName1, java.lang.String styleName2)
-
-