Code snippets

From Impure Wiki

Jump to: navigation, search

This code snippets contains patterns that would be useful for certain purposes. In fact some of them will become deprecated because of the creation of an operator or control that replaces it. In the future, code snippets will be patches available on a public library. Remember that you have to click on the I button at the menu in order to insert a group of modules by pasting its code.


Contents

counting words on a text

0 String   335 402
1 Boolean true 277 181
2 Boolean true 277 206
3 Boolean true 277 231
4 Boolean true 277 256
5 Boolean true 142 279
6 String Replace this text with any other String. Notice that you can switch [to lower case] to false in stringTransformation (and thus the process will be case sensitive) 874 68
8 splitString 439 260
10 stringTransformations 355 154
13 countElementsRepetitionOnList 542 361
12 TableVisualizator 702 167 256 527
0 8 1
1 10 1
2 10 2
3 10 3
4 10 4
5 10 5
10 8
6 10
8 13
13 12


RemarkableWords and CirclesTagVisualizator

1 Number 0 428 478
2 Number 1 431 572
3 getElementFromList 509 545
4 getElementFromList 506 451
5 RemarkableWords 214 381
6 CirclesTagCloud 634 148 411 425
5 4
1 4 1
4 6
2 3 1
5 3
3 6 1


quick access to files at Bestiario's data repository

0 String http://feeds.delicious.com/v2/rss/datarepository?count=100 372 202
9 String url 711 543
12 String description 709 632
16 String name 709 590
19 String ¬¬ 946 653
3 rssToBipartitionIT 313 347
8 getPropertyValue 801 496
11 getItemList 320 414
13 getPropertyValue 807 630
17 getPropertyValue 802 566
18 addition 898 586
20 addition 944 517
21 addition 1002 592
22 addition 1050 516
7 Pulse 809 389
6 FileLoader 976 390
2 FileLoader 280 271
14 SimpleStringVisualizator 703 64 372 292
5 ListElementSelector 415 59 260 437
0 2
2 3
7 6
5 8
9 8 1
8 7
3 11
11 5
12 13 1
5 13
16 17 1
5 17
17 18
19 18 1
8 20 1
18 20
19 21 1
20 21
21 22
13 22 1
22 14


[select all] / [deselect all] buttons for a subListSelector

0 String this code snippet allow user to select or deselect every element on a SubListSelector 479 29
1 String   419 89
2 Number 0 449 699
3 String select all 819 499
4 String deselect all 819 629
5 String EXAMPLE List 489 139
6 String LINK HERE YOUR List ---> 579 269
7 Number 0 1169 849
8 splitString 489 69
9 lengthOfAList 429 589
10 orderedNaturalNumbers 609 499
11 orderedNaturalNumbers 619 589
12 lengthOfAList 539 689
13 equivalence 619 749
14 not 719 749
15 equivalence 619 829
16 not 719 829
17 listAssembler5 899 779
18 getElementFromList 1329 589
19 identity 639 269
20 LastToChange 1279 679
21 PulseCounter 1119 629
22 PulseCounter 1119 799
23 Pulse 899 679 140 20
26 Confluence 1209 759
24 SubListSelector 899 229 140 180
25 Pulse 899 539 140 20
0 8
1 8 1
9 10
2 11
3 25 1
10 25
4 23 1
11 23
24 12
2 13 1
12 13
13 14
14 23 2
15 16
12 15
9 15 1
16 25 2
23 22
25 21
17 18
8 19
19 24
19 9
18 24 2
20 18 1
10 17 1
11 17
21 20 1
22 26
26 20
7 26 1

Network Visualized

This set of modules contains a ForcesOnNetwork control, a Network2D and a system that smoothly frames the Network.

0 Number 0.02 382 577
1 Number 1.4 232 727
2 expandRectangle 362 667
3 getFrame 202 657
4 getNodeList 222 497
5 Network2D 722 67 636 636
6 ExponentialConvergence 462 597
7 ForcesOnNetwork2 202 307
7 4
3 2
1 2 1
2 6
0 6 1
4 3
6 5 1
7 5

first five elelements from a List

