Skip to content

Commit 986acb8

Browse files
committed
fixed probability update box poc (to extend to the whole palette)
1 parent 1f64c33 commit 986acb8

File tree

2 files changed

+157
-6
lines changed

2 files changed

+157
-6
lines changed

CategoricalDistribution.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ public void setOutcomeProbabilities(double[] dist)
9696

9797
public double getOutcomeProbability(int index)
9898
{
99+
//System.out.println("outcome prob: " + distribution[index]);
99100
return distribution[index];
100101
}
101102

golly_vectorializer.pde

Lines changed: 156 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,6 +1046,13 @@ void setup()
10461046
.moveTo(winG)
10471047
.hide()
10481048
;
1049+
cp5.addTextlabel("labelPaletteProb")
1050+
.setValue("Probabilita' %:")
1051+
.setPosition(190,60)
1052+
.setSize(20,10)
1053+
.moveTo(winG)
1054+
.hide()
1055+
;
10491056
cp5.addTextfield("inputPaletteColor1")
10501057
.setLabel("Stato 1")
10511058
.setPosition(100,80)
@@ -1059,9 +1066,10 @@ void setup()
10591066
.hide()
10601067
;
10611068
cp5.addTextfield("inputPaletteProb1")
1069+
.setLabel("")
10621070
.setInputFilter(ControlP5.FLOAT)
10631071
.setPosition(200,80)
1064-
.setSize(50,13)
1072+
.setSize(40,13)
10651073
.setColorBackground(0)
10661074
.setFocus(false)
10671075
.setAutoClear(false)
@@ -1082,6 +1090,19 @@ void setup()
10821090
.moveTo(winG)
10831091
.hide()
10841092
;
1093+
cp5.addTextfield("inputPaletteProb2")
1094+
.setLabel("")
1095+
.setInputFilter(ControlP5.FLOAT)
1096+
.setPosition(200,120)
1097+
.setSize(40,13)
1098+
.setColorBackground(0)
1099+
.setFocus(false)
1100+
.setAutoClear(false)
1101+
.setColor(color(255,0,0))
1102+
.setColorActive(255)
1103+
.moveTo(winG)
1104+
.hide()
1105+
;
10851106
cp5.addTextfield("inputPaletteColor3")
10861107
.setLabel("Stato 3")
10871108
.setPosition(100,160)
@@ -1094,6 +1115,19 @@ void setup()
10941115
.moveTo(winG)
10951116
.hide()
10961117
;
1118+
cp5.addTextfield("inputPaletteProb3")
1119+
.setLabel("")
1120+
.setInputFilter(ControlP5.FLOAT)
1121+
.setPosition(200,160)
1122+
.setSize(40,13)
1123+
.setColorBackground(0)
1124+
.setFocus(false)
1125+
.setAutoClear(false)
1126+
.setColor(color(255,0,0))
1127+
.setColorActive(255)
1128+
.moveTo(winG)
1129+
.hide()
1130+
;
10971131
cp5.addTextfield("inputPaletteColor4")
10981132
.setLabel("Stato 4")
10991133
.setPosition(100,200)
@@ -1106,6 +1140,19 @@ void setup()
11061140
.moveTo(winG)
11071141
.hide()
11081142
;
1143+
cp5.addTextfield("inputPaletteProb4")
1144+
.setLabel("")
1145+
.setInputFilter(ControlP5.FLOAT)
1146+
.setPosition(200,200)
1147+
.setSize(40,13)
1148+
.setColorBackground(0)
1149+
.setFocus(false)
1150+
.setAutoClear(false)
1151+
.setColor(color(255,0,0))
1152+
.setColorActive(255)
1153+
.moveTo(winG)
1154+
.hide()
1155+
;
11091156
cp5.addTextfield("inputPaletteColor5")
11101157
.setLabel("Stato 5")
11111158
.setPosition(100,240)
@@ -1118,6 +1165,19 @@ void setup()
11181165
.moveTo(winG)
11191166
.hide()
11201167
;
1168+
cp5.addTextfield("inputPaletteProb5")
1169+
.setLabel("")
1170+
.setInputFilter(ControlP5.FLOAT)
1171+
.setPosition(200,240)
1172+
.setSize(40,13)
1173+
.setColorBackground(0)
1174+
.setFocus(false)
1175+
.setAutoClear(false)
1176+
.setColor(color(255,0,0))
1177+
.setColorActive(255)
1178+
.moveTo(winG)
1179+
.hide()
1180+
;
11211181
cp5.addTextfield("inputPaletteColor6")
11221182
.setLabel("Stato 6")
11231183
.setPosition(100,280)
@@ -1130,6 +1190,19 @@ void setup()
11301190
.moveTo(winG)
11311191
.hide()
11321192
;
1193+
cp5.addTextfield("inputPaletteProb6")
1194+
.setLabel("")
1195+
.setInputFilter(ControlP5.FLOAT)
1196+
.setPosition(200,280)
1197+
.setSize(40,13)
1198+
.setColorBackground(0)
1199+
.setFocus(false)
1200+
.setAutoClear(false)
1201+
.setColor(color(255,0,0))
1202+
.setColorActive(255)
1203+
.moveTo(winG)
1204+
.hide()
1205+
;
11331206
cp5.addTextfield("inputPaletteColor7")
11341207
.setLabel("Stato 7")
11351208
.setPosition(100,320)
@@ -1142,6 +1215,19 @@ void setup()
11421215
.moveTo(winG)
11431216
.hide()
11441217
;
1218+
cp5.addTextfield("inputPaletteProb7")
1219+
.setLabel("")
1220+
.setInputFilter(ControlP5.FLOAT)
1221+
.setPosition(200,320)
1222+
.setSize(40,13)
1223+
.setColorBackground(0)
1224+
.setFocus(false)
1225+
.setAutoClear(false)
1226+
.setColor(color(255,0,0))
1227+
.setColorActive(255)
1228+
.moveTo(winG)
1229+
.hide()
1230+
;
11451231
cp5.addTextfield("inputPaletteColorVoid")
11461232
.setLabel("Stato 0 (INATTIVO)")
11471233
.setPosition(100,360)
@@ -1345,7 +1431,8 @@ void inputPaletteColor1(String val) {
13451431

13461432
void inputPaletteProb1(String val) {
13471433
val = val.replace(',', '.');
1348-
currentSettings.setColorProbability(0, Float.parseFloat(val));
1434+
Textfield txt = ((Textfield)cp5.getController("inputPaletteProb1"));
1435+
txt.setValue(val);
13491436
}
13501437

13511438
void inputPaletteColor2(String val) {
@@ -1357,41 +1444,83 @@ void inputPaletteColor2(String val) {
13571444
updatePaletteDrawable(1);
13581445
}
13591446
}
1447+
1448+
void inputPaletteProb2(String val) {
1449+
val = val.replace(',', '.');
1450+
Textfield txt = ((Textfield)cp5.getController("inputPaletteProb2"));
1451+
txt.setValue(val);
1452+
}
1453+
13601454
void inputPaletteColor3(String val) {
13611455
val = sanitizeHexInput(val);
13621456
Textfield txt = ((Textfield)cp5.getController("inputPaletteColor3"));
13631457
txt.setValue(val);
13641458
color newColor = getColorFromHex(val);
13651459
updatePaletteDrawable(2);
13661460
}
1461+
1462+
void inputPaletteProb3(String val) {
1463+
val = val.replace(',', '.');
1464+
Textfield txt = ((Textfield)cp5.getController("inputPaletteProb3"));
1465+
txt.setValue(val);
1466+
}
1467+
13671468
void inputPaletteColor4(String val) {
13681469
val = sanitizeHexInput(val);
13691470
Textfield txt = ((Textfield)cp5.getController("inputPaletteColor4"));
13701471
txt.setValue(val);
13711472
color newColor = getColorFromHex(val);
13721473
updatePaletteDrawable(3);
13731474
}
1475+
1476+
void inputPaletteProb4(String val) {
1477+
val = val.replace(',', '.');
1478+
Textfield txt = ((Textfield)cp5.getController("inputPaletteProb4"));
1479+
txt.setValue(val);
1480+
}
1481+
13741482
void inputPaletteColor5(String val) {
13751483
val = sanitizeHexInput(val);
13761484
Textfield txt = ((Textfield)cp5.getController("inputPaletteColor5"));
13771485
txt.setValue(val);
13781486
color newColor = getColorFromHex(val);
13791487
updatePaletteDrawable(4);
13801488
}
1489+
1490+
void inputPaletteProb5(String val) {
1491+
val = val.replace(',', '.');
1492+
Textfield txt = ((Textfield)cp5.getController("inputPaletteProb5"));
1493+
txt.setValue(val);
1494+
}
1495+
13811496
void inputPaletteColor6(String val) {
13821497
val = sanitizeHexInput(val);
13831498
Textfield txt = ((Textfield)cp5.getController("inputPaletteColor6"));
13841499
txt.setValue(val);
13851500
color newColor = getColorFromHex(val);
13861501
updatePaletteDrawable(5);
13871502
}
1503+
1504+
void inputPaletteProb6(String val) {
1505+
val = val.replace(',', '.');
1506+
Textfield txt = ((Textfield)cp5.getController("inputPaletteProb6"));
1507+
txt.setValue(val);
1508+
}
1509+
13881510
void inputPaletteColor7(String val) {
13891511
val = sanitizeHexInput(val);
13901512
Textfield txt = ((Textfield)cp5.getController("inputPaletteColor7"));
13911513
txt.setValue(val);
13921514
color newColor = getColorFromHex(val);
13931515
updatePaletteDrawable(6);
13941516
}
1517+
1518+
void inputPaletteProb7(String val) {
1519+
val = val.replace(',', '.');
1520+
Textfield txt = ((Textfield)cp5.getController("inputPaletteProb7"));
1521+
txt.setValue(val);
1522+
}
1523+
13951524
void inputPaletteColorVoid(String val) {
13961525
val = sanitizeHexInput(val);
13971526
Textfield txt = ((Textfield)cp5.getController("inputPaletteColorVoid"));
@@ -1410,7 +1539,17 @@ void updatePaletteDrawable(int number) {
14101539
setDrawable(index, 50, 80 + (40 * index), 10, 10, newColor);
14111540
winG.addDrawable(d[index]);
14121541
}
1542+
void saveProbabilities() {
1543+
for (int i = 0; i < paletteColors; i++) {
1544+
String currentInput = "inputPaletteProb" + (i + 1);
1545+
Textfield content = ((Textfield)cp5.getController(currentInput));
1546+
double prob = Double.parseDouble(content.getText()) / 100;
1547+
println(prob);
1548+
currentSettings.setColorProbability(i, (float)prob);
1549+
}
1550+
}
14131551
void savePalette() {
1552+
saveProbabilities();
14141553
for (int i = 0; i < paletteColors; i++) {
14151554
String currentInput = "inputPaletteColor" + (i + 1);
14161555
Textfield content = ((Textfield)cp5.getController(currentInput));
@@ -1434,12 +1573,22 @@ void openPalette(int value) {
14341573
showPopup("Inserire gli esadecimali per ogni stato:\n(dare INVIO ad ogni inserimento!)", 300, 450, 4, 2);
14351574
showPalette();
14361575
}
1576+
void showProbabilities() {
1577+
winG.controller("labelPaletteProb").show();
1578+
for (int i = 0; i < paletteColors; i++) {
1579+
String currentInput = "inputPaletteProb" + (i + 1);
1580+
winG.controller(currentInput).show();
1581+
winG.controller(currentInput).setBroadcast(true);
1582+
Textfield txt = ((Textfield)cp5.getController(currentInput));
1583+
double prob = currentSettings.getColorProbability(i) * 100;
1584+
String probString = String.format("%.2f", prob);
1585+
txt.setText(probString.replace(",", "."));
1586+
winG.controller(currentInput).setBroadcast(false);
1587+
}
1588+
}
14371589
void showPalette() {
1590+
showProbabilities();
14381591
winG.controller("labelPalettePreview").show();
1439-
winG.controller("inputPaletteProb1").show();
1440-
winG.controller("inputPaletteProb1").setBroadcast(false);
1441-
winG.controller("inputPaletteProb1").setValue((float)currentSettings.getColorProbability(0));
1442-
winG.controller("inputPaletteProb1").setBroadcast(true);
14431592
for (int i = 0; i < paletteColors; i++) {
14441593
String currentInput = "inputPaletteColor" + (i + 1);
14451594
Textfield content = ((Textfield)cp5.getController(currentInput));
@@ -1500,6 +1649,7 @@ void killPalette() {
15001649
winG.controller("inputPaletteColor6").hide();
15011650
winG.controller("inputPaletteColor7").hide();
15021651
winG.controller("inputPaletteColorVoid").hide();
1652+
winG.controller("labelPaletteProb").show();
15031653
winG.controller("inputPaletteProb1").hide();
15041654
}
15051655
void buttonPaletteOK() {

0 commit comments

Comments
 (0)