mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
fix up line endings, improve code quality (issue #522)
This commit is contained in:
@@ -1,206 +1,206 @@
|
||||
70 35
|
||||
69 35
|
||||
68 39
|
||||
67 42
|
||||
66 47
|
||||
64 51
|
||||
64 54
|
||||
63 57
|
||||
60 60
|
||||
58 64
|
||||
51 69
|
||||
48 72
|
||||
44 73
|
||||
39 75
|
||||
35 75
|
||||
30 75
|
||||
25 75
|
||||
21 75
|
||||
17 73
|
||||
13 69
|
||||
12 66
|
||||
11 61
|
||||
11 57
|
||||
10 49
|
||||
10 45
|
||||
10 38
|
||||
12 32
|
||||
13 29
|
||||
16 23
|
||||
20 19
|
||||
24 16
|
||||
27 15
|
||||
31 13
|
||||
33 13
|
||||
37 13
|
||||
40 15
|
||||
42 16
|
||||
45 19
|
||||
46 21
|
||||
47 24
|
||||
48 26
|
||||
48 29
|
||||
48 33
|
||||
47 39
|
||||
43 45
|
||||
42 47
|
||||
38 50
|
||||
35 51
|
||||
32 51
|
||||
30 51
|
||||
27 50
|
||||
27 50
|
||||
26 46
|
||||
26 41
|
||||
29 36
|
||||
30 34
|
||||
31 33
|
||||
31 33
|
||||
32 33
|
||||
33 33
|
||||
34 33
|
||||
34 33
|
||||
35 33
|
||||
37 33
|
||||
39 33
|
||||
42 32
|
||||
44 31
|
||||
46 29
|
||||
48 29
|
||||
49 27
|
||||
52 24
|
||||
53 23
|
||||
57 19
|
||||
61 16
|
||||
63 14
|
||||
67 13
|
||||
69 12
|
||||
69 12
|
||||
77 11
|
||||
77 11
|
||||
80 11
|
||||
86 16
|
||||
90 21
|
||||
93 25
|
||||
95 29
|
||||
95 32
|
||||
95 33
|
||||
95 37
|
||||
94 41
|
||||
93 44
|
||||
92 46
|
||||
91 49
|
||||
89 51
|
||||
87 55
|
||||
85 59
|
||||
82 62
|
||||
80 64
|
||||
79 67
|
||||
77 69
|
||||
74 71
|
||||
68 72
|
||||
65 73
|
||||
63 73
|
||||
62 73
|
||||
60 72
|
||||
58 69
|
||||
57 67
|
||||
57 66
|
||||
56 60
|
||||
56 56
|
||||
56 54
|
||||
58 49
|
||||
60 47
|
||||
62 47
|
||||
63 47
|
||||
67 48
|
||||
70 52
|
||||
73 55
|
||||
74 57
|
||||
74 58
|
||||
74 60
|
||||
74 62
|
||||
73 65
|
||||
70 68
|
||||
67 69
|
||||
65 70
|
||||
63 70
|
||||
62 70
|
||||
60 68
|
||||
57 65
|
||||
55 64
|
||||
50 62
|
||||
46 61
|
||||
40 60
|
||||
38 60
|
||||
36 60
|
||||
32 61
|
||||
30 62
|
||||
27 64
|
||||
26 68
|
||||
25 71
|
||||
25 77
|
||||
25 81
|
||||
26 84
|
||||
28 86
|
||||
31 87
|
||||
33 88
|
||||
36 88
|
||||
39 86
|
||||
41 85
|
||||
43 83
|
||||
44 81
|
||||
45 76
|
||||
45 74
|
||||
45 71
|
||||
40 67
|
||||
37 65
|
||||
34 63
|
||||
33 61
|
||||
33 61
|
||||
32 60
|
||||
33 49
|
||||
37 45
|
||||
41 41
|
||||
45 39
|
||||
47 38
|
||||
51 37
|
||||
54 37
|
||||
58 38
|
||||
61 41
|
||||
63 44
|
||||
65 46
|
||||
66 49
|
||||
66 51
|
||||
67 55
|
||||
67 58
|
||||
67 60
|
||||
66 62
|
||||
64 65
|
||||
63 66
|
||||
61 67
|
||||
60 68
|
||||
58 68
|
||||
55 69
|
||||
54 69
|
||||
51 69
|
||||
48 69
|
||||
46 68
|
||||
45 66
|
||||
44 65
|
||||
44 63
|
||||
44 61
|
||||
44 59
|
||||
44 56
|
||||
44 55
|
||||
45 53
|
||||
47 52
|
||||
49 50
|
||||
50 48
|
||||
51 47
|
||||
52 46
|
||||
54 46
|
||||
55 45
|
||||
55 45
|
||||
56 44
|
||||
57 44
|
||||
70 35
|
||||
69 35
|
||||
68 39
|
||||
67 42
|
||||
66 47
|
||||
64 51
|
||||
64 54
|
||||
63 57
|
||||
60 60
|
||||
58 64
|
||||
51 69
|
||||
48 72
|
||||
44 73
|
||||
39 75
|
||||
35 75
|
||||
30 75
|
||||
25 75
|
||||
21 75
|
||||
17 73
|
||||
13 69
|
||||
12 66
|
||||
11 61
|
||||
11 57
|
||||
10 49
|
||||
10 45
|
||||
10 38
|
||||
12 32
|
||||
13 29
|
||||
16 23
|
||||
20 19
|
||||
24 16
|
||||
27 15
|
||||
31 13
|
||||
33 13
|
||||
37 13
|
||||
40 15
|
||||
42 16
|
||||
45 19
|
||||
46 21
|
||||
47 24
|
||||
48 26
|
||||
48 29
|
||||
48 33
|
||||
47 39
|
||||
43 45
|
||||
42 47
|
||||
38 50
|
||||
35 51
|
||||
32 51
|
||||
30 51
|
||||
27 50
|
||||
27 50
|
||||
26 46
|
||||
26 41
|
||||
29 36
|
||||
30 34
|
||||
31 33
|
||||
31 33
|
||||
32 33
|
||||
33 33
|
||||
34 33
|
||||
34 33
|
||||
35 33
|
||||
37 33
|
||||
39 33
|
||||
42 32
|
||||
44 31
|
||||
46 29
|
||||
48 29
|
||||
49 27
|
||||
52 24
|
||||
53 23
|
||||
57 19
|
||||
61 16
|
||||
63 14
|
||||
67 13
|
||||
69 12
|
||||
69 12
|
||||
77 11
|
||||
77 11
|
||||
80 11
|
||||
86 16
|
||||
90 21
|
||||
93 25
|
||||
95 29
|
||||
95 32
|
||||
95 33
|
||||
95 37
|
||||
94 41
|
||||
93 44
|
||||
92 46
|
||||
91 49
|
||||
89 51
|
||||
87 55
|
||||
85 59
|
||||
82 62
|
||||
80 64
|
||||
79 67
|
||||
77 69
|
||||
74 71
|
||||
68 72
|
||||
65 73
|
||||
63 73
|
||||
62 73
|
||||
60 72
|
||||
58 69
|
||||
57 67
|
||||
57 66
|
||||
56 60
|
||||
56 56
|
||||
56 54
|
||||
58 49
|
||||
60 47
|
||||
62 47
|
||||
63 47
|
||||
67 48
|
||||
70 52
|
||||
73 55
|
||||
74 57
|
||||
74 58
|
||||
74 60
|
||||
74 62
|
||||
73 65
|
||||
70 68
|
||||
67 69
|
||||
65 70
|
||||
63 70
|
||||
62 70
|
||||
60 68
|
||||
57 65
|
||||
55 64
|
||||
50 62
|
||||
46 61
|
||||
40 60
|
||||
38 60
|
||||
36 60
|
||||
32 61
|
||||
30 62
|
||||
27 64
|
||||
26 68
|
||||
25 71
|
||||
25 77
|
||||
25 81
|
||||
26 84
|
||||
28 86
|
||||
31 87
|
||||
33 88
|
||||
36 88
|
||||
39 86
|
||||
41 85
|
||||
43 83
|
||||
44 81
|
||||
45 76
|
||||
45 74
|
||||
45 71
|
||||
40 67
|
||||
37 65
|
||||
34 63
|
||||
33 61
|
||||
33 61
|
||||
32 60
|
||||
33 49
|
||||
37 45
|
||||
41 41
|
||||
45 39
|
||||
47 38
|
||||
51 37
|
||||
54 37
|
||||
58 38
|
||||
61 41
|
||||
63 44
|
||||
65 46
|
||||
66 49
|
||||
66 51
|
||||
67 55
|
||||
67 58
|
||||
67 60
|
||||
66 62
|
||||
64 65
|
||||
63 66
|
||||
61 67
|
||||
60 68
|
||||
58 68
|
||||
55 69
|
||||
54 69
|
||||
51 69
|
||||
48 69
|
||||
46 68
|
||||
45 66
|
||||
44 65
|
||||
44 63
|
||||
44 61
|
||||
44 59
|
||||
44 56
|
||||
44 55
|
||||
45 53
|
||||
47 52
|
||||
49 50
|
||||
50 48
|
||||
51 47
|
||||
52 46
|
||||
54 46
|
||||
55 45
|
||||
55 45
|
||||
56 44
|
||||
57 44
|
||||
|
||||
@@ -14,8 +14,7 @@ PFont body;
|
||||
int num = 9; // Display this many entries on each screen.
|
||||
int startingEntry = 0; // Display from this entry number
|
||||
|
||||
void setup()
|
||||
{
|
||||
void setup() {
|
||||
size(200, 200);
|
||||
fill(255);
|
||||
noLoop();
|
||||
@@ -26,9 +25,14 @@ void setup()
|
||||
lines = loadStrings("cars2.tsv");
|
||||
records = new Record[lines.length];
|
||||
for (int i = 0; i < lines.length; i++) {
|
||||
String[] pieces = split(lines[i], '\t'); // Load data into arrayif (pieces.length == 9) {
|
||||
records[recordCount] = new Record(pieces);
|
||||
recordCount++;
|
||||
String[] pieces = split(lines[i], TAB); // Load data into array
|
||||
if (pieces.length == 9) {
|
||||
records[recordCount] = new Record(pieces);
|
||||
recordCount++;
|
||||
}
|
||||
}
|
||||
if (recordCount != records.length) {
|
||||
records = (Record[]) subset(records, 0, recordCount);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,37 +40,16 @@ void draw() {
|
||||
background(0);
|
||||
for (int i = 0; i < num; i++) {
|
||||
int thisEntry = startingEntry + i;
|
||||
text(thisEntry + " > " + records[thisEntry].name, 20, 20 + i*20); // Print name to console
|
||||
if (thisEntry < recordCount) {
|
||||
text(thisEntry + " > " + records[thisEntry].name, 20, 20 + i*20);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void mousePressed() {
|
||||
startingEntry += num;
|
||||
if (startingEntry + num > records.length) {
|
||||
startingEntry -= num;
|
||||
if (startingEntry > records.length) {
|
||||
startingEntry = 0; // go back to the beginning
|
||||
}
|
||||
redraw();
|
||||
}
|
||||
|
||||
class Record {
|
||||
String name;
|
||||
float mpg;
|
||||
int cylinders;
|
||||
float displacement;
|
||||
float horsepower;
|
||||
float weight;
|
||||
float acceleration;
|
||||
int year;
|
||||
float origin;
|
||||
public Record(String[] pieces) {
|
||||
name = pieces[0];
|
||||
mpg = float(pieces[1]);
|
||||
cylinders = int(pieces[2]);
|
||||
displacement = float(pieces[3]);
|
||||
horsepower = float(pieces[4]);
|
||||
weight = float(pieces[5]);
|
||||
acceleration = float(pieces[6]);
|
||||
year = int(pieces[7]);
|
||||
origin = float(pieces[8]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
class Record {
|
||||
String name;
|
||||
float mpg;
|
||||
int cylinders;
|
||||
float displacement;
|
||||
float horsepower;
|
||||
float weight;
|
||||
float acceleration;
|
||||
int year;
|
||||
float origin;
|
||||
|
||||
public Record(String[] pieces) {
|
||||
name = pieces[0];
|
||||
mpg = float(pieces[1]);
|
||||
cylinders = int(pieces[2]);
|
||||
displacement = float(pieces[3]);
|
||||
horsepower = float(pieces[4]);
|
||||
weight = float(pieces[5]);
|
||||
acceleration = float(pieces[6]);
|
||||
year = int(pieces[7]);
|
||||
origin = float(pieces[8]);
|
||||
}
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user