FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
processing/app/src/processing/app/syntax/SyntaxStyle.java at master · processing/processing · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
processing
/
processing
Public
Uh oh!
There was an error while loading.
Please reload this page
.
Notifications
You must be signed in to change notification settings
Fork
1.5k
Star
6.5k
Code
Issues
0
Pull requests
0
Actions
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
processing
/
app
/
src
/
processing
/
app
/
syntax
/
SyntaxStyle.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
187 lines (170 loc) · 5.59 KB
Breadcrumbs
processing
/
app
/
src
/
processing
/
app
/
syntax
/
SyntaxStyle.java
Copy path
File metadata and controls
187 lines (170 loc) · 5.59 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
/*
* SyntaxStyle.java - A simple text style class
* Copyright (C) 1999 Slava Pestov
*
* You may use and modify this package for any purpose. Redistribution is
* permitted, in both source and binary form, provided that this notice
* remains intact in all source distributions of this package.
*/
package
processing
.
app
.
syntax
;
import
java
.
awt
.
Color
;
/**
* A simple text style class.
* It can specify the color and bold flag of a run of text.
* @author Slava Pestov
* @version $Id$
*/
public
class
SyntaxStyle
{
private
Color
color
;
// private boolean italic;
private
boolean
bold
;
// private Font lastFont;
// private Font lastStyledFont;
// private FontMetrics fontMetrics;
/**
* Creates a new SyntaxStyle.
* @param color The text color
* @param bold True if the text should be bold
*/
// * @param italic True if the text should be italics
// public SyntaxStyle(Color color, boolean italic, boolean bold) {
public
SyntaxStyle
(
Color
color
,
boolean
bold
) {
this
.
color
=
color
;
// this.italic = italic;
this
.
bold
=
bold
;
}
/** Returns the color specified in this style. */
public
Color
getColor
() {
return
color
;
}
// /**
// * Returns true if no font styles are enabled.
// */
// public boolean isPlain() {
// return !(bold || italic);
// }
// /**
// * Returns true if italics is enabled for this style.
// */
// public boolean isItalic() {
// return italic;
// }
/** Returns true if boldface is enabled for this style. */
public
boolean
isBold
() {
return
bold
;
}
// /**
// * Returns the specified font, but with the style's bold flags applied.
// */
// public Font getStyledFont(Font font) {
// if (font.equals(lastFont)) {
// return lastStyledFont;
// }
// lastFont = font;
// lastStyledFont =
// findFont(font.getFamily(), bold ? Font.BOLD : Font.PLAIN, font.getSize());
// return lastStyledFont;
// }
//
//
// /**
// * Returns the font metrics for the styled font.
// */
// public FontMetrics getFontMetrics(Font font, JComponent comp) {
//// if (font == null) {
//// throw new NullPointerException("font param must not be null");
//// }
// if (font.equals(lastFont) && fontMetrics != null) {
// return fontMetrics;
// }
// lastFont = font;
//// lastStyledFont = new Font(font.getFamily(),
//// (bold ? Font.BOLD : 0)
//// | (italic ? Font.ITALIC : 0),
//// font.getSize());
// lastStyledFont =
// findFont(font.getFamily(), bold ? Font.BOLD : Font.PLAIN, font.getSize());
//
// //fontMetrics = Toolkit.getDefaultToolkit().getFontMetrics(lastStyledFont);
// fontMetrics = comp.getFontMetrics(lastStyledFont);
// return fontMetrics;
// }
//
//
// /*
// on Windows (and I presume Linux) we get something like this:
//
// mono family Source Code Pro
// mono fontname Source Code Pro
// mono name Source Code Pro
// mono psname SourceCodePro-Regular
//
// mono family Source Code Pro Semibold
// mono fontname Source Code Pro Semibold
// mono name Source Code Pro Semibold
// mono psname SourceCodePro-Semibold
//
// ...which means that 'family' is not a usable method.
// */
// //private String monoFontFamily;
//
// private Font findFont(String familyName, int style, int size) {
//// // getFamily() is too unreliable across platforms
//// if (Preferences.get("editor.font").startsWith("processing.mono")) {
//// return processing.app.Toolkit.getMonoFont(size, style);
//// } else {
// System.out.println("creating new font for " + familyName);
// return new Font(familyName, style, size);
//// }
//
// /*
// if (monoFontFamily == null) {
// // This should be more reliable across platforms than the
// // family name, which only seems to work correctly on OS X.
// // (Or perhaps only when it's installed locally.)
// String psName =
// processing.app.Toolkit.getMonoFont(size, style).getPSName();
// int dash = psName.indexOf('-');
// monoFontFamily = psName.substring(0, dash);
//
// // Just get the font family name for comparison
// //monoFontFamily =
// //processing.app.Toolkit.getMonoFont(size, style).getFamily();
// //processing.app.Toolkit.getMonoFont(size, style).getFamily();
// Font mono = processing.app.Toolkit.getMonoFont(size, style);
// System.out.println("mono family " + mono.getFamily());
// System.out.println("mono fontname " + mono.getFontName());
// System.out.println("mono name " + mono.getName());
// System.out.println("mono psname " + mono.getPSName());
// }
// if (familyName.equals(monoFontFamily)) {
// System.out.println("getting style bold? " + (style == Font.BOLD));
// return processing.app.Toolkit.getMonoFont(size, style);
// } else {
// //System.out.println("name is " + name + " mono name is " + monoFontName + " " + style);
// return new Font(familyName, style, size);
// }
// */
// }
//
//
// /**
// * Sets the foreground color and font of the specified graphics
// * context to that specified in this style.
// * @param gfx The graphics context
// * @param font The font to add the styles to
// */
// public void setGraphicsFlags(Graphics gfx, Font font) {
// Font _font = getStyledFont(font);
// gfx.setFont(_font);
// gfx.setColor(color);
// }
/**
* Returns a string representation of this object.
*/
public
String
toString
() {
return
getClass
().
getName
() +
"[color="
+
color
+
// (italic ? ",italic" : "") +
(
bold
?
",bold"
:
""
) +
"]"
;
}
}
Back
|
FazBrowse Home
|
New Git URL