FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
processing/app/src/processing/app/contrib/Contribution.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
/
contrib
/
Contribution.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
332 lines (254 loc) · 8.37 KB
Breadcrumbs
processing
/
app
/
src
/
processing
/
app
/
contrib
/
Contribution.java
Copy path
File metadata and controls
332 lines (254 loc) · 8.37 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
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
Part of the Processing project - http://processing.org
Copyright (c) 2013-15 The Processing Foundation
Copyright (c) 2011-12 Ben Fry and Casey Reas
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2
as published by the Free Software Foundation.
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
.
contrib
;
import
java
.
io
.
File
;
import
java
.
util
.
Arrays
;
import
java
.
util
.
List
;
import
processing
.
core
.
PApplet
;
import
processing
.
data
.
StringDict
;
import
processing
.
data
.
StringList
;
import
processing
.
app
.
Language
;
import
processing
.
app
.
Util
;
abstract
public
class
Contribution
{
static
final
String
IMPORTS_PROPERTY
=
"imports"
;
static
final
String
CATEGORIES_PROPERTY
=
"categories"
;
static
final
String
MODES_PROPERTY
=
"modes"
;
static
final
String
AUTHORS_PROPERTY
=
"authors"
;
static
final
String
SPECIAL_CATEGORY
=
"Starred"
;
static
final
String
UNKNOWN_CATEGORY
=
"Unknown"
;
static
final
List
validCategories
=
Arrays
.
asList
(
"3D"
,
"Animation"
,
"Data"
,
"Geometry"
,
"GUI"
,
"Hardware"
,
"I/O"
,
"Math"
,
"Simulation"
,
"Sound"
,
SPECIAL_CATEGORY
,
"Typography"
,
"Utilities"
,
"Video & Vision"
,
"Other"
);
static
final
String
FOUNDATION_AUTHOR
=
"The Processing Foundation"
;
protected
StringList
categories
;
// "Sound", "Typography"
protected
String
name
;
// "pdf" or "PDF Export"
protected
String
authors
;
// [Ben Fry](http://benfry.com)
protected
String
url
;
// http://processing.org
protected
String
sentence
;
// Write graphics to PDF files.
protected
String
paragraph
;
// <paragraph length description for site>
protected
int
version
;
// 102
protected
String
prettyVersion
;
// "1.0.2"
protected
long
lastUpdated
;
// 1402805757
protected
int
minRevision
;
// 0
protected
int
maxRevision
;
// 227
protected
StringList
imports
;
// pdf.export,pdf.convert.common (list of packages, not imports)
// "Sound", "Utilities"... see valid list in ContributionListing
protected
StringList
getCategories
() {
return
categories
;
}
protected
String
getCategoryStr
() {
StringBuilder
sb
=
new
StringBuilder
();
for
(
String
category
:
categories
) {
sb
.
append
(
category
);
sb
.
append
(
','
);
}
sb
.
deleteCharAt
(
sb
.
length
()-
1
);
// delete last comma
return
sb
.
toString
();
}
protected
boolean
hasCategory
(
String
category
) {
if
(
category
!=
null
) {
for
(
String
c
:
categories
) {
if
(
category
.
equalsIgnoreCase
(
c
)) {
return
true
;
}
}
}
return
false
;
}
// pdf.export.*,pdf.convert.common.*
protected
StringList
getImports
() {
return
imports
;
}
/*
protected String getImportStr() {
if (imports == null || imports.isEmpty()) {
return "";
}
StringBuilder sb = new StringBuilder();
for (String importName : imports) {
sb.append(importName);
sb.append(',');
}
sb.deleteCharAt(sb.length() - 1); // delete last comma
return sb.toString();
}
*/
protected
boolean
hasImport
(
String
importName
) {
if
(
imports
!=
null
&&
importName
!=
null
) {
for
(
String
c
:
imports
) {
if
(
importName
.
equals
(
c
)) {
return
true
;
}
}
}
return
false
;
}
// "pdf" or "PDF Export"
public
String
getName
() {
return
name
;
}
// "[Ben Fry](http://benfry.com/)"
public
String
getAuthorList
() {
return
authors
;
}
// "http://processing.org"
public
String
getUrl
() {
return
url
;
}
// "Write graphics to PDF files."
public
String
getSentence
() {
return
sentence
;
}
// <paragraph length description for site>
public
String
getParagraph
() {
return
paragraph
;
}
// 102
public
int
getVersion
() {
return
version
;
}
// "1.0.2"
public
String
getPrettyVersion
() {
return
prettyVersion
;
}
// 1402805757
public
long
getLastUpdated
() {
return
lastUpdated
;
}
// 0
public
int
getMinRevision
() {
return
minRevision
;
}
// 227
public
int
getMaxRevision
() {
return
maxRevision
;
}
public
boolean
isCompatible
(
int
versionNum
) {
return
((
maxRevision
==
0
||
versionNum
<=
maxRevision
) &&
versionNum
>=
minRevision
);
}
abstract
public
ContributionType
getType
();
public
String
getTypeName
() {
return
getType
().
toString
();
}
abstract
public
boolean
isInstalled
();
// /**
// * Returns true if the type of contribution requires the PDE to restart
// * when being added or removed.
// */
// public boolean requiresRestart() {
// return getType() == ContributionType.TOOL || getType() == ContributionType.MODE;
// }
boolean
isRestartFlagged
() {
return
false
;
}
/** Overridden by LocalContribution. */
boolean
isDeletionFlagged
() {
return
false
;
}
boolean
isUpdateFlagged
() {
return
false
;
}
/**
* Returns true if the contribution is a starred/recommended contribution,
* or is by the Processing Foundation.
*/
boolean
isSpecial
() {
if
(
authors
!=
null
&&
authors
.
contains
(
FOUNDATION_AUTHOR
)) {
return
true
;
}
if
(
categories
!=
null
&&
categories
.
hasValue
(
SPECIAL_CATEGORY
)) {
return
true
;
}
return
false
;
}
public
boolean
isFoundation
() {
return
FOUNDATION_AUTHOR
.
equals
(
authors
);
}
public
StringDict
loadProperties
(
File
contribFolder
) {
return
loadProperties
(
contribFolder
,
getType
());
}
static
public
StringDict
loadProperties
(
File
contribFolder
,
ContributionType
type
) {
File
propertiesFile
=
new
File
(
contribFolder
,
type
.
getPropertiesName
());
if
(
propertiesFile
.
exists
()) {
return
Util
.
readSettings
(
propertiesFile
);
}
return
null
;
}
/**
* @return a single element list with "Unknown" as the category.
*/
static
StringList
unknownCategoryList
() {
return
new
StringList
(
UNKNOWN_CATEGORY
);
}
/**
* @return the list of categories that this contribution is part of
* (e.g. "Typography / Geometry"). "Unknown" if the category null.
*/
static
StringList
parseCategories
(
StringDict
properties
) {
StringList
outgoing
=
new
StringList
();
String
categoryStr
=
properties
.
get
(
CATEGORIES_PROPERTY
);
if
(
categoryStr
==
null
) {
categoryStr
=
properties
.
get
(
"category"
);
// try the old way
}
if
(
categoryStr
!=
null
) {
// Can't use splitTokens() because the names sometimes have spaces
String
[]
listing
=
PApplet
.
trim
(
PApplet
.
split
(
categoryStr
,
','
));
for
(
String
category
:
listing
) {
if
(
validCategories
.
contains
(
category
)) {
category
=
translateCategory
(
category
);
outgoing
.
append
(
category
);
}
}
}
if
(
outgoing
.
size
() ==
0
) {
return
unknownCategoryList
();
}
return
outgoing
;
}
/**
* Returns the list of imports specified by this library author. Only
* necessary for library authors that want to override the default behavior
* of importing all packages in their library.
* @return null if no entries found
*/
static
StringList
parseImports
(
StringDict
properties
) {
StringList
outgoing
=
new
StringList
();
String
importStr
=
properties
.
get
(
IMPORTS_PROPERTY
);
if
(
importStr
!=
null
) {
String
[]
importList
=
PApplet
.
trim
(
PApplet
.
split
(
importStr
,
','
));
for
(
String
importName
:
importList
) {
if
(!
importName
.
isEmpty
()) {
outgoing
.
append
(
importName
);
}
}
}
return
(
outgoing
.
size
() >
0
) ?
outgoing
:
null
;
}
static
private
String
translateCategory
(
String
cat
) {
// Converts Other to other, I/O to i_o, Video & Vision to video_vision
String
cleaned
=
cat
.
replaceAll
(
"[
\\
W]+"
,
"_"
).
toLowerCase
();
return
Language
.
text
(
"contrib.category."
+
cleaned
);
}
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
public
interface
Filter
{
boolean
matches
(
Contribution
contrib
);
}
}
Back
|
FazBrowse Home
|
New Git URL