7 Number 1 580 455
8 Number 2 580 555
9 Number 3 580 655
10 Number 4 580 755
1 identity 499 367
2 getElementFromList 655 325
3 getElementFromList 655 425
4 getElementFromList 655 525
5 getElementFromList 655 625
6 getElementFromList 655 725
1 2
1 3
1 4
1 5
1 6
7 3 1
8 4 1
9 5 1
10 6 1


processing message

This pattern is quite advanced. It's useful to detect (and communicate) whenever a flow of operations and/or data loadings are performing. You have to link the very beginning of the process to one of the PulseCounter modules, and the end of the process to the second one. A pulse on the first PulseCounter will activate a "processing..." message, and a Pulse on the second will activate a "process finished" message.

0 String processing... 413 470
1 Number 14 643 540
2 String process finished 413 510
10 String Link here a module that changes at the very BEGINNING of the process --------> 283 160
11 String Link here a module that changes at the very END of the process --------> 283 310
3 getElementFromList 693 430
4 listAssembler5 503 480
5 listAssembler5 503 640
6 PulseCounter 353 400
8 LastToChange 503 320
7 PulseCounter 353 250
9 TextVisualizator 733 590 180 20
1 9 1
7 8
6 8 1
0 4
2 4 1
4 3
0 5
8 3 1
3 9
5 9 2


google news search (based on RSSLoader)

As google news RSS service enables use of several parameters (for instance: feed://news.google.es/news?output=rss&num=100&q=query), it's possible, with the convenient group of modules, to obtain the same functionality of an API module. Hence, this code snippets acts as an API module for google news.

0 String description 367 664
1 String *** 367 704
2 String es 247 264
3 String com 247 234
4 String 100 831 278
5 String query here 247 94
6 String feed://news.google. 811 182
7 String /news?output=rss&num= 737 226
8 String &q= 816 330
9 String name 697 554
10 String <--- TITLES 967 514
11 String <--- CONTENTS 967 604
12 getPropertyValuesFromList 437 644
13 getItemList 457 584
14 joinStringList 467 744
15 getReadableStringFromHTMLString 587 604
16 splitString 757 604
22 getPropertyValuesFromList 757 514
26 addition5 879 206
27 addition 959 350
23 RSSLoader 297 414
24 Switch5 437 204
25 Pulse 157 414 50 20
23 13
13 12
0 12 1
12 14
1 14 1
14 15
15 16
1 16 1
9 22 1
13 22
25 23
3 24
2 24 1
6 26
24 26 1
7 26 2
4 26 3
8 26 4
26 27
5 27 1
27 25

alternating Colors from different ColorScales

Some visualizators such as FlowVisualizator place together shapes that should have colors different enough to avoid perceptual collision (the eye/mind isn't able to recognize the difference). But if a ColorList is created from a ColorScale chances are that similar color will be used in neighbour shapes. A valid tactic to avoid this problem is alternating two ColorScales in a way that similar Colors remain distant. It's not perfect and it will not work in every situation, but in many cases this solution will be convinient enough. The image below shows the FlowVisualizator with a ColorList created with ColorScales. With this code snippet you can of course choose which ColorScales to use.

Alternating colors.png


2 String temperature 228 181
4 String antitemperature 228 221
7 Number 41 228 141
9 String floor(x*0.5+0.5) 628 121
19 String SELECT NUMBER OF ELEMENTS, AND ColorScales 348 261
20 String <----- THIS IS THE RESULTANT ColorList 1418 111
1 createColorScale 458 261
3 createColorScale 468 451
6 colorListFromColorScale 808 241
8 mathExpressionEvaluator 688 151
10 colorListFromColorScale 808 311
11 listAssembler5 928 261
12 diagonalizeTable 968 151
13 concatListsFromTable 1018 261
14 colorListFromNumberList 1068 111
18 listAssembler5 1148 221
17 ColorScaleVisualizator 518 521 140 40
15 ColorScaleVisualizator 518 331 140 40
16 SimpleColorKeyVisualizator 1228 221
2 1
4 3
9 8
7 8 1
8 6 1
1 6
8 10 1
3 10
6 11
10 11 1
11 12
12 13
13 14
1 15
3 17
14 18
14 18 1
18 16
Personal tools