FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
processing/app/src/processing/app/ui/EditorStatus.java at master · 2php/processing · GitHub
2php
processing
Repository navigation
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
processing
/
app
/
src
/
processing
/
app
/
ui
/
EditorStatus.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
303 lines (236 loc) · 7.19 KB
Breadcrumbs
processing
/
app
/
src
/
processing
/
app
/
ui
/
EditorStatus.java
Copy path
File metadata and controls
303 lines (236 loc) · 7.19 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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
Part of the Processing project - http://processing.org
Copyright (c) 2012-15 The Processing Foundation
Copyright (c) 2004-12 Ben Fry and Casey Reas
Copyright (c) 2001-04 Massachusetts Institute of Technology
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package
processing
.
app
.
ui
;
import
java
.
awt
.
Color
;
import
java
.
awt
.
Cursor
;
import
java
.
awt
.
Dimension
;
import
java
.
awt
.
Font
;
import
java
.
awt
.
FontMetrics
;
import
java
.
awt
.
Graphics
;
import
java
.
awt
.
Image
;
import
java
.
awt
.
event
.
MouseAdapter
;
import
java
.
awt
.
event
.
MouseEvent
;
import
javax
.
swing
.
plaf
.
basic
.
BasicSplitPaneDivider
;
import
javax
.
swing
.
plaf
.
basic
.
BasicSplitPaneUI
;
import
processing
.
app
.
Mode
;
import
processing
.
app
.
Platform
;
import
processing
.
core
.
PApplet
;
/**
* Panel just below the editing area that contains status messages.
*/
public
class
EditorStatus
extends
BasicSplitPaneDivider
{
//JPanel {
static
final
int
HIGH
=
28
;
static
final
int
LEFT_MARGIN
=
Editor
.
LEFT_GUTTER
;
static
final
int
RIGHT_MARGIN
=
20
;
Color
[]
fgColor
;
Color
[]
bgColor
;
Image
[]
bgImage
;
@
SuppressWarnings
(
"hiding"
)
static
public
final
int
ERROR
=
1
;
static
public
final
int
CURSOR_LINE_ERROR
=
2
;
static
public
final
int
WARNING
=
3
;
static
public
final
int
CURSOR_LINE_WARNING
=
4
;
static
public
final
int
NOTICE
=
0
;
static
final
int
YES
=
1
;
static
final
int
NO
=
2
;
static
final
int
CANCEL
=
3
;
static
final
int
OK
=
4
;
static
final
String
NO_MESSAGE
=
""
;
Editor
editor
;
int
mode
;
String
message
;
String
url
;
Font
font
;
FontMetrics
metrics
;
int
ascent
;
Image
offscreen
;
int
sizeW
,
sizeH
;
// JButton cancelButton;
// JButton okButton;
// JTextField editField;
int
response
;
boolean
indeterminate
;
Thread
thread
;
public
EditorStatus
(
BasicSplitPaneUI
ui
,
Editor
editor
) {
super
(
ui
);
this
.
editor
=
editor
;
empty
();
updateMode
();
addMouseListener
(
new
MouseAdapter
() {
public
void
mouseEntered
(
MouseEvent
e
) {
if
(
url
!=
null
) {
setCursor
(
Cursor
.
getPredefinedCursor
(
Cursor
.
HAND_CURSOR
));
}
}
public
void
mousePressed
(
MouseEvent
e
) {
if
(
url
!=
null
) {
Platform
.
openURL
(
url
);
}
}
});
}
static
String
findURL
(
String
message
) {
String
[]
m
=
PApplet
.
match
(
message
,
"http
\\
S+"
);
if
(
m
!=
null
) {
return
m
[
0
];
}
return
null
;
}
public
void
updateMode
() {
Mode
mode
=
editor
.
getMode
();
fgColor
=
new
Color
[] {
mode
.
getColor
(
"status.notice.fgcolor"
),
mode
.
getColor
(
"status.error.fgcolor"
),
mode
.
getColor
(
"status.error.fgcolor"
),
mode
.
getColor
(
"status.warning.fgcolor"
),
mode
.
getColor
(
"status.warning.fgcolor"
)
};
bgColor
=
new
Color
[] {
mode
.
getColor
(
"status.notice.bgcolor"
),
mode
.
getColor
(
"status.error.bgcolor"
),
mode
.
getColor
(
"status.error.bgcolor"
),
mode
.
getColor
(
"status.warning.bgcolor"
),
mode
.
getColor
(
"status.warning.bgcolor"
)
};
bgImage
=
new
Image
[] {
mode
.
loadImage
(
"/lib/status/notice.png"
),
mode
.
loadImage
(
"/lib/status/error.png"
),
mode
.
loadImage
(
"/lib/status/error.png"
),
mode
.
loadImage
(
"/lib/status/warning.png"
),
mode
.
loadImage
(
"/lib/status/warning.png"
)
};
font
=
mode
.
getFont
(
"status.font"
);
metrics
=
null
;
}
public
void
empty
() {
mode
=
NOTICE
;
message
=
NO_MESSAGE
;
url
=
null
;
repaint
();
}
public
void
message
(
String
message
,
int
mode
) {
this
.
message
=
message
;
this
.
mode
=
mode
;
url
=
findURL
(
message
);
repaint
();
}
public
void
notice
(
String
message
) {
message
(
message
,
NOTICE
);
// mode = NOTICE;
// this.message = message;
// url = findURL(message);
// repaint();
}
// public void unnotice(String unmessage) {
// if (message.equals(unmessage)) empty();
// }
public
void
warning
(
String
message
) {
message
(
message
,
WARNING
);
// this.message = message;
// mode = WARNING;
// url = findURL(message);
// repaint();
}
public
void
error
(
String
message
) {
message
(
message
,
ERROR
);
// this.message = message;
// mode = ERROR;
// url = findURL(message);
// repaint();
}
public
void
startIndeterminate
() {
indeterminate
=
true
;
thread
=
new
Thread
() {
public
void
run
() {
while
(
Thread
.
currentThread
() ==
thread
) {
repaint
();
try
{
Thread
.
sleep
(
1000
/
10
);
}
catch
(
InterruptedException
e
) { }
}
}
};
thread
.
setName
(
"Editor Status"
);
thread
.
start
();
}
public
void
stopIndeterminate
() {
indeterminate
=
false
;
thread
=
null
;
repaint
();
}
//public void paintComponent(Graphics screen) {
public
void
paint
(
Graphics
screen
) {
// if (okButton == null) setup();
Dimension
size
=
getSize
();
if
((
size
.
width
!=
sizeW
) || (
size
.
height
!=
sizeH
)) {
// component has been resized
offscreen
=
null
;
}
if
(
offscreen
==
null
) {
sizeW
=
size
.
width
;
sizeH
=
size
.
height
;
// setButtonBounds();
if
(
Toolkit
.
highResDisplay
()) {
offscreen
=
createImage
(
sizeW
*
2
,
sizeH
*
2
);
}
else
{
offscreen
=
createImage
(
sizeW
,
sizeH
);
}
}
Graphics
g
=
offscreen
.
getGraphics
();
/*Graphics2D g2 =*/
Toolkit
.
prepareGraphics
(
g
);
g
.
setFont
(
font
);
if
(
metrics
==
null
) {
metrics
=
g
.
getFontMetrics
();
ascent
=
metrics
.
getAscent
();
}
//g.setColor(bgColor[mode]);
//g.fillRect(0, 0, sizeW, sizeH);
g
.
drawImage
(
bgImage
[
mode
],
0
,
0
,
sizeW
,
sizeH
,
this
);
g
.
setColor
(
fgColor
[
mode
]);
// https://github.com/processing/processing/issues/3265
if
(
message
!=
null
) {
g
.
setFont
(
font
);
// needs to be set each time on osx
g
.
drawString
(
message
,
LEFT_MARGIN
, (
sizeH
+
ascent
) /
2
);
}
if
(
indeterminate
) {
//int x = cancelButton.getX();
//int w = cancelButton.getWidth();
int
w
=
Toolkit
.
getButtonWidth
();
int
x
=
getWidth
() -
RIGHT_MARGIN
-
w
;
int
y
=
getHeight
() /
3
;
int
h
=
getHeight
() /
3
;
g
.
setColor
(
new
Color
(
0x80000000
,
true
));
g
.
drawRect
(
x
,
y
,
w
,
h
);
for
(
int
i
=
0
;
i
<
10
;
i
++) {
int
r
= (
int
) (
x
+
Math
.
random
() *
w
);
g
.
drawLine
(
r
,
y
,
r
,
y
+
h
);
}
}
screen
.
drawImage
(
offscreen
,
0
,
0
,
sizeW
,
sizeH
,
null
);
}
public
Dimension
getPreferredSize
() {
return
getMinimumSize
();
}
public
Dimension
getMinimumSize
() {
return
new
Dimension
(
300
,
HIGH
);
}
public
Dimension
getMaximumSize
() {
return
new
Dimension
(
super
.
getMaximumSize
().
width
,
HIGH
);
}
}
Back
|
FazBrowse Home
|
New Git URL