Skip to content

Commit 8159f1e

Browse files
author
realPaulsen
committed
v1.1.3b
Small Additions: - PUIRotaryControl has a setValue() function without updates Changes: - Released all Elements in clear-function of PUIScrollPanel - Changed valueUpdate-Functions in PUIScrollPanel, PUISlider & PUIRotaryControl from Runnable to PUIAction - Also made the lists Threadsafe - Optimize repaint()-calls in PUIFrame: No paints when minimized Fixes: - PUICore: when interactionLayer is -1 the element behind got called as well
1 parent 8ca20df commit 8159f1e

24 files changed

+838
-691
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ out/
3131
*.classpath
3232
*.project
3333
*.iml
34+
*.MF
3435
.idea
3536

3637
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,14 @@ by [`Paulsen`](https://github.com/realPaulsen)
9292

9393
### Planned Improvements / In Development
9494

95-
- **Graph plotter**: Plot multiple graphs and analyze them
96-
- **Comments**/JavaDoc still missing😬
95+
- **BugFixes:**
96+
- Make `run()` of **PConsole** _semi-blocking_ instead of _full-blocking_. In case the Console/Terminal wants an input the run() would be blocked forever
97+
- Make `PUIElement` **abstract** and create `PUIButton` to replace the parent-class of the other Elements
9798
- **FixPoints** on PUISlider
9899
- **Free** movable PUIElements on PUIScrollPanel (without snapped locations)
99-
- **BugFixes:**
100-
- PUICore: when interactionLayer is -1 the element behind gets called as well
100+
- **Graph plotter**: Plot multiple graphs and analyze them
101+
- **Comments**/JavaDoc still missing😬
102+
101103

102104
## Build-Notes
103105

src/ooo/paulsen/demo/Demo.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import ooo.paulsen.ui.*;
44
import ooo.paulsen.ui.PUIElement.ElementAlignment;
5+
import ooo.paulsen.ui.core.*;
56
import ooo.paulsen.utils.PSystem;
67

78
import java.awt.*;
@@ -88,9 +89,9 @@ public void run(PUIElement that) {
8889
});
8990

9091
rc = new PUIRotaryControl(f, 1);
91-
rc.addValueUpdateAction(new Runnable() {
92+
rc.addValueUpdateAction(new PUIAction() {
9293
@Override
93-
public void run() {
94+
public void run(PUIElement that) {
9495
// RotaryControl changes spacing between elements in PUIScrollPanel & PUIMatrix
9596
int space = (int) (rc.getValue() * 7);
9697
sp.setElementSpacing(space, space, space * 2, space * 2);
@@ -101,18 +102,18 @@ public void run() {
101102
slider = new PUISlider(f);
102103
slider.setValue(0.5f);
103104
slider.setAlignment(ElementAlignment.HORIZONTAL);
104-
slider.addValueUpdateAction(new Runnable() {
105+
slider.addValueUpdateAction(new PUIAction() {
105106
@Override
106-
public void run() {
107+
public void run(PUIElement that) {
107108
rc.setValueLength(slider.getValue());
108109
}
109110
});
110111

111112
slider2 = new PUISlider(f);
112113
slider2.setAlignment(ElementAlignment.HORIZONTAL);
113-
slider2.addValueUpdateAction(new Runnable() {
114+
slider2.addValueUpdateAction(new PUIAction() {
114115
@Override
115-
public void run() {
116+
public void run(PUIElement that) {
116117
rc.setValueThickness((int) (360 * slider2.getValue()));
117118
}
118119
});

src/ooo/paulsen/io/PCustomProtocol.java

Lines changed: 93 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -2,108 +2,109 @@
22

33
public class PCustomProtocol {
44

5-
private String IDENTIFIER = "CP";
5+
private String IDENTIFIER = "CP";
66

7-
private char BLOCK_START = '[', BLOCK_END = ']';
8-
/**
9-
* Replacement if start- or end-character is included in data (1)=> store data
10-
* with replaced characters (2)=> read data with replacements back replaced to
11-
* start or end
12-
*/
13-
private String START_REPLACEMENT = "^<<^", END_REPLACEMENT = "^>>^";
7+
private char BLOCK_START = '[', BLOCK_END = ']';
8+
/**
9+
* Replacement if start- or end-character is included in data (1)=> store data
10+
* with replaced characters (2)=> read data with replacements back replaced to
11+
* start or end
12+
*/
13+
private String START_REPLACEMENT = "^<<^", END_REPLACEMENT = "^>>^";
1414

15-
public PCustomProtocol() {
16-
}
15+
public PCustomProtocol() {
16+
}
1717

18-
public PCustomProtocol(String identifier, char blockStart, char blockEnd, String startReplacement,
19-
String endRemplacement) {
20-
IDENTIFIER = identifier;
21-
BLOCK_START = blockStart;
22-
BLOCK_END = blockEnd;
23-
START_REPLACEMENT = startReplacement;
24-
END_REPLACEMENT = endRemplacement;
25-
}
18+
public PCustomProtocol(String identifier, char blockStart, char blockEnd, String startReplacement,
19+
String endRemplacement) {
20+
IDENTIFIER = identifier;
21+
BLOCK_START = blockStart;
22+
BLOCK_END = blockEnd;
23+
START_REPLACEMENT = startReplacement;
24+
END_REPLACEMENT = endRemplacement;
25+
}
2626

27-
public boolean isPartOfProtocol(String s) {
28-
s = trimEnd(trimStart(s));
29-
// Message must start immediatley with IDENTIFIER and BLOCK_START
30-
if (s.startsWith(IDENTIFIER + BLOCK_START) && s.endsWith(String.valueOf(BLOCK_END))) {
31-
String message = removeStart(s, IDENTIFIER.length());
32-
// Message can only contain BLOCK_START && BLOCK_END once
33-
if (count(message, BLOCK_START) != 1 || count(message, BLOCK_END) != 1) {
34-
return false;
35-
}
36-
return true;
37-
}
38-
return false;
39-
}
27+
public boolean isPartOfProtocol(String s) {
28+
s = trimEnd(trimStart(s));
29+
// Message must start immediatley with IDENTIFIER and BLOCK_START
30+
if (s.startsWith(IDENTIFIER + BLOCK_START) && s.endsWith(String.valueOf(BLOCK_END))) {
31+
String message = removeStart(s, IDENTIFIER.length());
32+
// Message can only contain BLOCK_START && BLOCK_END once
33+
if (count(message, BLOCK_START) != 1 || count(message, BLOCK_END) != 1) {
34+
return false;
35+
}
36+
return true;
37+
}
38+
return false;
39+
}
4040

41-
/**
42-
* @param Protocol-Output
43-
* @return Message
44-
*/
45-
public String getMessage(String input) {
46-
if (isPartOfProtocol(input)) {
47-
String message = removeStart(trimEnd(trimStart(input)), IDENTIFIER.length());
41+
/**
42+
* @param input Message
43+
* @return Protocol-Output
44+
*/
45+
public String getMessage(String input) {
46+
if (isPartOfProtocol(input)) {
47+
String message = removeStart(trimEnd(trimStart(input)), IDENTIFIER.length());
4848

49-
// remove block-character and fill replcements
50-
String mN = "";
51-
for (int i = 1; i < message.length() - 1; i++)
52-
mN += message.charAt(i);
53-
message = mN.replace(START_REPLACEMENT, String.valueOf(BLOCK_START)).replace(END_REPLACEMENT,
54-
String.valueOf(BLOCK_END));
49+
// remove block-character and fill replcements
50+
String mN = "";
51+
for (int i = 1; i < message.length() - 1; i++)
52+
mN += message.charAt(i);
53+
message = mN.replace(START_REPLACEMENT, String.valueOf(BLOCK_START)).replace(END_REPLACEMENT,
54+
String.valueOf(BLOCK_END));
5555

56-
return message;
57-
}
58-
return null;
59-
}
56+
return message;
57+
}
58+
return null;
59+
}
6060

61-
/**
62-
* @param Message that gets convertet into the protocol-format
63-
* @return Protocol-Output
64-
*/
65-
public String getProtocolOutput(String message) {
66-
return IDENTIFIER + BLOCK_START + message.replace(String.valueOf(BLOCK_START), START_REPLACEMENT)
67-
.replace(String.valueOf(BLOCK_END), END_REPLACEMENT) + BLOCK_END;
68-
}
61+
/**
62+
* @param message that gets convertet into the protocol-format
63+
* @return Protocol-Output
64+
*/
65+
public String getProtocolOutput(String message) {
66+
return IDENTIFIER + BLOCK_START + message.replace(String.valueOf(BLOCK_START), START_REPLACEMENT)
67+
.replace(String.valueOf(BLOCK_END), END_REPLACEMENT) + BLOCK_END;
68+
}
6969

70-
private static String trimStart(String sIn) {
71-
String s = "";
72-
boolean hasBeenStart = false;
73-
for (int i = 0; i < sIn.length(); i++) {
74-
if (sIn.charAt(i) != ' ')
75-
hasBeenStart = true;
76-
if (hasBeenStart)
77-
s += sIn.charAt(i);
78-
}
79-
return s;
80-
}
70+
private static String trimStart(String sIn) {
71+
String s = "";
72+
boolean hasBeenStart = false;
73+
for (int i = 0; i < sIn.length(); i++) {
74+
if (sIn.charAt(i) != ' ')
75+
hasBeenStart = true;
76+
if (hasBeenStart)
77+
s += sIn.charAt(i);
78+
}
79+
return s;
80+
}
8181

82-
private static String removeStart(String in, int length) {
83-
String s = "";
84-
for (int i = length; i < in.length(); i++)
85-
s += in.charAt(i);
86-
return s;
87-
}
82+
private static String removeStart(String in, int length) {
83+
String s = "";
84+
for (int i = length; i < in.length(); i++)
85+
s += in.charAt(i);
86+
return s;
87+
}
8888

89-
private static String trimEnd(String sIn) {
90-
String s = "";
91-
boolean hasBeenEnd = false;
92-
for (int i = sIn.length() - 1; i >= 0; i--) {
93-
if (sIn.charAt(i) != ' ')
94-
hasBeenEnd = true;
95-
if (hasBeenEnd)
96-
s = sIn.charAt(i) + s;
97-
}
98-
return s;
99-
}
89+
private static String trimEnd(String sIn) {
90+
String s = "";
91+
boolean hasBeenEnd = false;
92+
for (int i = sIn.length() - 1; i >= 0; i--) {
93+
if (sIn.charAt(i) != ' ')
94+
hasBeenEnd = true;
95+
if (hasBeenEnd)
96+
s = sIn.charAt(i) + s;
97+
}
98+
return s;
99+
}
100+
101+
private static int count(String s, char c) {
102+
int count = 0;
103+
for (int i = 0; i < s.length(); i++) {
104+
if (s.charAt(i) == c)
105+
count++;
106+
}
107+
return count;
108+
}
100109

101-
private static int count(String s, char c) {
102-
int count = 0;
103-
for (int i = 0; i < s.length(); i++) {
104-
if (s.charAt(i) == c)
105-
count++;
106-
}
107-
return count;
108-
}
109110
}

0 commit comments

Comments
 (0)